Skip to content

Commit 2dca925

Browse files
committed
add option to return the bare minimum project info (id and e uuid)
1 parent 13d8ff5 commit 2dca925

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,19 @@ public Response deleteAllHooks() {
187187
@Counted(name = "project-by-uuid", description = "Count of project-by-uuid requests")
188188
@Timed(name = "performedProjectByUuidGet", description = "Time to get project", unit = MetricUnits.MILLISECONDS)
189189
@Tag(name = "Projects", description = "Project retrieval")
190-
public Response getProjectByUuid(@PathParam("uuid") String uuid) {
190+
public Response getProjectByUuid(@PathParam("uuid") String uuid, @QueryParam("mini") boolean mini) {
191191
Optional<Project> p = engagementService.getProjectByUuid(uuid);
192192

193193
if(p.isEmpty()) {
194194
return Response.status(404).build();
195195
}
196196

197+
if(mini) {
198+
Project project = p.get();
199+
EngagementProject ep = EngagementProject.builder().projectId(project.getId()).uuid(project.getDescription()).build();
200+
return Response.ok(ep).build();
201+
}
202+
197203
return Response.ok(p.get()).build();
198204
}
199205

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,14 @@ void testGetProjectByUuid() {
555555
given().when().get("/api/v1/engagements/projects/eeee").then().statusCode(404);
556556
}
557557

558+
@Test
559+
void testGetProjectByUuidMini() {
560+
561+
MockUtils.setFindProjectByEngagementId(gitLabService, 2, "abcd", Project.builder().id(1).build());
562+
given().when().get("/api/v1/engagements/projects/abcd?mini=true").then().statusCode(200).body("project_id", equalTo(1));
563+
564+
}
565+
558566
@Test
559567
void testGetEngagementUuidProjectId() {
560568
List<Project> projects = new ArrayList<>();

src/test/java/com/redhat/labs/lodestar/service/MigrationServiceTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import com.redhat.labs.lodestar.models.gitlab.File;
1717
import com.redhat.labs.lodestar.models.gitlab.Project;
1818

19-
import io.quarkus.runtime.StartupEvent;
2019
import io.quarkus.test.junit.QuarkusMock;
2120
import io.quarkus.test.junit.QuarkusTest;
2221

0 commit comments

Comments
 (0)