ThriftDocServicePlugin implements DocServicePlugin { @VisibleForTesting static TypeSignature toTypeSignature(FieldValueMetaData fieldValueMetaData) { if (fieldValueMetaData instanceof StructMetaData) { return TypeSignature.ofNamed(((StructMetaData) fieldValueMetaData).structClass); } if (fieldValueMetaData instanceof EnumMetaData) { return TypeSignature.ofNamed(((EnumMetaData) fieldValueMetaData).enumClass); } if (fieldValueMetaData instanceof ListMetaData) { return TypeSignature.ofList(toTypeSignature(((ListMetaData) fieldValueMetaData).elemMetaData)); } if (fieldValueMetaData instanceof SetMetaData) { return TypeSignature.ofSet(toTypeSignature(((SetMetaData) fieldValueMetaData).elemMetaData)); } if (fieldValueMetaData instanceof MapMetaData) { return TypeSignature.ofMap(toTypeSignature(((MapMetaData) fieldValueMetaData).keyMetaData), toTypeSignature(((MapMetaData) fieldValueMetaData).valueMetaData)); } if (fieldValueMetaData.isBinary()) { return BINARY; } switch (fieldValueMetaData.type) { case TType.VOID: return VOID; case TType.BOOL: return BOOL; case TType.BYTE: return I8; case TType.DOUBLE: return DOUBLE; case TType.I16: return I16; case TType.I32: return I32; case TType.I64: return I64; case TType.STRING: return STRING; } final String unresolvedName; if (fieldValueMetaData.isTypedef()) { unresolvedName = fieldValueMetaData.getTypedefName(); } else { unresolvedName = null; } return TypeSignature.ofUnresolved(firstNonNull(unresolvedName, "unknown")); }  @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 incompleteStructMetadata() throws Exception { assertThat(toTypeSignature(new FieldValueMetaData(TType.STRUCT))) .isEqualTo(TypeSignature.ofUnresolved("unknown")); }