ThriftDocServicePlugin implements DocServicePlugin { @VisibleForTesting static StructInfo newStructInfo(Class<? extends TBase<?, ?>> structClass) { final String name = structClass.getName(); final Map<?, FieldMetaData> metaDataMap = FieldMetaData.getStructMetaDataMap(structClass); final List<FieldInfo> fields = metaDataMap.values().stream() .map(fieldMetaData -> newFieldInfo(structClass, fieldMetaData)) .collect(Collectors.toList()); return new StructInfo(name, fields); }  @Override String name(); @Override Set<Class<? extends Service<?, ?>>> supportedServiceTypes(); @Override ServiceSpecification generateSpecification(Set<ServiceConfig> serviceConfigs,
                                                      DocServiceFilter filter); @VisibleForTesting ServiceSpecification generate(List<Entry> entries, DocServiceFilter filter); @Override Map<String, String> loadDocStrings(Set<ServiceConfig> serviceConfigs); @Override Set<Class<?>> supportedExampleRequestTypes(); @Override String guessServiceName(Object exampleRequest); @Override String guessServiceMethodName(Object exampleRequest); @Override String serializeExampleRequest(String serviceName, String methodName,
                                          Object exampleRequest);  }
@Test void testNewStructInfoTest() throws Exception { final TypeSignature string = TypeSignature.ofBase("string"); final List<FieldInfo> fields = new ArrayList<>(); fields.add(FieldInfo.of("boolVal", TypeSignature.ofBase("bool"))); fields.add(FieldInfo.of("byteVal", TypeSignature.ofBase("i8"))); fields.add(FieldInfo.of("i16Val", TypeSignature.ofBase("i16"))); fields.add(FieldInfo.of("i32Val", TypeSignature.ofBase("i32"))); fields.add(FieldInfo.of("i64Val", TypeSignature.ofBase("i64"))); fields.add(FieldInfo.of("doubleVal", TypeSignature.ofBase("double"))); fields.add(FieldInfo.of("stringVal", string)); fields.add(FieldInfo.of("binaryVal", TypeSignature.ofBase("binary"))); fields.add(FieldInfo.of("enumVal", TypeSignature.ofNamed(FooEnum.class))); fields.add(FieldInfo.of("unionVal", TypeSignature.ofNamed(FooUnion.class))); fields.add(FieldInfo.of("mapVal", TypeSignature.ofMap( string, TypeSignature.ofNamed(FooEnum.class)))); fields.add(FieldInfo.of("setVal", TypeSignature.ofSet(FooUnion.class))); fields.add(FieldInfo.of("listVal", TypeSignature.ofList(string))); fields.add(FieldInfo.builder("selfRef", TypeSignature.ofNamed(FooStruct.class)) .requirement(FieldRequirement.OPTIONAL).build()); final StructInfo fooStruct = newStructInfo(FooStruct.class); assertThat(fooStruct).isEqualTo(new StructInfo(FooStruct.class.getName(), fields)); }