diff --git a/pom.xml b/pom.xml index 050fc27eb4d8306d6947ae4e424795f471361d14..9a47c61536c8d2e07ea0c714f546570cb4417efb 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.ozgcloud.common</groupId> @@ -38,7 +40,7 @@ <version>2.1.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> @@ -223,6 +226,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 a587f10d3b1579dff07a272100138d6701f7fc5e..a5d351a764916201ad928d5fd34a545189de3cd1 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> @@ -39,10 +41,13 @@ <dependencies> <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-grpc</artifactId> + <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 +56,8 @@ </dependencies> <build> + <sourceDirectory>src/main/proto</sourceDirectory> + <plugins> <plugin> <groupId>io.quarkus.platform</groupId> @@ -60,6 +67,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 +82,31 @@ </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.60.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 93% rename from user-manager-interface/src/main/proto/userprofile.model.proto rename to user-manager-interface/src/main/protobuf/userprofile.model.proto index f4e97598853a044e31dc5d56819e61019243bb3e..0a5db4334318f844dca9c0bf1c96dcc07b4d405c 100644 --- a/user-manager-interface/src/main/proto/userprofile.model.proto +++ b/user-manager-interface/src/main/protobuf/userprofile.model.proto @@ -33,6 +33,7 @@ message GrpcUserProfile { string id = 1; string firstName = 2; string lastName = 3; + string email = 4; } @@ -54,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 3cbc7cec3d181989200f5ec64c91ecf8d2975506..578993752d7ae2fa1307629afb210f00d35c69ad 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/main/java/de/ozgcloud/user/userprofile/UserProfileMapper.java b/user-manager-server/src/main/java/de/ozgcloud/user/userprofile/UserProfileMapper.java index 8f16ad1bf42f42a9cc40834612889d4c8eb9fc24..c29c5e8d949d498714bc39c1fa38623b2c16f7fd 100644 --- a/user-manager-server/src/main/java/de/ozgcloud/user/userprofile/UserProfileMapper.java +++ b/user-manager-server/src/main/java/de/ozgcloud/user/userprofile/UserProfileMapper.java @@ -25,16 +25,26 @@ package de.ozgcloud.user.userprofile; import org.bson.types.ObjectId; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; import org.mapstruct.NullValueCheckStrategy; import org.mapstruct.ReportingPolicy; import de.ozgcloud.user.User; @Mapper(unmappedTargetPolicy = ReportingPolicy.WARN, // - unmappedSourcePolicy = ReportingPolicy.WARN, // nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS) interface UserProfileMapper { + @Mapping(target = "emailBytes", ignore = true) + @Mapping(target = "mergeFrom", ignore = true) + @Mapping(target = "clearField", ignore = true) + @Mapping(target = "clearOneof", ignore = true) + @Mapping(target = "mergeUnknownFields", ignore = true) + @Mapping(target = "firstNameBytes", ignore = true) + @Mapping(target = "idBytes", ignore = true) + @Mapping(target = "lastNameBytes", ignore = true) + @Mapping(target = "unknownFields", ignore = true) + @Mapping(target = "allFields", ignore = true) GrpcUserProfile mapTo(User userProfile); default String toString(ObjectId objectId) { 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 diff --git a/user-manager-server/src/test/java/de/ozgcloud/user/userprofile/UserProfileMapperTest.java b/user-manager-server/src/test/java/de/ozgcloud/user/userprofile/UserProfileMapperTest.java index c9002fa39f17b01261095f2412dea607549b07e0..fa280033555979187ac89125d3b219b44ff82429 100644 --- a/user-manager-server/src/test/java/de/ozgcloud/user/userprofile/UserProfileMapperTest.java +++ b/user-manager-server/src/test/java/de/ozgcloud/user/userprofile/UserProfileMapperTest.java @@ -56,6 +56,13 @@ class UserProfileMapperTest { assertThat(userProfile.getLastName()).isEqualTo(UserTestFactory.LAST_NAME); } + @Test + void shouldMapEMail() { + var userProfile = map(); + + assertThat(userProfile.getEmail()).isEqualTo(UserTestFactory.EMAIL); + } + @Test void shouldMapId() { var userProfile = map();