Skip to content

Commit

Permalink
NCL-7815 Rename ArtifactVersion DTO to ParsedArtifact
Browse files Browse the repository at this point in the history
  • Loading branch information
patrikk0123 committed Jan 29, 2025
1 parent ea83c5a commit db665ef
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class DeliveredArtifactInMilestones {
* Product Milestone ID mapped to list of Artifact versions delivered in the Milestone with the same identifier
* prefix.
*/
private final Map<String, List<ArtifactVersion>> productMilestoneArtifacts;
private final Map<String, List<ParsedArtifact>> productMilestoneArtifacts;

@JsonPOJOBuilder(withPrefix = "")
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
import lombok.Data;

/**
* Artifact identifier version part with ID of the Artifact.
* Artifact identifier parsed into its version, type, and optional classifier.
*
* @author Patrik Korytár &lt;[email protected]&gt;
*/
@Data
@lombok.Builder(builderClassName = "Builder", toBuilder = true)
@JsonDeserialize(builder = ArtifactVersion.Builder.class)
@JsonDeserialize(builder = ParsedArtifact.Builder.class)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ArtifactVersion {
public class ParsedArtifact {

/**
* ID of the artifact.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.jboss.pnc.common.util.ArtifactCoordinatesUtils;
import org.jboss.pnc.constants.Patterns;
import org.jboss.pnc.datastore.repositories.internal.SortInfoConverter;
import org.jboss.pnc.dto.response.ArtifactVersion;
import org.jboss.pnc.dto.response.ParsedArtifact;
import org.jboss.pnc.dto.response.DeliveredArtifactInMilestones;
import org.jboss.pnc.dto.ProductMilestone;
import org.jboss.pnc.dto.ProductMilestoneCloseResult;
Expand Down Expand Up @@ -62,7 +62,6 @@
import org.jboss.pnc.model.Product_;
import org.jboss.pnc.spi.datastore.repositories.DeliverableArtifactRepository;
import org.jboss.pnc.spi.datastore.repositories.ProductMilestoneRepository;
import org.jboss.pnc.spi.datastore.repositories.api.PageInfo;
import org.jboss.pnc.spi.datastore.repositories.api.Predicate;
import org.jboss.pnc.spi.datastore.repositories.api.SortInfo;
import org.slf4j.Logger;
Expand All @@ -82,8 +81,6 @@
import javax.persistence.criteria.Root;
import javax.persistence.criteria.SetJoin;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
Expand Down Expand Up @@ -370,7 +367,7 @@ public List<DeliveredArtifactInMilestones> getArtifactsDeliveredInMilestonesGrou
private List<DeliveredArtifactInMilestones> parseDeliveredArtifactsInMilestoneTuples(
List<Tuple> tuples,
List<Integer> milestoneId) {
Map<String, Map<String, List<ArtifactVersion>>> artifactsDeliveredInMilestonesMap = tuples.stream()
Map<String, Map<String, List<ParsedArtifact>>> artifactsDeliveredInMilestonesMap = tuples.stream()
.collect(
Collectors.groupingBy(
this::parseArtifactNameFromTuple,
Expand Down Expand Up @@ -426,7 +423,7 @@ private String parseArtifactNameFromDeployPath(String deployPath, RepositoryType
return "";
}

private Stream<Map.Entry<String, List<ArtifactVersion>>> parseMilestonePresencesFromTuple(
private Stream<Map.Entry<String, List<ParsedArtifact>>> parseMilestonePresencesFromTuple(
Tuple tuple,
List<Integer> milestoneIds) {
String id = tuple.get(0, Integer.class).toString();
Expand All @@ -437,7 +434,7 @@ private Stream<Map.Entry<String, List<ArtifactVersion>>> parseMilestonePresences
String type = parseArtifactTypeFromDeployPath(deployPath, repositoryType);
String classifier = parseArtifactClassifierFromDeployPath(deployPath, repositoryType);

ArtifactVersion artifactVersion = ArtifactVersion.builder()
ParsedArtifact parsedArtifact = ParsedArtifact.builder()
.id(id)
.artifactVersion(version)
.type(type)
Expand All @@ -447,7 +444,7 @@ private Stream<Map.Entry<String, List<ArtifactVersion>>> parseMilestonePresences
return milestoneIds.stream().filter(milestoneId -> {
Boolean milestonePresence = tuple.get(3 + milestoneIds.indexOf(milestoneId), Boolean.class);
return milestonePresence.booleanValue();
}).map(milestoneId -> Map.entry(milestoneId.toString(), List.of(artifactVersion)));
}).map(milestoneId -> Map.entry(milestoneId.toString(), List.of(parsedArtifact)));
}

private String parseArtifactVersionFromDeployPath(String deployPath, RepositoryType repositoryType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.jboss.pnc.dto.Artifact;
import org.jboss.pnc.dto.Build;
import org.jboss.pnc.dto.DeliverableAnalyzerOperation;
import org.jboss.pnc.dto.response.ArtifactVersion;
import org.jboss.pnc.dto.response.ParsedArtifact;
import org.jboss.pnc.dto.response.DeliveredArtifactInMilestones;
import org.jboss.pnc.dto.Product;
import org.jboss.pnc.dto.ProductMilestone;
Expand Down Expand Up @@ -431,13 +431,13 @@ public void testCompareArtifactsDeliveredInMilestonesWithTwoMilestonesAndCommonP
// arrange
ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asAnonymous());

ArtifactVersion artifactVersion1 = ArtifactVersion.builder()
ParsedArtifact parsedArtifact1 = ParsedArtifact.builder()
.id("117")
.artifactVersion("1.0.redhat-a")
.type("jar")
.classifier(null)
.build();
ArtifactVersion artifactVersion2 = ArtifactVersion.builder()
ParsedArtifact parsedArtifact2 = ParsedArtifact.builder()
.id("118")
.artifactVersion("1.0.redhat-b")
.type("jar")
Expand All @@ -447,7 +447,7 @@ public void testCompareArtifactsDeliveredInMilestonesWithTwoMilestonesAndCommonP
DeliveredArtifactInMilestones expectedDeliveredArtifactsInMilestones = DeliveredArtifactInMilestones.builder()
.artifactIdentifierPrefix("demo:built-artifact16")
.productMilestoneArtifacts(
Map.of("100", List.of(artifactVersion1, artifactVersion2), "101", List.of(artifactVersion2)))
Map.of("100", List.of(parsedArtifact1, parsedArtifact2), "101", List.of(parsedArtifact2)))
.build();

// act
Expand Down

0 comments on commit db665ef

Please sign in to comment.