use of com.synopsys.integration.alert.update.model.DockerTagsResponseModel in project hub-alert by blackducksoftware.
the class UpdateChecker method getLatestAvailableTag.
private Optional<VersionDateModel> getLatestAvailableTag(DockerTagRetriever dockerTagRetriever, boolean isProduction) {
DockerTagsResponseModel tagsResponseModel = dockerTagRetriever.getTagsModel();
List<DockerTagModel> tags = new LinkedList<>();
while (!tagsResponseModel.isEmpty()) {
tags.addAll(tagsResponseModel.getResults());
tagsResponseModel = dockerTagRetriever.getNextPage(tagsResponseModel);
}
return tags.stream().filter(dockerTagModel -> {
if (isProduction) {
return isProductionVersion(dockerTagModel.getName());
}
return true;
}).map(dockerTagModel -> new VersionDateModel(dockerTagModel.getName(), dockerTagModel.getLastUpdated())).min(versionDateModelComparator());
}
use of com.synopsys.integration.alert.update.model.DockerTagsResponseModel in project hub-alert by blackducksoftware.
the class DockerTagRetrieverTest method getTagsModelTest.
@Test
public void getTagsModelTest() throws IntegrationException {
IntHttpClient intHttpClient = Mockito.mock(IntHttpClient.class);
Response mockResponse = createMockResponse();
Mockito.when(intHttpClient.execute(Mockito.any(Request.class))).thenReturn(mockResponse);
DockerTagRetriever dockerTagRetriever = new DockerTagRetriever(gson, intHttpClient);
DockerTagsResponseModel tagsModel = dockerTagRetriever.getTagsModel();
assertEquals(TAGS_COUNT, tagsModel.getCount());
assertEquals(TAGS_COUNT, tagsModel.getResults().size());
}
use of com.synopsys.integration.alert.update.model.DockerTagsResponseModel in project hub-alert by blackducksoftware.
the class DockerTagRetrieverTest method createMockResponse.
private Response createMockResponse() throws IntegrationException {
Response mockResponse = Mockito.mock(Response.class);
List<DockerTagModel> tagModels = List.of(createDockerTagModel("1.0.0"), createDockerTagModel("1.0.1"));
DockerTagsResponseModel mockDockerTagsResponseModel = new DockerTagsResponseModel(TAGS_COUNT, null, null, tagModels);
String jsonString = gson.toJson(mockDockerTagsResponseModel);
Mockito.when(mockResponse.getContentString()).thenReturn(jsonString);
Mockito.doNothing().when(mockResponse).throwExceptionForError();
return mockResponse;
}
use of com.synopsys.integration.alert.update.model.DockerTagsResponseModel in project hub-alert by blackducksoftware.
the class DockerTagRetrieverTest method getTagsModelTestIT.
@Test
@Tags({ @Tag(TestTags.DEFAULT_INTEGRATION), @Tag(TestTags.CUSTOM_EXTERNAL_CONNECTION) })
public void getTagsModelTestIT() throws IntegrationException {
IntLogger intLogger = new PrintStreamIntLogger(System.out, LogLevel.INFO);
IntHttpClient intHttpClient = new IntHttpClient(intLogger, gson, 10, true, ProxyInfo.NO_PROXY_INFO);
HttpUrl httpUrl = new HttpUrl("https://google.com");
Request testRequest = new Request.Builder(httpUrl).build();
try (Response googleResponse = intHttpClient.execute(testRequest)) {
googleResponse.throwExceptionForError();
} catch (IntegrationException | IOException e) {
assumeTrue(null == e, "Could not connect. Skipping this test...");
}
DockerTagRetriever dockerTagRetriever = new DockerTagRetriever(gson, intHttpClient);
DockerTagsResponseModel tagsModel = dockerTagRetriever.getTagsModel();
assertFalse(tagsModel.isEmpty(), "Expected tags from the docker repo to exist");
}
Aggregations