Search in sources :

Example 6 with SystemMessageModel

use of com.synopsys.integration.alert.common.persistence.model.SystemMessageModel in project hub-alert by blackducksoftware.

the class SystemActions method getSystemMessagesBefore.

private ActionResponse<MultiSystemMessageModel> getSystemMessagesBefore(String endDate) throws ParseException {
    OffsetDateTime date = DateUtils.parseDateFromJsonString(endDate);
    List<SystemMessageModel> messages = systemMessageAccessor.getSystemMessagesBefore(date);
    return new ActionResponse<>(HttpStatus.OK, new MultiSystemMessageModel(messages));
}
Also used : OffsetDateTime(java.time.OffsetDateTime) SystemMessageModel(com.synopsys.integration.alert.common.persistence.model.SystemMessageModel) ActionResponse(com.synopsys.integration.alert.common.action.ActionResponse)

Example 7 with SystemMessageModel

use of com.synopsys.integration.alert.common.persistence.model.SystemMessageModel in project hub-alert by blackducksoftware.

the class AboutReaderTest method initialize.

@BeforeEach
public void initialize() {
    alertWebServerUrlManager = Mockito.mock(AlertWebServerUrlManager.class);
    Mockito.when(alertWebServerUrlManager.getServerComponentsBuilder()).thenReturn(UriComponentsBuilder.newInstance());
    defaultSystemStatusUtility = Mockito.mock(DefaultSystemStatusAccessor.class);
    Mockito.when(defaultSystemStatusUtility.isSystemInitialized()).thenReturn(Boolean.TRUE);
    Mockito.when(defaultSystemStatusUtility.getStartupTime()).thenReturn(DateUtils.createCurrentDateTimestamp());
    defaultSystemMessageUtility = Mockito.mock(DefaultSystemMessageAccessor.class);
    Mockito.when(defaultSystemMessageUtility.getSystemMessages()).thenReturn(Collections.singletonList(new SystemMessageModel("1", RestConstants.formatDate(new Date()), "ERROR", "startup errors", "type")));
    descriptorMetadataActions = Mockito.mock(DescriptorMetadataActions.class);
    DescriptorsResponseModel descriptorsResponseModel = new DescriptorsResponseModel(Set.of(Mockito.mock(DescriptorMetadata.class), Mockito.mock(DescriptorMetadata.class)));
    Mockito.when(descriptorMetadataActions.getDescriptorsByType(Mockito.anyString())).thenReturn(new ActionResponse<>(HttpStatus.OK, descriptorsResponseModel));
}
Also used : DefaultSystemStatusAccessor(com.synopsys.integration.alert.database.api.DefaultSystemStatusAccessor) SystemMessageModel(com.synopsys.integration.alert.common.persistence.model.SystemMessageModel) DescriptorMetadataActions(com.synopsys.integration.alert.web.api.metadata.DescriptorMetadataActions) AlertWebServerUrlManager(com.synopsys.integration.alert.common.rest.AlertWebServerUrlManager) DefaultSystemMessageAccessor(com.synopsys.integration.alert.database.system.DefaultSystemMessageAccessor) Date(java.util.Date) DescriptorsResponseModel(com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with SystemMessageModel

use of com.synopsys.integration.alert.common.persistence.model.SystemMessageModel in project hub-alert by blackducksoftware.

the class SystemActions method getSystemMessagesAfter.

private ActionResponse<MultiSystemMessageModel> getSystemMessagesAfter(String startDate) throws ParseException {
    OffsetDateTime date = DateUtils.parseDateFromJsonString(startDate);
    List<SystemMessageModel> messages = systemMessageAccessor.getSystemMessagesAfter(date);
    return new ActionResponse<>(HttpStatus.OK, new MultiSystemMessageModel(messages));
}
Also used : OffsetDateTime(java.time.OffsetDateTime) SystemMessageModel(com.synopsys.integration.alert.common.persistence.model.SystemMessageModel) ActionResponse(com.synopsys.integration.alert.common.action.ActionResponse)

Example 9 with SystemMessageModel

use of com.synopsys.integration.alert.common.persistence.model.SystemMessageModel in project hub-alert by blackducksoftware.

the class SystemMessageModelTest method testContructor.

@Test
public void testContructor() {
    final String id = "1";
    final String severity = "type";
    final String createdAt = "createdAt";
    final String content = "content";
    final String type = "type";
    SystemMessageModel model = new SystemMessageModel(id, severity, createdAt, content, type);
    assertEquals(id, model.getId());
    assertEquals(severity, model.getSeverity());
    assertEquals(createdAt, model.getCreatedAt());
    assertEquals(content, model.getContent());
    assertEquals(type, model.getType());
}
Also used : SystemMessageModel(com.synopsys.integration.alert.common.persistence.model.SystemMessageModel) Test(org.junit.jupiter.api.Test)

Example 10 with SystemMessageModel

use of com.synopsys.integration.alert.common.persistence.model.SystemMessageModel in project hub-alert by blackducksoftware.

the class SystemMessageAccessorTestIT method testFindCreatedBeforeEmptyList.

@Test
public void testFindCreatedBeforeEmptyList() {
    OffsetDateTime currentDate = DateUtils.createCurrentDateTimestamp();
    List<SystemMessageModel> actualMessageList = defaultSystemMessageUtility.getSystemMessagesBefore(currentDate);
    assertTrue(actualMessageList.isEmpty());
}
Also used : OffsetDateTime(java.time.OffsetDateTime) SystemMessageModel(com.synopsys.integration.alert.common.persistence.model.SystemMessageModel) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

SystemMessageModel (com.synopsys.integration.alert.common.persistence.model.SystemMessageModel)10 OffsetDateTime (java.time.OffsetDateTime)6 Test (org.junit.jupiter.api.Test)5 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)4 ActionResponse (com.synopsys.integration.alert.common.action.ActionResponse)3 DateRange (com.synopsys.integration.alert.common.message.model.DateRange)2 ArrayList (java.util.ArrayList)2 AlertWebServerUrlManager (com.synopsys.integration.alert.common.rest.AlertWebServerUrlManager)1 DefaultSystemStatusAccessor (com.synopsys.integration.alert.database.api.DefaultSystemStatusAccessor)1 DefaultSystemMessageAccessor (com.synopsys.integration.alert.database.system.DefaultSystemMessageAccessor)1 DescriptorMetadataActions (com.synopsys.integration.alert.web.api.metadata.DescriptorMetadataActions)1 DescriptorsResponseModel (com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel)1 ZonedDateTime (java.time.ZonedDateTime)1 Date (java.util.Date)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1