@Test void testPersonWithAddressProtoFile() { Proto proto = generator.generate("org.kie.kogito.test", Collections.singleton(PersonWithAddress.class)); assertThat(proto).isNotNull(); assertThat(proto.getPackageName()).isEqualTo("org.kie.kogito.test"); assertThat(proto.getSyntax()).isEqualTo("proto2"); assertThat(proto.getMessages()).hasSize(2); ProtoMessage address = proto.getMessages().get(0); assertThat(address).isNotNull(); assertThat(address.getName()).isEqualTo("Address"); assertThat(address.getJavaPackageOption()).isEqualTo("org.kie.kogito.codegen.data"); assertThat(address.getFields()).hasSize(4); ProtoField field = address.getFields().get(0); assertThat(field).isNotNull(); assertThat(field.getName()).isEqualTo("city"); assertThat(field.getType()).isEqualTo("string"); assertThat(field.getApplicability()).isEqualTo("optional"); field = address.getFields().get(1); assertThat(field).isNotNull(); assertThat(field.getName()).isEqualTo("country"); assertThat(field.getType()).isEqualTo("string"); assertThat(field.getApplicability()).isEqualTo("optional"); field = address.getFields().get(2); assertThat(field).isNotNull(); assertThat(field.getName()).isEqualTo("street"); assertThat(field.getType()).isEqualTo("string"); assertThat(field.getApplicability()).isEqualTo("optional"); field = address.getFields().get(3); assertThat(field).isNotNull(); assertThat(field.getName()).isEqualTo("zipCode"); assertThat(field.getType()).isEqualTo("string"); assertThat(field.getApplicability()).isEqualTo("optional"); ProtoMessage person = proto.getMessages().get(1); assertThat(person).isNotNull(); assertThat(person.getName()).isEqualTo("PersonWithAddress"); assertThat(person.getJavaPackageOption()).isEqualTo("org.kie.kogito.codegen.data"); assertThat(person.getFields()).hasSize(4); field = person.getFields().get(0); assertThat(field).isNotNull(); assertThat(field.getName()).isEqualTo("address"); assertThat(field.getType()).isEqualTo("Address"); assertThat(field.getApplicability()).isEqualTo("optional"); field = person.getFields().get(1); assertThat(field).isNotNull(); assertThat(field.getName()).isEqualTo("adult"); assertThat(field.getType()).isEqualTo("bool"); assertThat(field.getApplicability()).isEqualTo("optional"); field = person.getFields().get(2); assertThat(field).isNotNull(); assertThat(field.getName()).isEqualTo("age"); assertThat(field.getType()).isEqualTo("int32"); assertThat(field.getApplicability()).isEqualTo("optional"); field = person.getFields().get(3); assertThat(field).isNotNull(); assertThat(field.getName()).isEqualTo("name"); assertThat(field.getType()).isEqualTo("string"); assertThat(field.getApplicability()).isEqualTo("optional"); }
public Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers) { try { Proto proto = new Proto(packageName, headers); for (Class<?> clazz : dataModel) { if (clazz.isEnum()) { enumFromClass(proto, clazz, null); } else { messageFromClass(proto, clazz, null, null, null); } } return proto; } catch (Exception e) { throw new RuntimeException("Error while generating proto for data model", e); } }
ReflectionProtoGenerator extends AbstractProtoGenerator<Class<?>> { public Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers) { try { Proto proto = new Proto(packageName, headers); for (Class<?> clazz : dataModel) { if (clazz.isEnum()) { enumFromClass(proto, clazz, null); } else { messageFromClass(proto, clazz, null, null, null); } } return proto; } catch (Exception e) { throw new RuntimeException("Error while generating proto for data model", e); } } }
ReflectionProtoGenerator extends AbstractProtoGenerator<Class<?>> { public Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers) { try { Proto proto = new Proto(packageName, headers); for (Class<?> clazz : dataModel) { if (clazz.isEnum()) { enumFromClass(proto, clazz, null); } else { messageFromClass(proto, clazz, null, null, null); } } return proto; } catch (Exception e) { throw new RuntimeException("Error while generating proto for data model", e); } }  }
ReflectionProtoGenerator extends AbstractProtoGenerator<Class<?>> { public Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers) { try { Proto proto = new Proto(packageName, headers); for (Class<?> clazz : dataModel) { if (clazz.isEnum()) { enumFromClass(proto, clazz, null); } else { messageFromClass(proto, clazz, null, null, null); } } return proto; } catch (Exception e) { throw new RuntimeException("Error while generating proto for data model", e); } }  Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers); @Override Proto generate(String messageComment, String fieldComment, String packageName, Class<?> dataModel, String... headers); Collection<Class<?>> extractDataClasses(Collection<Class<?>> input, String targetDirectory); }
ReflectionProtoGenerator extends AbstractProtoGenerator<Class<?>> { public Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers) { try { Proto proto = new Proto(packageName, headers); for (Class<?> clazz : dataModel) { if (clazz.isEnum()) { enumFromClass(proto, clazz, null); } else { messageFromClass(proto, clazz, null, null, null); } } return proto; } catch (Exception e) { throw new RuntimeException("Error while generating proto for data model", e); } }  Proto generate(String packageName, Collection<Class<?>> dataModel, String... headers); @Override Proto generate(String messageComment, String fieldComment, String packageName, Class<?> dataModel, String... headers); Collection<Class<?>> extractDataClasses(Collection<Class<?>> input, String targetDirectory);  }