diff --git a/src/main/java/com/redhat/labs/lodestar/model/Artifact.java b/src/main/java/com/redhat/labs/lodestar/model/Artifact.java index 96d40634..ad708b4e 100644 --- a/src/main/java/com/redhat/labs/lodestar/model/Artifact.java +++ b/src/main/java/com/redhat/labs/lodestar/model/Artifact.java @@ -18,6 +18,7 @@ public class Artifact extends EngagementAttribute { private String title; private String description; private String type; + private String prettyType; private String linkAddress; } \ No newline at end of file diff --git a/src/main/java/com/redhat/labs/lodestar/model/EngagementArtifact.java b/src/main/java/com/redhat/labs/lodestar/model/EngagementArtifact.java index e40fb6d6..07560ed1 100644 --- a/src/main/java/com/redhat/labs/lodestar/model/EngagementArtifact.java +++ b/src/main/java/com/redhat/labs/lodestar/model/EngagementArtifact.java @@ -23,5 +23,6 @@ public class EngagementArtifact extends Artifact { private String projectName; private String customerName; + private String region; } diff --git a/src/main/java/com/redhat/labs/lodestar/service/ArtifactService.java b/src/main/java/com/redhat/labs/lodestar/service/ArtifactService.java index b7f8b495..bee074c3 100644 --- a/src/main/java/com/redhat/labs/lodestar/service/ArtifactService.java +++ b/src/main/java/com/redhat/labs/lodestar/service/ArtifactService.java @@ -1,6 +1,7 @@ package com.redhat.labs.lodestar.service; import java.util.List; +import java.util.Map; import java.util.Optional; import java.util.Set; @@ -35,6 +36,9 @@ public class ArtifactService { @Inject EngagementService engagementService; + @Inject + ConfigService configService; + public List getArtifacts(String engagementUuid) { ArtifactOptions options = ArtifactOptions.builder().page(0).pageSize(1000) .engagementUuid(engagementUuid).build(); @@ -60,15 +64,18 @@ public Response getArtifacts(ListFilterOptions filterOptions, String engagementU int totalArtifacts = Integer.parseInt(response.getHeaderString("x-total-artifacts")); int totalPages = totalArtifacts / pageSize + 1; List artifacts = response.readEntity(new GenericType<>(){}); - - //if(dashboardView) { //enrich data with customer and engagement name - for(EngagementArtifact artifact : artifacts) { - Engagement e = engagementService.getByUuid(artifact.getEngagementUuid()); - artifact.setCustomerName(e.getCustomerName()); - artifact.setProjectName(e.getProjectName()); - - } - // } + + Map artifactOptions = configService.getArtifactOptions(); + + for(EngagementArtifact artifact : artifacts) { + Engagement e = engagementService.getByUuid(artifact.getEngagementUuid()); + artifact.setCustomerName(e.getCustomerName()); + artifact.setProjectName(e.getProjectName()); + artifact.setRegion(e.getRegion()); + + artifact.setPrettyType(artifactOptions.get(artifact.getType())); + + } return Response.ok(artifacts).header("x-current-page", currentPage).header("x-per-page", pageSize) .header("x-total-artifacts", totalArtifacts).header("x-next-page", currentPage + 1) diff --git a/src/test/java/com/redhat/labs/lodestar/service/ArtifactServiceTest.java b/src/test/java/com/redhat/labs/lodestar/service/ArtifactServiceTest.java index 0107bf5b..30ee35a1 100644 --- a/src/test/java/com/redhat/labs/lodestar/service/ArtifactServiceTest.java +++ b/src/test/java/com/redhat/labs/lodestar/service/ArtifactServiceTest.java @@ -72,4 +72,12 @@ void testSendUpdateWebError() { Mockito.verify(artifactClient, Mockito.never()).updateArtifacts("uuid3", "na", artifacts, "Mitch", "mitch@mitch.com"); } + + @Test + void testArtifactTypeCount() { + + artifactService.getTypesCount(Collections.emptyList()); + + Mockito.verify(artifactClient).getTypesCount(Collections.emptyList()); + } }