Search in sources :

Example 1 with DescriptorMetadataActions

use of com.synopsys.integration.alert.web.api.metadata.DescriptorMetadataActions in project hub-alert by blackducksoftware.

the class AboutActionsTest method testGetAboutDataNotPresent.

@Test
public void testGetAboutDataNotPresent() {
    Gson gson = new Gson();
    AlertWebServerUrlManager alertWebServerUrlManager = Mockito.mock(AlertWebServerUrlManager.class);
    SystemStatusAccessor systemStatusAccessor = Mockito.mock(SystemStatusAccessor.class);
    DescriptorMetadataActions descriptorActions = Mockito.mock(DescriptorMetadataActions.class);
    AboutReader aboutReader = new AboutReader(gson, alertWebServerUrlManager, systemStatusAccessor, descriptorActions);
    AboutActions aboutActions = new AboutActions(aboutReader);
    ActionResponse<AboutModel> resultModel = aboutActions.getAboutModel();
    assertTrue(resultModel.isError());
    assertFalse(resultModel.hasContent());
}
Also used : SystemStatusAccessor(com.synopsys.integration.alert.common.persistence.accessor.SystemStatusAccessor) Gson(com.google.gson.Gson) DescriptorMetadataActions(com.synopsys.integration.alert.web.api.metadata.DescriptorMetadataActions) AlertWebServerUrlManager(com.synopsys.integration.alert.common.rest.AlertWebServerUrlManager) Test(org.junit.jupiter.api.Test)

Example 2 with DescriptorMetadataActions

use of com.synopsys.integration.alert.web.api.metadata.DescriptorMetadataActions 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 3 with DescriptorMetadataActions

use of com.synopsys.integration.alert.web.api.metadata.DescriptorMetadataActions in project hub-alert by blackducksoftware.

the class UpdateCheckerTest method getUpdateModelTest.

@Test
@Tags({ @Tag(TestTags.DEFAULT_INTEGRATION), @Tag(TestTags.CUSTOM_EXTERNAL_CONNECTION) })
public void getUpdateModelTest() {
    ProxyManager proxyManager = Mockito.mock(ProxyManager.class);
    Mockito.when(proxyManager.createProxyInfoForHost(Mockito.anyString())).thenReturn(ProxyInfo.NO_PROXY_INFO);
    DefaultSystemStatusAccessor defaultSystemStatusUtility = Mockito.mock(DefaultSystemStatusAccessor.class);
    Mockito.when(defaultSystemStatusUtility.isSystemInitialized()).thenReturn(Boolean.TRUE);
    Mockito.when(defaultSystemStatusUtility.getStartupTime()).thenReturn(DateUtils.createCurrentDateTimestamp());
    DescriptorMetadataActions descriptorMetadataActions = Mockito.mock(DescriptorMetadataActions.class);
    Mockito.when(descriptorMetadataActions.getDescriptorsByType(Mockito.anyString())).thenReturn(new ActionResponse<>(HttpStatus.OK, new DescriptorsResponseModel()));
    AlertWebServerUrlManager alertWebServerUrlManager = Mockito.mock(AlertWebServerUrlManager.class);
    Mockito.when(alertWebServerUrlManager.getServerComponentsBuilder()).thenReturn(UriComponentsBuilder.newInstance());
    AlertProperties alertProperties = Mockito.mock(AlertProperties.class);
    Mockito.when(alertProperties.getAlertTrustCertificate()).thenReturn(Optional.of(Boolean.TRUE));
    AboutReader reader = new AboutReader(gson, alertWebServerUrlManager, defaultSystemStatusUtility, descriptorMetadataActions);
    UpdateChecker updateChecker = new UpdateChecker(gson, reader, proxyManager, alertProperties);
    UpdateModel updateModel = updateChecker.getUpdateModel();
    assertNotNull(updateModel);
}
Also used : AboutReader(com.synopsys.integration.alert.web.api.about.AboutReader) DefaultSystemStatusAccessor(com.synopsys.integration.alert.database.api.DefaultSystemStatusAccessor) ProxyManager(com.synopsys.integration.alert.common.rest.proxy.ProxyManager) DescriptorMetadataActions(com.synopsys.integration.alert.web.api.metadata.DescriptorMetadataActions) AlertWebServerUrlManager(com.synopsys.integration.alert.common.rest.AlertWebServerUrlManager) AlertProperties(com.synopsys.integration.alert.common.AlertProperties) UpdateModel(com.synopsys.integration.alert.update.model.UpdateModel) DescriptorsResponseModel(com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) TestTags(com.synopsys.integration.alert.test.common.TestTags) Tags(org.junit.jupiter.api.Tags)

Aggregations

AlertWebServerUrlManager (com.synopsys.integration.alert.common.rest.AlertWebServerUrlManager)3 DescriptorMetadataActions (com.synopsys.integration.alert.web.api.metadata.DescriptorMetadataActions)3 DefaultSystemStatusAccessor (com.synopsys.integration.alert.database.api.DefaultSystemStatusAccessor)2 DescriptorsResponseModel (com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel)2 Test (org.junit.jupiter.api.Test)2 Gson (com.google.gson.Gson)1 AlertProperties (com.synopsys.integration.alert.common.AlertProperties)1 SystemStatusAccessor (com.synopsys.integration.alert.common.persistence.accessor.SystemStatusAccessor)1 SystemMessageModel (com.synopsys.integration.alert.common.persistence.model.SystemMessageModel)1 ProxyManager (com.synopsys.integration.alert.common.rest.proxy.ProxyManager)1 DefaultSystemMessageAccessor (com.synopsys.integration.alert.database.system.DefaultSystemMessageAccessor)1 TestTags (com.synopsys.integration.alert.test.common.TestTags)1 UpdateModel (com.synopsys.integration.alert.update.model.UpdateModel)1 AboutReader (com.synopsys.integration.alert.web.api.about.AboutReader)1 Date (java.util.Date)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Tags (org.junit.jupiter.api.Tags)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1