diff --git a/pom.xml b/pom.xml index b5ab986f306a2144d42bc41f1807d207613b39f6..edf02f448e14745fe9311e823868dfe85f63b474 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,9 @@ unter der Lizenz sind dem Lizenztext zu entnehmen. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <parent> <groupId>de.itvsh.kop.common</groupId> @@ -38,7 +40,7 @@ <version>2.0.0-SNAPSHOT</version> <name>OZG-Cloud User Manager</name> <packaging>pom</packaging> - + <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> @@ -55,9 +57,10 @@ <jandex-maven-plugin-version>1.2.3</jandex-maven-plugin-version> <compiler-plugin.version>3.8.1</compiler-plugin.version> <jacoco.plugin.version>0.8.8</jacoco.plugin.version> - <surefire-plugin.version>3.0.0-M7</surefire-plugin.version> - <maven-failsafe-plugin.version>3.0.0-M7</maven-failsafe-plugin.version> + <surefire-plugin.version>3.2.2</surefire-plugin.version> + <maven-failsafe-plugin.version>3.2.2</maven-failsafe-plugin.version> <git-commit-id-plugin.version>4.9.10</git-commit-id-plugin.version> + <maven-source.plugin.version>3.3.0</maven-source.plugin.version> </properties> <modules> @@ -110,10 +113,10 @@ </dependency> </dependencies> </dependencyManagement> - + <build> <pluginManagement> - <plugins> + <plugins> <plugin> <groupId>com.mycila</groupId> <artifactId>license-maven-plugin</artifactId> @@ -210,7 +213,8 @@ <configuration> <propertyName>surefire.jacoco.args</propertyName> <exclClassLoaders>*QuarkusClassLoader</exclClassLoaders> - <destFile>${project.build.directory}/jacoco-quarkus.exec</destFile> + <destFile> + ${project.build.directory}/jacoco-quarkus.exec</destFile> <append>true</append> </configuration> </execution> @@ -223,6 +227,19 @@ </execution> </executions> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>${maven-source.plugin.version}</version> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </pluginManagement> </build> diff --git a/user-manager-interface/pom.xml b/user-manager-interface/pom.xml index c97d160968ecd2cc47ff9dca0af7006e584cf9f0..2ea405736404bf88977ee35d129ea524dcdd2777 100644 --- a/user-manager-interface/pom.xml +++ b/user-manager-interface/pom.xml @@ -24,7 +24,9 @@ unter der Lizenz sind dem Lizenztext zu entnehmen. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> @@ -38,11 +40,18 @@ <description>gRPC Interface for User Manager</description> <dependencies> - <dependency> + <!-- <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-grpc</artifactId> + </dependency>--> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-stub</artifactId> + </dependency> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-protobuf</artifactId> </dependency> - <!-- Java 9+ compatibility --> <dependency> <groupId>javax.annotation</groupId> @@ -51,6 +60,8 @@ </dependencies> <build> + <sourceDirectory>src/main/proto</sourceDirectory> + <plugins> <plugin> <groupId>io.quarkus.platform</groupId> @@ -60,6 +71,11 @@ <groupId>org.jboss.jandex</groupId> <artifactId>jandex-maven-plugin</artifactId> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + </plugin> + <plugin> <groupId>com.mycila</groupId> <artifactId>license-maven-plugin</artifactId> @@ -70,6 +86,32 @@ </mapping> </configuration> </plugin> + + <plugin> + <groupId>com.github.os72</groupId> + <artifactId>protoc-jar-maven-plugin</artifactId> + <version>${protoc-jar-plugin.version}</version> + <executions> + <execution> + <phase>generate-sources</phase> + <goals> + <goal>run</goal> + </goals> + <configuration> + <outputTargets> + <outputTarget> + <type>java</type> + </outputTarget> + <outputTarget> + <type>grpc-java</type> + <pluginArtifact> + io.grpc:protoc-gen-grpc-java:1.58.0</pluginArtifact> + </outputTarget> + </outputTargets> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> </project> diff --git a/user-manager-interface/src/main/proto/organisationseinheit.model.proto b/user-manager-interface/src/main/protobuf/organisationseinheit.model.proto similarity index 95% rename from user-manager-interface/src/main/proto/organisationseinheit.model.proto rename to user-manager-interface/src/main/protobuf/organisationseinheit.model.proto index 94aeb3cdf52069f51014137801a91bc01f476436..1f8a0e68362471b5ebfb17bcc3091bb810cbc71f 100644 --- a/user-manager-interface/src/main/proto/organisationseinheit.model.proto +++ b/user-manager-interface/src/main/protobuf/organisationseinheit.model.proto @@ -31,4 +31,7 @@ option java_outer_classname = "OrganisationsEinheitModelProto"; message GrpcOrganisationsEinheit { string organisationsEinheitId = 1; +} + +message GrpcGetSupportedOrganisationsEinheitenRequest { } \ No newline at end of file diff --git a/user-manager-interface/src/main/proto/organisationseinheit.proto b/user-manager-interface/src/main/protobuf/organisationseinheit.proto similarity index 89% rename from user-manager-interface/src/main/proto/organisationseinheit.proto rename to user-manager-interface/src/main/protobuf/organisationseinheit.proto index 6303fbfef6b6f40b778368acef0dd1b5071b5488..6073585fdb2cd3dd6facaf0cd26c7ec7be90ac7f 100644 --- a/user-manager-interface/src/main/proto/organisationseinheit.proto +++ b/user-manager-interface/src/main/protobuf/organisationseinheit.proto @@ -22,7 +22,6 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ syntax = "proto3"; -import "google/protobuf/empty.proto"; import "organisationseinheit.model.proto"; package de.ozgcloud.user.grpc; @@ -32,7 +31,7 @@ option java_package = "de.ozgcloud.user.grpc.organisationseinheit"; option java_outer_classname = "OrganisationsEinheitProto"; service OrganisationsEinheitService { - rpc GetSupportedOrganisationsEinheiten(google.protobuf.Empty) returns (GrpcGetSupportedOrganisationsEinheitenResponse); + rpc GetSupportedOrganisationsEinheiten(GrpcGetSupportedOrganisationsEinheitenRequest) returns (GrpcGetSupportedOrganisationsEinheitenResponse); } message GrpcGetSupportedOrganisationsEinheitenResponse { diff --git a/user-manager-interface/src/main/proto/recipient.model.proto b/user-manager-interface/src/main/protobuf/recipient.model.proto similarity index 100% rename from user-manager-interface/src/main/proto/recipient.model.proto rename to user-manager-interface/src/main/protobuf/recipient.model.proto diff --git a/user-manager-interface/src/main/proto/recipient.proto b/user-manager-interface/src/main/protobuf/recipient.proto similarity index 100% rename from user-manager-interface/src/main/proto/recipient.proto rename to user-manager-interface/src/main/protobuf/recipient.proto diff --git a/user-manager-interface/src/main/proto/userprofile.model.proto b/user-manager-interface/src/main/protobuf/userprofile.model.proto similarity index 94% rename from user-manager-interface/src/main/proto/userprofile.model.proto rename to user-manager-interface/src/main/protobuf/userprofile.model.proto index 8cadd28eda0a7f52d1140844c8ea984f676a46ea..0a5db4334318f844dca9c0bf1c96dcc07b4d405c 100644 --- a/user-manager-interface/src/main/proto/userprofile.model.proto +++ b/user-manager-interface/src/main/protobuf/userprofile.model.proto @@ -55,4 +55,10 @@ message GrpcUserProfileId { message GrpcDeleteInactiveUserRequest { string userId = 1; +} + +message GrpcFindInactiveUserIdsRequest { +} + +message GrpcDeleteInactiveUserResponse { } \ No newline at end of file diff --git a/user-manager-interface/src/main/proto/userprofile.proto b/user-manager-interface/src/main/protobuf/userprofile.proto similarity index 90% rename from user-manager-interface/src/main/proto/userprofile.proto rename to user-manager-interface/src/main/protobuf/userprofile.proto index 8bdaf438dd546ff271e1cb723858ed8ad9d120d4..ab445da50c1b7fa166a7d7baae574042f70bddd7 100644 --- a/user-manager-interface/src/main/proto/userprofile.proto +++ b/user-manager-interface/src/main/protobuf/userprofile.proto @@ -26,7 +26,6 @@ syntax = "proto3"; package de.ozgcloud.user.grpc; import "userprofile.model.proto"; -import "google/protobuf/empty.proto"; option java_multiple_files = true; option java_package = "de.ozgcloud.user.grpc.userprofile"; @@ -38,8 +37,8 @@ service UserProfileService { rpc GetByExternalId(GrpcGetUserProfileRequest) returns (GrpcGetUserProfileResponse); - rpc FindInactiveUserIds(google.protobuf.Empty) returns (GrpcFindInactiveUserIdsResponse); + rpc FindInactiveUserIds(GrpcFindInactiveUserIdsRequest) returns (GrpcFindInactiveUserIdsResponse); - rpc DeleteInactiveUser(GrpcDeleteInactiveUserRequest) returns (google.protobuf.Empty); + rpc DeleteInactiveUser(GrpcDeleteInactiveUserRequest) returns (GrpcDeleteInactiveUserResponse); } \ No newline at end of file diff --git a/user-manager-server/pom.xml b/user-manager-server/pom.xml index 2d8abe44efc0e5fb7692457456eae1709a586f4a..8f8d0a46a0a9321c25b1bcf0b49af305247c9de5 100644 --- a/user-manager-server/pom.xml +++ b/user-manager-server/pom.xml @@ -114,6 +114,10 @@ <groupId>io.quarkus</groupId> <artifactId>quarkus-scheduler</artifactId> </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-grpc</artifactId> + </dependency> <!-- Logging --> <dependency> diff --git a/user-manager-server/src/main/java/de/ozgcloud/user/organisationseinheit/OrganisationsEinheitGrpcService.java b/user-manager-server/src/main/java/de/ozgcloud/user/organisationseinheit/OrganisationsEinheitGrpcService.java index b4dc3e8b67c150023f0a1a8c4bebe419b0be7003..1f6fdc40b4489be0ca2899c57838a94d6586f4e1 100644 --- a/user-manager-server/src/main/java/de/ozgcloud/user/organisationseinheit/OrganisationsEinheitGrpcService.java +++ b/user-manager-server/src/main/java/de/ozgcloud/user/organisationseinheit/OrganisationsEinheitGrpcService.java @@ -27,8 +27,6 @@ import java.util.Collection; import jakarta.inject.Inject; -import com.google.protobuf.Empty; - import de.ozgcloud.user.grpc.organisationseinheit.GrpcGetSupportedOrganisationsEinheitenResponse; import de.ozgcloud.user.grpc.organisationseinheit.OrganisationsEinheitServiceGrpc.OrganisationsEinheitServiceImplBase; import io.grpc.stub.StreamObserver; @@ -41,7 +39,8 @@ public class OrganisationsEinheitGrpcService extends OrganisationsEinheitService OrganisationsEinheitService organisationsEinheitService; @Override - public void getSupportedOrganisationsEinheiten(Empty request, StreamObserver<GrpcGetSupportedOrganisationsEinheitenResponse> responseObserver) { + public void getSupportedOrganisationsEinheiten(GrpcGetSupportedOrganisationsEinheitenRequest request, + StreamObserver<GrpcGetSupportedOrganisationsEinheitenResponse> responseObserver) { var organisationsEinheitIds = organisationsEinheitService.findAllOrganisationsEinheitIds(); var response = GrpcGetSupportedOrganisationsEinheitenResponse.newBuilder() .addAllOrganisationseinheiten(mapToGrpc(organisationsEinheitIds)) diff --git a/user-manager-server/src/main/java/de/ozgcloud/user/userprofile/UserProfileGrpcService.java b/user-manager-server/src/main/java/de/ozgcloud/user/userprofile/UserProfileGrpcService.java index 481f6c4a2863caf536ed7ba7f7ad6cebd16456f3..c9d773bed326d3465751c780baf122d39c7c7005 100644 --- a/user-manager-server/src/main/java/de/ozgcloud/user/userprofile/UserProfileGrpcService.java +++ b/user-manager-server/src/main/java/de/ozgcloud/user/userprofile/UserProfileGrpcService.java @@ -27,8 +27,6 @@ import java.util.stream.Stream; import jakarta.inject.Inject; -import com.google.protobuf.Empty; - import de.ozgcloud.user.User; import de.ozgcloud.user.UserService; import de.ozgcloud.user.grpc.userprofile.UserProfileServiceGrpc.UserProfileServiceImplBase; @@ -65,7 +63,7 @@ public class UserProfileGrpcService extends UserProfileServiceImplBase { } @Override - public void findInactiveUserIds(Empty request, StreamObserver<GrpcFindInactiveUserIdsResponse> responseObserver) { + public void findInactiveUserIds(GrpcFindInactiveUserIdsRequest request, StreamObserver<GrpcFindInactiveUserIdsResponse> responseObserver) { var userIds = service.findAllInactiveUserIds(); responseObserver.onNext(buildGrpcGetInactiveUserIdsResponse(userIds)); @@ -79,10 +77,10 @@ public class UserProfileGrpcService extends UserProfileServiceImplBase { } @Override - public void deleteInactiveUser(GrpcDeleteInactiveUserRequest request, StreamObserver<Empty> responseObserver) { + public void deleteInactiveUser(GrpcDeleteInactiveUserRequest request, StreamObserver<GrpcDeleteInactiveUserResponse> responseObserver) { service.deleteInactive(request.getUserId()); - responseObserver.onNext(Empty.getDefaultInstance()); + responseObserver.onNext(GrpcDeleteInactiveUserResponse.newBuilder().build()); responseObserver.onCompleted(); } } \ No newline at end of file diff --git a/user-manager-server/src/test/java/de/ozgcloud/user/organisationseinheit/OrganisationsEinheitRepositoryTest.java b/user-manager-server/src/test/java/de/ozgcloud/user/organisationseinheit/OrganisationsEinheitRepositoryTest.java index 9d6c2fe82e9dad5e1b5e041f7a4c0ad120bd5084..ca3a6160009f909ddb03185732eba024ef9d3553 100644 --- a/user-manager-server/src/test/java/de/ozgcloud/user/organisationseinheit/OrganisationsEinheitRepositoryTest.java +++ b/user-manager-server/src/test/java/de/ozgcloud/user/organisationseinheit/OrganisationsEinheitRepositoryTest.java @@ -3,11 +3,11 @@ package de.ozgcloud.user.organisationseinheit; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; -import org.apache.commons.lang3.StringUtils; import org.bson.conversions.Bson; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; +import org.mockito.Mock; import org.mockito.Spy; import com.mongodb.client.DistinctIterable; @@ -25,16 +25,16 @@ class OrganisationsEinheitRepositoryTest { @DisplayName("Test find Organisationseinheiten Ids") @Nested class TestFindOrganisationsEinheitIds { - - private MongoCollection mongoCollection = mock(MongoCollection.class); - private MongoCursor mongoCursor = mock(MongoCursor.class); + @Mock + private MongoCollection<?> mongoCollection; + @Mock + private MongoCursor<String> mongoCursor; @Test void shouldFindAllOrganisationsEinheitIds() { var iterable = mock(DistinctIterable.class); when(iterable.iterator()).thenReturn(mongoCursor); doReturn(mongoCollection).when(organisationsEinheitRepository).mongoCollection(); - when(mongoCursor.next()).thenReturn(StringUtils.EMPTY); when(mongoCollection.distinct(anyString(), any(Bson.class), any())).thenReturn(iterable); organisationsEinheitRepository.findAllOrganisationsEinheitIds(); diff --git a/user-manager-server/src/test/java/de/ozgcloud/user/organisationseinheit/OrganisationseinheitGrpcServiceTest.java b/user-manager-server/src/test/java/de/ozgcloud/user/organisationseinheit/OrganisationseinheitGrpcServiceTest.java index eb8f64b977590d7aaaa700a60758f777344c834c..9839171436f7ff6ed96e59a2a7330c475bf22dca 100644 --- a/user-manager-server/src/test/java/de/ozgcloud/user/organisationseinheit/OrganisationseinheitGrpcServiceTest.java +++ b/user-manager-server/src/test/java/de/ozgcloud/user/organisationseinheit/OrganisationseinheitGrpcServiceTest.java @@ -8,8 +8,6 @@ import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock; -import com.google.protobuf.Empty; - import de.ozgcloud.user.grpc.organisationseinheit.GrpcGetSupportedOrganisationsEinheitenResponse; import io.grpc.stub.StreamObserver; @@ -31,7 +29,7 @@ public class OrganisationseinheitGrpcServiceTest { @Test void shouldGetOrganisationsEinheiten() { organisationsEinheitGrpcService.getSupportedOrganisationsEinheiten( - Empty.getDefaultInstance(), + GrpcGetSupportedOrganisationsEinheitenRequest.newBuilder().build(), streamObserver); verify(organisationsEinheitService).findAllOrganisationsEinheitIds(); diff --git a/user-manager-server/src/test/java/de/ozgcloud/user/userprofile/UserProfileGrpcServiceTest.java b/user-manager-server/src/test/java/de/ozgcloud/user/userprofile/UserProfileGrpcServiceTest.java index 157375cae3489fee6006f53d8e25be4c9fac73a3..3b8038541b8de00c0392014cc886cb611710598a 100644 --- a/user-manager-server/src/test/java/de/ozgcloud/user/userprofile/UserProfileGrpcServiceTest.java +++ b/user-manager-server/src/test/java/de/ozgcloud/user/userprofile/UserProfileGrpcServiceTest.java @@ -40,8 +40,6 @@ import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Spy; -import com.google.protobuf.Empty; - import de.ozgcloud.user.User; import de.ozgcloud.user.UserService; import de.ozgcloud.user.UserTestFactory; @@ -216,7 +214,7 @@ class UserProfileGrpcServiceTest { } private void callService() { - grpcService.findInactiveUserIds(Empty.getDefaultInstance(), streamObserver); + grpcService.findInactiveUserIds(GrpcFindInactiveUserIdsRequest.newBuilder().build(), streamObserver); } } @@ -224,7 +222,7 @@ class UserProfileGrpcServiceTest { class TestDeleteInactiveUser { @Mock - private StreamObserver<Empty> streamObserver; + private StreamObserver<GrpcDeleteInactiveUserResponse> streamObserver; @Test void shouldCallService() { @@ -237,7 +235,7 @@ class UserProfileGrpcServiceTest { void shouldCallOnNext() { callService(); - verify(streamObserver).onNext(Empty.getDefaultInstance()); + verify(streamObserver).onNext(GrpcDeleteInactiveUserResponse.newBuilder().build()); } @Test