use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStep in project synopsys-detect by blackducksoftware.
the class IntermediateStepParseValuesFromXmlTest method test.
@Test
public void test() throws IntegrationException, ExecutableFailedException {
IntermediateStep intermediateStep = new IntermediateStepParseValuesFromXml("/query/rule[@class='maven_jar']/string[@name='artifact']", "value");
List<String> input = Arrays.asList(COMMONS_IO_XML, GUAVA_XML);
List<String> results = intermediateStep.process(input);
assertEquals(2, results.size());
assertEquals("org.apache.commons:commons-io:1.3.2", results.get(0));
assertEquals("com.google.guava:guava:18.0", results.get(1));
}
use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStep in project synopsys-detect by blackducksoftware.
the class IntermediateStepExecuteBazelOnEachLineTest method testNoInput.
@Test
public void testNoInput() throws ExecutableRunnerException, IntegrationException, ExecutableFailedException {
File workspaceDir = new File(".");
DetectableExecutableRunner executableRunner = Mockito.mock(DetectableExecutableRunner.class);
ExecutableTarget bazelExe = ExecutableTarget.forCommand("/usr/bin/bazel");
ExecutableOutput bazelCmdExecutableOutput = Mockito.mock(ExecutableOutput.class);
Mockito.when(bazelCmdExecutableOutput.getReturnCode()).thenReturn(0);
Mockito.when(bazelCmdExecutableOutput.getStandardOutput()).thenReturn("@org_apache_commons_commons_io//jar:jar\n@com_google_guava_guava//jar:jar");
Mockito.when(executableRunner.executeSuccessfully(Mockito.any(Executable.class))).thenReturn(bazelCmdExecutableOutput);
BazelCommandExecutor bazelCommandExecutor = new BazelCommandExecutor(executableRunner, workspaceDir, bazelExe);
BazelVariableSubstitutor bazelVariableSubstitutor = new BazelVariableSubstitutor("//:ProjectRunner", null);
IntermediateStep executor = new IntermediateStepExecuteBazelOnEachLine(bazelCommandExecutor, bazelVariableSubstitutor, Arrays.asList("cquery", "filter(\\\"@.*:jar\\\", deps(${detect.bazel.target}))"), false);
List<String> input = new ArrayList<>(0);
List<String> output = executor.process(input);
assertEquals(1, output.size());
assertEquals("@org_apache_commons_commons_io//jar:jar\n@com_google_guava_guava//jar:jar", output.get(0));
}
use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStep in project synopsys-detect by blackducksoftware.
the class IntermediateStepParseFilterLinesTest method testOtherTagType.
@Test
public void testOtherTagType() throws IntegrationException, ExecutableFailedException {
IntermediateStep intermediateStep = new IntermediateStepParseFilterLines(".*maven_coordinates=.*");
List<String> input = Arrays.asList(NAME_LINE, TAGS_LINE_OTHER);
List<String> output = intermediateStep.process(input);
assertEquals(0, output.size());
}
use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStep in project synopsys-detect by blackducksoftware.
the class IntermediateStepParseReplaceInEachLineTest method testInsertPrefix.
@Test
public void testInsertPrefix() throws IntegrationException, ExecutableFailedException {
List<String> input = Arrays.asList("org_apache_commons_commons_io", "com_google_guava_guava");
IntermediateStep intermediateStep = new IntermediateStepParseReplaceInEachLine("^", "//external:");
List<String> output = intermediateStep.process(input);
assertEquals(2, output.size());
assertEquals("//external:org_apache_commons_commons_io", output.get(0));
assertEquals("//external:com_google_guava_guava", output.get(1));
}
use of com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStep in project synopsys-detect by blackducksoftware.
the class IntermediateStepParseReplaceInEachLineTest method testMavenInstallBuildOutputExtractMavenCoordinates.
@Test
public void testMavenInstallBuildOutputExtractMavenCoordinates() throws IntegrationException, ExecutableFailedException {
List<String> input = Arrays.asList(" tags = [\"maven_coordinates=com.google.guava:guava:27.0-jre\"],");
IntermediateStep intermediateStepOne = new IntermediateStepParseReplaceInEachLine("^\\s*tags\\s*\\s*=\\s*\\[\\s*\"maven_coordinates=", "");
List<String> stepOneOutput = intermediateStepOne.process(input);
IntermediateStep intermediateStepTwo = new IntermediateStepParseReplaceInEachLine("\".*", "");
List<String> output = intermediateStepTwo.process(stepOneOutput);
assertEquals(1, output.size());
assertEquals("com.google.guava:guava:27.0-jre", output.get(0));
}
Aggregations