Search in sources :

Example 26 with BufferedIntLogger

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());
}
Also used : BlackDuckResponseResolver(com.synopsys.integration.blackduck.http.transform.subclass.BlackDuckResponseResolver) InputStream(java.io.InputStream) Gson(com.google.gson.Gson) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) IntLogger(com.synopsys.integration.log.IntLogger) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) BufferedIntLogger(com.synopsys.integration.log.BufferedIntLogger) HttpUrl(com.synopsys.integration.rest.HttpUrl) BlackDuckJsonTransformer(com.synopsys.integration.blackduck.http.transform.BlackDuckJsonTransformer) ApiDiscovery(com.synopsys.integration.blackduck.api.generated.discovery.ApiDiscovery) ProjectVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView) ProjectView(com.synopsys.integration.blackduck.api.generated.view.ProjectView) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

BufferedIntLogger (com.synopsys.integration.log.BufferedIntLogger)26 Test (org.junit.jupiter.api.Test)20 IntLogger (com.synopsys.integration.log.IntLogger)8 File (java.io.File)7 UserView (com.synopsys.integration.blackduck.api.generated.view.UserView)6 NotificationTaskRange (com.synopsys.integration.blackduck.service.model.NotificationTaskRange)6 HttpUrl (com.synopsys.integration.rest.HttpUrl)6 CodeLocationView (com.synopsys.integration.blackduck.api.generated.view.CodeLocationView)5 NotificationUserView (com.synopsys.integration.blackduck.api.manual.view.NotificationUserView)5 VersionBomCodeLocationBomComputedNotificationUserView (com.synopsys.integration.blackduck.api.manual.view.VersionBomCodeLocationBomComputedNotificationUserView)5 BlackDuckHttpClient (com.synopsys.integration.blackduck.http.client.BlackDuckHttpClient)5 BlackDuckServicesFactory (com.synopsys.integration.blackduck.service.BlackDuckServicesFactory)5 NotificationService (com.synopsys.integration.blackduck.service.dataservice.NotificationService)5 HashSet (java.util.HashSet)5 ProjectVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView)4 BlackDuckServerConfigBuilder (com.synopsys.integration.blackduck.configuration.BlackDuckServerConfigBuilder)4 BlackDuckResponseResolver (com.synopsys.integration.blackduck.http.transform.subclass.BlackDuckResponseResolver)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Gson (com.google.gson.Gson)3 UploadBatchRunner (com.synopsys.integration.blackduck.codelocation.bdiolegacy.UploadBatchRunner)3