Skip to content

Commit fdd0497

Browse files
committed
more sorting
1 parent 8387ff8 commit fdd0497

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

src/main/java/com/redhat/labs/lodestar/model/Artifact.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ public static List<Artifact> pagedArtifactsByRegionAndType(String type, List<Str
173173
* @param pageSize
174174
* @return
175175
*/
176-
public static List<Artifact> pagedArtifactsByEngagementUuid(String engagementUuid, int page, int pageSize) {
177-
return find("engagementUuid", Sort.descending(MODIFIED), engagementUuid).page(page, pageSize).list();
176+
public static List<Artifact> pagedArtifactsByEngagementUuid(String engagementUuid, int page, int pageSize, Sort sort) {
177+
return find("engagementUuid", sort, engagementUuid).page(page, pageSize).list();
178178
}
179179

180180
/**

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public Response processEngagementArtifacts(@Valid List<Artifact> artifacts, @Pat
4646
@QueryParam("authorName") Optional<String> authorName) {
4747

4848
service.updateArtifacts(engagementUuid, region, artifacts, authorEmail, authorName);
49-
return Response.ok().build();
49+
return Response.ok(service.getArtifactsByEngagement(engagementUuid)).build();
5050

5151
}
5252

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,15 @@ public List<Artifact> getArtifacts(GetListOptions options) {
186186

187187
return engagementUuid.isPresent()
188188
? Artifact.pagedArtifactsByEngagementUuid(engagementUuid.get(), options.getPage(),
189-
options.getPageSize()) //by uuid
189+
options.getPageSize(), options.getQuerySort(Sort.descending("modified"))) //by uuid
190190
: Artifact.pagedArtifacts(options.getPage(), options.getPageSize(), options.getQuerySort(Sort.descending("modified").and("engagementUuid"))); //all
191191

192192
}
193193

194+
public List<Artifact> getArtifactsByEngagement(String engagementUuid) {
195+
return Artifact.pagedArtifactsByEngagementUuid(engagementUuid, 0, 1000, Sort.descending("modified"));
196+
}
197+
194198
public List<ArtifactCount> getArtifactTypeSummary(List<String> regions) {
195199
return Artifact.countArtifactsForEachRegionAndType(regions);
196200
}

src/test/java/com/redhat/labs/model/ArtifactTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void testPagedArtifacts() {
4848

4949
@Test
5050
void testPagedArtifactsByEngagementUuid() {
51-
assertEquals(1, Artifact.pagedArtifactsByEngagementUuid("1111", 0, 1).size());
51+
assertEquals(1, Artifact.pagedArtifactsByEngagementUuid("1111", 0, 1, Sort.by("uuid")).size());
5252
}
5353

5454
@Test

src/test/java/com/redhat/labs/service/ArtifactServiceTest.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void testModifyByEngagementIdUpdateInGit() {
8686
assertNotNull(updated);
8787
assertEquals(2, updated.size());
8888

89-
updated.stream().forEach(a -> {
89+
updated.forEach(a -> {
9090
if (a.getType().equals("Demo")) {
9191
assertEquals("Updated", a.getDescription());
9292
} else if (a.getType().equals("typeOne")) {
@@ -180,9 +180,7 @@ void testGetArtifactsByTypeException() {
180180
options.setType("Demo");
181181
options.setEngagementUuid("1111");
182182

183-
WebApplicationException ex = assertThrows(WebApplicationException.class, () -> {
184-
artifactService.getArtifacts(options);
185-
});
183+
WebApplicationException ex = assertThrows(WebApplicationException.class, () -> artifactService.getArtifacts(options));
186184

187185
assertEquals(400, ex.getResponse().getStatus());
188186

@@ -287,7 +285,6 @@ void testCountArtifactsByEngagement() {
287285
// when
288286
ArtifactCount count = artifactService.countArtifacts(options);
289287

290-
// then
291288
// then
292289
assertNotNull(count);
293290
assertEquals(2, count.getCount());

0 commit comments

Comments
 (0)