SecurityRoleFunctionDaoHelper { public SecurityRoleFunctionEntity getSecurityRoleFunctionEntity(SecurityRoleFunctionKey securityRoleFunctionKey) { SecurityRoleFunctionEntity securityRoleFunctionEntity = securityRoleFunctionDao.getSecurityRoleFunctionByKey(securityRoleFunctionKey); if (securityRoleFunctionEntity == null) { throw new ObjectNotFoundException(String .format("Security role to function mapping with \"%s\" security role name and \"%s\" security function name doesn't exist.", securityRoleFunctionKey.getSecurityRoleName(), securityRoleFunctionKey.getSecurityFunctionName())); } return securityRoleFunctionEntity; }  SecurityRoleFunctionEntity getSecurityRoleFunctionEntity(SecurityRoleFunctionKey securityRoleFunctionKey);  }
@Test public void testGetSecurityRoleFunctionEntity() { SecurityRoleFunctionKey securityRoleFunctionKey = new SecurityRoleFunctionKey(SECURITY_ROLE, SECURITY_FUNCTION); SecurityRoleFunctionEntity securityRoleFunctionEntity = new SecurityRoleFunctionEntity(); when(securityRoleFunctionDao.getSecurityRoleFunctionByKey(securityRoleFunctionKey)).thenReturn(securityRoleFunctionEntity); SecurityRoleFunctionEntity result = securityRoleFunctionDaoHelper.getSecurityRoleFunctionEntity(securityRoleFunctionKey); assertEquals(securityRoleFunctionEntity, result); verify(securityRoleFunctionDao).getSecurityRoleFunctionByKey(securityRoleFunctionKey); verifyNoMoreInteractionsHelper(); }
@Test public void testGetSecurityRoleFunctionEntitySecurityRoleFunctionNoExists() { SecurityRoleFunctionKey securityRoleFunctionKey = new SecurityRoleFunctionKey(SECURITY_ROLE, SECURITY_FUNCTION); when(securityRoleFunctionDao.getSecurityRoleFunctionByKey(securityRoleFunctionKey)).thenReturn(null); expectedException.expect(ObjectNotFoundException.class); expectedException.expectMessage(String .format("Security role to function mapping with \"%s\" security role name and \"%s\" security function name doesn't exist.", SECURITY_ROLE, SECURITY_FUNCTION)); securityRoleFunctionDaoHelper.getSecurityRoleFunctionEntity(securityRoleFunctionKey); verify(securityRoleFunctionDao).getSecurityRoleFunctionByKey(securityRoleFunctionKey); verifyNoMoreInteractionsHelper(); }