MessageTypeDaoHelper { public MessageTypeEntity getMessageTypeEntity(String code) { MessageTypeEntity messageTypeEntity = messageTypeDao.getMessageTypeByCode(code); if (messageTypeEntity == null) { throw new ObjectNotFoundException(String.format("Message type with code \"%s\" doesn't exist.", code)); } return messageTypeEntity; }  MessageTypeEntity getMessageTypeEntity(String code);  }
@Test public void testGetMessageTypeEntity() { MessageTypeEntity messageTypeEntity = messageTypeDaoTestHelper.createMessageTypeEntity(MESSAGE_TYPE); assertEquals(messageTypeEntity, messageTypeDaoHelper.getMessageTypeEntity(MESSAGE_TYPE)); assertEquals(messageTypeEntity, messageTypeDaoHelper.getMessageTypeEntity(MESSAGE_TYPE.toUpperCase())); assertEquals(messageTypeEntity, messageTypeDaoHelper.getMessageTypeEntity(MESSAGE_TYPE.toLowerCase())); try { messageTypeDaoHelper.getMessageTypeEntity(I_DO_NOT_EXIST); fail(); } catch (ObjectNotFoundException e) { assertEquals(String.format("Message type with code \"%s\" doesn't exist.", I_DO_NOT_EXIST), e.getMessage()); } }