feat(test): Edited CpanCliDetectableTest to extend DetectableFunctionalTest
@@ -25,20 +25,32 @@ package com.synopsys.integration.detectable.detectables.cpan.unit;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
+import java.io.IOException;
+import org.jetbrains.annotations.NotNull;
+import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
+import com.synopsys.integration.bdio.model.Forge;
+import com.synopsys.integration.detectable.Detectable;
import com.synopsys.integration.detectable.DetectableEnvironment;
+import com.synopsys.integration.detectable.Extraction;
+import com.synopsys.integration.detectable.detectable.executable.ExecutableOutput;
import com.synopsys.integration.detectable.detectable.executable.resolver.CpanResolver;
import com.synopsys.integration.detectable.detectable.executable.resolver.CpanmResolver;
import com.synopsys.integration.detectable.detectable.file.FileFinder;
import com.synopsys.integration.detectable.detectables.cpan.CpanCliDetectable;
import com.synopsys.integration.detectable.detectables.cpan.CpanCliExtractor;
+import com.synopsys.integration.detectable.functional.DetectableFunctionalTest;
import com.synopsys.integration.detectable.util.MockDetectableEnvironment;
import com.synopsys.integration.detectable.util.MockFileFinder;
+import com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert;
+
+public class CpanCliDetectableTest extends DetectableFunctionalTest {
+ public CpanCliDetectableTest() throws IOException {
+ super("cpan");
+ }
-public class CpanCliDetectableTest {
@Test
public void testApplicable() {
@@ -53,4 +65,55 @@ public class CpanCliDetectableTest {
assertTrue(detectable.applicable().getPassed());
}
+
+ @Override
+ protected void setup() throws IOException {
+ addFile("Makefile.PL");
+
+ ExecutableOutput cpanListOutput = createStandardOutput(
+ "AnyEvent\t7.14",
+ "Clone\t0.39",
+ "DateTime\t1.43",
+ "DBI\t1.636"
+ );
+ addExecutableOutput(cpanListOutput, "cpan", "-l");
+
+ ExecutableOutput cpanmShowDepsOutput = createStandardOutput(
+ "--> Working on .",
+ "Configuring App-cpanminus-1.7043 ... OK",
+ "ExtUtils::MakeMaker~6.58",
+ "Test::More",
+ "perl~5.008001",
+ "ExtUtils::MakeMaker"
+ );
+ addExecutableOutput(cpanmShowDepsOutput, "cpanm", "--showdeps", ".");
+ }
+
+ @NotNull
+ @Override
+ public Detectable create(@NotNull final DetectableEnvironment detectableEnvironment) {
+ class CpanResolverTest implements CpanResolver {
+ @Override
+ public File resolveCpan() {
+ return new File("cpan");
+ }
+ }
+
+ class CpanmResolverTest implements CpanmResolver {
+ @Override
+ public File resolveCpanm() {
+ return new File("cpanm");
+ }
+ }
+ return detectableFactory.createCpanCliDetectable(detectableEnvironment, new CpanResolverTest(), new CpanmResolverTest());
+ }
+
+ @Override
+ public void assertExtraction(@NotNull final Extraction extraction) {
+ Assertions.assertNotEquals(0, extraction.getCodeLocations().size());
+
+ NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.CPAN, extraction.getCodeLocations().get(0).getDependencyGraph());
+ graphAssert.hasRootSize(0);
+
+ }
}
