Spotify100 implements ConsumerSchema { static ObjectMapper objectMapper() { return new ObjectMapper() .registerModule(new Jdk8Module().configureAbsentsAsNulls(true)) .registerModule(new KotlinModule()); }  String toString(); @Override Exposed setup(final ConsumerSchema.Depends depends);  }
@Test public void testCases() throws Exception { final ObjectMapper expectedMapper = expectedObjectMapper(); final ObjectMapper mapper = Spotify100.objectMapper(); final List<String> lines = Resources.readLines( Resources.getResource(Spotify100Test.class, "spotify-100-tests.txt"), StandardCharsets.UTF_8); int i = 0; for (final String test : lines) { if (test.trim().isEmpty()) { continue; } if (test.trim().startsWith("#")) { continue; } final String[] parts = test.split("\\|"); final int line = i++; final JsonMetric value; try { value = mapper.readValue(parts[0].trim(), JsonMetric.class); } catch (final Exception e) { throw new RuntimeException(line + ": " + e.getMessage(), e); } final Expected expected = expectedMapper.readValue(parts[1].trim(), Expected.class); expected.key().ifPresent(key -> { assertEquals(line + ": expected key", key, value.getKey()); }); expected.host().ifPresent(host -> { assertEquals(line + ": expected host", host, value.getHost()); }); expected.time().ifPresent(time -> { assertEquals(line + ": expected time", time, value.getTime()); }); expected.attributes().ifPresent(attributes -> { assertEquals(line + ": expected attributes", attributes, value.getAttributes()); }); expected.resource().ifPresent(resource -> { assertEquals(line + ": expected resource", resource, value.getResource()); }); expected.value().ifPresent(v -> { assertEquals(line + ": expected value", v, value.getValue()); }); } }