Skip to content

Commit

Permalink
fix: Use Long for id
Browse files Browse the repository at this point in the history
  • Loading branch information
Inderpal Singh committed Mar 21, 2024
1 parent 6ed53f2 commit 795bb4c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public Response saveApplicationFormsAndDuosV1(String id, SaveFormsAndDuos saveFo
}

@Override
public Response submitApplicationV1(String id) {
public Response submitApplicationV1(Long id) {
submitApplicationService.submitApplication(id);
return Response.noContent().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ListedApplication parse(ApplicationOverview applicationOverview) {
return ListedApplication.builder()
.id(applicationOverview.getApplicationId().toString())
.title(applicationOverview.getApplicationExternalId())
.currentState(applicationOverview.getApplicationState())
.currentState(applicationOverview.getApplicationState().value())
.stateChangedAt(applicationOverview.getApplicationLastActivity())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public SubmitApplicationService(
this.remsApplicationsApi = applicationsApi;
}

public void submitApplication(String id) {
public void submitApplication(Long id) {
var principal = (OidcJwtCallerPrincipal) identity.getPrincipal();
String userId = principal.getClaim(USER_ID_CLAIM);

try {
var application = remsApplicationsApi.apiApplicationsApplicationIdGet(Long.valueOf(id), remsApiKey, userId);
var application = remsApplicationsApi.apiApplicationsApplicationIdGet(id, remsApiKey, userId);

if (!application.getApplicationApplicant().getUserid().equals(userId)) {
throw new UserNotApplicantException("User is not the applicant of the application");
Expand Down
3 changes: 2 additions & 1 deletion src/main/openapi/daam.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ paths:
description: ID of application to submit
required: true
schema:
type: string
type: integer
format: int64
responses:
"204":
description: Successful Response (no content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
// SPDX-License-Identifier: Apache-2.0
package io.github.genomicdatainfrastructure.daam.api;

import io.github.genomicdatainfrastructure.daam.exceptions.ApplicationNotInCorrectStateException;
import io.github.genomicdatainfrastructure.daam.model.CreateApplication;
import org.junit.jupiter.api.Test;

import static org.hamcrest.Matchers.equalTo;
import io.quarkus.test.junit.QuarkusTest;
import static io.restassured.RestAssured.given;
import io.quarkus.test.keycloak.client.KeycloakTestClient;
Expand Down Expand Up @@ -61,7 +59,7 @@ void submitApplication_when_application_not_found() {
.when()
.post("/api/v1/applications/12345/submit")
.then()
.statusCode(403);
.statusCode(404);
}

@Test
Expand All @@ -72,7 +70,7 @@ void submitApplication_when_not_applicant() {
.when()
.post("/api/v1/applications/1/submit")
.then()
.statusCode(401);
.statusCode(403);
}

@Test
Expand Down

0 comments on commit 795bb4c

Please sign in to comment.