DataSetMarshaller { DataSet unmarshalToDataSet(Reader reader) { try { return mapper.readValue(reader, DataSet.class); } catch (IOException e) { throw new IllegalStateException("Can't read demo data set", e); } } DataSetMarshaller();   DataSetMarshaller(ObjectMapper mapper); RoutingProblem unmarshal(Reader reader); String marshal(RoutingProblem routingProblem);  }
@Test void unmarshal_data_set() throws IOException { DataSet dataSet; try (InputStream inputStream = DataSetMarshallerTest.class.getResourceAsStream("test-belgium.yaml")) { dataSet = new DataSetMarshaller().unmarshalToDataSet( new InputStreamReader(inputStream, StandardCharsets.UTF_8)); } assertThat(dataSet).isNotNull(); assertThat(dataSet.getName()).isEqualTo("Belgium test"); assertThat(dataSet.getDepot()).isNotNull(); assertThat(dataSet.getDepot().getLabel()).isEqualTo("Brussels"); assertThat(dataSet.getDepot().getLatitude()).isEqualTo(50.85); assertThat(dataSet.getDepot().getLongitude()).isEqualTo(4.35); assertThat(dataSet.getVisits()) .extracting("label") .containsExactlyInAnyOrder("Aalst", "Châtelet", "La Louvière", "Sint-Niklaas", "Ypres"); assertThat(dataSet.getVehicles()) .extracting(dataSetVehicle -> dataSetVehicle.name, dataSetVehicle -> dataSetVehicle.capacity) .containsExactlyInAnyOrder( tuple("vehicle 1", 10), tuple("vehicle 2", 12), tuple("vehicle 3", 1_000_000)); }