APIDefinitionBuilder { public APIDefinitionResponse build() { var response = new APIDefinitionResponse(); response.services = services.stream().map(this::serviceResponse).collect(Collectors.toList()); response.types = Lists.newArrayList(); response.types.addAll(beanTypes.entrySet().stream().map(this::beanTypeResponse).collect(Collectors.toList())); response.types.addAll(enumTypes.entrySet().stream().map(this::enumTypeResponse).collect(Collectors.toList())); return response; }  void addServiceInterface(Class<?> serviceInterface); APIDefinitionResponse build(); String parseType(Type type);  }
@Test void build() { builder.addServiceInterface(TestWebService.class); APIDefinitionResponse response = builder.build(); APIDefinitionResponse expectedResponse = JSON.fromJSON(APIDefinitionResponse.class, ClasspathResources.text("api-test/test-webservice.json")); assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); }