use of com.synopsys.integration.detectable.detectables.cargo.parse.CargoDependencyLineParser in project synopsys-detect by blackducksoftware.
the class DetectableFactory method createCargoDetectable.
public CargoDetectable createCargoDetectable(DetectableEnvironment environment) {
CargoTomlParser cargoTomlParser = new CargoTomlParser();
CargoDependencyLineParser cargoDependencyLineParser = new CargoDependencyLineParser();
CargoLockPackageDataTransformer cargoLockPackageDataTransformer = new CargoLockPackageDataTransformer(cargoDependencyLineParser);
CargoLockPackageTransformer cargoLockPackageTransformer = new CargoLockPackageTransformer();
CargoExtractor cargoExtractor = new CargoExtractor(cargoTomlParser, cargoLockPackageDataTransformer, cargoLockPackageTransformer);
return new CargoDetectable(environment, fileFinder, cargoExtractor);
}
use of com.synopsys.integration.detectable.detectables.cargo.parse.CargoDependencyLineParser in project synopsys-detect by blackducksoftware.
the class CargoLockPackageDataTransformerTest method transform.
@Test
void transform() {
CargoDependencyLineParser cargoDependencyLineParser = new CargoDependencyLineParser();
CargoLockPackageDataTransformer transformer = new CargoLockPackageDataTransformer(cargoDependencyLineParser);
List<String> dependencies = Arrays.asList("dep1", "dep2 2.0.0", "dep3 3.0.0 (registry+https://some-registry-url");
CargoLockPackageData cargoLockPackageData = new CargoLockPackageData("some-name", "some-version", null, null, dependencies);
CargoLockPackage cargoLockPackage = transformer.transform(cargoLockPackageData);
assertEquals(new NameVersion("some-name", "some-version"), cargoLockPackage.getPackageNameVersion());
assertEquals(3, cargoLockPackage.getDependencies().size());
NameOptionalVersion dep1Actual = cargoLockPackage.getDependencies().get(0);
assertEquals("dep1", dep1Actual.getName());
assertFalse(dep1Actual.getVersion().isPresent());
assertPackageNameVersion("dep2", "2.0.0", cargoLockPackage.getDependencies().get(1));
assertPackageNameVersion("dep3", "3.0.0", cargoLockPackage.getDependencies().get(2));
}
use of com.synopsys.integration.detectable.detectables.cargo.parse.CargoDependencyLineParser in project synopsys-detect by blackducksoftware.
the class CargoLockPackageDataTransformerTest method transformNoVersion.
@Test
void transformNoVersion() {
CargoDependencyLineParser cargoDependencyLineParser = new CargoDependencyLineParser();
CargoLockPackageDataTransformer transformer = new CargoLockPackageDataTransformer(cargoDependencyLineParser);
CargoLockPackageData cargoLockPackageData = new CargoLockPackageData("some-name", null, null, null, Collections.emptyList());
CargoLockPackage cargoLockPackage = transformer.transform(cargoLockPackageData);
assertEquals(new NameVersion("some-name", null), cargoLockPackage.getPackageNameVersion());
assertTrue(cargoLockPackage.getDependencies().isEmpty());
}
Aggregations