Search in sources :

Example 1 with AboutModel

use of com.synopsys.integration.alert.web.api.about.AboutModel in project hub-alert by blackducksoftware.

the class UpdateChecker method getUpdateModel.

public UpdateModel getUpdateModel() {
    IntHttpClient intHttpClient = createHttpClient();
    DockerTagRetriever dockerTagRetriever = new DockerTagRetriever(gson, intHttpClient);
    Optional<AboutModel> aboutModel = aboutReader.getAboutModel();
    String currentVersion = aboutModel.map(AboutModel::getVersion).orElse(null);
    String alertCreated = aboutModel.map(AboutModel::getCreated).orElse(null);
    boolean isProduction = isProductionVersion(currentVersion);
    Optional<VersionDateModel> latestAvailableVersion = getLatestAvailableTag(dockerTagRetriever, isProduction);
    String repositoryUrl = dockerTagRetriever.getRepositoryUrl();
    // latestAvailableVersion will not be present if Alert can not reach Docker Hub and DockerTagRetriever will log a warning
    // if latestAvailableVersion is empty, use the Alert version and date so we report no update available
    String latestVersion = latestAvailableVersion.map(VersionDateModel::getVersionName).orElse(currentVersion);
    String latestDate = latestAvailableVersion.map(VersionDateModel::getDate).orElse(alertCreated);
    return getUpdateModel(currentVersion, alertCreated, latestVersion, latestDate, repositoryUrl);
}
Also used : IntHttpClient(com.synopsys.integration.rest.client.IntHttpClient) AboutModel(com.synopsys.integration.alert.web.api.about.AboutModel)

Example 2 with AboutModel

use of com.synopsys.integration.alert.web.api.about.AboutModel in project hub-alert by blackducksoftware.

the class AboutReaderTest method testAboutRead.

@Test
public void testAboutRead() {
    AboutReader reader = new AboutReader(new Gson(), alertWebServerUrlManager, defaultSystemStatusUtility, descriptorMetadataActions);
    Optional<AboutModel> aboutModel = reader.getAboutModel();
    assertTrue(aboutModel.isPresent());
}
Also used : AboutReader(com.synopsys.integration.alert.web.api.about.AboutReader) Gson(com.google.gson.Gson) AboutModel(com.synopsys.integration.alert.web.api.about.AboutModel) Test(org.junit.jupiter.api.Test)

Example 3 with AboutModel

use of com.synopsys.integration.alert.web.api.about.AboutModel in project hub-alert by blackducksoftware.

the class AboutReaderTest method testAboutReadNull.

@Test
public void testAboutReadNull() {
    AboutReader reader = new AboutReader(null, alertWebServerUrlManager, defaultSystemStatusUtility, descriptorMetadataActions);
    Optional<AboutModel> aboutModel = reader.getAboutModel();
    assertTrue(aboutModel.isEmpty());
}
Also used : AboutReader(com.synopsys.integration.alert.web.api.about.AboutReader) AboutModel(com.synopsys.integration.alert.web.api.about.AboutModel) Test(org.junit.jupiter.api.Test)

Example 4 with AboutModel

use of com.synopsys.integration.alert.web.api.about.AboutModel in project hub-alert by blackducksoftware.

the class AboutModelTest method testWithValues.

@Test
public void testWithValues() {
    String version = "1.2.3";
    String created = "date";
    String description = "description";
    String projectUrl = "https://www.google.com";
    String documentationUrl = "https://www.google.com";
    boolean initialized = true;
    String startupTime = "startup time is now";
    DescriptorMetadata providerMetadata = Mockito.mock(DescriptorMetadata.class);
    DescriptorMetadata channelMetadata = Mockito.mock(DescriptorMetadata.class);
    Set<DescriptorMetadata> providers = Set.of(providerMetadata);
    Set<DescriptorMetadata> channels = Set.of(channelMetadata);
    AboutModel model = new AboutModel(version, created, description, projectUrl, documentationUrl, initialized, startupTime, providers, channels);
    assertEquals(version, model.getVersion());
    assertEquals(description, model.getDescription());
    assertEquals(projectUrl, model.getProjectUrl());
    assertEquals(documentationUrl, model.getDocumentationUrl());
    assertEquals(initialized, model.isInitialized());
    assertEquals(startupTime, model.getStartupTime());
    assertEquals(providers, model.getProviders());
    assertEquals(channels, model.getChannels());
}
Also used : DescriptorMetadata(com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata) AboutModel(com.synopsys.integration.alert.web.api.about.AboutModel) Test(org.junit.jupiter.api.Test)

Aggregations

AboutModel (com.synopsys.integration.alert.web.api.about.AboutModel)4 Test (org.junit.jupiter.api.Test)3 AboutReader (com.synopsys.integration.alert.web.api.about.AboutReader)2 Gson (com.google.gson.Gson)1 DescriptorMetadata (com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata)1 IntHttpClient (com.synopsys.integration.rest.client.IntHttpClient)1