@Test void parseSourcePackageWhenArchIsNotProvided() { String packageName = "libstdc++-9.2.1-1.fc30.src.rpm"; RpmArtifactCoordinates actualCoord = RpmArtifactCoordinatesUtils.parse(packageName); List<String> expectedCoord = Arrays.asList("libstdc++", "9.2.1", "1.fc30", null, "src"); assertThat(expectedCoord.get(0)).isEqualTo(actualCoord.getId()); assertThat(expectedCoord.get(1)).isEqualTo(actualCoord.getVersion()); assertThat(expectedCoord.get(2)).isEqualTo(actualCoord.getRelease()); assertThat(expectedCoord.get(3)).isEqualTo(actualCoord.getArchitecture()); assertThat(expectedCoord.get(4)).isEqualTo(actualCoord.getPackageType()); }
public static RpmArtifactCoordinates parse(@NotEmpty String path) { String fileName = FilenameUtils.getName(path); if (!fileName.endsWith(".rpm")) { throw new IllegalArgumentException("The artifact packaging can be only '.rpm'"); } String baseName = parseBaseName(fileName); String version = parseVersion(fileName); String release = parseRelease(fileName); RpmPackageType packageType = parsePackageType(fileName); RpmArtifactCoordinates artifactCoordinates; if (packageType == RpmPackageType.SOURCE) { artifactCoordinates = new RpmArtifactCoordinates(baseName, version, release, packageType); } else { RpmPackageArch arch = parseArch(fileName); artifactCoordinates = new RpmArtifactCoordinates(baseName, version, release, packageType, arch); } return artifactCoordinates; }
RpmArtifactCoordinatesUtils { public static RpmArtifactCoordinates parse(@NotEmpty String path) { String fileName = FilenameUtils.getName(path); if (!fileName.endsWith(".rpm")) { throw new IllegalArgumentException("The artifact packaging can be only '.rpm'"); } String baseName = parseBaseName(fileName); String version = parseVersion(fileName); String release = parseRelease(fileName); RpmPackageType packageType = parsePackageType(fileName); RpmArtifactCoordinates artifactCoordinates; if (packageType == RpmPackageType.SOURCE) { artifactCoordinates = new RpmArtifactCoordinates(baseName, version, release, packageType); } else { RpmPackageArch arch = parseArch(fileName); artifactCoordinates = new RpmArtifactCoordinates(baseName, version, release, packageType, arch); } return artifactCoordinates; } }
RpmArtifactCoordinatesUtils { public static RpmArtifactCoordinates parse(@NotEmpty String path) { String fileName = FilenameUtils.getName(path); if (!fileName.endsWith(".rpm")) { throw new IllegalArgumentException("The artifact packaging can be only '.rpm'"); } String baseName = parseBaseName(fileName); String version = parseVersion(fileName); String release = parseRelease(fileName); RpmPackageType packageType = parsePackageType(fileName); RpmArtifactCoordinates artifactCoordinates; if (packageType == RpmPackageType.SOURCE) { artifactCoordinates = new RpmArtifactCoordinates(baseName, version, release, packageType); } else { RpmPackageArch arch = parseArch(fileName); artifactCoordinates = new RpmArtifactCoordinates(baseName, version, release, packageType, arch); } return artifactCoordinates; }  }
RpmArtifactCoordinatesUtils { public static RpmArtifactCoordinates parse(@NotEmpty String path) { String fileName = FilenameUtils.getName(path); if (!fileName.endsWith(".rpm")) { throw new IllegalArgumentException("The artifact packaging can be only '.rpm'"); } String baseName = parseBaseName(fileName); String version = parseVersion(fileName); String release = parseRelease(fileName); RpmPackageType packageType = parsePackageType(fileName); RpmArtifactCoordinates artifactCoordinates; if (packageType == RpmPackageType.SOURCE) { artifactCoordinates = new RpmArtifactCoordinates(baseName, version, release, packageType); } else { RpmPackageArch arch = parseArch(fileName); artifactCoordinates = new RpmArtifactCoordinates(baseName, version, release, packageType, arch); } return artifactCoordinates; }  static RpmArtifactCoordinates parse(@NotEmpty String path); }
RpmArtifactCoordinatesUtils { public static RpmArtifactCoordinates parse(@NotEmpty String path) { String fileName = FilenameUtils.getName(path); if (!fileName.endsWith(".rpm")) { throw new IllegalArgumentException("The artifact packaging can be only '.rpm'"); } String baseName = parseBaseName(fileName); String version = parseVersion(fileName); String release = parseRelease(fileName); RpmPackageType packageType = parsePackageType(fileName); RpmArtifactCoordinates artifactCoordinates; if (packageType == RpmPackageType.SOURCE) { artifactCoordinates = new RpmArtifactCoordinates(baseName, version, release, packageType); } else { RpmPackageArch arch = parseArch(fileName); artifactCoordinates = new RpmArtifactCoordinates(baseName, version, release, packageType, arch); } return artifactCoordinates; }  static RpmArtifactCoordinates parse(@NotEmpty String path);  }