Search in sources :

Example 1 with StatusMessage

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());
}
Also used : StatusMessage(org.motechproject.admin.domain.StatusMessage) Test(org.junit.Test)

Example 2 with StatusMessage

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);
}
Also used : StatusMessage(org.motechproject.admin.domain.StatusMessage) Test(org.junit.Test)

Example 3 with StatusMessage

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);
}
Also used : StatusMessage(org.motechproject.admin.domain.StatusMessage) Test(org.junit.Test)

Example 4 with StatusMessage

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);
}
Also used : StatusMessage(org.motechproject.admin.domain.StatusMessage) Test(org.junit.Test)

Example 5 with StatusMessage

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;
}
Also used : ArrayList(java.util.ArrayList) StatusMessage(org.motechproject.admin.domain.StatusMessage) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

StatusMessage (org.motechproject.admin.domain.StatusMessage)12 Test (org.junit.Test)8 Transactional (org.springframework.transaction.annotation.Transactional)3 DateTime (org.joda.time.DateTime)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 NotificationRule (org.motechproject.admin.domain.NotificationRule)1 Level (org.motechproject.admin.messages.Level)1 MotechEvent (org.motechproject.event.MotechEvent)1