Search in sources :

Example 21 with CodeLocationView

use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project blackduck-common by blackducksoftware.

the class CodeLocationsRetrieverTest method testCodeLocationsBeingCreatedDuringRetrieve.

@Test
public void testCodeLocationsBeingCreatedDuringRetrieve() {
    ProjectVersionView projectVersionView = buildProjectVersionView();
    BlackDuckApiClient blackDuckApiClient = Mockito.mock(BlackDuckApiClient.class);
    UrlMultipleResponses<CodeLocationView> expectedArg = new UrlMultipleResponses<>(url, CodeLocationView.class);
    try {
        Mockito.when(blackDuckApiClient.getAllResponses(Mockito.eq(expectedArg))).thenReturn(listWithDuplicates());
    } catch (IntegrationException e) {
        fail("No exception is expected when mocking.", e);
    }
    CodeLocationsRetriever codeLocationsRetriever = new CodeLocationsRetriever(blackDuckApiClient);
    try {
        Map<String, String> hrefToName = codeLocationsRetriever.retrieveCodeLocations(projectVersionView, expectedNames());
        assertEquals(expectedResults(), hrefToName);
    } catch (IntegrationException e) {
        fail("No exception is expected when retrieving.", e);
    }
// TODO ejk 2021-06-18 it appears that a single invocation of verify
// causes all unverified code to error
// Mockito.verify(blackDuckApiClient);
}
Also used : CodeLocationView(com.synopsys.integration.blackduck.api.generated.view.CodeLocationView) UrlMultipleResponses(com.synopsys.integration.blackduck.api.core.response.UrlMultipleResponses) IntegrationException(com.synopsys.integration.exception.IntegrationException) ProjectVersionView(com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView) BlackDuckApiClient(com.synopsys.integration.blackduck.service.BlackDuckApiClient) Test(org.junit.jupiter.api.Test)

Example 22 with CodeLocationView

use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project blackduck-common by blackducksoftware.

the class CodeLocationsRetrieverTest method createCodeLocation.

private CodeLocationView createCodeLocation(String href, String name) {
    ResourceMetadata resourceMetadata = new ResourceMetadata();
    try {
        resourceMetadata.setHref(new HttpUrl(href));
    } catch (IntegrationException e) {
        fail("The urls should all be valid.", e);
    }
    CodeLocationView codeLocationView = new CodeLocationView();
    codeLocationView.setMeta(resourceMetadata);
    codeLocationView.setName(name);
    return codeLocationView;
}
Also used : CodeLocationView(com.synopsys.integration.blackduck.api.generated.view.CodeLocationView) IntegrationException(com.synopsys.integration.exception.IntegrationException) ResourceMetadata(com.synopsys.integration.blackduck.api.core.ResourceMetadata) HttpUrl(com.synopsys.integration.rest.HttpUrl)

Example 23 with CodeLocationView

use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project blackduck-common by blackducksoftware.

the class CodeLocationService method createFakeCodeLocationView.

private CodeLocationView createFakeCodeLocationView(HttpUrl codeLocationUrl) {
    ResourceMetadata resourceMetadata = new ResourceMetadata();
    resourceMetadata.setHref(codeLocationUrl);
    CodeLocationView codeLocationView = new CodeLocationView();
    codeLocationView.setMeta(resourceMetadata);
    NullNode pathJsonNode = new JsonNodeFactory(false).nullNode();
    codeLocationView.setPatch(pathJsonNode);
    return codeLocationView;
}
Also used : CodeLocationView(com.synopsys.integration.blackduck.api.generated.view.CodeLocationView) ResourceMetadata(com.synopsys.integration.blackduck.api.core.ResourceMetadata) NullNode(com.fasterxml.jackson.databind.node.NullNode) JsonNodeFactory(com.fasterxml.jackson.databind.node.JsonNodeFactory)

Example 24 with CodeLocationView

use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project blackduck-common by blackducksoftware.

the class CodeLocationService method unmapCodeLocation.

public void unmapCodeLocation(HttpUrl codeLocationUrl) throws IntegrationException {
    CodeLocationView codeLocationView = createFakeCodeLocationView(codeLocationUrl);
    mapCodeLocation(codeLocationView, (HttpUrl) null);
}
Also used : CodeLocationView(com.synopsys.integration.blackduck.api.generated.view.CodeLocationView)

Example 25 with CodeLocationView

use of com.synopsys.integration.blackduck.api.generated.view.CodeLocationView in project blackduck-common by blackducksoftware.

the class BinaryScanUploadServiceTestIT method testJapaneseCharactersForBinaryUpload.

@Test
@Disabled
public // also, because as of 2020.8.0, binary upload doesn't support utf-8
void testJapaneseCharactersForBinaryUpload() throws IntegrationException, InterruptedException {
    BlackDuckServices blackDuckServices = new BlackDuckServices(intHttpClientTestHelper);
    File binaryFile = getTestBinaryFile();
    BinaryScan binaryScan = new BinaryScan(binaryFile, JAPANESE_PROJECT_NAME, JAPANESE_VERSION_NAME, JAPANESE_CODE_LOCATION_NAME);
    BinaryScanData binaryScanData = createBinaryScanData(blackDuckServices, binaryScan);
    assertBinaryUploadCompleted(blackDuckServices, binaryScanData);
    Optional<ProjectVersionWrapper> optionalProjectVersionWrapper = blackDuckServices.projectService.getProjectVersion(JAPANESE_PROJECT_NAME, JAPANESE_VERSION_NAME);
    Optional<CodeLocationView> optionalCodeLocationView = blackDuckServices.codeLocationService.getCodeLocationByName(JAPANESE_CODE_LOCATION_NAME);
    assertTrue(optionalProjectVersionWrapper.isPresent());
    assertTrue(optionalCodeLocationView.isPresent());
}
Also used : CodeLocationView(com.synopsys.integration.blackduck.api.generated.view.CodeLocationView) BlackDuckServices(com.synopsys.integration.blackduck.comprehensive.BlackDuckServices) File(java.io.File) ProjectVersionWrapper(com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

CodeLocationView (com.synopsys.integration.blackduck.api.generated.view.CodeLocationView)26 Test (org.junit.jupiter.api.Test)9 ProjectVersionWrapper (com.synopsys.integration.blackduck.service.model.ProjectVersionWrapper)8 File (java.io.File)7 ResourceMetadata (com.synopsys.integration.blackduck.api.core.ResourceMetadata)6 IntegrationException (com.synopsys.integration.exception.IntegrationException)6 BufferedIntLogger (com.synopsys.integration.log.BufferedIntLogger)6 HttpUrl (com.synopsys.integration.rest.HttpUrl)6 ProjectVersionView (com.synopsys.integration.blackduck.api.generated.view.ProjectVersionView)5 IntLogger (com.synopsys.integration.log.IntLogger)5 ProjectView (com.synopsys.integration.blackduck.api.generated.view.ProjectView)4 UserView (com.synopsys.integration.blackduck.api.generated.view.UserView)4 UploadBatch (com.synopsys.integration.blackduck.codelocation.upload.UploadBatch)4 BlackDuckApiClient (com.synopsys.integration.blackduck.service.BlackDuckApiClient)4 NameVersion (com.synopsys.integration.util.NameVersion)4 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)3 NullNode (com.fasterxml.jackson.databind.node.NullNode)3 BdioUploadCodeLocationCreationRequest (com.synopsys.integration.blackduck.codelocation.bdiolegacy.BdioUploadCodeLocationCreationRequest)3 BdioUploadService (com.synopsys.integration.blackduck.codelocation.bdiolegacy.BdioUploadService)3 UploadTarget (com.synopsys.integration.blackduck.codelocation.upload.UploadTarget)3