diff --git a/demo-data/src/main/java/org/jboss/pnc/demo/data/DatabaseDataInitializer.java b/demo-data/src/main/java/org/jboss/pnc/demo/data/DatabaseDataInitializer.java index 2640bec7f1..6cc4d747ea 100644 --- a/demo-data/src/main/java/org/jboss/pnc/demo/data/DatabaseDataInitializer.java +++ b/demo-data/src/main/java/org/jboss/pnc/demo/data/DatabaseDataInitializer.java @@ -1177,11 +1177,39 @@ public void initiliazeBuildRecordDemoData() { .deployPath("/built15") .build(); + Artifact builtArtifact16a = Artifact.Builder.newBuilder() + .buildRecord(buildRecord7) + .identifier("demo:built-artifact16:jar:1.0.redhat-a") + .targetRepository(targetRepository) + .filename("demo built artifact 16a") + .md5("md5-fake-123abc") + .sha1("sha1-fake-123abc") + .sha256("sha256-fake-123abc") + .size(16L) + .artifactQuality(ArtifactQuality.NEW) + .deployPath("/demo/built-artifact16/1.0.redhat-a/built-artifact16-1.0.redhat-a.jar") + .build(); + + Artifact builtArtifact16b = Artifact.Builder.newBuilder() + .buildRecord(buildRecord7) + .identifier("demo:built-artifact16:jar:1.0.redhat-b") + .targetRepository(targetRepository) + .filename("demo built artifact 16b") + .md5("md5-fake-123abc") + .sha1("sha1-fake-123abc") + .sha256("sha256-fake-123abc") + .size(16L) + .artifactQuality(ArtifactQuality.NEW) + .deployPath("/demo/built-artifact16/1.0.redhat-b/built-artifact16-1.0.redhat-b.jar") + .build(); + builtArtifact11 = artifactRepository.save(builtArtifact11); builtArtifact12 = artifactRepository.save(builtArtifact12); builtArtifact13 = artifactRepository.save(builtArtifact13); builtArtifact14 = artifactRepository.save(builtArtifact14); builtArtifact15 = artifactRepository.save(builtArtifact15); + builtArtifact16a = artifactRepository.save(builtArtifact16a); + builtArtifact16b = artifactRepository.save(builtArtifact16b); demoProductMilestone1 = productMilestoneRepository.queryById(demoProductMilestone1.getId()); demoProductMilestone3 = productMilestoneRepository.queryById(demoProductMilestone3.getId()); @@ -1265,6 +1293,26 @@ public void initiliazeBuildRecordDemoData() { .build(); operation4 = deliverableAnalyzerOperationRepository.save(operation4); + DeliverableAnalyzerOperation operation5 = DeliverableAnalyzerOperation.Builder.newBuilder() + .id(new Base32LongID(1000005l)) + .progressStatus(ProgressStatus.FINISHED) + .submitTime(TODAY) + .startTime(TODAY) + .user(demoUser) + .productMilestone(demoProductMilestone1) + .build(); + operation5 = deliverableAnalyzerOperationRepository.save(operation5); + + DeliverableAnalyzerOperation operation6 = DeliverableAnalyzerOperation.Builder.newBuilder() + .id(new Base32LongID(1000006l)) + .progressStatus(ProgressStatus.FINISHED) + .submitTime(TODAY) + .startTime(TODAY) + .user(demoUser) + .productMilestone(demoProductMilestone2) + .build(); + operation6 = deliverableAnalyzerOperationRepository.save(operation6); + DeliverableAnalyzerReport report1 = DeliverableAnalyzerReport.builder() .operation(operation2) .labels(EnumSet.of(DeliverableAnalyzerReportLabel.RELEASED)) @@ -1283,6 +1331,18 @@ public void initiliazeBuildRecordDemoData() { .build(); report3 = deliverableAnalyzerReportRepository.save(report3); + DeliverableAnalyzerReport report4 = DeliverableAnalyzerReport.builder() + .operation(operation5) + .labels(EnumSet.noneOf(DeliverableAnalyzerReportLabel.class)) + .build(); + report4 = deliverableAnalyzerReportRepository.save(report4); + + DeliverableAnalyzerReport report5 = DeliverableAnalyzerReport.builder() + .operation(operation6) + .labels(EnumSet.noneOf(DeliverableAnalyzerReportLabel.class)) + .build(); + report5 = deliverableAnalyzerReportRepository.save(report5); + DeliverableAnalyzerLabelEntry report1LabelEntry1 = DeliverableAnalyzerLabelEntry.builder() .report(report1) .changeOrder(1) @@ -1354,6 +1414,24 @@ public void initiliazeBuildRecordDemoData() { .builtFromSource(true) .brewBuildId(null) .build(); + DeliverableArtifact analyzedArtifact11a = DeliverableArtifact.builder() + .report(report4) + .artifact(builtArtifact16a) + .builtFromSource(true) + .brewBuildId(null) + .build(); + DeliverableArtifact analyzedArtifact11b = DeliverableArtifact.builder() + .report(report4) + .artifact(builtArtifact16b) + .builtFromSource(true) + .brewBuildId(null) + .build(); + DeliverableArtifact analyzedArtifact12 = DeliverableArtifact.builder() + .report(report5) + .artifact(builtArtifact16b) + .builtFromSource(true) + .brewBuildId(null) + .build(); deliverableArtifactRepository.save(analyzedArtifact1); deliverableArtifactRepository.save(analyzedArtifact2); @@ -1365,6 +1443,9 @@ public void initiliazeBuildRecordDemoData() { deliverableArtifactRepository.save(analyzedArtifact8); deliverableArtifactRepository.save(analyzedArtifact9); deliverableArtifactRepository.save(analyzedArtifact10); + deliverableArtifactRepository.save(analyzedArtifact11a); + deliverableArtifactRepository.save(analyzedArtifact11b); + deliverableArtifactRepository.save(analyzedArtifact12); } private RepositoryConfiguration createRepositoryConfiguration(String internalScmUrl, String externalUrl) { diff --git a/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/ArtifactEndpointTest.java b/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/ArtifactEndpointTest.java index 99bf063923..6d4925f4cb 100644 --- a/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/ArtifactEndpointTest.java +++ b/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/ArtifactEndpointTest.java @@ -114,7 +114,7 @@ public void testGetAllArtifacts() throws RemoteResourceException { RemoteCollection all = client.getAll(null, null, null); - assertThat(all).hasSize(17); // from DatabaseDataInitializer + assertThat(all).hasSize(19); // from DatabaseDataInitializer } @Test diff --git a/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/DeliverableAnalyzerReportEndpointTest.java b/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/DeliverableAnalyzerReportEndpointTest.java index 1ee088b33f..076adb8efc 100644 --- a/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/DeliverableAnalyzerReportEndpointTest.java +++ b/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/DeliverableAnalyzerReportEndpointTest.java @@ -73,7 +73,7 @@ public void shouldGetDeliverableAnalyzerReports() throws RemoteResourceException RestClientConfiguration.asAnonymous()); RemoteCollection all = client.getAll(); - assertThat(all).hasSize(3); + assertThat(all).hasSize(5); } @Test diff --git a/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/ProductMilestoneEndpointTest.java b/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/ProductMilestoneEndpointTest.java index 3fcf3cc3b3..fb4145f765 100644 --- a/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/ProductMilestoneEndpointTest.java +++ b/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/ProductMilestoneEndpointTest.java @@ -17,6 +17,8 @@ */ package org.jboss.pnc.integration.endpoints; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.junit.Arquillian; @@ -31,6 +33,8 @@ 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.DeliveredArtifactInMilestones; import org.jboss.pnc.dto.Product; import org.jboss.pnc.dto.ProductMilestone; import org.jboss.pnc.dto.ProductMilestoneCloseResult; @@ -341,7 +345,7 @@ public void testGetDeliveredArtifacts() throws ClientException { RemoteCollection all = client.getDeliveredArtifacts(milestoneId); - assertThat(all).hasSize(7); + assertThat(all).hasSize(9); RemoteCollection built = client.getDeliveredArtifacts( milestoneId, Optional.empty(), @@ -358,7 +362,7 @@ public void testGetDeliverableAnalyzerOperations() throws ClientException { RemoteCollection all = client.getAllDeliverableAnalyzerOperations(milestoneId); - assertThat(all).hasSize(5); + assertThat(all).hasSize(6); RemoteCollection allInProgress = client.getAllDeliverableAnalyzerOperations( milestoneId, @@ -378,18 +382,18 @@ public void testGetStatistics() throws ClientException { .thisMilestone(2L) // builtArtifact1, builtArtifact9 .otherMilestones(1L) // builtArtifact10 .otherProducts(2L) // builtArtifact11, builtArtifact12 - .noMilestone(1L) // builtArtifact5 + .noMilestone(3L) // builtArtifact5 .noBuild(1L) // importedArtifact2 .build(); EnumMap expectedArtifactQualities = Maps .initEnumMapWithDefaultValue(ArtifactQuality.class, 0L); - expectedArtifactQualities.put(ArtifactQuality.NEW, 6L); + expectedArtifactQualities.put(ArtifactQuality.NEW, 8L); expectedArtifactQualities.put(ArtifactQuality.VERIFIED, 1L); EnumMap expectedRepositoryTypes = Maps .initEnumMapWithDefaultValue(RepositoryType.class, 0L); - expectedRepositoryTypes.put(RepositoryType.MAVEN, 7L); + expectedRepositoryTypes.put(RepositoryType.MAVEN, 9L); ProductMilestoneStatistics expectedStats = ProductMilestoneStatistics.builder() .artifactsInMilestone(3L) // builtArtifact1, builtArtifact2, builtArtifact9 @@ -418,6 +422,48 @@ public void testGetStatistics() throws ClientException { assertThat(actualStats).isEqualTo(expectedStats); } + @Test + public void testGetArtifactsDeliveredInMilestonesGroupedByPrefix_twoMilestones_foundArtifacts() + throws ClientException { + // arrange + ProductMilestoneClient client = new ProductMilestoneClient(RestClientConfiguration.asAnonymous()); + + ArtifactVersion artifactVersion1 = ArtifactVersion.builder() + .id("117") + .artifactVersion("1.0.redhat-a") + .type("jar") + .build(); + ArtifactVersion artifactVersion2 = ArtifactVersion.builder() + .id("118") + .artifactVersion("1.0.redhat-b") + .type("jar") + .build(); + + DeliveredArtifactInMilestones expectedDeliveredArtifactsInMilestones = DeliveredArtifactInMilestones.builder() + .artifactIdentifierPrefix("demo:built-artifact16") + .productMilestoneArtifacts( + ImmutableMap.of( + "100", + Lists.newArrayList(artifactVersion1, artifactVersion2), + "101", + Lists.newArrayList(artifactVersion2))) + .build(); + + // act + List actualDeliveredArtifactsInMilestonesList = client + .getArtifactsDeliveredInMilestonesGroupedByPrefix( + Lists.newArrayList(milestone.getId(), milestone2.getId())); + + // assert + assertThat(actualDeliveredArtifactsInMilestonesList).hasSize(1); + var actualDeliveredArtifactsInMilestones = actualDeliveredArtifactsInMilestonesList.iterator().next(); + + assertThat(actualDeliveredArtifactsInMilestones.getArtifactIdentifierPrefix()) + .isEqualTo(expectedDeliveredArtifactsInMilestones.getArtifactIdentifierPrefix()); + assertThat(actualDeliveredArtifactsInMilestones.getProductMilestoneArtifacts()) + .isEqualTo(expectedDeliveredArtifactsInMilestones.getProductMilestoneArtifacts()); + } + @Test public void shouldScratchFlagBeFalseImplicitly() throws ClientException { // given diff --git a/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/ProductVersionEndpointTest.java b/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/ProductVersionEndpointTest.java index 1f82ddbabc..95af70e179 100644 --- a/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/ProductVersionEndpointTest.java +++ b/integration-test/src/test/java/org/jboss/pnc/integration/endpoints/ProductVersionEndpointTest.java @@ -442,7 +442,7 @@ public void testGetStatisticsForExistingProductVersion() throws ClientException .thisVersion(3L) // bA1, bA9, bA10 .otherVersions(1L) // bA13 .otherProducts(2L) // bA11, bA12 - .noMilestone(1L) // bA5 + .noMilestone(4L) // bA5 .noBuild(1L) // iA2 .build(); @@ -508,7 +508,7 @@ public void testGetArtifactQualitiesStatisticsForExistingProductVersion() throws EnumMap expectedArtifactQualities = Maps .initEnumMapWithDefaultValue(ArtifactQuality.class, 0L); - expectedArtifactQualities.put(ArtifactQuality.NEW, 6L); + expectedArtifactQualities.put(ArtifactQuality.NEW, 8L); expectedArtifactQualities.put(ArtifactQuality.VERIFIED, 1L); ProductMilestoneArtifactQualityStatistics expectedArtQualityStats = ProductMilestoneArtifactQualityStatistics @@ -557,7 +557,7 @@ public void testGetRepositoryTypesStatisticsForExistingProductVersion() throws C EnumMap expectedRepositoryTypes = Maps .initEnumMapWithDefaultValue(RepositoryType.class, 0L); - expectedRepositoryTypes.put(RepositoryType.MAVEN, 7L); + expectedRepositoryTypes.put(RepositoryType.MAVEN, 9L); ProductMilestoneRepositoryTypeStatistics expectedRepoTypeStats = ProductMilestoneRepositoryTypeStatistics .builder() @@ -597,5 +597,4 @@ public void testGetRepositoryTypesStatisticsForNonexistingProductVersion() throw // then assertThat(all).isEmpty(); } - }