Skip to content

Commit 15604aa

Browse files
authored
fix count of participants when getting all engagements (#171)
1 parent d23cf06 commit 15604aa

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/main/java/com/redhat/labs/lodestar/resource/EngagementResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ public Response post(@Valid Engagement engagement, @Context UriInfo uriInfo) {
315315

316316
// create the resource
317317
Engagement created = engagementService.create(engagement);
318+
LOGGER.debug("New Engagement {}", created);
318319

319320
// build location response
320321
UriBuilder builder = uriInfo.getAbsolutePathBuilder();
@@ -360,7 +361,6 @@ public Response put(@PathParam("customerName") String customerName, @PathParam("
360361
@Operation(summary = "Updates the engagement resource in the database.")
361362
public Response put(@PathParam("id") String uuid, @Valid Engagement engagement) {
362363

363-
364364
boolean writer = jwtUtils.isAllowedToWriteEngagement(jwt, configService.getPermission(engagement.getType()));
365365
if(!writer) {
366366
return forbiddenResponse(engagement.getType());

src/main/java/com/redhat/labs/lodestar/service/EngagementService.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ public Engagement update(Engagement engagement) {
209209
//TODO update cache
210210
if(somethingChanged) {
211211
engagementApiClient.registerUpdate(engagementUuid);
212+
} else {
213+
LOGGER.debug("Nothing changed for {}", engagementUuid);
212214
}
213215
return getEngagement(engagementUuid);
214216
}
@@ -343,8 +345,9 @@ public Response getEngagementsPaged(ListFilterOptions listFilterOptions) {
343345
//TODO this loop is to allow frontend to change after v2 deployment.
344346
// FE should use participant, artifact count field, and categories (string version)
345347
for(Engagement e : engagements) {
348+
346349
for(int i=0; i<e.getParticipantCount(); i++) {
347-
e.addParticipant(new EngagementUser());
350+
e.addParticipant(EngagementUser.builder().email(String.valueOf(i)).build());
348351
}
349352

350353
for(int i=0; i<e.getArtifactCount(); i++) {

src/test/java/com/redhat/labs/lodestar/resource/EngagementResourceGetTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,10 @@ void testGetEngagementsSuccessNoEngagements() {
112112
@Test
113113
void testGetEngagementsSuccess() {
114114

115-
Engagement engagement1 = Engagement.builder().uuid("1234").type("Residency").customerName("Customer").projectName("Project1").build();
116-
Engagement engagement2 = Engagement.builder().uuid("1235").type("Residency").customerName("Customer").projectName("Project2").build();
115+
Engagement engagement1 = Engagement.builder().uuid("1234").type("Residency").customerName("Customer").projectName("Project1")
116+
.artifactCount(4).build();
117+
Engagement engagement2 = Engagement.builder().uuid("1235").type("Residency").customerName("Customer").projectName("Project2")
118+
.participantCount(10).build();
117119

118120
Mockito.when(engagementApiClient.getEngagements(0, 500, Collections.emptySet())).thenReturn(Response.ok(List.of(engagement1, engagement2)).build());
119121

@@ -126,7 +128,9 @@ void testGetEngagementsSuccess() {
126128
.get("/engagements")
127129
.then()
128130
.statusCode(200)
129-
.body("size()", equalTo(2));
131+
.body("size()", equalTo(2))
132+
.body("[1].engagement_users.size()", equalTo(10))
133+
.body("[0].artifacts.size()", equalTo(4));
130134

131135
Mockito.verify(engagementApiClient).getEngagements(0, 500, Collections.emptySet());
132136
}

0 commit comments

Comments
 (0)