TaxonomyService extends BaseService { @POST @Path("{taxonomyName}/terms/{termName}/{remainder:.*}") @Produces(Servlets.JSON_MEDIA_TYPE) public Response createSubTerm(String body, @Context HttpHeaders headers, @Context UriInfo ui, @PathParam("taxonomyName") String taxonomyName, @PathParam("termName") String termName, @PathParam("remainder") String remainder) throws CatalogException { AtlasPerfTracer perf = null; try { if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) { perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TaxonomyService.createSubTerm(" + taxonomyName + ", " + termName + ", " + remainder + ")"); } Map<String, Object> properties = parsePayload(body); String[] pathTokens = remainder.split("/"); validateName(pathTokens[pathTokens.length - 1]); properties.put("termPath", new TermPath(taxonomyName, String.format("%s%s", termName, remainder.replaceAll("/?terms/?([.]*)", "$1.")))); createResource(termResourceProvider, new InstanceRequest(properties)); return Response.status(Response.Status.CREATED).entity( new Results(ui.getRequestUri().toString(), 201)).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 testCreateSubTerm() throws Exception { String taxonomyName = "testTaxonomy"; String termName = "testTerm"; 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: Capture<Request> requestCapture = newCapture(); String body = "{ \"description\" : \"test description\" } "; expect(uriInfo.getRequestUri()).andReturn(uri); expect(metadataService.getTypeDefinition(TaxonomyResourceProvider.TAXONOMY_TERM_TYPE)).andReturn(TaxonomyResourceProvider.TAXONOMY_TERM_TYPE + "-definition"); termResourceProvider.createResource(capture(requestCapture)); replay(uriInfo, metadataService, taxonomyResourceProvider, termResourceProvider); TestTaxonomyService service = new TestTaxonomyService( metadataService, typeDefStore, taxonomyResourceProvider, termResourceProvider, null); Response response = service.createSubTerm(body, null, uriInfo, taxonomyName, termName, "/terms/testTerm2"); Request request = requestCapture.getValue(); assertEquals(request.getQueryProperties().size(), 2); assertEquals(request.getQueryProperties().get("description"), "test description"); TermPath termPath = (TermPath) request.getQueryProperties().get("termPath"); assertEquals(termPath.getFullyQualifiedName(), "testTaxonomy.testTerm.testTerm2"); assertNull(request.getQueryString()); assertEquals(response.getStatus(), 201); BaseService.Results createResults = (BaseService.Results) response.getEntity(); assertEquals(createResults.href, "http: assertEquals(createResults.status, 201); verify(uriInfo, taxonomyResourceProvider, termResourceProvider); }