SecurityFunctionDaoHelper { public SecurityFunctionEntity getSecurityFunctionEntity(String securityFunctionName) { SecurityFunctionEntity securityFunctionEntity = securityFunctionDao.getSecurityFunctionByName(securityFunctionName); if (securityFunctionEntity == null) { throw new ObjectNotFoundException(String.format("Security function with name \"%s\" doesn't exist.", securityFunctionName)); } return securityFunctionEntity; }  SecurityFunctionEntity getSecurityFunctionEntity(String securityFunctionName);  }
@Test public void testGetSecurityFunctionEntity() { SecurityFunctionEntity securityFunctionEntity = new SecurityFunctionEntity(); when(securityFunctionDao.getSecurityFunctionByName(SECURITY_FUNCTION)).thenReturn(securityFunctionEntity); SecurityFunctionEntity result = securityFunctionDaoHelper.getSecurityFunctionEntity(SECURITY_FUNCTION); assertEquals(securityFunctionEntity, result); verify(securityFunctionDao).getSecurityFunctionByName(SECURITY_FUNCTION); verifyNoMoreInteractionsHelper(); }
@Test public void testGetSecurityFunctionEntitySecurityFunctionNoExists() { when(securityFunctionDao.getSecurityFunctionByName(SECURITY_FUNCTION)).thenReturn(null); expectedException.expect(ObjectNotFoundException.class); expectedException.expectMessage(String.format("Security function with name \"%s\" doesn't exist.", SECURITY_FUNCTION)); securityFunctionDaoHelper.getSecurityFunctionEntity(SECURITY_FUNCTION); verify(securityFunctionDao).getSecurityFunctionByName(SECURITY_FUNCTION); verifyNoMoreInteractionsHelper(); }