use of com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner in project synopsys-detect by blackducksoftware.
the class ApkPackageManagerTest method canParseArchitecture.
@Test
public void canParseArchitecture() throws ExecutableRunnerException {
final String exampleOutput = "x86_64\n";
DetectableExecutableRunner executableRunner = Mockito.mock(DetectableExecutableRunner.class);
Mockito.when(executableRunner.execute(null, "apk", Arrays.asList("info", "--print-arch"))).thenReturn(new ExecutableOutput(0, exampleOutput, ""));
ApkArchitectureResolver architectureResolver = new ApkArchitectureResolver();
Optional<String> architecture = architectureResolver.resolveArchitecture(new ClangPackageManagerInfoFactory().apk(), null, executableRunner);
assertTrue(architecture.isPresent());
Assertions.assertEquals("x86_64", architecture.get());
}
use of com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner 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());
}
use of com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner in project synopsys-detect by blackducksoftware.
the class PubDepsExtractorTest method testGracefulFailure.
private void testGracefulFailure(ExecutableOutput mockExecutableOutput) throws ExecutableRunnerException {
DetectableExecutableRunner executableRunner = Mockito.mock(DetectableExecutableRunner.class);
Mockito.when(executableRunner.execute(Mockito.any())).thenReturn(mockExecutableOutput);
PubDepsExtractor extractor = new PubDepsExtractor(executableRunner, new PubDepsParser(), null, new ToolVersionLogger(executableRunner));
Extraction extraction = extractor.extract(null, null, null, new DartPubDepsDetectableOptions(EnumListFilter.excludeNone()), null);
Assertions.assertFalse(extraction.isSuccess() && null == extraction.getError());
}
use of com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner in project synopsys-detect by blackducksoftware.
the class DockerExtractorTest method getDetectableExecutableRunner.
@NotNull
private DetectableExecutableRunner getDetectableExecutableRunner() throws ExecutableRunnerException {
DetectableExecutableRunner executableRunner = Mockito.mock(DetectableExecutableRunner.class);
ExecutableOutput executableOutput = Mockito.mock(ExecutableOutput.class);
Mockito.when(executableOutput.getReturnCode()).thenReturn(0);
Mockito.when(executableRunner.execute(Mockito.any(Executable.class))).thenReturn(executableOutput);
return executableRunner;
}
use of com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner in project synopsys-detect by blackducksoftware.
the class DockerExtractorTest method testExtractImageReturningContainerFileSystem.
@Test
@DisabledOnOs(WINDOWS)
public void testExtractImageReturningContainerFileSystem() throws ExecutableRunnerException, IOException {
final String image = "ubuntu:latest";
String imageId = null;
String tar = null;
DetectableExecutableRunner executableRunner = getDetectableExecutableRunner();
Extraction extraction = extract(image, imageId, tar, fakeContainerFileSystemFile, null, fakeResultsFile, executableRunner);
assertEquals("ubuntu:latest", extraction.getMetaData(DockerExtractor.DOCKER_IMAGE_NAME_META_DATA).get());
assertTrue(extraction.getMetaData(DockerExtractor.CONTAINER_FILESYSTEM_META_DATA).get().getName().endsWith("_containerfilesystem.tar.gz"));
ArgumentCaptor<Executable> executableArgumentCaptor = ArgumentCaptor.forClass(Executable.class);
Mockito.verify(executableRunner).execute(executableArgumentCaptor.capture());
Executable executableToVerify = executableArgumentCaptor.getValue();
List<String> command = executableToVerify.getCommandWithArguments();
assertTrue(command.get(0).endsWith("/fake/test/java"));
assertEquals("-jar", command.get(1));
assertTrue(command.get(2).endsWith("/fake/test/dockerinspector.jar"));
assertTrue(command.get(3).startsWith("--spring.config.location="));
assertTrue(command.get(3).endsWith("/application.properties"));
assertEquals("--docker.image=ubuntu:latest", command.get(4));
}
Aggregations