@Test public void test3updateRepository() throws Exception { VXAsset vXAsset = new VXAsset(); RangerService rangerService = rangerService(); HttpServletRequest request = null; VXRepository vXRepository = vXRepository(rangerService); XXService xService = xService(); XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class); Mockito.when(daoMgr.getXXService()).thenReturn(xServiceDao); Mockito.when(xServiceDao.getById(Id)).thenReturn(xService); Mockito.when(serviceUtil.publicObjecttoVXAsset(vXRepository)).thenReturn(vXAsset); Mockito.when(serviceUtil.toRangerService(vXAsset)).thenReturn(rangerService); Mockito.when(serviceREST.updateService(rangerService, request)).thenReturn(rangerService); Mockito.when(serviceUtil.toVXAsset(rangerService)).thenReturn(vXAsset); Mockito.when(serviceUtil.vXAssetToPublicObject(vXAsset)).thenReturn(vXRepository); VXRepository dbVXRepository = publicAPIs.updateRepository(vXRepository, Id); Assert.assertNotNull(dbVXRepository); Assert.assertEquals(dbVXRepository, vXRepository); Assert.assertEquals(dbVXRepository.getId(), vXRepository.getId()); Assert.assertEquals(dbVXRepository.getName(), vXRepository.getName()); Mockito.verify(serviceREST).updateService(rangerService, request); Mockito.verify(serviceUtil).publicObjecttoVXAsset(vXRepository); Mockito.verify(serviceUtil).toRangerService(vXAsset); Mockito.verify(serviceUtil).toVXAsset(rangerService); Mockito.verify(serviceUtil).vXAssetToPublicObject(vXAsset); Mockito.verify(daoMgr).getXXService(); }
@PUT @Path("/api/repository/{id}") @Produces({ "application/json", "application/xml" }) public VXRepository updateRepository(VXRepository vXRepository, @PathParam("id") Long id) { if(logger.isDebugEnabled()) { logger.debug("==> PublicAPIs.updateRepository(" + id + ")"); } XXService existing = daoMgr.getXXService().getById(id); if(existing == null) { throw restErrorUtil.createRESTException("Repository not found for Id: " + id, MessageEnums.DATA_NOT_FOUND); } vXRepository.setId(id); VXAsset vXAsset = serviceUtil.publicObjecttoVXAsset(vXRepository); RangerService service = serviceUtil.toRangerService(vXAsset); service.setVersion(existing.getVersion()); RangerService updatedService = serviceREST.updateService(service, null); VXAsset retvXAsset = serviceUtil.toVXAsset(updatedService); VXRepository ret = serviceUtil.vXAssetToPublicObject(retvXAsset); if(logger.isDebugEnabled()) { logger.debug("<== PublicAPIs.updateRepository(" + ret + ")"); } return ret; }
PublicAPIs { @PUT @Path("/api/repository/{id}") @Produces({ "application/json", "application/xml" }) public VXRepository updateRepository(VXRepository vXRepository, @PathParam("id") Long id) { if(logger.isDebugEnabled()) { logger.debug("==> PublicAPIs.updateRepository(" + id + ")"); } XXService existing = daoMgr.getXXService().getById(id); if(existing == null) { throw restErrorUtil.createRESTException("Repository not found for Id: " + id, MessageEnums.DATA_NOT_FOUND); } vXRepository.setId(id); VXAsset vXAsset = serviceUtil.publicObjecttoVXAsset(vXRepository); RangerService service = serviceUtil.toRangerService(vXAsset); service.setVersion(existing.getVersion()); RangerService updatedService = serviceREST.updateService(service, null); VXAsset retvXAsset = serviceUtil.toVXAsset(updatedService); VXRepository ret = serviceUtil.vXAssetToPublicObject(retvXAsset); if(logger.isDebugEnabled()) { logger.debug("<== PublicAPIs.updateRepository(" + ret + ")"); } return ret; } }
PublicAPIs { @PUT @Path("/api/repository/{id}") @Produces({ "application/json", "application/xml" }) public VXRepository updateRepository(VXRepository vXRepository, @PathParam("id") Long id) { if(logger.isDebugEnabled()) { logger.debug("==> PublicAPIs.updateRepository(" + id + ")"); } XXService existing = daoMgr.getXXService().getById(id); if(existing == null) { throw restErrorUtil.createRESTException("Repository not found for Id: " + id, MessageEnums.DATA_NOT_FOUND); } vXRepository.setId(id); VXAsset vXAsset = serviceUtil.publicObjecttoVXAsset(vXRepository); RangerService service = serviceUtil.toRangerService(vXAsset); service.setVersion(existing.getVersion()); RangerService updatedService = serviceREST.updateService(service, null); VXAsset retvXAsset = serviceUtil.toVXAsset(updatedService); VXRepository ret = serviceUtil.vXAssetToPublicObject(retvXAsset); if(logger.isDebugEnabled()) { logger.debug("<== PublicAPIs.updateRepository(" + ret + ")"); } return ret; }  }
PublicAPIs { @PUT @Path("/api/repository/{id}") @Produces({ "application/json", "application/xml" }) public VXRepository updateRepository(VXRepository vXRepository, @PathParam("id") Long id) { if(logger.isDebugEnabled()) { logger.debug("==> PublicAPIs.updateRepository(" + id + ")"); } XXService existing = daoMgr.getXXService().getById(id); if(existing == null) { throw restErrorUtil.createRESTException("Repository not found for Id: " + id, MessageEnums.DATA_NOT_FOUND); } vXRepository.setId(id); VXAsset vXAsset = serviceUtil.publicObjecttoVXAsset(vXRepository); RangerService service = serviceUtil.toRangerService(vXAsset); service.setVersion(existing.getVersion()); RangerService updatedService = serviceREST.updateService(service, null); VXAsset retvXAsset = serviceUtil.toVXAsset(updatedService); VXRepository ret = serviceUtil.vXAssetToPublicObject(retvXAsset); if(logger.isDebugEnabled()) { logger.debug("<== PublicAPIs.updateRepository(" + ret + ")"); } return ret; }  @GET @Path("/api/repository/{id}") @Produces({ "application/json", "application/xml" }) VXRepository getRepository(@PathParam("id") Long id); @POST @Path("/api/repository/") @Produces({ "application/json", "application/xml" }) VXRepository createRepository(VXRepository vXRepository); @PUT @Path("/api/repository/{id}") @Produces({ "application/json", "application/xml" }) VXRepository updateRepository(VXRepository vXRepository,
			@PathParam("id") Long id); @DELETE @Path("/api/repository/{id}") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") @RangerAnnotationClassName(class_name = VXAsset.class) void deleteRepository(@PathParam("id") Long id,
			@Context HttpServletRequest request); @GET @Path("/api/repository/") @Produces({ "application/json", "application/xml" }) VXRepositoryList searchRepositories(
			@Context HttpServletRequest request); @GET @Path("/api/repository/count") @Produces({ "application/json", "application/xml" }) VXLong countRepositories(@Context HttpServletRequest request); @GET @Path("/api/policy/{id}") @Produces({ "application/json", "application/xml" }) VXPolicy getPolicy(@PathParam("id") Long id); @POST @Path("/api/policy") @Produces({ "application/json", "application/xml" }) VXPolicy createPolicy(VXPolicy vXPolicy); @PUT @Path("/api/policy/{id}") @Produces({ "application/json", "application/xml" }) VXPolicy updatePolicy(VXPolicy vXPolicy, @PathParam("id") Long id); @DELETE @Path("/api/policy/{id}") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") @RangerAnnotationClassName(class_name = VXResource.class) void deletePolicy(@PathParam("id") Long id,
			@Context HttpServletRequest request); @GET @Path("/api/policy") @Produces({ "application/json", "application/xml" }) VXPolicyList searchPolicies(@Context HttpServletRequest request); @GET @Path("/api/policy/count") @Produces({ "application/xml", "application/json" }) VXLong countPolicies(@Context HttpServletRequest request); }
PublicAPIs { @PUT @Path("/api/repository/{id}") @Produces({ "application/json", "application/xml" }) public VXRepository updateRepository(VXRepository vXRepository, @PathParam("id") Long id) { if(logger.isDebugEnabled()) { logger.debug("==> PublicAPIs.updateRepository(" + id + ")"); } XXService existing = daoMgr.getXXService().getById(id); if(existing == null) { throw restErrorUtil.createRESTException("Repository not found for Id: " + id, MessageEnums.DATA_NOT_FOUND); } vXRepository.setId(id); VXAsset vXAsset = serviceUtil.publicObjecttoVXAsset(vXRepository); RangerService service = serviceUtil.toRangerService(vXAsset); service.setVersion(existing.getVersion()); RangerService updatedService = serviceREST.updateService(service, null); VXAsset retvXAsset = serviceUtil.toVXAsset(updatedService); VXRepository ret = serviceUtil.vXAssetToPublicObject(retvXAsset); if(logger.isDebugEnabled()) { logger.debug("<== PublicAPIs.updateRepository(" + ret + ")"); } return ret; }  @GET @Path("/api/repository/{id}") @Produces({ "application/json", "application/xml" }) VXRepository getRepository(@PathParam("id") Long id); @POST @Path("/api/repository/") @Produces({ "application/json", "application/xml" }) VXRepository createRepository(VXRepository vXRepository); @PUT @Path("/api/repository/{id}") @Produces({ "application/json", "application/xml" }) VXRepository updateRepository(VXRepository vXRepository,
			@PathParam("id") Long id); @DELETE @Path("/api/repository/{id}") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") @RangerAnnotationClassName(class_name = VXAsset.class) void deleteRepository(@PathParam("id") Long id,
			@Context HttpServletRequest request); @GET @Path("/api/repository/") @Produces({ "application/json", "application/xml" }) VXRepositoryList searchRepositories(
			@Context HttpServletRequest request); @GET @Path("/api/repository/count") @Produces({ "application/json", "application/xml" }) VXLong countRepositories(@Context HttpServletRequest request); @GET @Path("/api/policy/{id}") @Produces({ "application/json", "application/xml" }) VXPolicy getPolicy(@PathParam("id") Long id); @POST @Path("/api/policy") @Produces({ "application/json", "application/xml" }) VXPolicy createPolicy(VXPolicy vXPolicy); @PUT @Path("/api/policy/{id}") @Produces({ "application/json", "application/xml" }) VXPolicy updatePolicy(VXPolicy vXPolicy, @PathParam("id") Long id); @DELETE @Path("/api/policy/{id}") @PreAuthorize("hasRole('ROLE_SYS_ADMIN')") @RangerAnnotationClassName(class_name = VXResource.class) void deletePolicy(@PathParam("id") Long id,
			@Context HttpServletRequest request); @GET @Path("/api/policy") @Produces({ "application/json", "application/xml" }) VXPolicyList searchPolicies(@Context HttpServletRequest request); @GET @Path("/api/policy/count") @Produces({ "application/xml", "application/json" }) VXLong countPolicies(@Context HttpServletRequest request);  }