Search in sources :

Example 11 with DetectFileFinder

use of com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder in project hub-detect by blackducksoftware.

the class DetectFileFinderTest method testFindAllFilesToDepthSimpleMsgString.

@Test
public void testFindAllFilesToDepthSimpleMsgString() {
    final DetectFileFinder finder = new DetectFileFinder();
    File targetDir = new File("src/test/resources/fileFinder");
    List<File> filesFound = finder.findAllFilesToDepth(targetDir, new StringBuilder("Maximum search depth hit during test"), 2, "*.txt");
    assertEquals(1, filesFound.size());
}
Also used : DetectFileFinder(com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder) File(java.io.File) Test(org.junit.Test)

Example 12 with DetectFileFinder

use of com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder in project hub-detect by blackducksoftware.

the class CodeLocationNameGeneratorTest method testDockerScanCodeLocationName.

@Test
public void testDockerScanCodeLocationName() {
    final String expected = "dockerTar.tar.gz/hub-common-rest/2.5.1-SNAPSHOT scan";
    final DetectFileFinder detectFileFinder = mock(DetectFileFinder.class);
    when(detectFileFinder.extractFinalPieceFromPath("")).thenReturn("hub-common-rest");
    final CodeLocationNameGenerator codeLocationNameGenerator = new CodeLocationNameGenerator(detectFileFinder);
    final String dockerTarFileName = "dockerTar.tar.gz";
    final String projectName = "hub-common-rest";
    final String projectVersionName = "2.5.1-SNAPSHOT";
    final String prefix = "";
    final String suffix = "";
    final String actual = codeLocationNameGenerator.createDockerScanCodeLocationName(dockerTarFileName, projectName, projectVersionName, prefix, suffix);
    assertEquals(expected, actual);
}
Also used : DetectFileFinder(com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder) Test(org.junit.Test)

Example 13 with DetectFileFinder

use of com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder in project hub-detect by blackducksoftware.

the class CodeLocationNameGeneratorTest method testLongCodeLocationNames.

@Test
public void testLongCodeLocationNames() {
    final String expected = "hub-common-rest/hub...esthub-common-rest/group/name/version npm/bom";
    final ExternalIdFactory factory = new ExternalIdFactory();
    final ExternalId externalId = factory.createMavenExternalId("group", "name", "version");
    final DetectFileFinder detectFileFinder = new DetectFileFinder();
    final CodeLocationNameGenerator codeLocationNameGenerator = new CodeLocationNameGenerator(detectFileFinder);
    final String sourcePath = "/Users/ekerwin/Documents/source/integration/hub-common-rest";
    final String codeLocationPath = "/Users/ekerwin/Documents/source/integration/hub-common-rest/hub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-resthub-common-rest";
    final String prefix = "";
    final String suffix = "";
    final String actual = codeLocationNameGenerator.createBomCodeLocationName(sourcePath, codeLocationPath, externalId, DetectCodeLocationType.NPM, prefix, suffix);
    assertEquals(expected, actual);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) DetectFileFinder(com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder) Test(org.junit.Test)

Example 14 with DetectFileFinder

use of com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder in project hub-detect by blackducksoftware.

the class CodeLocationNameGeneratorTest method testScanCodeLocationName.

@Test
public void testScanCodeLocationName() {
    final String expected = "hub-common-rest/target/hub-common-rest/2.5.1-SNAPSHOT scan";
    final DetectFileFinder detectFileFinder = mock(DetectFileFinder.class);
    when(detectFileFinder.extractFinalPieceFromPath("/Users/ekerwin/Documents/source/integration/hub-common-rest")).thenReturn("hub-common-rest");
    final CodeLocationNameGenerator codeLocationNameGenerator = new CodeLocationNameGenerator(detectFileFinder);
    final String sourcePath = "/Users/ekerwin/Documents/source/integration/hub-common-rest";
    final String scanTargetPath = "/Users/ekerwin/Documents/source/integration/hub-common-rest/target";
    final String projectName = "hub-common-rest";
    final String projectVersionName = "2.5.1-SNAPSHOT";
    final String prefix = "";
    final String suffix = "";
    final String actual = codeLocationNameGenerator.createScanCodeLocationName(sourcePath, scanTargetPath, projectName, projectVersionName, prefix, suffix);
    assertEquals(expected, actual);
}
Also used : DetectFileFinder(com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder) Test(org.junit.Test)

Example 15 with DetectFileFinder

use of com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder in project hub-detect by blackducksoftware.

the class GradleExtractionDebugger method debug.

public void debug(LoggedDetectExtraction extraction, DetectRunInfo detectRunInfo, DetectConfiguration detectConfiguration) throws ExecutableRunnerException {
    String id = extraction.extractionIdentifier;
    ExecutableRunner executableRunner = Mockito.mock(ExecutableRunner.class);
    Mockito.when(executableRunner.execute(Mockito.any())).thenReturn(new ExecutableOutput("", ""));
    DetectFileFinder detectFileFinder = new DetectFileFinder();
    File mockSourceFile = Mockito.mock(File.class);
    File outputDirectory = new File(detectRunInfo.getExtractionsFolder(), extraction.extractionIdentifier);
    GradleInspectorExtractor gradleInspectorExtractor = new GradleInspectorExtractor(executableRunner, detectFileFinder, new GradleReportParser(new ExternalIdFactory()), detectConfiguration);
    Extraction extractionResult = gradleInspectorExtractor.extract(mockSourceFile, "", "", outputDirectory);
}
Also used : GradleInspectorExtractor(com.blackducksoftware.integration.hub.detect.detector.gradle.GradleInspectorExtractor) ExecutableOutput(com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput) GradleReportParser(com.blackducksoftware.integration.hub.detect.detector.gradle.GradleReportParser) ExternalIdFactory(com.synopsys.integration.hub.bdio.model.externalid.ExternalIdFactory) DetectFileFinder(com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder) Extraction(com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction) LoggedDetectExtraction(com.synopsys.detect.doctor.logparser.LoggedDetectExtraction) File(java.io.File) ExecutableRunner(com.blackducksoftware.integration.hub.detect.util.executable.ExecutableRunner)

Aggregations

DetectFileFinder (com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder)15 Test (org.junit.Test)13 File (java.io.File)10 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)6 ExecutableOutput (com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput)5 Extraction (com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction)5 ExtractionId (com.blackducksoftware.integration.hub.detect.detector.ExtractionId)4 ExecutableRunner (com.blackducksoftware.integration.hub.detect.util.executable.ExecutableRunner)4 DirectoryManager (com.blackducksoftware.integration.hub.detect.workflow.file.DirectoryManager)3 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 LoggedDetectExtraction (com.synopsys.detect.doctor.logparser.LoggedDetectExtraction)2 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)2 GradleInspectorExtractor (com.blackducksoftware.integration.hub.detect.detector.gradle.GradleInspectorExtractor)1 GradleReportParser (com.blackducksoftware.integration.hub.detect.detector.gradle.GradleReportParser)1 NugetInspectorExtractor (com.blackducksoftware.integration.hub.detect.detector.nuget.NugetInspectorExtractor)1 NugetInspectorPackager (com.blackducksoftware.integration.hub.detect.detector.nuget.NugetInspectorPackager)1 NugetInspector (com.blackducksoftware.integration.hub.detect.detector.nuget.inspector.NugetInspector)1 Gson (com.google.gson.Gson)1