@Test public void newInstance() throws IOException { WorkloadParser parser = new WorkloadParser(); Reader reader = new StringReader(ResourcesUtils.loadAsString("workloads/simple-config-01.json")); Workload config = parser.parse(reader); SimpleDocumentFactory factory = new SimpleDocumentFactory(config.getIndiceTypes().get(0)); String fstJson = factory.newInstance(0); String expected = ResourcesUtils.loadAsString("documents/expected-simple-config-01-A.json"); JsonAssert.assertJsonEquals(expected, fstJson); String sndJson = factory.newInstance(0); expected = ResourcesUtils.loadAsString("documents/expected-simple-config-01-A.json"); JsonAssert.assertJsonEquals(expected, sndJson); }
@Override public String newInstance(int instanceId) { try(StringWriter writer = new StringWriter(); JsonGenerator generator = factory.createGenerator(writer);) { generator.writeStartObject(); for(JsonBuilder builder : builders) { builder.write(generator, instanceId); } generator.writeEndObject(); generator.flush(); return writer.toString(); } catch (IOException e) { throw new IllegalStateException(e); } }
SimpleDocumentFactory implements DocumentFactory<String> { @Override public String newInstance(int instanceId) { try(StringWriter writer = new StringWriter(); JsonGenerator generator = factory.createGenerator(writer);) { generator.writeStartObject(); for(JsonBuilder builder : builders) { builder.write(generator, instanceId); } generator.writeEndObject(); generator.flush(); return writer.toString(); } catch (IOException e) { throw new IllegalStateException(e); } } }
SimpleDocumentFactory implements DocumentFactory<String> { @Override public String newInstance(int instanceId) { try(StringWriter writer = new StringWriter(); JsonGenerator generator = factory.createGenerator(writer);) { generator.writeStartObject(); for(JsonBuilder builder : builders) { builder.write(generator, instanceId); } generator.writeEndObject(); generator.flush(); return writer.toString(); } catch (IOException e) { throw new IllegalStateException(e); } } SimpleDocumentFactory(IndexTypeMetadata indexTypeMetadata);  SimpleDocumentFactory(IndexTypeMetadata indexTypeMetadata, int cachingLimit); }
SimpleDocumentFactory implements DocumentFactory<String> { @Override public String newInstance(int instanceId) { try(StringWriter writer = new StringWriter(); JsonGenerator generator = factory.createGenerator(writer);) { generator.writeStartObject(); for(JsonBuilder builder : builders) { builder.write(generator, instanceId); } generator.writeEndObject(); generator.flush(); return writer.toString(); } catch (IOException e) { throw new IllegalStateException(e); } } SimpleDocumentFactory(IndexTypeMetadata indexTypeMetadata);  SimpleDocumentFactory(IndexTypeMetadata indexTypeMetadata, int cachingLimit); @Override String newInstance(int instanceId); }
SimpleDocumentFactory implements DocumentFactory<String> { @Override public String newInstance(int instanceId) { try(StringWriter writer = new StringWriter(); JsonGenerator generator = factory.createGenerator(writer);) { generator.writeStartObject(); for(JsonBuilder builder : builders) { builder.write(generator, instanceId); } generator.writeEndObject(); generator.flush(); return writer.toString(); } catch (IOException e) { throw new IllegalStateException(e); } } SimpleDocumentFactory(IndexTypeMetadata indexTypeMetadata);  SimpleDocumentFactory(IndexTypeMetadata indexTypeMetadata, int cachingLimit); @Override String newInstance(int instanceId);  }