Search in sources :

Example 11 with FileFinder

use of com.synopsys.integration.common.util.finder.FileFinder in project synopsys-detect by blackducksoftware.

the class NugetProjectDetectableTest method testApplicableForRproj.

@Test
public void testApplicableForRproj() {
    NugetInspectorOptions nugetInspectorOptions = null;
    NugetInspectorResolver nugetInspectorResolver = null;
    NugetInspectorExtractor nugetInspectorExtractor = null;
    DetectableEnvironment environment = MockDetectableEnvironment.empty();
    FileFinder fileFinder = MockFileFinder.withFileNamed("example.rproj");
    NugetProjectDetectable detectable = new NugetProjectDetectable(environment, fileFinder, nugetInspectorOptions, nugetInspectorResolver, nugetInspectorExtractor);
    assertTrue(detectable.applicable().getPassed());
}
Also used : NugetInspectorExtractor(com.synopsys.integration.detectable.detectables.nuget.NugetInspectorExtractor) NugetProjectDetectable(com.synopsys.integration.detectable.detectables.nuget.NugetProjectDetectable) NugetInspectorResolver(com.synopsys.integration.detectable.detectable.inspector.nuget.NugetInspectorResolver) MockFileFinder(com.synopsys.integration.detectable.util.MockFileFinder) FileFinder(com.synopsys.integration.common.util.finder.FileFinder) NugetInspectorOptions(com.synopsys.integration.detectable.detectables.nuget.NugetInspectorOptions) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) MockDetectableEnvironment(com.synopsys.integration.detectable.util.MockDetectableEnvironment) Test(org.junit.jupiter.api.Test)

Example 12 with FileFinder

use of com.synopsys.integration.common.util.finder.FileFinder in project synopsys-detect by blackducksoftware.

the class NugetSolutionDetectableTest method notApplicableForPodfile.

@Test
public void notApplicableForPodfile() {
    NugetInspectorResolver nugetInspectorManager = null;
    NugetInspectorExtractor nugetInspectorExtractor = null;
    NugetInspectorOptions nugetInspectorOptions = null;
    DetectableEnvironment environment = MockDetectableEnvironment.empty();
    FileFinder fileFinder = MockFileFinder.withFileNamed("podfile.lock");
    NugetSolutionDetectable detectable = new NugetSolutionDetectable(environment, fileFinder, nugetInspectorManager, nugetInspectorExtractor, nugetInspectorOptions);
    assertFalse(detectable.applicable().getPassed());
}
Also used : NugetInspectorExtractor(com.synopsys.integration.detectable.detectables.nuget.NugetInspectorExtractor) NugetSolutionDetectable(com.synopsys.integration.detectable.detectables.nuget.NugetSolutionDetectable) NugetInspectorResolver(com.synopsys.integration.detectable.detectable.inspector.nuget.NugetInspectorResolver) MockFileFinder(com.synopsys.integration.detectable.util.MockFileFinder) FileFinder(com.synopsys.integration.common.util.finder.FileFinder) NugetInspectorOptions(com.synopsys.integration.detectable.detectables.nuget.NugetInspectorOptions) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) MockDetectableEnvironment(com.synopsys.integration.detectable.util.MockDetectableEnvironment) Test(org.junit.jupiter.api.Test)

Example 13 with FileFinder

use of com.synopsys.integration.common.util.finder.FileFinder in project synopsys-detect by blackducksoftware.

the class BazelDetectableTest method testApplicable.

@Test
public void testApplicable() {
    DetectableEnvironment environment = MockDetectableEnvironment.empty();
    FileFinder fileFinder = Mockito.mock(FileFinder.class);
    Mockito.when(fileFinder.findFile(new File("."), "WORKSPACE")).thenReturn(new File("src/test/resources/functional/bazel/WORKSPACE"));
    BazelExtractor bazelExtractor = null;
    BazelResolver bazelResolver = null;
    BazelDetectableOptions bazelDetectableOptions = new BazelDetectableOptions("target", null, null);
    BazelDetectable detectable = new BazelDetectable(environment, fileFinder, bazelExtractor, bazelResolver, bazelDetectableOptions.getTargetName().orElse(null));
    assertTrue(detectable.applicable().getPassed());
}
Also used : BazelExtractor(com.synopsys.integration.detectable.detectables.bazel.BazelExtractor) BazelDetectableOptions(com.synopsys.integration.detectable.detectables.bazel.BazelDetectableOptions) BazelDetectable(com.synopsys.integration.detectable.detectables.bazel.BazelDetectable) BazelResolver(com.synopsys.integration.detectable.detectable.executable.resolver.BazelResolver) FileFinder(com.synopsys.integration.common.util.finder.FileFinder) File(java.io.File) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) MockDetectableEnvironment(com.synopsys.integration.detectable.util.MockDetectableEnvironment) Test(org.junit.jupiter.api.Test)

Example 14 with FileFinder

use of com.synopsys.integration.common.util.finder.FileFinder in project synopsys-detect by blackducksoftware.

the class ClangDetectableTest method testApplicable.

@Test
public void testApplicable() {
    DetectableExecutableRunner executableRunner = null;
    List<ClangPackageManager> availablePackageManagers = new ArrayList<>(0);
    ClangExtractor clangExtractor = null;
    ClangPackageManagerRunner packageManagerRunner = null;
    ClangDetectableOptions options = new ClangDetectableOptions(false);
    DetectableEnvironment environment = MockDetectableEnvironment.empty();
    FileFinder fileFinder = MockFileFinder.withFileNamed(JSON_COMPILATION_DATABASE_FILENAME);
    ClangDetectable detectable = new ClangDetectable(environment, executableRunner, fileFinder, availablePackageManagers, clangExtractor, options, packageManagerRunner);
    assertTrue(detectable.applicable().getPassed());
}
Also used : ClangPackageManager(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManager) ClangExtractor(com.synopsys.integration.detectable.detectables.clang.ClangExtractor) DetectableExecutableRunner(com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner) ClangPackageManagerRunner(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerRunner) ClangDetectable(com.synopsys.integration.detectable.detectables.clang.ClangDetectable) ArrayList(java.util.ArrayList) MockFileFinder(com.synopsys.integration.detectable.util.MockFileFinder) FileFinder(com.synopsys.integration.common.util.finder.FileFinder) ClangDetectableOptions(com.synopsys.integration.detectable.detectables.clang.ClangDetectableOptions) MockDetectableEnvironment(com.synopsys.integration.detectable.util.MockDetectableEnvironment) DetectableEnvironment(com.synopsys.integration.detectable.DetectableEnvironment) Test(org.junit.jupiter.api.Test)

Example 15 with FileFinder

use of com.synopsys.integration.common.util.finder.FileFinder in project synopsys-detect by blackducksoftware.

the class DockerExtractorTest method testGetImageIdentifierFromOutputDirectoryIfImageIdPresent.

@Test
@DisabledOnOs(WINDOWS)
public void testGetImageIdentifierFromOutputDirectoryIfImageIdPresent() throws URISyntaxException {
    String testString = "test";
    String imageIdArgument = "--docker.image.id=";
    String imageName = "ubuntu:latest";
    File outputDirectoryWithPopulatedResultsFile = new File(DockerExtractorTest.class.getClassLoader().getSystemResource("detectables/functional/docker/unit/outputDirectoryWithPopulatedResultsFile").toURI());
    File outputDirectoryWithNonPopulatedResultsFile = new File(DockerExtractorTest.class.getClassLoader().getSystemResource("detectables/functional/docker/unit/outputDirectoryWithNonPopulatedResultsFile").toURI());
    DetectableExecutableRunner executableRunner = Mockito.mock(DetectableExecutableRunner.class);
    FileFinder fileFinder = Mockito.mock(FileFinder.class);
    Mockito.when(fileFinder.findFile(outputDirectoryWithPopulatedResultsFile, DockerExtractor.RESULTS_FILENAME_PATTERN)).thenReturn(new File(outputDirectoryWithPopulatedResultsFile, "results.json"));
    Mockito.when(fileFinder.findFile(outputDirectoryWithNonPopulatedResultsFile, DockerExtractor.RESULTS_FILENAME_PATTERN)).thenReturn(new File(outputDirectoryWithNonPopulatedResultsFile, "results.json"));
    DockerExtractor dockerExtractor = getMockDockerExtractor(executableRunner, fileFinder);
    assertEquals(imageName, dockerExtractor.getImageIdentifierFromOutputDirectoryIfImageIdPresent(outputDirectoryWithPopulatedResultsFile, testString, ImageIdentifierType.IMAGE_ID));
    assertEquals(testString, dockerExtractor.getImageIdentifierFromOutputDirectoryIfImageIdPresent(outputDirectoryWithPopulatedResultsFile, testString, ImageIdentifierType.IMAGE_NAME));
    assertEquals(testString, dockerExtractor.getImageIdentifierFromOutputDirectoryIfImageIdPresent(outputDirectoryWithNonPopulatedResultsFile, testString, ImageIdentifierType.IMAGE_ID));
}
Also used : DetectableExecutableRunner(com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner) DockerExtractor(com.synopsys.integration.detectable.detectables.docker.DockerExtractor) FileFinder(com.synopsys.integration.common.util.finder.FileFinder) File(java.io.File) DisabledOnOs(org.junit.jupiter.api.condition.DisabledOnOs) Test(org.junit.jupiter.api.Test)

Aggregations

FileFinder (com.synopsys.integration.common.util.finder.FileFinder)15 DetectableEnvironment (com.synopsys.integration.detectable.DetectableEnvironment)12 Test (org.junit.jupiter.api.Test)12 MockDetectableEnvironment (com.synopsys.integration.detectable.util.MockDetectableEnvironment)9 MockFileFinder (com.synopsys.integration.detectable.util.MockFileFinder)8 File (java.io.File)6 NugetInspectorResolver (com.synopsys.integration.detectable.detectable.inspector.nuget.NugetInspectorResolver)3 NugetInspectorExtractor (com.synopsys.integration.detectable.detectables.nuget.NugetInspectorExtractor)3 NugetInspectorOptions (com.synopsys.integration.detectable.detectables.nuget.NugetInspectorOptions)3 SimpleFileFinder (com.synopsys.integration.common.util.finder.SimpleFileFinder)2 DetectableExecutableRunner (com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner)2 DetectableResult (com.synopsys.integration.detectable.detectable.result.DetectableResult)2 DockerExtractor (com.synopsys.integration.detectable.detectables.docker.DockerExtractor)2 NugetSolutionDetectable (com.synopsys.integration.detectable.detectables.nuget.NugetSolutionDetectable)2 Gson (com.google.gson.Gson)1 DetectInfo (com.synopsys.integration.detect.configuration.DetectInfo)1 DetectBootResult (com.synopsys.integration.detect.lifecycle.boot.DetectBootResult)1 ExitManager (com.synopsys.integration.detect.lifecycle.exit.ExitManager)1 ProductRunData (com.synopsys.integration.detect.lifecycle.run.data.ProductRunData)1 ExceptionUtility (com.synopsys.integration.detect.lifecycle.shutdown.ExceptionUtility)1