Search in sources :

Example 16 with UpdateModel

use of com.synopsys.integration.alert.update.model.UpdateModel 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)

Example 17 with UpdateModel

use of com.synopsys.integration.alert.update.model.UpdateModel in project hub-alert by blackducksoftware.

the class UpdateCheckerTest method testAlertIsOlderButCloseSnapshot.

@ParameterizedTest
@ValueSource(strings = { SUFFIX_SNAPSHOT, SUFFIX_SIGQA_1, SUFFIX_OTHER_TEXT })
public void testAlertIsOlderButCloseSnapshot(String versionSuffix) {
    UpdateChecker updateChecker = getEmptyUpdateChecker();
    OffsetDateTime alertTime = DateUtils.createCurrentDateTimestamp();
    OffsetDateTime dockerTagDate = alertTime.plusMinutes(20);
    UpdateModel updateModel = updateChecker.getUpdateModel("1.0.0-" + versionSuffix, formatDate(alertTime, DOCKER_DATE_FORMAT), "1.0.0", formatDate(dockerTagDate, DOCKER_DATE_FORMAT), null);
    assertTrue(updateModel.getUpdatable());
}
Also used : OffsetDateTime(java.time.OffsetDateTime) UpdateModel(com.synopsys.integration.alert.update.model.UpdateModel) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with UpdateModel

use of com.synopsys.integration.alert.update.model.UpdateModel in project hub-alert by blackducksoftware.

the class UpdateCheckerTest method testAlertIsNewerDateBothSnapshot.

@ParameterizedTest
@ValueSource(strings = { SUFFIX_SNAPSHOT, SUFFIX_SIGQA_1, SUFFIX_OTHER_TEXT })
public void testAlertIsNewerDateBothSnapshot(String versionSuffix) {
    UpdateChecker updateChecker = getEmptyUpdateChecker();
    OffsetDateTime alertTime = DateUtils.createCurrentDateTimestamp();
    OffsetDateTime dockerTagDate = alertTime.minusMinutes(80);
    UpdateModel updateModel = updateChecker.getUpdateModel("1.0.0-" + versionSuffix, formatDate(alertTime, DOCKER_DATE_FORMAT), "1.0.0-" + versionSuffix, formatDate(dockerTagDate, DOCKER_DATE_FORMAT), null);
    assertFalse(updateModel.getUpdatable());
}
Also used : OffsetDateTime(java.time.OffsetDateTime) UpdateModel(com.synopsys.integration.alert.update.model.UpdateModel) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 19 with UpdateModel

use of com.synopsys.integration.alert.update.model.UpdateModel in project hub-alert by blackducksoftware.

the class UpdateCheckerTest method testAlertIsOlderDockerSnapshot.

@ParameterizedTest
@ValueSource(strings = { SUFFIX_SNAPSHOT, SUFFIX_SIGQA_1, SUFFIX_OTHER_TEXT })
public void testAlertIsOlderDockerSnapshot(String versionSuffix) {
    UpdateChecker updateChecker = getEmptyUpdateChecker();
    OffsetDateTime alertTime = DateUtils.createCurrentDateTimestamp();
    OffsetDateTime dockerTagDate = alertTime.plusMinutes(80);
    UpdateModel updateModel = updateChecker.getUpdateModel("1.0.0", formatDate(alertTime, DOCKER_DATE_FORMAT), "1.0.0-" + versionSuffix, formatDate(dockerTagDate, DOCKER_DATE_FORMAT), null);
    assertFalse(updateModel.getUpdatable());
}
Also used : OffsetDateTime(java.time.OffsetDateTime) UpdateModel(com.synopsys.integration.alert.update.model.UpdateModel) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 20 with UpdateModel

use of com.synopsys.integration.alert.update.model.UpdateModel in project hub-alert by blackducksoftware.

the class UpdateCheckerTest method testAlertIsOlderBothSnapshot.

@ParameterizedTest
@ValueSource(strings = { SUFFIX_SNAPSHOT, SUFFIX_SIGQA_1, SUFFIX_OTHER_TEXT })
public void testAlertIsOlderBothSnapshot(String versionSuffix) {
    UpdateChecker updateChecker = getEmptyUpdateChecker();
    OffsetDateTime alertTime = DateUtils.createCurrentDateTimestamp();
    OffsetDateTime dockerTagDate = alertTime.plusMinutes(80);
    UpdateModel updateModel = updateChecker.getUpdateModel("1.0.0-" + versionSuffix, formatDate(alertTime, DOCKER_DATE_FORMAT), "1.0.0-" + versionSuffix, formatDate(dockerTagDate, DOCKER_DATE_FORMAT), null);
    assertTrue(updateModel.getUpdatable());
}
Also used : OffsetDateTime(java.time.OffsetDateTime) UpdateModel(com.synopsys.integration.alert.update.model.UpdateModel) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

UpdateModel (com.synopsys.integration.alert.update.model.UpdateModel)20 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)19 ValueSource (org.junit.jupiter.params.provider.ValueSource)13 OffsetDateTime (java.time.OffsetDateTime)10 Test (org.junit.jupiter.api.Test)6 AlertProperties (com.synopsys.integration.alert.common.AlertProperties)1 AlertWebServerUrlManager (com.synopsys.integration.alert.common.rest.AlertWebServerUrlManager)1 ProxyManager (com.synopsys.integration.alert.common.rest.proxy.ProxyManager)1 DefaultSystemStatusAccessor (com.synopsys.integration.alert.database.api.DefaultSystemStatusAccessor)1 TestTags (com.synopsys.integration.alert.test.common.TestTags)1 AboutReader (com.synopsys.integration.alert.web.api.about.AboutReader)1 DescriptorMetadataActions (com.synopsys.integration.alert.web.api.metadata.DescriptorMetadataActions)1 DescriptorsResponseModel (com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel)1 Tags (org.junit.jupiter.api.Tags)1