Search in sources :

Example 6 with IntermediateStep

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));
}
Also used : IntermediateStep(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStep) IntermediateStepParseValuesFromXml(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStepParseValuesFromXml) Test(org.junit.jupiter.api.Test)

Example 7 with IntermediateStep

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));
}
Also used : DetectableExecutableRunner(com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner) ExecutableOutput(com.synopsys.integration.executable.ExecutableOutput) IntermediateStep(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStep) ArrayList(java.util.ArrayList) BazelVariableSubstitutor(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelVariableSubstitutor) Executable(com.synopsys.integration.executable.Executable) File(java.io.File) ExecutableTarget(com.synopsys.integration.detectable.ExecutableTarget) BazelCommandExecutor(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelCommandExecutor) IntermediateStepExecuteBazelOnEachLine(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStepExecuteBazelOnEachLine) Test(org.junit.jupiter.api.Test)

Example 8 with IntermediateStep

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());
}
Also used : IntermediateStepParseFilterLines(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStepParseFilterLines) IntermediateStep(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStep) Test(org.junit.jupiter.api.Test)

Example 9 with IntermediateStep

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));
}
Also used : IntermediateStepParseReplaceInEachLine(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStepParseReplaceInEachLine) IntermediateStep(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStep) Test(org.junit.jupiter.api.Test)

Example 10 with IntermediateStep

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));
}
Also used : IntermediateStepParseReplaceInEachLine(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStepParseReplaceInEachLine) IntermediateStep(com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStep) Test(org.junit.jupiter.api.Test)

Aggregations

IntermediateStep (com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStep)11 Test (org.junit.jupiter.api.Test)11 IntermediateStepParseReplaceInEachLine (com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStepParseReplaceInEachLine)5 IntermediateStepParseFilterLines (com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStepParseFilterLines)3 ExecutableTarget (com.synopsys.integration.detectable.ExecutableTarget)1 DetectableExecutableRunner (com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner)1 BazelCommandExecutor (com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelCommandExecutor)1 BazelVariableSubstitutor (com.synopsys.integration.detectable.detectables.bazel.pipeline.step.BazelVariableSubstitutor)1 IntermediateStepExecuteBazelOnEachLine (com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStepExecuteBazelOnEachLine)1 IntermediateStepParseSplitEach (com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStepParseSplitEach)1 IntermediateStepParseValuesFromXml (com.synopsys.integration.detectable.detectables.bazel.pipeline.step.IntermediateStepParseValuesFromXml)1 Executable (com.synopsys.integration.executable.Executable)1 ExecutableOutput (com.synopsys.integration.executable.ExecutableOutput)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1