TaxonomyService extends BaseService { @GET @Produces(Servlets.JSON_MEDIA_TYPE) public Response getTaxonomies(@Context HttpHeaders headers, @Context UriInfo ui) throws CatalogException { AtlasPerfTracer perf = null; try { if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TaxonomyService.getTaxonomies()"); } String queryString = decode(getQueryString(ui)); Request request = new CollectionRequest(Collections.<String, Object>emptyMap(), queryString); Result result = getResources(taxonomyResourceProvider, request); return Response.status(Response.Status.OK).entity(getSerializer().serialize(result, ui)).build(); } finally { AtlasPerfTracer.log(perf); } }  @Inject void setMetadataService(MetadataService metadataService, AtlasTypeDefStore typeDefStore); @GET @Path("{taxonomyName}") @Produces(Servlets.JSON_MEDIA_TYPE) Response getTaxonomy(@Context HttpHeaders headers,
                                @Context UriInfo ui,
                                @PathParam("taxonomyName") String taxonomyName); @GET @Produces(Servlets.JSON_MEDIA_TYPE) Response getTaxonomies(@Context HttpHeaders headers, @Context UriInfo ui); @POST @Path("{taxonomyName}") @Produces(Servlets.JSON_MEDIA_TYPE) Response createTaxonomy(String body,
                                   @Context HttpHeaders headers,
                                   @Context UriInfo ui,
                                   @PathParam("taxonomyName") String taxonomyName); @PUT @Path("{taxonomyName}") @Produces(Servlets.JSON_MEDIA_TYPE) Response updateTaxonomy(String body,
                                   @Context HttpHeaders headers,
                                   @Context UriInfo ui,
                                   @PathParam("taxonomyName") String taxonomyName); @DELETE @Path("{taxonomyName}") @Produces(Servlets.JSON_MEDIA_TYPE) Response deleteTaxonomy(@Context HttpHeaders headers,
                                   @Context UriInfo ui,
                                   @PathParam("taxonomyName") String taxonomyName); @GET @Path("{taxonomyName}/terms/{termName}") @Produces(Servlets.JSON_MEDIA_TYPE) Response getTaxonomyTerm(@Context HttpHeaders headers,
                                    @Context UriInfo ui,
                                    @PathParam("taxonomyName") String taxonomyName,
                                    @PathParam("termName") String termName); @GET @Path("{taxonomyName}/terms") @Produces(Servlets.JSON_MEDIA_TYPE) Response getTaxonomyTerms(@Context HttpHeaders headers,
                                     @Context UriInfo ui,
                                     @PathParam("taxonomyName") String taxonomyName); @GET @Path("{taxonomyName}/terms/{rootTerm}/{remainder:.*}") @Produces(Servlets.JSON_MEDIA_TYPE) Response getSubTerms(@Context HttpHeaders headers,
                            @Context UriInfo ui,
                            @PathParam("taxonomyName") String taxonomyName,
                            @PathParam("rootTerm") String rootTerm,
                            @PathParam("remainder") String remainder); @POST @Path("{taxonomyName}/terms/{termName}") @Produces(Servlets.JSON_MEDIA_TYPE) Response createTerm(String body,
                               @Context HttpHeaders headers,
                               @Context UriInfo ui,
                               @PathParam("taxonomyName") String taxonomyName,
                               @PathParam("termName") String termName); @POST @Path("{taxonomyName}/terms/{termName}/{remainder:.*}") @Produces(Servlets.JSON_MEDIA_TYPE) Response createSubTerm(String body,
                                  @Context HttpHeaders headers,
                                  @Context UriInfo ui,
                                  @PathParam("taxonomyName") String taxonomyName,
                                  @PathParam("termName") String termName,
                                  @PathParam("remainder") String remainder); @PUT @Path("{taxonomyName}/terms/{termName}") @Produces(Servlets.JSON_MEDIA_TYPE) Response updateTerm(String body,
                               @Context HttpHeaders headers,
                               @Context UriInfo ui,
                               @PathParam("taxonomyName") String taxonomyName,
                               @PathParam("termName") String termName); @PUT @Path("{taxonomyName}/terms/{termName}/{remainder:.*}") @Produces(Servlets.JSON_MEDIA_TYPE) Response updateSubTerm(String body,
                                  @Context HttpHeaders headers,
                                  @Context UriInfo ui,
                                  @PathParam("taxonomyName") String taxonomyName,
                                  @PathParam("termName") String termName,
                                  @PathParam("remainder") String remainder); @DELETE @Path("{taxonomyName}/terms/{termName}") @Produces(Servlets.JSON_MEDIA_TYPE) Response deleteTerm(@Context HttpHeaders headers,
                               @Context UriInfo ui,
                               @PathParam("taxonomyName") String taxonomyName,
                               @PathParam("termName") String termName); @DELETE @Path("{taxonomyName}/terms/{termName}/{remainder:.*}") @Produces(Servlets.JSON_MEDIA_TYPE) Response deleteSubTerm(@Context HttpHeaders headers,
                                  @Context UriInfo ui,
                                  @PathParam("taxonomyName") String taxonomyName,
                                  @PathParam("termName") String termName,
                                  @PathParam("remainder") String remainder);  }
@Test public void testGetTaxonomies() throws Exception { MetadataService metadataService = createStrictMock(MetadataService.class); AtlasTypeDefStore typeDefStore = createStrictMock(AtlasTypeDefStore.class); ResourceProvider taxonomyResourceProvider = createStrictMock(ResourceProvider.class); ResourceProvider termResourceProvider = createStrictMock(ResourceProvider.class); UriInfo uriInfo = createNiceMock(UriInfo.class); URI uri = new URI("http: JsonSerializer serializer = createStrictMock(JsonSerializer.class); Capture<Request> requestCapture = newCapture(); Collection<Map<String, Object>> resultPropertyMaps = new ArrayList<>(); Map<String, Object> propertyMap = new HashMap<>(); propertyMap.put("name", "testTaxonomy"); resultPropertyMaps.add(propertyMap); Result result = new Result(resultPropertyMaps); expect(uriInfo.getRequestUri()).andReturn(uri); expect(taxonomyResourceProvider.getResources(capture(requestCapture))).andReturn(result); expect(serializer.serialize(result, uriInfo)).andReturn("Taxonomy Get Response"); expect(metadataService.getTypeDefinition(TaxonomyResourceProvider.TAXONOMY_TERM_TYPE)).andReturn(TaxonomyResourceProvider.TAXONOMY_TERM_TYPE + "-definition"); replay(uriInfo, metadataService, taxonomyResourceProvider, termResourceProvider, serializer); TestTaxonomyService service = new TestTaxonomyService( metadataService, typeDefStore, taxonomyResourceProvider, termResourceProvider, serializer); Response response = service.getTaxonomies(null, uriInfo); Request request = requestCapture.getValue(); assertTrue(request.getQueryProperties().isEmpty()); assertEquals(request.getQueryString(), "name:testTaxonomy"); assertEquals(response.getStatus(), 200); assertEquals(response.getEntity(), "Taxonomy Get Response"); verify(uriInfo, taxonomyResourceProvider, termResourceProvider, serializer); }