Skip to content

Commit

Permalink
Test dataset translation
Browse files Browse the repository at this point in the history
  • Loading branch information
paytoncain committed Apr 29, 2024
1 parent 5cf9324 commit fd4fae7
Show file tree
Hide file tree
Showing 2 changed files with 1,130 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected Stream<MapWithRowNumber> getPropertyStream(Reader reader,
Project.class,
Platform.class
})
void translate(Class<ObjectWithName> clazz) throws IOException, TranslatorValidationException {
void translateFromInputStream(Class<ObjectWithName> clazz) throws IOException, TranslatorValidationException {
List<Map<String, Optional<String>>> maps = List.of(
Map.of(
"uuid", Optional.of(UUID.randomUUID().toString()),
Expand All @@ -129,6 +129,38 @@ void translate(Class<ObjectWithName> clazz) throws IOException, TranslatorValida
assertEquals(maps.get(1).get("name").orElseThrow(), results.get(1).object().getName());
}

@ParameterizedTest
@ValueSource(classes = {
Ship.class,
Sea.class,
Project.class,
Platform.class
})
void translateFromReader(Class<ObjectWithName> clazz) throws IOException, TranslatorValidationException {
List<Map<String, Optional<String>>> maps = List.of(
Map.of(
"uuid", Optional.of(UUID.randomUUID().toString()),
"name", Optional.of("test-name-1")
),
Map.of(
"uuid", Optional.of(UUID.randomUUID().toString()),
"name", Optional.of("test-name-2")
)
);

List<ObjectWithRowConversionException<ObjectWithName>> results = createExecutor(new TestTranslator(List.of(
new TestTranslatorField("uuid", 1),
new TestTranslatorField("name", 2)
)), maps, clazz).translate((Reader) null).toList();
assertEquals(2, results.size());
assertEquals(maps.get(0).get("uuid").orElseThrow(), results.get(0).object().getUuid().toString());
assertNull(results.get(0).rowConversionException());
assertEquals(maps.get(0).get("name").orElseThrow(), results.get(0).object().getName());
assertEquals(maps.get(1).get("uuid").orElseThrow(), results.get(1).object().getUuid().toString());
assertNull(results.get(1).rowConversionException());
assertEquals(maps.get(1).get("name").orElseThrow(), results.get(1).object().getName());
}

@Test
void translateSoundSource() throws IOException, TranslatorValidationException {
List<Map<String, Optional<String>>> maps = List.of(
Expand Down
Loading

0 comments on commit fd4fae7

Please sign in to comment.