ProjectHandleResolverManager implements IProjectHandleResolverManager { @Override @Transactional public boolean deleteProjectHandleResolver(IProjectHandleResolver resolver) { if (resolverDao.getProjectsForResolverId(resolver.getId()).size() > 0) { return false; } ProjectHandleResolverDTO resolverDto = mapper.mapProjectHandleResolver(resolver); resolverDao.deleteDTO(resolverDto); return true; }  @Override @Transactional boolean saveProjectHandleResolver(IProjectHandleResolver resolver, String username); @Override IProjectHandleResolver getProjectHandleResolver(String id); @Override List<IProjectHandleResolver> getProjectHandleResolvers(String username); @Override @Transactional boolean deleteProjectHandleResolver(IProjectHandleResolver resolver); @Transactional @Override Status validateProjectResolverHandle(IProjectHandleResolver resolver, boolean setResolverValidation);  }
@Test public void deleteProjectHandleResolverTest() throws QuadrigaException { String id = "123"; IProjectHandleResolver resolver = new ProjectHandleResolver(); resolver.setId(id); ProjectHandleResolverDTO projectHandlerResolverDTO = new ProjectHandleResolverDTO(); projectHandlerResolverDTO.setDescription("sample"); List<ProjectDTO> projectDTOList = new ArrayList<ProjectDTO>(); Mockito.when(resolverDao.getProjectsForResolverId(id)).thenReturn(projectDTOList); Mockito.when(mapper.mapProjectHandleResolver(resolver)).thenReturn(projectHandlerResolverDTO); boolean deleteStatus = projectHandleResolverManagerUnderTest.deleteProjectHandleResolver(resolver); assertEquals(deleteStatus, true); }
@Test public void deleteProjectHandleResolverCannotDeleteTest() throws QuadrigaException { String id = "456"; IProjectHandleResolver resolver = new ProjectHandleResolver(); resolver.setId(id); List<ProjectDTO> projectDTOList = new ArrayList<ProjectDTO>(); projectDTOList.add(new ProjectDTO()); Mockito.when(resolverDao.getProjectsForResolverId(id)).thenReturn(projectDTOList); boolean deleteStatus = projectHandleResolverManagerUnderTest.deleteProjectHandleResolver(resolver); assertEquals(deleteStatus, false); }