use of org.motechproject.admin.domain.StatusMessage in project motech by motech.
the class AdminBundleIT method testStatusMessageService.
@Test
public void testStatusMessageService() {
statusMessageService.error(ERROR_MSG, MODULE_NAME, TIMEOUT);
statusMessageService.warn(WARNING_MSG, MODULE_NAME, TIMEOUT);
statusMessageService.debug(DEBUG_MSG, MODULE_NAME, TIMEOUT);
List<StatusMessage> messages = statusMessageService.getActiveMessages();
messages = Lambda.filter(having(on(StatusMessage.class).getTimeout(), equalTo(TIMEOUT)), messages);
assertFalse(messages.isEmpty());
StatusMessage msg = findMsgByText(messages, ERROR_MSG);
assertEquals(Level.ERROR, msg.getLevel());
assertEquals(MODULE_NAME, msg.getModuleName());
msg = findMsgByText(messages, WARNING_MSG);
assertEquals(Level.WARN, msg.getLevel());
assertEquals(MODULE_NAME, msg.getModuleName());
msg = findMsgByText(messages, DEBUG_MSG);
assertEquals(Level.DEBUG, msg.getLevel());
assertEquals(MODULE_NAME, msg.getModuleName());
}
use of org.motechproject.admin.domain.StatusMessage in project motech by motech.
the class StatusMessageServiceTest method testPostMessageNullText.
@Test(expected = IllegalArgumentException.class)
public void testPostMessageNullText() {
StatusMessage illegalMessage = new StatusMessage(null, MODULE_NAME, Level.INFO);
statusMessageService.postMessage(illegalMessage);
}
use of org.motechproject.admin.domain.StatusMessage in project motech by motech.
the class StatusMessageServiceTest method testPostMessageNullLevel.
@Test(expected = IllegalArgumentException.class)
public void testPostMessageNullLevel() {
StatusMessage illegal = new StatusMessage("text", MODULE_NAME, null);
statusMessageService.postMessage(illegal);
}
use of org.motechproject.admin.domain.StatusMessage in project motech by motech.
the class StatusMessageServiceTest method testPostMessageNullTimeout.
@Test(expected = IllegalArgumentException.class)
public void testPostMessageNullTimeout() {
StatusMessage illegalMessage = new StatusMessage("text", MODULE_NAME, Level.INFO, null);
statusMessageService.postMessage(illegalMessage);
}
use of org.motechproject.admin.domain.StatusMessage in project motech by motech.
the class StatusMessageServiceImpl method getAllMessages.
@Override
@Transactional
public List<StatusMessage> getAllMessages() {
List<StatusMessage> statusMessages = new ArrayList<>();
if (getStatusMessagesDataService() == null) {
StatusMessage noDbMessage = new StatusMessage("{noDB}", "", Level.ERROR);
statusMessages.add(noDbMessage);
} else {
statusMessages = statusMessagesDataService.retrieveAll();
}
return statusMessages;
}
Aggregations