SchemaGenerator { public String generate(Schema schema) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("package ") .append(schema.getPkg()) .append(";\n"); stringBuilder.append(this.buildMessages(schema.getMessages())); return stringBuilder.toString(); }  String generate(Schema schema);  }
@Test public void testBuildSchema() { Message message = new Message("KObject", new HashSet<>(Arrays.asList(new Field(ProtobufScope.REQUIRED, "int32", "embedded", 1), new Field(ProtobufScope.REQUIRED, "string", "anotherEmbedded", 2)) )); Schema schema = new Schema("KObjectSchema", "org.appformer", Collections.singleton(message)); String generatedMessage = this.schemaGenerator.generate(schema); logger.debug(generatedMessage); assertThat(this.sanitize(generatedMessage)) .isEqualToIgnoringWhitespace(this.read("proto/schema.proto")); }