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);
}
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());
}
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());
}
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());
}
Aggregations