LegacyScanContainerEmitter implements Emitter { @Override public Stream<Object> stream() { return StreamSupport.stream(entries, false); } LegacyScanContainerEmitter(InputStream inputStream); @Override void emit(Consumer<Object> onNext, Consumer<Throwable> onError, Runnable onComplete); @Override Stream<Object> stream();  }
@Test public void metadata() throws Exception { InputStream inputStream = CharSource.wrap("{" + "\"scannerVersion\": \"0.0.0.0\"," + "\"signatureVersion\": \"7.0.0\"," + "\"ownerEntityToken\": \"SP#example.com-test\"," + "\"createdOn\": \"2016-11-22T16:33:20.000Z\"," + "\"timeToScan\": 111," + "\"name\": \"Test Metadata 1\"," + "\"hostName\": \"example.com\"," + "\"baseDir\": \"/test\"," + "\"scanNodeList\": []" + "}").asByteSource(UTF_8).openStream(); Map<?, ?> metadata = (Map<?, ?>) emitterFactory.apply(inputStream).stream().limit(1).collect(onlyElement()); assertThat(context.fromFieldValue(nameKey, metadata.get(nameKey))) .isEqualTo("Test Metadata 1"); assertThat(context.fromFieldValue(publisherKey, metadata.get(publisherKey))) .isEqualTo(ProductList.from("ScanClient/0.0.0.0 (signature 7.0.0) (snippets) LegacyScanContainerEmitter")); assertThat(context.fromFieldValue(creationDateTimeKey, metadata.get(creationDateTimeKey))) .isEqualTo(ZonedDateTime.parse("2016-11-22T16:33:20.000Z")); assertThat(context.fromFieldValue(creatorKey, metadata.get(creatorKey))) .isEqualTo("@example.com"); assertThat(context.fromFieldValue(captureInterval, metadata.get(captureInterval))) .isEqualTo("2016-11-22T16:33:20Z/2016-11-22T16:33:20.111Z"); }