Search in sources :

Example 1 with CargoLockPackageData

use of com.synopsys.integration.detectable.detectables.cargo.data.CargoLockPackageData 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));
}
Also used : NameOptionalVersion(com.synopsys.integration.detectable.util.NameOptionalVersion) NameVersion(com.synopsys.integration.util.NameVersion) CargoLockPackageData(com.synopsys.integration.detectable.detectables.cargo.data.CargoLockPackageData) CargoDependencyLineParser(com.synopsys.integration.detectable.detectables.cargo.parse.CargoDependencyLineParser) CargoLockPackage(com.synopsys.integration.detectable.detectables.cargo.model.CargoLockPackage) Test(org.junit.jupiter.api.Test)

Example 2 with CargoLockPackageData

use of com.synopsys.integration.detectable.detectables.cargo.data.CargoLockPackageData 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());
}
Also used : NameVersion(com.synopsys.integration.util.NameVersion) CargoLockPackageData(com.synopsys.integration.detectable.detectables.cargo.data.CargoLockPackageData) CargoDependencyLineParser(com.synopsys.integration.detectable.detectables.cargo.parse.CargoDependencyLineParser) CargoLockPackage(com.synopsys.integration.detectable.detectables.cargo.model.CargoLockPackage) Test(org.junit.jupiter.api.Test)

Aggregations

CargoLockPackageData (com.synopsys.integration.detectable.detectables.cargo.data.CargoLockPackageData)2 CargoLockPackage (com.synopsys.integration.detectable.detectables.cargo.model.CargoLockPackage)2 CargoDependencyLineParser (com.synopsys.integration.detectable.detectables.cargo.parse.CargoDependencyLineParser)2 NameVersion (com.synopsys.integration.util.NameVersion)2 Test (org.junit.jupiter.api.Test)2 NameOptionalVersion (com.synopsys.integration.detectable.util.NameOptionalVersion)1