use of com.synopsys.integration.log.BufferedIntLogger in project blackduck-common by blackducksoftware.
the class ProjectServiceTest method testGettingLatestProjectVersion.
@Disabled
@Test
public void testGettingLatestProjectVersion() throws IOException, IntegrationException {
IntLogger logger = new BufferedIntLogger();
Gson gson = BlackDuckServicesFactory.createDefaultGson();
ObjectMapper objectMapper = BlackDuckServicesFactory.createDefaultObjectMapper();
BlackDuckResponseResolver blackDuckResponseResolver = new BlackDuckResponseResolver(gson);
BlackDuckJsonTransformer blackDuckJsonTransformer = new BlackDuckJsonTransformer(gson, objectMapper, blackDuckResponseResolver, logger);
InputStream inputStream = getClass().getResourceAsStream("/json/pageOfProjectVersionViews.json");
String pageJson = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
BlackDuckPageResponse<ProjectVersionView> pageOfProjectVersionViews = blackDuckJsonTransformer.getResponses(pageJson, ProjectVersionView.class);
List<ProjectVersionView> projectVersionViews = pageOfProjectVersionViews.getItems();
BlackDuckApiClient blackDuckApiClient = Mockito.mock(BlackDuckApiClient.class);
ProjectGetService projectGetService = Mockito.mock(ProjectGetService.class);
ApiDiscovery apiDiscovery = new ApiDiscovery(new HttpUrl("https://synopsys.com"));
ProjectService projectService = new ProjectService(blackDuckApiClient, apiDiscovery, logger, projectGetService);
ProjectView projectView = new ProjectView();
projectView.setName("unit test");
Mockito.when(blackDuckApiClient.getAllResponses(Mockito.eq(projectView.metaVersionsLink()))).thenReturn(projectVersionViews);
Optional<ProjectVersionView> projectVersionView = projectService.getNewestProjectVersion(projectView);
assertTrue(projectVersionView.isPresent());
assertEquals("dockertar", projectVersionView.get().getVersionName());
}
Aggregations