@Test
void testPersonWithAddressesProtoFile() {

    
    Proto proto = generator.generate("org.kie.kogito.test", Collections.singleton(PersonWithAddresses.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("PersonWithAddresses");
    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("addresses");
    assertThat(field.getType()).isEqualTo("Address");
    assertThat(field.getApplicability()).isEqualTo("repeated");
    
    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");
}