Skip to content

Commit

Permalink
chore: execute prettier and linter
Browse files Browse the repository at this point in the history
  • Loading branch information
brunopacheco1 committed Mar 20, 2024
1 parent df946f0 commit 6d1aadb
Show file tree
Hide file tree
Showing 12 changed files with 107 additions and 129 deletions.
3 changes: 3 additions & 0 deletions checkstyle.xml.license
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: 2024 PNED G.I.E.

SPDX-License-Identifier: Apache-2.0
Original file line number Diff line number Diff line change
@@ -1,98 +1,79 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0

package io.github.genomicdatainfrastructure.daam.api;
import java.io.File;
import java.util.List;

import io.github.genomicdatainfrastructure.daam.services.CreateApplicationService;
import io.github.genomicdatainfrastructure.daam.model.AddApplicationEvent;
import io.github.genomicdatainfrastructure.daam.model.AddedAttachments;
import io.github.genomicdatainfrastructure.daam.model.CreateApplication;
import io.github.genomicdatainfrastructure.daam.model.RemoveMember;
import io.github.genomicdatainfrastructure.daam.model.SaveFormsAndDuos;
import io.github.genomicdatainfrastructure.daam.model.UpdateDatasets;
import io.github.genomicdatainfrastructure.daam.services.CreateApplicationService;
import jakarta.ws.rs.core.Response;
import java.io.File;
import java.util.List;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public class ApplicationCommandApiImpl implements ApplicationCommandApi {

private final CreateApplicationService createApplicationService;
private final CreateApplicationService createApplicationService;

@Override
public Response acceptApplicationTermsV1(String id) {
throw new UnsupportedOperationException(
"Unimplemented method 'acceptApplicationTermsV1'"
);
}
@Override
public Response acceptApplicationTermsV1(String id) {
throw new UnsupportedOperationException("Unimplemented method 'acceptApplicationTermsV1'");
}

@Override
public List<AddedAttachments> addAttachmentToApplicationV1(String id, File body) {
throw new UnsupportedOperationException(
"Unimplemented method 'addAttachmentToApplicationV1'"
);
}
@Override
public List<AddedAttachments> addAttachmentToApplicationV1(String id, File body) {
throw new UnsupportedOperationException("Unimplemented method 'addAttachmentToApplicationV1'");
}

@Override
public Response addEventToApplicationV1(String id, AddApplicationEvent addApplicationEvent) {
throw new UnsupportedOperationException(
"Unimplemented method 'addEventToApplicationV1'"
);
}
@Override
public Response addEventToApplicationV1(String id, AddApplicationEvent addApplicationEvent) {
throw new UnsupportedOperationException("Unimplemented method 'addEventToApplicationV1'");
}

@Override
public Response cancelApplicationV1(String id) {
throw new UnsupportedOperationException(
"Unimplemented method 'cancelApplicationV1'"
);
}
@Override
public Response cancelApplicationV1(String id) {
throw new UnsupportedOperationException("Unimplemented method 'cancelApplicationV1'");
}

@Override
public Response copyApplicationAsNewV1(String id) {
throw new UnsupportedOperationException(
"Unimplemented method 'copyApplicationAsNewV1'"
);
}
@Override
public Response copyApplicationAsNewV1(String id) {
throw new UnsupportedOperationException("Unimplemented method 'copyApplicationAsNewV1'");
}

@Override
public Response createApplicationV1(CreateApplication createApplication) {
createApplicationService.createRemsApplication(createApplication);
return Response.noContent().build();
}
@Override
public Response createApplicationV1(CreateApplication createApplication) {
createApplicationService.createRemsApplication(createApplication);
return Response.noContent().build();
}

@Override
public Response inviteMemberToApplicationV1(String id) {
throw new UnsupportedOperationException(
"Unimplemented method 'inviteMemberToApplicationV1'"
);
}
@Override
public Response inviteMemberToApplicationV1(String id) {
throw new UnsupportedOperationException("Unimplemented method 'inviteMemberToApplicationV1'");
}

@Override
public Response removeMemberFromApplicationV1(String id, RemoveMember removeMember) {
throw new UnsupportedOperationException(
"Unimplemented method 'removeMemberFromApplicationV1'"
);
}
@Override
public Response removeMemberFromApplicationV1(String id, RemoveMember removeMember) {
throw new UnsupportedOperationException("Unimplemented method 'removeMemberFromApplicationV1'");
}

@Override
public Response saveApplicationFormsAndDuosV1(String id, SaveFormsAndDuos saveFormsAndDuos) {
throw new UnsupportedOperationException(
"Unimplemented method 'saveApplicationFormsAndDuosV1'"
);
}
@Override
public Response saveApplicationFormsAndDuosV1(String id, SaveFormsAndDuos saveFormsAndDuos) {
throw new UnsupportedOperationException("Unimplemented method 'saveApplicationFormsAndDuosV1'");
}

@Override
public Response submitApplicationV1(String id) {
throw new UnsupportedOperationException(
"Unimplemented method 'submitApplicationV1'"
);
}
@Override
public Response submitApplicationV1(String id) {
throw new UnsupportedOperationException("Unimplemented method 'submitApplicationV1'");
}

@Override
public Response updateDatasetsOfApplicationV1(String id, List<UpdateDatasets> updateDatasets) {
throw new UnsupportedOperationException(
"Unimplemented method 'updateDatasetsOfApplicationV1'"
);
}
@Override
public Response updateDatasetsOfApplicationV1(String id, List<UpdateDatasets> updateDatasets) {
throw new UnsupportedOperationException("Unimplemented method 'updateDatasetsOfApplicationV1'");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0

package io.github.genomicdatainfrastructure.daam.api;

import static io.github.genomicdatainfrastructure.daam.security.PostAuthenticationFilter.USER_ID_CLAIM;
Expand Down Expand Up @@ -35,7 +36,6 @@ public RetrievedApplication retrieveApplicationV1(String id) {
@Override
public File retrieveAttachmentFromApplicationV1(String id, String attachmentId) {
throw new UnsupportedOperationException(
"Unimplemented method 'retrieveAttachmentFromApplicationV1'"
);
"Unimplemented method 'retrieveAttachmentFromApplicationV1'");
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0

package io.github.genomicdatainfrastructure.daam.security;

import io.github.genomicdatainfrastructure.daam.services.CreateRemsUserService;
Expand All @@ -25,9 +26,8 @@ public class PostAuthenticationFilter implements ContainerRequestFilter {
private final CreateRemsUserService createRemsUserService;

@Inject
public PostAuthenticationFilter(SecurityIdentity identity,
CreateRemsUserService createRemsUserService
) {
public PostAuthenticationFilter(
SecurityIdentity identity, CreateRemsUserService createRemsUserService) {
this.identity = identity;
this.createRemsUserService = createRemsUserService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,44 @@
package io.github.genomicdatainfrastructure.daam.services;

import static io.github.genomicdatainfrastructure.daam.security.PostAuthenticationFilter.USER_ID_CLAIM;

import io.github.genomicdatainfrastructure.daam.model.CreateApplication;
import io.github.genomicdatainfrastructure.daam.remote.rems.api.RemsApplicationCommandApi;
import io.github.genomicdatainfrastructure.daam.remote.rems.model.CreateApplicationCommand;
import io.quarkus.oidc.runtime.OidcJwtCallerPrincipal;
import io.quarkus.security.identity.SecurityIdentity;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.util.List;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.eclipse.microprofile.rest.client.inject.RestClient;

import java.util.List;

@ApplicationScoped
public class CreateApplicationService {

private final SecurityIdentity identity;
private final String remsApiKey;
private final RemsApplicationCommandApi remsApplicationCommandApi;

@Inject
public CreateApplicationService(
@ConfigProperty(name = "quarkus.rest-client.rems_yaml.api-key") String remsApiKey,
SecurityIdentity identity,
@RestClient RemsApplicationCommandApi applicationsApi
) {
this.remsApiKey = remsApiKey;
this.identity = identity;
this.remsApplicationCommandApi = applicationsApi;
}

public void createRemsApplication(CreateApplication createApplication) {
var principal = (OidcJwtCallerPrincipal) identity.getPrincipal();
String userId = principal.getClaim(USER_ID_CLAIM);

List<String> catalogueItemIds = createApplication.getDatasetIds();

CreateApplicationCommand command = CreateApplicationCommand.builder()
.catalogueItemIds(catalogueItemIds)
.build();

remsApplicationCommandApi.apiApplicationsCreatePost(command, remsApiKey, userId);
}
private final SecurityIdentity identity;
private final String remsApiKey;
private final RemsApplicationCommandApi remsApplicationCommandApi;

@Inject
public CreateApplicationService(
@ConfigProperty(name = "quarkus.rest-client.rems_yaml.api-key") String remsApiKey,
SecurityIdentity identity,
@RestClient RemsApplicationCommandApi applicationsApi) {
this.remsApiKey = remsApiKey;
this.identity = identity;
this.remsApplicationCommandApi = applicationsApi;
}

public void createRemsApplication(CreateApplication createApplication) {
var principal = (OidcJwtCallerPrincipal) identity.getPrincipal();
String userId = principal.getClaim(USER_ID_CLAIM);

List<String> catalogueItemIds = createApplication.getDatasetIds();

CreateApplicationCommand command =
CreateApplicationCommand.builder().catalogueItemIds(catalogueItemIds).build();

remsApplicationCommandApi.apiApplicationsCreatePost(command, remsApiKey, userId);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0

package io.github.genomicdatainfrastructure.daam.services;

import io.github.genomicdatainfrastructure.daam.remote.rems.api.RemsUsersApi;
Expand All @@ -21,8 +22,7 @@ public class CreateRemsUserService {
public CreateRemsUserService(
@ConfigProperty(name = "quarkus.rest-client.rems_yaml.api-key") String remsApiKey,
@ConfigProperty(name = "quarkus.rest-client.rems_yaml.bot-user") String remsBotUser,
@RestClient RemsUsersApi usersApi
) {
@RestClient RemsUsersApi usersApi) {
this.remsApiKey = remsApiKey;
this.remsBotUser = remsBotUser;
this.usersApi = usersApi;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0

package io.github.genomicdatainfrastructure.daam.services;

import io.github.genomicdatainfrastructure.daam.model.ListedApplication;
Expand All @@ -21,8 +22,7 @@ public class ListApplicationsService {
@Inject
public ListApplicationsService(
@ConfigProperty(name = "quarkus.rest-client.rems_yaml.api-key") String remsApiKey,
@RestClient RemsApplicationsApi applicationsApi
) {
@RestClient RemsApplicationsApi applicationsApi) {
this.remsApiKey = remsApiKey;
this.applicationsApi = applicationsApi;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0

package io.github.genomicdatainfrastructure.daam.api;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class ApplicationCommandApiImplIT extends ApplicationCommandApiImplTest {

}
public class ApplicationCommandApiImplIT extends ApplicationCommandApiImplTest {}
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0

package io.github.genomicdatainfrastructure.daam.api;

import io.github.genomicdatainfrastructure.daam.model.CreateApplication;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;

import static org.hamcrest.Matchers.equalTo;
import io.github.genomicdatainfrastructure.daam.model.CreateApplication;
import io.quarkus.test.junit.QuarkusTest;
import static io.restassured.RestAssured.given;
import io.quarkus.test.keycloak.client.KeycloakTestClient;
import java.util.Arrays;

import org.junit.jupiter.api.Test;

@QuarkusTest
public class ApplicationCommandApiImplTest {
Expand All @@ -23,13 +22,13 @@ void unauthorized_when_no_user() {
given().when().get("/api/v1/applications/create").then().statusCode(401);
}


@Test
void createApplication_when_authenticated() {
CreateApplication createApplication = CreateApplication.builder()
.datasetIds(Arrays.asList("dataset1", "dataset2", "dataset3"))
.build();

CreateApplication createApplication =
CreateApplication.builder()
.datasetIds(Arrays.asList("dataset1", "dataset2", "dataset3"))
.build();

given()
.auth()
.oauth2(getAccessToken("alice"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0

package io.github.genomicdatainfrastructure.daam.api;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class ApplicationQueryApiImplIT extends ApplicationQueryApiImplTest {

}
public class ApplicationQueryApiImplIT extends ApplicationQueryApiImplTest {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-FileCopyrightText: 2024 PNED G.I.E.
//
// SPDX-License-Identifier: Apache-2.0

package io.github.genomicdatainfrastructure.daam.api;

import static io.restassured.RestAssured.given;
Expand Down
Loading

0 comments on commit 6d1aadb

Please sign in to comment.