15
15
import org .junit .jupiter .api .BeforeAll ;
16
16
import org .junit .jupiter .api .Test ;
17
17
18
- /**
19
- * Tests the {@link TagTranslator} class.
20
- */
21
- class TagTranslatorTest {
22
- private static JdbcConnectionPool source ;
18
+ public abstract class AbstractTagTranslatorTest {
19
+
20
+ protected static JdbcConnectionPool source ;
23
21
24
22
/**
25
23
* Initialize tests by loading the H2 driver and open a connection via jdbc.
26
- *
27
24
*/
28
25
@ BeforeAll
29
26
static void setUpClass () {
@@ -35,12 +32,12 @@ static void breakDownClass() {
35
32
source .dispose ();
36
33
}
37
34
38
- TagTranslatorTest () {}
35
+ abstract TagTranslator getTranslator ();
39
36
40
37
@ Test
41
38
void testTag2Int () throws OSHDBKeytablesNotFoundException {
42
39
OSMTag tag = new OSMTag ("building" , "yes" );
43
- var instance = new JdbcTagTranslator ( source );
40
+ TagTranslator instance = getTranslator ( );
44
41
OSHDBTag expResult = new OSHDBTag (1 , 0 );
45
42
OSHDBTag result = instance .getOSHDBTagOf (tag ).get ();
46
43
assertEquals (expResult , result );
@@ -53,7 +50,7 @@ void testTags2Int() throws OSHDBKeytablesNotFoundException {
53
50
new OSMTag ("building" , "residential" ), new OSHDBTag (1 , 2 ),
54
51
new OSMTag ("highway" , "primary" ), new OSHDBTag (2 , 7 ));
55
52
56
- var instance = new JdbcTagTranslator ( source );
53
+ TagTranslator instance = getTranslator ( );
57
54
var result = instance .getOSHDBTagOf (tags .keySet ());
58
55
assertEquals (tags .size (), result .size ());
59
56
for (var entry : tags .entrySet ()) {
@@ -62,12 +59,11 @@ void testTags2Int() throws OSHDBKeytablesNotFoundException {
62
59
}
63
60
}
64
61
65
-
66
62
@ Test
67
63
void testTag2String () throws OSHDBKeytablesNotFoundException {
68
64
OSHDBTag tag = new OSHDBTag (1 , 2 );
69
65
OSMTag expResult = new OSMTag ("building" , "residential" );
70
- var instance = new JdbcTagTranslator ( source );
66
+ TagTranslator instance = getTranslator ( );
71
67
OSMTag result = instance .lookupTag (tag );
72
68
assertEquals (expResult , result );
73
69
}
@@ -78,7 +74,7 @@ void testTags2String() {
78
74
new OSHDBTag (1 , 0 ), new OSMTag ("building" , "yes" ),
79
75
new OSHDBTag (1 , 2 ), new OSMTag ("building" , "residential" ),
80
76
new OSHDBTag (2 , 7 ), new OSMTag ("highway" , "primary" ));
81
- var instance = new JdbcTagTranslator ( source );
77
+ TagTranslator instance = getTranslator ( );
82
78
var result = instance .lookupTag (tags .keySet ());
83
79
assertEquals (tags .size (), result .size ());
84
80
for (var entry : tags .entrySet ()) {
@@ -89,8 +85,8 @@ void testTags2String() {
89
85
90
86
@ Test
91
87
void testOSMEntityTag2String () {
92
- var osm = OSM .node (123 , 1 , 1000L , 100L , 1 , new int [] {1 , 0 , 2 , 7 }, 0 , 0 );
93
- var instance = new JdbcTagTranslator ( source );
88
+ var osm = OSM .node (123 , 1 , 1000L , 100L , 1 , new int []{1 , 0 , 2 , 7 }, 0 , 0 );
89
+ TagTranslator instance = getTranslator ( );
94
90
var tags = instance .lookupTag (osm .getTags ());
95
91
assertEquals (2 , tags .size ());
96
92
assertEquals (new OSMTag ("building" , "yes" ), tags .get (new OSHDBTag (1 , 0 )));
@@ -100,7 +96,7 @@ void testOSMEntityTag2String() {
100
96
@ Test
101
97
void testKey2Int () throws OSHDBKeytablesNotFoundException {
102
98
OSMTagKey key = new OSMTagKey ("highway" );
103
- var instance = new JdbcTagTranslator ( source );
99
+ TagTranslator instance = getTranslator ( );
104
100
OSHDBTagKey expResult = new OSHDBTagKey (2 );
105
101
OSHDBTagKey result = instance .getOSHDBTagKeyOf (key ).get ();
106
102
assertEquals (expResult , result );
@@ -109,7 +105,7 @@ void testKey2Int() throws OSHDBKeytablesNotFoundException {
109
105
@ Test
110
106
void testRole2Int () throws OSHDBKeytablesNotFoundException {
111
107
OSMRole role = new OSMRole ("from" );
112
- var instance = new JdbcTagTranslator ( source );
108
+ TagTranslator instance = getTranslator ( );
113
109
OSHDBRole expResult = OSHDBRole .of (4 );
114
110
OSHDBRole result = instance .getOSHDBRoleOf (role ).get ();
115
111
assertEquals (expResult , result );
@@ -118,15 +114,15 @@ void testRole2Int() throws OSHDBKeytablesNotFoundException {
118
114
@ Test
119
115
void testRole2String () throws OSHDBKeytablesNotFoundException {
120
116
OSHDBRole role = OSHDBRole .of (1 );
121
- var instance = new JdbcTagTranslator ( source );
117
+ TagTranslator instance = getTranslator ( );
122
118
OSMRole expResult = new OSMRole ("inner" );
123
119
OSMRole result = instance .lookupRole (role );
124
120
assertEquals (expResult , result );
125
121
}
126
122
127
123
@ Test
128
124
void testKeysIdentity () {
129
- var instance = new JdbcTagTranslator ( source );
125
+ TagTranslator instance = getTranslator ( );
130
126
var tags = new ArrayList <OSMTag >(10 );
131
127
for (var i = 0 ; i < 10 ; i ++) {
132
128
tags .add (instance .lookupTag (new OSHDBTag (1 , i )));
0 commit comments