Skip to content

Commit c55c0cc

Browse files
mmerdesrtroilo
authored andcommitted
#470: fix various warnings
1 parent a53769b commit c55c0cc

File tree

6 files changed

+25
-20
lines changed

6 files changed

+25
-20
lines changed

oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/db/H2Support.java

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
public class H2Support {
66

7+
private H2Support() {
8+
}
9+
710
public static String pathToUrl(Path path) {
811
var absolutePath = path.toAbsolutePath().toString();
912
absolutePath = absolutePath.replaceAll("\\.mv\\.db$", "");

oshdb-api/src/main/java/org/heigit/ohsome/oshdb/api/db/OSHDBJdbc.java

+1
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,6 @@ public boolean multithreading() {
135135

136136
@Override
137137
public void close() throws Exception {
138+
//nothing to do
138139
}
139140
}

oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/HelpersOSMContributionViewTest.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.heigit.ohsome.oshdb.api.tests;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertNull;
45

56
import java.util.EnumSet;
67
import java.util.HashSet;
@@ -32,11 +33,11 @@ class HelpersOSMContributionViewTest {
3233

3334
private static final double DELTA = 1e-8;
3435

35-
HelpersOSMContributionViewTest() throws Exception {
36+
HelpersOSMContributionViewTest() {
3637
oshdb = new OSHDBH2("../data/test-data");
3738
}
3839

39-
private MapReducer<OSMContribution> createMapReducer() throws Exception {
40+
private MapReducer<OSMContribution> createMapReducer() {
4041
return OSMContributionView
4142
.on(oshdb)
4243
.areaOfInterest(bbox)
@@ -85,7 +86,7 @@ void testSum() throws Exception {
8586
.sum(contribution -> 1);
8687

8788
assertEquals(42, result4.get(EnumSet.of(ContributionType.CREATION).toString()));
88-
assertEquals(null, result4.get(EnumSet.of(ContributionType.DELETION).toString()));
89+
assertNull(result4.get(EnumSet.of(ContributionType.DELETION).toString()));
8990
}
9091

9192
@Test
@@ -135,7 +136,7 @@ void testAverage() throws Exception {
135136
contribution.getContributionTypes().contains(ContributionType.TAG_CHANGE) ? 1 : 0)
136137
.average();
137138

138-
assertEquals(1.0, result1.doubleValue(), DELTA);
139+
assertEquals(1.0, result1, DELTA);
139140

140141
// many timestamps
141142
SortedMap<OSHDBTimestamp, Double> result2 = this.createMapReducer()
@@ -161,7 +162,7 @@ void testAverage() throws Exception {
161162
.contains(ContributionType.CREATION))
162163
.average(contribution -> contribution.getEntityAfter().getId() % 2);
163164

164-
assertEquals(0.5, result4.get(true).doubleValue(), DELTA);
165+
assertEquals(0.5, result4.get(true), DELTA);
165166
}
166167

167168
@Test
@@ -174,7 +175,7 @@ void testWeightedAverage() throws Exception {
174175
2 * (contribution.getEntityAfter().getId() % 2)
175176
));
176177

177-
assertEquals(1.0, result1.doubleValue(), DELTA);
178+
assertEquals(1.0, result1, DELTA);
178179

179180
// many timestamps
180181
SortedMap<OSHDBTimestamp, Double> result2 = this.createMapReducer()
@@ -203,7 +204,7 @@ void testWeightedAverage() throws Exception {
203204
2 * (contribution.getEntityAfter().getId() % 2)
204205
));
205206

206-
assertEquals(1.0, result4.get(true).doubleValue(), DELTA);
207+
assertEquals(1.0, result4.get(true), DELTA);
207208
}
208209

209210
@Test
@@ -252,7 +253,7 @@ void testUniq() throws Exception {
252253
.timestamps(timestamps2)
253254
.map(x -> null)
254255
.uniq();
255-
assertEquals(result5.size(), 1);
256+
assertEquals(1, result5.size() );
256257
}
257258

258259
}

oshdb-api/src/test/java/org/heigit/ohsome/oshdb/api/tests/MapAggregateByGeometryTest.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ class MapAggregateByGeometryTest {
3939

4040
private static final double DELTA = 1e-4;
4141

42-
MapAggregateByGeometryTest() throws Exception {
42+
MapAggregateByGeometryTest() {
4343
oshdb = new OSHDBH2("../data/test-data");
4444
}
4545

46-
private MapReducer<OSMContribution> createMapReducerOSMContribution() throws Exception {
46+
private MapReducer<OSMContribution> createMapReducerOSMContribution() {
4747
return OSMContributionView
4848
.on(oshdb)
4949
.areaOfInterest(bbox)
5050
.filter("type:way and highway=*");
5151
}
5252

53-
private MapReducer<OSMEntitySnapshot> createMapReducerOSMEntitySnapshot() throws Exception {
53+
private MapReducer<OSMEntitySnapshot> createMapReducerOSMEntitySnapshot() {
5454
return OSMEntitySnapshotView
5555
.on(oshdb)
5656
.areaOfInterest(bbox)
@@ -205,13 +205,13 @@ void testCombinedWithAggregateByTimestampOrder() throws Exception {
205205

206206
@SuppressWarnings("ResultOfMethodCallIgnored") // we test for a thrown exception here
207207
@Test()
208-
void testCombinedWithAggregateByTimestampUnsupportedOrder3() throws Exception {
209-
assertThrows(UnsupportedOperationException.class, () -> {
208+
void testCombinedWithAggregateByTimestampUnsupportedOrder3() {
209+
assertThrows(UnsupportedOperationException.class, () ->
210210
createMapReducerOSMEntitySnapshot()
211211
.timestamps(timestamps1)
212212
.groupByEntity()
213213
.aggregateByGeometry(getSubRegions())
214-
.collect();
215-
});
214+
.collect()
215+
);
216216
}
217217
}

oshdb-util/src/main/java/org/heigit/ohsome/oshdb/util/tagtranslator/JdbcTagTranslator.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public class JdbcTagTranslator implements TagTranslator {
2929
+ " where k.txt = ? and kv.txt = any (?)", TableNames.E_KEY, TableNames.E_KEYVALUE);
3030

3131
private static final String OSHDB_OSM_KEY = String.format("SELECT txt, id"
32-
+ " from %s"
33-
+ " where id = any(?)", TableNames.E_KEY);
32+
+ " from %s"
33+
+ " where id = any(?)", TableNames.E_KEY);
3434

3535
private static final String OSHDB_OSM_TAG = String.format("SELECT txt, valueid"
3636
+ " from %s"
@@ -166,7 +166,7 @@ public Map<OSHDBTag, OSMTag> lookupTag(Set<? extends OSHDBTag> tags) {
166166
return result;
167167
}
168168

169-
private Map<? extends Integer, ? extends String> lookupKeys(Set<? extends Integer> osm) {
169+
private Map<Integer, String> lookupKeys(Set<? extends Integer> osm) {
170170
try (var conn = source.getConnection();
171171
var sqlArray = createArray(conn, "int", osm);
172172
var pstmt = conn.prepareStatement(OSHDB_OSM_KEY)) {

oshdb-util/src/test/java/org/heigit/ohsome/oshdb/util/tagtranslator/AbstractTagTranslatorTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.heigit.ohsome.oshdb.util.tagtranslator;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4-
import static org.junit.jupiter.api.Assertions.assertTrue;
4+
import static org.junit.jupiter.api.Assertions.assertSame;
55

66
import java.util.ArrayList;
77
import java.util.Map;
@@ -128,7 +128,7 @@ void testKeysIdentity() {
128128
tags.add(instance.lookupTag(new OSHDBTag(1, i)));
129129
}
130130
for (var i = 1; i < tags.size(); i++) {
131-
assertTrue(tags.get(i - 1).getKey() == tags.get(i).getKey());
131+
assertSame(tags.get(i - 1).getKey(), tags.get(i).getKey());
132132
}
133133
}
134134
}

0 commit comments

Comments
 (0)