@Test void discover() throws IOException { final Kitap kitap = new Kitap(new SingerArgs("--config", config.toAbsolutePath().toString(), "--discover"), new Singer(new IO(), () -> CONSTANT_DATE)); kitap.run(); flushIO.run(); assertEquals("{\"streams\":[" + "{\"tap_stream_id\":\"default\",\"stream\":\"default\"," + "\"schema\":{\"type\":[\"null\",\"object\"],\"additionalProperties\":false,\"properties\":{\"record_number\":{\"type\":[\"integer\"]}}}," + "\"metadata\":[{\"metadata\":{\"inclusion\":\"automatic\",\"selected-by-default\":true},\"breadcrumb\":[\"properties\",\"record_number\"]}]}]}\n", stdout.toString("UTF-8")); }
private void discover(final Mapper mapper) { final JsonObject schema = records(mapper) .findFirst() .map(record -> new JsonSchemaGenerator(record.getSchema().getEntries(), jsonBuilderFactory).get()) .orElseThrow(() -> new IllegalArgumentException( "No record found for " + mapper.rootName() + '#' + mapper.name())); final JsonArray metadata = schema .getJsonObject("properties") .entrySet() .stream() .collect(jsonBuilderFactory::createArrayBuilder, (a, p) -> { a .add(jsonBuilderFactory .createObjectBuilder() .add("metadata", jsonBuilderFactory .createObjectBuilder() .add("inclusion", "automatic") .add("selected-by-default", true)) .add("breadcrumb", jsonBuilderFactory.createArrayBuilder().add("properties").add(p.getKey()))); }, JsonArrayBuilder::addAll) .build(); final String streams = jsonBuilderFactory .createObjectBuilder() .add("streams", jsonBuilderFactory .createArrayBuilder() .add(jsonBuilderFactory .createObjectBuilder() .add("tap_stream_id", "default") .add("stream", "default") .add("schema", schema) .add("metadata", metadata))) .build() .toString(); singer.stdout(streams); }
Kitap implements Runnable { private void discover(final Mapper mapper) { final JsonObject schema = records(mapper) .findFirst() .map(record -> new JsonSchemaGenerator(record.getSchema().getEntries(), jsonBuilderFactory).get()) .orElseThrow(() -> new IllegalArgumentException( "No record found for " + mapper.rootName() + '#' + mapper.name())); final JsonArray metadata = schema .getJsonObject("properties") .entrySet() .stream() .collect(jsonBuilderFactory::createArrayBuilder, (a, p) -> { a .add(jsonBuilderFactory .createObjectBuilder() .add("metadata", jsonBuilderFactory .createObjectBuilder() .add("inclusion", "automatic") .add("selected-by-default", true)) .add("breadcrumb", jsonBuilderFactory.createArrayBuilder().add("properties").add(p.getKey()))); }, JsonArrayBuilder::addAll) .build(); final String streams = jsonBuilderFactory .createObjectBuilder() .add("streams", jsonBuilderFactory .createArrayBuilder() .add(jsonBuilderFactory .createObjectBuilder() .add("tap_stream_id", "default") .add("stream", "default") .add("schema", schema) .add("metadata", metadata))) .build() .toString(); singer.stdout(streams); } }
Kitap implements Runnable { private void discover(final Mapper mapper) { final JsonObject schema = records(mapper) .findFirst() .map(record -> new JsonSchemaGenerator(record.getSchema().getEntries(), jsonBuilderFactory).get()) .orElseThrow(() -> new IllegalArgumentException( "No record found for " + mapper.rootName() + '#' + mapper.name())); final JsonArray metadata = schema .getJsonObject("properties") .entrySet() .stream() .collect(jsonBuilderFactory::createArrayBuilder, (a, p) -> { a .add(jsonBuilderFactory .createObjectBuilder() .add("metadata", jsonBuilderFactory .createObjectBuilder() .add("inclusion", "automatic") .add("selected-by-default", true)) .add("breadcrumb", jsonBuilderFactory.createArrayBuilder().add("properties").add(p.getKey()))); }, JsonArrayBuilder::addAll) .build(); final String streams = jsonBuilderFactory .createObjectBuilder() .add("streams", jsonBuilderFactory .createArrayBuilder() .add(jsonBuilderFactory .createObjectBuilder() .add("tap_stream_id", "default") .add("stream", "default") .add("schema", schema) .add("metadata", metadata))) .build() .toString(); singer.stdout(streams); } Kitap(final String... args);  Kitap(final SingerArgs args, final Singer singer); }
Kitap implements Runnable { private void discover(final Mapper mapper) { final JsonObject schema = records(mapper) .findFirst() .map(record -> new JsonSchemaGenerator(record.getSchema().getEntries(), jsonBuilderFactory).get()) .orElseThrow(() -> new IllegalArgumentException( "No record found for " + mapper.rootName() + '#' + mapper.name())); final JsonArray metadata = schema .getJsonObject("properties") .entrySet() .stream() .collect(jsonBuilderFactory::createArrayBuilder, (a, p) -> { a .add(jsonBuilderFactory .createObjectBuilder() .add("metadata", jsonBuilderFactory .createObjectBuilder() .add("inclusion", "automatic") .add("selected-by-default", true)) .add("breadcrumb", jsonBuilderFactory.createArrayBuilder().add("properties").add(p.getKey()))); }, JsonArrayBuilder::addAll) .build(); final String streams = jsonBuilderFactory .createObjectBuilder() .add("streams", jsonBuilderFactory .createArrayBuilder() .add(jsonBuilderFactory .createObjectBuilder() .add("tap_stream_id", "default") .add("stream", "default") .add("schema", schema) .add("metadata", metadata))) .build() .toString(); singer.stdout(streams); } Kitap(final String... args);  Kitap(final SingerArgs args, final Singer singer); @Override void run(); static void main(final String... args); }
Kitap implements Runnable { private void discover(final Mapper mapper) { final JsonObject schema = records(mapper) .findFirst() .map(record -> new JsonSchemaGenerator(record.getSchema().getEntries(), jsonBuilderFactory).get()) .orElseThrow(() -> new IllegalArgumentException( "No record found for " + mapper.rootName() + '#' + mapper.name())); final JsonArray metadata = schema .getJsonObject("properties") .entrySet() .stream() .collect(jsonBuilderFactory::createArrayBuilder, (a, p) -> { a .add(jsonBuilderFactory .createObjectBuilder() .add("metadata", jsonBuilderFactory .createObjectBuilder() .add("inclusion", "automatic") .add("selected-by-default", true)) .add("breadcrumb", jsonBuilderFactory.createArrayBuilder().add("properties").add(p.getKey()))); }, JsonArrayBuilder::addAll) .build(); final String streams = jsonBuilderFactory .createObjectBuilder() .add("streams", jsonBuilderFactory .createArrayBuilder() .add(jsonBuilderFactory .createObjectBuilder() .add("tap_stream_id", "default") .add("stream", "default") .add("schema", schema) .add("metadata", metadata))) .build() .toString(); singer.stdout(streams); } Kitap(final String... args);  Kitap(final SingerArgs args, final Singer singer); @Override void run(); static void main(final String... args);  }