SecurityRoleDaoHelper { public SecurityRoleEntity getSecurityRoleEntity(String securityRoleName) { SecurityRoleEntity securityRoleEntity = securityRoleDao.getSecurityRoleByName(securityRoleName); if (securityRoleEntity == null) { throw new ObjectNotFoundException(String.format("Security role with name \"%s\" doesn't exist.", securityRoleName)); } return securityRoleEntity; }  SecurityRoleEntity getSecurityRoleEntity(String securityRoleName);  }
@Test public void testGetSecurityRoleEntity() { SecurityRoleEntity securityRoleEntity = new SecurityRoleEntity(); when(securityRoleDao.getSecurityRoleByName(SECURITY_ROLE)).thenReturn(securityRoleEntity); SecurityRoleEntity result = securityRoleDaoHelper.getSecurityRoleEntity(SECURITY_ROLE); assertEquals(securityRoleEntity, result); verify(securityRoleDao).getSecurityRoleByName(SECURITY_ROLE); verifyNoMoreInteractionsHelper(); }
@Test public void testGetSecurityRoleEntitySecurityRoleNoExists() { expectedException.expect(ObjectNotFoundException.class); expectedException.expectMessage(String.format("Security role with name \"%s\" doesn't exist.", SECURITY_ROLE)); when(securityRoleDao.getSecurityRoleByName(SECURITY_ROLE)).thenReturn(null); securityRoleDaoHelper.getSecurityRoleEntity(SECURITY_ROLE); verify(securityRoleDao).getSecurityRoleByName(SECURITY_ROLE); verifyNoMoreInteractionsHelper(); }