Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Nov 11, 2024
1 parent 9b7d424 commit 3bca38d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,7 @@ public static synchronized void addSourcesToPaintStyle(DataSet ds) {
return;
}
List<String> sources = ds.allPrimitives().stream().map(MapPaintUtils::getSourceValue).filter(Objects::nonNull)
.map(s -> s.replace('.', '_'))
.distinct().collect(Collectors.toList());
.map(s -> s.replace('.', '_')).distinct().collect(Collectors.toList());
if (!styleSource.isLoaded()) {
styleSource.loadStyleSource();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.io.IOException;
import java.io.StringReader;
import java.util.Collections;
import java.util.List;

Expand All @@ -20,6 +21,7 @@
import jakarta.json.JsonArrayBuilder;
import jakarta.json.JsonObjectBuilder;
import jakarta.json.JsonValue;
import jakarta.json.stream.JsonParser;

@BasicPreferences
@Territories
Expand All @@ -29,8 +31,12 @@ class MapWithAISourceReaderTest {
void testParseSimple() throws IOException {
JsonObjectBuilder builder = Json.createObjectBuilder();
builder.add("nowhere", JsonValue.NULL);
try (var reader = new MapWithAISourceReader("")) {
List<MapWithAIInfo> infoList = reader.parseJson(builder.build());
final String json = builder.build().toString();
try (var reader = new MapWithAISourceReader("");
StringReader sr = new java.io.StringReader(json);
JsonParser parser = Json.createParser(sr)) {
parser.next();
List<MapWithAIInfo> infoList = reader.parseJson(parser);
assertEquals(1, infoList.size());
assertEquals("nowhere", infoList.get(0).getName());
}
Expand All @@ -45,9 +51,12 @@ void testParseComplex() throws IOException {
JsonArrayBuilder coCountriesArray = Json.createArrayBuilder(Collections.singleton("addr:housenumber"));
coCountries.add("US-CO", coCountriesArray.build());
co.add("countries", coCountries.build());
builder.add("Colorado", co);
try (var reader = new MapWithAISourceReader("")) {
List<MapWithAIInfo> infoList = reader.parseJson(builder.build());
String json = builder.add("Colorado", co).build().toString();
try (var reader = new MapWithAISourceReader("");
StringReader sr = new StringReader(json);
JsonParser parser = Json.createParser(sr)) {
parser.next();
List<MapWithAIInfo> infoList = reader.parseJson(parser);
assertEquals(1, infoList.size());
MapWithAIInfo info = infoList.stream().filter(i -> "Colorado".equals(i.getName())).findFirst().orElse(null);
assertNotNull(info);
Expand Down

0 comments on commit 3bca38d

Please sign in to comment.