assertSearchRequestFields(descriptor.getFields());
}
private void assertSearchRequestFields(List<FieldDescriptor> fields) {
FieldDescriptor queryField = fields.get(0);
assertThat(queryField.getRule()).isEqualTo(Rule.REQUIRED);
assertThat(queryField.getType()).isEqualTo(Type.STRING);
assertThat(queryField.getJavaType()).isEqualTo(JavaType.STRING);
assertThat(queryField.getFullName()).isEqualTo("org.infinispan.protostream.test.SearchRequest.query");
assertThat(queryField.getName()).isEqualTo("query");
assertThat(queryField.getNumber()).isEqualTo(1);
assertThat(queryField.getMessageType()).isNull();
assertThat(queryField.getContainingMessage().getName()).isEqualTo("SearchRequest");
FieldDescriptor pageNumberField = fields.get(1);
assertThat(pageNumberField.getRule()).isEqualTo(Rule.OPTIONAL);
assertThat(pageNumberField.getType()).isEqualTo(Type.INT32);
assertThat(pageNumberField.getJavaType()).isEqualTo(JavaType.INT);
assertThat(pageNumberField.getName()).isEqualTo("page_number");
assertThat(pageNumberField.getNumber()).isEqualTo(2);
assertThat(pageNumberField.hasDefaultValue()).isTrue();
assertThat(pageNumberField.getDefaultValue()).isEqualTo(10);
assertThat(pageNumberField.getMessageType()).isNull();
FieldDescriptor flagField = fields.get(3);
assertThat(flagField.getRule()).isEqualTo(Rule.REPEATED);
assertThat(flagField.getType()).isEqualTo(Type.INT32);
assertThat(flagField.getJavaType()).isEqualTo(JavaType.INT);
assertThat(flagField.getOptionByName("packed")).isEqualTo("true");
FieldDescriptor dntField = fields.get(4);
assertThat(dntField.getRule()).isEqualTo(Rule.OPTIONAL);
assertThat(dntField.getType()).isEqualTo(Type.ENUM);
assertThat(dntField.getEnumDescriptor().findValueByName("DONT_CARE").getNumber()).isEqualTo(2);
assertThat(dntField.getEnumDescriptor().findValueByNumber(1).getName()).isEqualTo("TRACK_FOR_SURE");
assertThat(dntField.getEnumDescriptor().getFileDescriptor()).isNotNull();
assertThat(dntField.getFileDescriptor()).isNotNull();
assertThat(dntField.getJavaType()).isEqualTo(JavaType.ENUM);
FieldDescriptor reqEnumField = fields.get(5);
assertThat(reqEnumField.getRule()).isEqualTo(Rule.REQUIRED);
assertThat(reqEnumField.getType()).isEqualTo(Type.ENUM);
assertThat(reqEnumField.getJavaType()).isEqualTo(JavaType.ENUM);
assertThat(reqEnumField.hasDefaultValue()).isFalse();
assertThat(reqEnumField.getEnumDescriptor()).isNotNull();
assertThat(reqEnumField.getEnumDescriptor().findValueByNumber(0).getFileDescriptor()).isNotNull();
assertThat(reqEnumField.getOptionByName("deprecated")).isEqualTo("true");
FieldDescriptor labelField = fields.get(6);
assertThat(labelField.hasDefaultValue()).isTrue();
assertThat(labelField.getDefaultValue()).isEqualTo("whatever");
FieldDescriptor typedField = fields.get(7);
Descriptor messageType = typedField.getMessageType();
assertThat(messageType.getFullName()).isEqualTo("org.infinispan.protostream.test.SearchRequest.Inner");
assertThat(messageType.getContainingType().getName()).isEqualTo("SearchRequest");
assertThat(typedField.getType()).isEqualTo(Type.MESSAGE);
assertThat(typedField.getFullName()).isEqualTo("org.infinispan.protostream.test.SearchRequest.typed");
}