From e29999f80556f87b971a13eaf40084a1e1ed5ea7 Mon Sep 17 00:00:00 2001 From: Lukas Freesemann <lukas.freesemann@worldiety.de> Date: Fri, 28 Feb 2025 16:15:08 +0100 Subject: [PATCH 1/2] WO-192 update spring boot, keycloak, openfeign and rabbitmq --- SAMO-Interface/.gitignore | 1 + SAMO-Interface/pom.xml | 34 ++- SARIS-Interface/.gitignore | 1 + SARIS-Interface/pom.xml | 31 ++- addressImport/.gitignore | 1 + addressImport/pom.xml | 17 +- .../AddressImportApplication.java | 2 +- .../config/TestConfiguration.java | 5 - deployment/dockercompose/cbd/.env | 2 +- .../dockercompose/cbd/docker-compose.yml | 4 +- .../dockercompose/gfi-dmz/docker-compose.yml | 4 +- .../gfi-dmz/traefik/docker-compose.yml | 4 +- .../configBackend/configMain/application.yml | 6 +- .../dockercompose/gfi/docker-compose.yml | 8 +- .../db/postgresql/docker-compose.yml | 16 +- .../dockercompose/mailhog/docker-compose.yml | 13 + deployment/dockercompose/portal/Dockerfile | 6 +- .../dockercompose/portal/docker-compose.yml | 8 +- .../dockercompose/start_tools_compose.sh | 5 + gfsBackendService/.gitignore | 1 + gfsBackendService/pom.xml | 222 ++++++++++++++++-- .../api/SitCacheApi.java | 7 +- .../bpmn/impl/GfiProcessEnvironment.java | 10 +- .../bpmn/impl/tasks/ProcessHelper.java | 16 +- .../config/DmzExportSchedulerConfig.java | 18 +- .../FailureInformationController.java | 10 +- .../gridfailureinformation/email/Email.java | 4 +- .../email/GfiEmail.java | 8 +- ...nformationDistributionGroupRepository.java | 2 +- .../FailureInformationRepository.java | 1 - .../service/DistributionGroupService.java | 17 +- .../DistributionTextPlaceholderService.java | 3 +- .../service/ExportService.java | 40 ++-- .../service/FailureInformationService.java | 21 +- .../FailureInformationStationService.java | 1 - .../HistFailureInformationStationService.java | 9 +- .../service/ImportGeoJsonService.java | 6 +- .../service/RadiusService.java | 2 +- .../service/StationService.java | 9 +- .../src/main/resources/application.yml | 5 +- .../config/TestConfiguration.java | 3 +- ...DistributionGroupMemberControllerTest.java | 23 +- .../service/EmailServiceTest.java | 7 +- .../support/MockDataHelper.java | 35 ++- mailExport/.gitignore | 1 + mailExport/pom.xml | 33 ++- stoerungsauskunftInterface/.gitignore | 1 + stoerungsauskunftInterface/pom.xml | 33 ++- .../service/ImportExportService.java | 1 - .../config/ImportSchedulerConfigTest.java | 6 +- .../config/TestConfiguration.java | 11 +- .../ImportExportControllerTest.java | 11 +- .../service/ImportExportServiceTest.java | 46 ++-- .../service/MessageConsumerServiceTest.java | 10 +- .../support/MockDataHelper.java | 4 - .../util/ResourceLoaderBase.java | 2 +- testImportGridFailures/pom.xml | 14 +- 57 files changed, 514 insertions(+), 307 deletions(-) create mode 100644 deployment/dockercompose/mailhog/docker-compose.yml diff --git a/SAMO-Interface/.gitignore b/SAMO-Interface/.gitignore index 22921f07..7f3a0b67 100644 --- a/SAMO-Interface/.gitignore +++ b/SAMO-Interface/.gitignore @@ -3,6 +3,7 @@ target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/** !**/src/test/** +.env.* ### STS ### .apt_generated diff --git a/SAMO-Interface/pom.xml b/SAMO-Interface/pom.xml index ec45b3dd..1f2d4585 100644 --- a/SAMO-Interface/pom.xml +++ b/SAMO-Interface/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>3.2.4</version> + <version>3.4.3</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>org.eclipse.openk</groupId> @@ -33,21 +33,14 @@ <maven.test.skip>false</maven.test.skip> <disable.xml.report>true</disable.xml.report> <surefire.useFile>false</surefire.useFile> - <skip.asciidoc>false</skip.asciidoc> - <spring-cloud.version>2023.0.0</spring-cloud.version> + + <spring-cloud.version>2024.0.0</spring-cloud.version> <powerMockReflect.version>2.0.9</powerMockReflect.version> <sonar-maven-plugin.version>3.2</sonar-maven-plugin.version> <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version> - <asciidoctor-maven-plugin-version>1.5.3</asciidoctor-maven-plugin-version> - <asciidoctorj-pdf-version>1.5.0-alpha.11</asciidoctorj-pdf-version> - <asciidoctorj-version>1.5.4</asciidoctorj-version> - <asciidoctorj-diagram-versions>1.5.4.1</asciidoctorj-diagram-versions> <mapstruct.version>1.5.5.Final</mapstruct.version> - <flyway-core.version>10.10.0</flyway-core.version> - <postgresql.version>42.7.3</postgresql.version> - <openfeign.version>4.1.0</openfeign.version> - <keycloak-core.version>24.0.2</keycloak-core.version> - <rabbitmq.version>5.20.0</rabbitmq.version> + <openfeign.version>4.2.0</openfeign.version> + <rabbitmq.version>5.21.0</rabbitmq.version> </properties> <dependencies> @@ -70,6 +63,7 @@ <dependency> <groupId>org.springframework.integration</groupId> <artifactId>spring-integration-sftp</artifactId> + <version>6.3.7</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> @@ -131,6 +125,22 @@ <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> <version>${openfeign.version}</version> + <exclusions> + <exclusion> + <groupId>org.bouncycastle</groupId> + <artifactId>bcprov-jdk18on</artifactId> + </exclusion> + <exclusion> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.16.1</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> diff --git a/SARIS-Interface/.gitignore b/SARIS-Interface/.gitignore index 1067014e..77fd3e2a 100644 --- a/SARIS-Interface/.gitignore +++ b/SARIS-Interface/.gitignore @@ -3,6 +3,7 @@ target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/** !**/src/test/** +.env.* ### STS ### .apt_generated diff --git a/SARIS-Interface/pom.xml b/SARIS-Interface/pom.xml index 3a831e3c..998997e4 100644 --- a/SARIS-Interface/pom.xml +++ b/SARIS-Interface/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>3.2.4</version> + <version>3.4.3</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>org.eclipse.openk</groupId> @@ -21,20 +21,13 @@ <surefire.useFile>false</surefire.useFile> <skip.asciidoc>false</skip.asciidoc> - <spring-cloud.version>2023.0.0</spring-cloud.version> + <spring-cloud.version>2024.0.0</spring-cloud.version> <powerMockReflect.version>2.0.9</powerMockReflect.version> <sonar-maven-plugin.version>3.2</sonar-maven-plugin.version> <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version> - <asciidoctor-maven-plugin-version>1.5.3</asciidoctor-maven-plugin-version> - <asciidoctorj-pdf-version>1.5.0-alpha.11</asciidoctorj-pdf-version> - <asciidoctorj-version>1.5.4</asciidoctorj-version> - <asciidoctorj-diagram-versions>1.5.4.1</asciidoctorj-diagram-versions> <mapstruct.version>1.5.5.Final</mapstruct.version> - <flyway-core.version>10.10.0</flyway-core.version> - <postgresql.version>42.7.3</postgresql.version> - <openfeign.version>4.1.0</openfeign.version> - <keycloak-core.version>24.0.2</keycloak-core.version> - <rabbitmq.version>5.20.0</rabbitmq.version> + <openfeign.version>4.2.0</openfeign.version> + <rabbitmq.version>5.21.0</rabbitmq.version> </properties> <dependencies> @@ -135,6 +128,22 @@ <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> <version>${openfeign.version}</version> + <exclusions> + <exclusion> + <groupId>org.bouncycastle</groupId> + <artifactId>bcprov-jdk18on</artifactId> + </exclusion> + <exclusion> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.16.1</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> diff --git a/addressImport/.gitignore b/addressImport/.gitignore index 22921f07..7f3a0b67 100644 --- a/addressImport/.gitignore +++ b/addressImport/.gitignore @@ -3,6 +3,7 @@ target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/** !**/src/test/** +.env.* ### STS ### .apt_generated diff --git a/addressImport/pom.xml b/addressImport/pom.xml index 32a4bfc4..0fdecf64 100644 --- a/addressImport/pom.xml +++ b/addressImport/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>3.2.4</version> + <version>3.4.3</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>org.eclipse.openk</groupId> @@ -34,26 +34,13 @@ <disable.xml.report>true</disable.xml.report> <surefire.useFile>false</surefire.useFile> - <spring-cloud.version>2023.0.0</spring-cloud.version> + <spring-cloud.version>2024.0.0</spring-cloud.version> <powerMockReflect.version>2.0.9</powerMockReflect.version> <sonar-maven-plugin.version>3.2</sonar-maven-plugin.version> <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version> <mapstruct.version>1.5.5.Final</mapstruct.version> - <flyway-core.version>10.10.0</flyway-core.version> - - <flyway.sqlMigrationSeparator>__</flyway.sqlMigrationSeparator> - <flyway.url>jdbc:postgresql://entopticadirx:5432/GridFailureInfoDevServer</flyway.url> - <flyway.user>gfi_service</flyway.user> - <flyway.password>gfi_service</flyway.password> - <flyway.schemas>public</flyway.schemas> - <flyway.table>address_flyway_schema_history</flyway.table> - <flyway.locations>filesystem:src/main/resources/db/migration/</flyway.locations> <postgresql.version>42.7.3</postgresql.version> - <openfeign.version>4.1.0</openfeign.version> - <keycloak-core.version>24.0.2</keycloak-core.version> - <greenmail.version>1.5.11</greenmail.version> - <greenmail.version>1.5.11</greenmail.version> <rabbitmq.version>5.20.0</rabbitmq.version> </properties> <dependencies> diff --git a/addressImport/src/main/java/org/eclipse/openk/gridfailureinformation/importadresses/AddressImportApplication.java b/addressImport/src/main/java/org/eclipse/openk/gridfailureinformation/importadresses/AddressImportApplication.java index c389299d..378b1f0f 100644 --- a/addressImport/src/main/java/org/eclipse/openk/gridfailureinformation/importadresses/AddressImportApplication.java +++ b/addressImport/src/main/java/org/eclipse/openk/gridfailureinformation/importadresses/AddressImportApplication.java @@ -23,6 +23,6 @@ public class AddressImportApplication { public static void main(String[] args) { // passing through args is a security issue at sonar. As long as we don't know what for, we won't passthrough // any arg - SpringApplication.run(AddressImportApplication.class, new String[0]); + SpringApplication.run(AddressImportApplication.class); } } diff --git a/addressImport/src/test/java/org/eclipse/openk/gridfailureinformation/importadresses/config/TestConfiguration.java b/addressImport/src/test/java/org/eclipse/openk/gridfailureinformation/importadresses/config/TestConfiguration.java index afe64eca..386bc93a 100644 --- a/addressImport/src/test/java/org/eclipse/openk/gridfailureinformation/importadresses/config/TestConfiguration.java +++ b/addressImport/src/test/java/org/eclipse/openk/gridfailureinformation/importadresses/config/TestConfiguration.java @@ -26,16 +26,11 @@ import org.eclipse.openk.gridfailureinformation.importadresses.service.AddressIm import org.eclipse.openk.gridfailureinformation.importadresses.service.AddressService; import org.eclipse.openk.gridfailureinformation.importadresses.service.StationService; import org.eclipse.openk.gridfailureinformation.importadresses.util.UtmConverter; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration; -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.ConfigDataApplicationContextInitializer; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Bean; import org.springframework.data.jpa.repository.config.EnableJpaRepositories; -import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; @EnableJpaRepositories(basePackages = "org.eclipse.openk.gridfailureinformation.importadresses") diff --git a/deployment/dockercompose/cbd/.env b/deployment/dockercompose/cbd/.env index 9368806c..10634c1a 100644 --- a/deployment/dockercompose/cbd/.env +++ b/deployment/dockercompose/cbd/.env @@ -7,4 +7,4 @@ APP_DB_ROLE=cbd_service APP_DB_PASSWORD=cbd_service APP_DBNAME=ContactBaseData -KEYCLOAK_PASSWORD_TECHUSER=admin \ No newline at end of file +KEYCLOAK_PASSWORD_TECHUSER=admin diff --git a/deployment/dockercompose/cbd/docker-compose.yml b/deployment/dockercompose/cbd/docker-compose.yml index 100e2448..29504227 100644 --- a/deployment/dockercompose/cbd/docker-compose.yml +++ b/deployment/dockercompose/cbd/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.5' - services: init-postgres-service: @@ -83,7 +81,7 @@ services: networks: openknet: name: openknet - driver: bridge + external: true volumes: postgres: diff --git a/deployment/dockercompose/gfi-dmz/docker-compose.yml b/deployment/dockercompose/gfi-dmz/docker-compose.yml index 6c1c8064..54ce5b00 100644 --- a/deployment/dockercompose/gfi-dmz/docker-compose.yml +++ b/deployment/dockercompose/gfi-dmz/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.5' - services: ############# Frontend ############# @@ -58,4 +56,4 @@ services: networks: openknet: name: openknet - driver: bridge + external: true diff --git a/deployment/dockercompose/gfi-dmz/traefik/docker-compose.yml b/deployment/dockercompose/gfi-dmz/traefik/docker-compose.yml index 9f09f9ce..30000417 100644 --- a/deployment/dockercompose/gfi-dmz/traefik/docker-compose.yml +++ b/deployment/dockercompose/gfi-dmz/traefik/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.5' - services: traefik-dmz: @@ -33,4 +31,4 @@ services: networks: openknet: - name: openknet \ No newline at end of file + name: openknet diff --git a/deployment/dockercompose/gfi/configBackend/configMain/application.yml b/deployment/dockercompose/gfi/configBackend/configMain/application.yml index b3ba5bdc..d50e7f68 100644 --- a/deployment/dockercompose/gfi/configBackend/configMain/application.yml +++ b/deployment/dockercompose/gfi/configBackend/configMain/application.yml @@ -221,8 +221,8 @@ services: moduleName: Störungsinformationstool sitCache: name: sitCacheService - #url: http://fe-webcache:3000 - url: http://host.docker.internal:3000 + url: http://fe-webcache:3000 + #url: http://host.docker.internal:3000 #url: http://localhost:3000 gridFailureInformation: @@ -274,7 +274,7 @@ geoJsonImport: email: sender: sender@test.tester - smtpHost: entdockergss + smtpHost: mailhog port: 1025 isHtmlEmail: true isUseHtmlEmailTemplate: true diff --git a/deployment/dockercompose/gfi/docker-compose.yml b/deployment/dockercompose/gfi/docker-compose.yml index 451c8392..fbabfd8b 100644 --- a/deployment/dockercompose/gfi/docker-compose.yml +++ b/deployment/dockercompose/gfi/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.5' - services: rabbitmq: image: rabbitmq:3-management-alpine @@ -93,9 +91,9 @@ services: rabbitmq: condition: service_healthy - saris-service: + saris-service: #image: registry.gitlab.com/openkonsequenz/usermodules/gridfailureinformation/gridfailureinformation.backend.interface.saris/tag/gfi-saris-interface:2.2.0 - registry.gitlab.com/openkonsequenz/usermodules/gridfailureinformation/gridfailureinformation.backend.interface.saris/develop/gfi-saris-interface:latest + image: registry.gitlab.com/openkonsequenz/usermodules/gridfailureinformation/gridfailureinformation.backend.interface.saris/develop/gfi-saris-interface:latest networks: - openknet environment: @@ -147,7 +145,7 @@ services: networks: openknet: name: openknet - driver: bridge + external: true volumes: gfidbvol: diff --git a/deployment/dockercompose/infrastructure/db/postgresql/docker-compose.yml b/deployment/dockercompose/infrastructure/db/postgresql/docker-compose.yml index adca7766..55f7070b 100644 --- a/deployment/dockercompose/infrastructure/db/postgresql/docker-compose.yml +++ b/deployment/dockercompose/infrastructure/db/postgresql/docker-compose.yml @@ -1,10 +1,7 @@ -version: '3.5' - services: postgres: container_name: postgres_container image: postgres:13.3 - #postgres:9.6.22-alpine3.14 environment: POSTGRES_USER: ${POSTGRES_USER:-postgres} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-postgres} @@ -48,17 +45,8 @@ services: networks: openknet: name: openknet -# external: true - -# networks: -# default: -# name: openknet -# external: true - -# networks: -# default: -# name: openknet + driver: bridge volumes: postgres: - pgadmin: \ No newline at end of file + pgadmin: diff --git a/deployment/dockercompose/mailhog/docker-compose.yml b/deployment/dockercompose/mailhog/docker-compose.yml new file mode 100644 index 00000000..5b792e78 --- /dev/null +++ b/deployment/dockercompose/mailhog/docker-compose.yml @@ -0,0 +1,13 @@ +services: + mailhog: + image: mailhog/mailhog + ports: + - "3025:1025" # SMTP server + - "8025:8025" # Web UI + networks: + - openknet + +networks: + openknet: + name: openknet + external: true diff --git a/deployment/dockercompose/portal/Dockerfile b/deployment/dockercompose/portal/Dockerfile index 0e3bf952..f394d544 100644 --- a/deployment/dockercompose/portal/Dockerfile +++ b/deployment/dockercompose/portal/Dockerfile @@ -1,4 +1,4 @@ -FROM quay.io/keycloak/keycloak:22.0.1 as builder +FROM quay.io/keycloak/keycloak:26.0 as builder ENV KC_HEALTH_ENABLED=true ENV KC_METRICS_ENABLED=true @@ -17,11 +17,11 @@ WORKDIR /opt/keycloak RUN /opt/keycloak/bin/kc.sh build -FROM quay.io/keycloak/keycloak:22.0.1 +FROM quay.io/keycloak/keycloak:26.0 COPY --from=builder /opt/keycloak/ /opt/keycloak/ # for demonstration purposes only, please make sure to use proper certificates in production instead #RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname "CN=server" -alias server -ext "SAN:c=DNS:localhost,IP:127.0.0.1" -keystore conf/server.keystore ENTRYPOINT ["/opt/keycloak/bin/kc.sh"] -CMD ["start"] \ No newline at end of file +CMD ["start"] diff --git a/deployment/dockercompose/portal/docker-compose.yml b/deployment/dockercompose/portal/docker-compose.yml index 6f1dbf04..ca98d487 100644 --- a/deployment/dockercompose/portal/docker-compose.yml +++ b/deployment/dockercompose/portal/docker-compose.yml @@ -1,11 +1,9 @@ -version: '3.8' - services: ############# Database Init ############# keycloakdb-init: - image: postgres:9.6.22-alpine3.14 + image: postgres:13.3 environment: PGHOST: ${APP_DB_HOST} PGPORT: ${APP_DB_PORT} @@ -31,7 +29,7 @@ services: build: context: . dockerfile: Dockerfile - image: keycloak-postgres:22.0.1 + image: keycloak-postgres:26.0 environment: #KC_TRANSACTION_XA_ENABLED: "false" # Build Params #KC_DB: postgresql # Build Params @@ -80,7 +78,7 @@ services: condition: service_completed_successfully init-keycloak-config: - image: adorsys/keycloak-config-cli:5.8.0-22.0.0 + image: adorsys/keycloak-config-cli:6.2.1-26.0.5 environment: IMPORT_VARSUBSTITUTION_ENABLED: "true" KEYCLOAK_PASSWORD_TECHUSER: ${KEYCLOAK_PASSWORD_TECHUSER:-admin} # This password will be set for the technical admin (subsituted in keycloak-config.json) diff --git a/deployment/dockercompose/start_tools_compose.sh b/deployment/dockercompose/start_tools_compose.sh index dc1e98a7..3f30dcf4 100644 --- a/deployment/dockercompose/start_tools_compose.sh +++ b/deployment/dockercompose/start_tools_compose.sh @@ -10,3 +10,8 @@ echo "portainer port: 9000" # dozzle docker-compose -f "$ROOT_DIR/infrastructure/dozzle/docker-compose.yml" up -d echo "dozzle port: 9999" + +# mailhog +docker-compose -f "$ROOT_DIR/mailhog/docker-compose.yml" up -d +echo "mailhog smtp port: 3025" +echo "mailhog webui port: 8025" diff --git a/gfsBackendService/.gitignore b/gfsBackendService/.gitignore index 2a0718ee..e40faa54 100644 --- a/gfsBackendService/.gitignore +++ b/gfsBackendService/.gitignore @@ -3,6 +3,7 @@ target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/** !**/src/test/** +.env.* ### STS ### .apt_generated diff --git a/gfsBackendService/pom.xml b/gfsBackendService/pom.xml index 628572ab..d5081251 100644 --- a/gfsBackendService/pom.xml +++ b/gfsBackendService/pom.xml @@ -20,7 +20,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>3.2.4</version> + <version>3.4.3</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>org.eclipse.openk</groupId> @@ -43,21 +43,39 @@ <flyway.table>flyway_schema_history</flyway.table> <flyway.locations>filesystem:src/main/resources/db/migration/</flyway.locations> - <spring-cloud.version>2023.0.0</spring-cloud.version> + <spring-cloud.version>2024.0.0</spring-cloud.version> <powerMockReflect.version>2.0.9</powerMockReflect.version> <sonar-maven-plugin.version>3.2</sonar-maven-plugin.version> <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version> <mapstruct.version>1.5.5.Final</mapstruct.version> <flyway-core.version>10.13.0</flyway-core.version> <postgresql.version>42.7.3</postgresql.version> - <openfeign.version>4.1.2</openfeign.version> - <keycloak-core.version>24.0.2</keycloak-core.version> + <openfeign.version>4.2.0</openfeign.version> + <keycloak-core.version>26.0.8</keycloak-core.version> <rabbitmq.version>5.21.0</rabbitmq.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> + <exclusions> + <exclusion> + <groupId>com.rabbitmq</groupId> + <artifactId>amqp-client</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- https://mvnrepository.com/artifact/org.springframework/spring-context --> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>6.2.1</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context-support</artifactId> + <version>6.2.1</version> + <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> @@ -84,12 +102,40 @@ <artifactId>spring-integration-jpa</artifactId> </dependency> <dependency> - <groupId>org.springframework.integration</groupId> - <artifactId>spring-integration-security</artifactId> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-validation</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-validation</artifactId> + <artifactId>spring-boot-starter-logging</artifactId> + <exclusions> + <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + </exclusion> + <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-core --> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + <version>1.5.16</version> + </dependency> + <!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic --> + <dependency> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-classic</artifactId> + <version>1.5.16</version> + <exclusions> + <exclusion> + <groupId>ch.qos.logback</groupId> + <artifactId>logback-core</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.springframework.boot</groupId> @@ -108,11 +154,27 @@ <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> <version>${openfeign.version}</version> + <exclusions> + <exclusion> + <groupId>org.bouncycastle</groupId> + <artifactId>bcprov-jdk18on</artifactId> + </exclusion> + <exclusion> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.16.1</version> </dependency> <dependency> <groupId>org.keycloak</groupId> <artifactId>keycloak-core</artifactId> - <version> ${keycloak-core.version}</version> + <version>${keycloak-core.version}</version> </dependency> <dependency> <groupId>org.postgresql</groupId> @@ -139,6 +201,12 @@ <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>33.1.0-jre</version> + <exclusions> + <exclusion> + <groupId>com.google.errorprone</groupId> + <artifactId>error_prone_annotations</artifactId> + </exclusion> + </exclusions> </dependency> <!-- <dependency> @@ -197,20 +265,25 @@ <artifactId>powermock-reflect</artifactId> <version>${powerMockReflect.version}</version> <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.objenesis</groupId> + <artifactId>objenesis</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-classworlds</artifactId> + <version>2.8.0</version> </dependency> <!-- https://mvnrepository.com/artifact/org.mockito/mockito-core --> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> - <version>5.11.0</version> + <version>5.15.2</version> <scope>test</scope> </dependency> - <!-- https://mvnrepository.com/artifact/net.bytebuddy/byte-buddy --> - <dependency> - <groupId>net.bytebuddy</groupId> - <artifactId>byte-buddy</artifactId> - <version>1.14.16</version> - </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> @@ -221,11 +294,6 @@ <artifactId>ojdbc8</artifactId> <version>19.6.0.0</version> </dependency> - <dependency> - <groupId>com.oracle.database.jdbc</groupId> - <artifactId>ucp</artifactId> - <version>19.6.0.0</version> - </dependency> <dependency> <groupId>com.sun.mail</groupId> <artifactId>jakarta.mail</artifactId> @@ -249,7 +317,112 @@ <dependency> <groupId>org.owasp</groupId> <artifactId>dependency-check-maven</artifactId> - <version>9.2.0</version> + <version>12.0.0</version> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.apache.commons</groupId> + <artifactId>commons-compress</artifactId> + </exclusion> + <exclusion> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.commons</groupId> + <artifactId>commons-jcs3-core</artifactId> + </exclusion> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + </exclusion> + <exclusion> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.maven</groupId> + <artifactId>maven-artifact</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.maven.shared</groupId> + <artifactId>maven-common-artifact-filters</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.maven.resolver</groupId> + <artifactId>maven-resolver-util</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-component-annotations</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + <version>4.0.2</version> + </dependency> + <!-- https://mvnrepository.com/artifact/org.apache.maven/maven-core --> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + <version>3.9.9</version> + <exclusions> + <exclusion> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-xml</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + </exclusion> + <exclusion> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-classworlds</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.maven.shared</groupId> + <artifactId>maven-common-artifact-filters</artifactId> + <version>3.4.0</version> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.apache.maven.resolver</groupId> + <artifactId>maven-resolver-util</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-jcs3-core</artifactId> + <version>3.2.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + <version>1.3.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-compress</artifactId> + <version>1.27.1</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.google.jimfs/jimfs --> @@ -258,13 +431,18 @@ <artifactId>jimfs</artifactId> <version>1.3.0</version> <scope>test</scope> + <exclusions> + <exclusion> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>jakarta.inject</groupId> <artifactId>jakarta.inject-api</artifactId> <version>2.0.1</version> </dependency> - </dependencies> <repositories> diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/api/SitCacheApi.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/api/SitCacheApi.java index 9eec4155..549d841c 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/api/SitCacheApi.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/api/SitCacheApi.java @@ -14,7 +14,6 @@ */ package org.eclipse.openk.gridfailureinformation.api; - import org.eclipse.openk.gridfailureinformation.viewmodel.ExportGridFailures; import org.eclipse.openk.gridfailureinformation.viewmodel.ExportSettings; import org.springframework.cloud.openfeign.FeignClient; @@ -24,10 +23,8 @@ import org.springframework.web.bind.annotation.RequestBody; @FeignClient(name = "${services.sitCache.name}", url = "${services.sitCache.url}") public interface SitCacheApi { @PostMapping("/internal-sit") - void postPublicFailureInfos( - @RequestBody ExportGridFailures export); + void postPublicFailureInfos(@RequestBody ExportGridFailures export); @PostMapping("/fe-settings") - void postFeSettings( - @RequestBody ExportSettings feSettings); + void postFeSettings(@RequestBody ExportSettings feSettings); } diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/GfiProcessEnvironment.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/GfiProcessEnvironment.java index 2e652526..765bc0be 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/GfiProcessEnvironment.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/GfiProcessEnvironment.java @@ -42,7 +42,15 @@ public class GfiProcessEnvironment { private final ExportService exportService; - public GfiProcessEnvironment(FailureClassificationRepository failureClassificationRepository, FailureInformationRepository failureInformationRepository, StatusRepository statusRepository, FailureInformationService failureInformationService, FailureInformationMapper failureInformationMapper, FailureInformationPublicationChannelRepository channelRepository, ExportService exportService) { + public GfiProcessEnvironment( + FailureClassificationRepository failureClassificationRepository, + FailureInformationRepository failureInformationRepository, + StatusRepository statusRepository, + FailureInformationService failureInformationService, + FailureInformationMapper failureInformationMapper, + FailureInformationPublicationChannelRepository channelRepository, + ExportService exportService + ) { this.failureClassificationRepository = failureClassificationRepository; this.failureInformationRepository = failureInformationRepository; this.statusRepository = statusRepository; diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/ProcessHelper.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/ProcessHelper.java index ba8bffd1..ee6ad804 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/ProcessHelper.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/bpmn/impl/tasks/ProcessHelper.java @@ -71,7 +71,7 @@ public class ProcessHelper { throw new BadRequestException("Publishing is only possible with state 'qualified'"); } TblFailureInformation tblFailureInfo = environment.getFailureInformationService().getFailureInformationRepository().findByUuid(failureInformationDto.getUuid()).orElseThrow(()-> new NotFoundException("")); - List<TblFailureInformationPublicationChannel> channelList = environment.getFailureInformationService().getFailureInformationPublicationChannelRepository().findByTblFailureInformation(tblFailureInfo); + List<TblFailureInformationPublicationChannel> channelList = environment.getFailureInformationService().getFailureInformationPublicationChannelRepository().findByTblFailureInformation(tblFailureInfo); if (channelList.isEmpty()) { throw new BadRequestException("Publishing is only possible with at least one selected channel"); } @@ -81,10 +81,9 @@ public class ProcessHelper { public FailureInformationDto processGrid(FailureInformationDto failureInfoDto, GfiProcessState forcedState) { GfiProcessSubject subject = GfiProcessSubject.of(failureInfoDto, this); - if(forcedState != null) { + if (forcedState != null) { subject.setStateInDb(forcedState); // use forced state - } - else { + } else { // use state from db RefStatus refStatus = environment.getFailureInformationService().getRefStatus(failureInfoDto); subject.setStateInDb(GfiProcessState.fromValue(refStatus.getId())); @@ -92,19 +91,18 @@ public class ProcessHelper { try { grid.recover(subject).start(subject::getStateInDb); } catch (ProcessException e) { - log.error(e.getMessage() + " -> \r\n" + Arrays.toString(e.getStackTrace())); + log.error("{} -> \r\n{}", e.getMessage(), Arrays.toString(e.getStackTrace())); throw new InternalServerErrorException(e.getMessage()); } return subject.getFailureInformationDto(); } - public ProcessState getProcessStateFromStatusUuid(UUID statusUuid) { Optional<RefStatus> optRefStatus = environment.getStatusRepository().findByUuid(statusUuid); - if(optRefStatus.isEmpty()) { - log.error("RefStatus <"+statusUuid+"> not found in DB"); - throw new InternalServerErrorException("status.uuid.not.found"); + if (optRefStatus.isEmpty()) { + log.error("RefStatus <{}> not found in DB", statusUuid); + throw new InternalServerErrorException("status.uuid.not.found"); } return GfiProcessState.fromValue(optRefStatus.get().getId()); } diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/config/DmzExportSchedulerConfig.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/config/DmzExportSchedulerConfig.java index 09ac555e..8f257141 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/config/DmzExportSchedulerConfig.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/config/DmzExportSchedulerConfig.java @@ -14,32 +14,38 @@ */ package org.eclipse.openk.gridfailureinformation.config; -import lombok.extern.log4j.Log4j2; +import jakarta.annotation.PostConstruct; import org.eclipse.openk.gridfailureinformation.service.ExportService; -import org.springframework.beans.factory.annotation.Autowired; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Configuration; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; -@Log4j2 @Configuration @EnableScheduling -@ConditionalOnProperty(prefix = "export-to-dmz", name = "enabled", havingValue = "true", matchIfMissing = false) +@ConditionalOnProperty(prefix = "export-to-dmz", name = "enabled", havingValue = "true") public class DmzExportSchedulerConfig { + private static final Logger log = LoggerFactory.getLogger(DmzExportSchedulerConfig.class); private static final String SCHEDULER_NAME = "DmzExport-Scheduler"; private final ExportService exportService; - @Value("${export-to-dmz.cron}") - private String cronExpression; + @Value("${export-to-dmz.enabled}") + private Boolean isEnabled; public DmzExportSchedulerConfig(ExportService exportService) { this.exportService = exportService; } + @PostConstruct + public void init() { + log.debug("{} enabled: {}", SCHEDULER_NAME, isEnabled); + } + @Scheduled(cron = "${export-to-dmz.cron}") public void scheduleTaskDmzExport() { log.trace("Executing" + SCHEDULER_NAME + " task: Exporting FailureInformations with Status 'published' to DMZ" ); diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/FailureInformationController.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/FailureInformationController.java index 355b8aa0..5481a598 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/FailureInformationController.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/controller/FailureInformationController.java @@ -46,6 +46,8 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.support.ServletUriComponentsBuilder; import java.net.URI; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -207,7 +209,9 @@ public class FailureInformationController { @PathVariable UUID failureInfoUuid, @RequestParam String publicationChannel) { - return failureInformationService.insertPublicationChannelForFailureInfo(failureInfoUuid, publicationChannel, false); + var decodedPublicationChannel = URLDecoder.decode(publicationChannel, StandardCharsets.UTF_8); + + return failureInformationService.insertPublicationChannelForFailureInfo(failureInfoUuid, decodedPublicationChannel, false); } @DeleteMapping("/{failureInfoUuid}/channels") @@ -222,7 +226,9 @@ public class FailureInformationController { @PathVariable UUID failureInfoUuid, @RequestParam String publicationChannel) { - failureInformationService.deletePublicationChannelForFailureInfo(failureInfoUuid, publicationChannel); + var decodedPublicationChannel = URLDecoder.decode(publicationChannel, StandardCharsets.UTF_8); + + failureInformationService.deletePublicationChannelForFailureInfo(failureInfoUuid, decodedPublicationChannel); } @GetMapping("/{failureInfoUuid}/channels") diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/email/Email.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/email/Email.java index 981e9160..6970c589 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/email/Email.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/email/Email.java @@ -76,7 +76,7 @@ public class Email { try { boolean validRecipient = validateEmailAddress(emailSender); if (!validRecipient) { - log.error("Invalid email-addresse for sender: " + emailSender); + log.error("Invalid email-address for sender: {}", emailSender); throw new MessagingException(); } message.setFrom(new InternetAddress(emailSender)); @@ -127,7 +127,7 @@ public class Email { private void validateEmailAddress(String[] recipientsSplit) throws MessagingException { for (String recipient : recipientsSplit) { if (!validateEmailAddress(recipient.trim())) { - log.error("Invalid email-addresse: " + recipient); + log.error("Invalid email-address: {}", recipient); //throw new MessagingException(); } } diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/email/GfiEmail.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/email/GfiEmail.java index 016f003a..753ffafd 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/email/GfiEmail.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/email/GfiEmail.java @@ -35,7 +35,7 @@ public class GfiEmail { log.debug("loading email content"); this.emailBody = textBody; this.subject = subject == null ? "- kein Betreff -" : subject; - log.debug("finsished loading email content"); + log.debug("finished loading email content"); } private void prepareMailToSend() throws MessagingException { @@ -52,13 +52,13 @@ public class GfiEmail { prepareMailToSend(); boolean ret = email.send(); if (ret) { - log.info("Email with subject: " + email.getMessage().getSubject() + " has been sent successfully sent to smtpserver"); + log.info("Email with subject: {} has been sent successfully sent to smtp-server", email.getMessage().getSubject()); } else { - log.error("Some error occured while sending email to smtpserver with subject: " + email.getMessage().getSubject() + " . Email wasn't sent."); + log.error("Some error occurred while sending email to smtp-server with subject: {} - Email wasn't sent.", email.getMessage().getSubject()); throw new MessagingException(); } } catch (MessagingException e) { - log.error("Error occured in sendEmail", e); + log.error("Error occurred in sendEmail", e); throw e; } } diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/FailureInformationDistributionGroupRepository.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/FailureInformationDistributionGroupRepository.java index 41eb1bd8..a5b91206 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/FailureInformationDistributionGroupRepository.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/FailureInformationDistributionGroupRepository.java @@ -28,5 +28,5 @@ public interface FailureInformationDistributionGroupRepository extends JpaReposi Optional<TblFailureInformationDistributionGroup> findByFailureInformationIdAndDistributionGroupId(Long failureInfoId, Long groupId); void deleteByFailureInformationId(Long id); - List<TblFailureInformationDistributionGroup> findByFailureInformationId( Long failureInformationId); + List<TblFailureInformationDistributionGroup> findByFailureInformationId(Long failureInformationId); } diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/FailureInformationRepository.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/FailureInformationRepository.java index d05d38fb..cea6113e 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/FailureInformationRepository.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/repository/FailureInformationRepository.java @@ -21,7 +21,6 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/DistributionGroupService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/DistributionGroupService.java index 10921d25..a1434cc2 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/DistributionGroupService.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/DistributionGroupService.java @@ -25,7 +25,6 @@ import org.eclipse.openk.gridfailureinformation.repository.DistributionGroupMemb import org.eclipse.openk.gridfailureinformation.repository.DistributionGroupRepository; import org.eclipse.openk.gridfailureinformation.viewmodel.DistributionGroupAllowedDto; import org.eclipse.openk.gridfailureinformation.viewmodel.DistributionGroupDto; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -43,14 +42,16 @@ public class DistributionGroupService { private final DistributionGroupMemberRepository distributionGroupMemberRepository; - private final DistributionGroupAllowedRepository allowedRepo; - - public DistributionGroupService(DistributionGroupRepository distributionGroupRepository, DistributionGroupAllowedRepository distributionGroupAllowedRepository, DistributionGroupMapper distributionGroupMapper, DistributionGroupMemberRepository distributionGroupMemberRepository, DistributionGroupAllowedRepository allowedRepo) { + public DistributionGroupService( + DistributionGroupRepository distributionGroupRepository, + DistributionGroupAllowedRepository distributionGroupAllowedRepository, + DistributionGroupMapper distributionGroupMapper, + DistributionGroupMemberRepository distributionGroupMemberRepository + ) { this.distributionGroupRepository = distributionGroupRepository; this.distributionGroupAllowedRepository = distributionGroupAllowedRepository; this.distributionGroupMapper = distributionGroupMapper; this.distributionGroupMemberRepository = distributionGroupMemberRepository; - this.allowedRepo = allowedRepo; } public List<DistributionGroupDto> getDistributionGroups() { @@ -126,17 +127,17 @@ public class DistributionGroupService { if (dto.isDeleted()) { - allowedRepo.deleteById(dto.getId()); + distributionGroupAllowedRepository.deleteById(dto.getId()); continue; } - TblDistributionGroupAllowed group = allowedRepo.findById(dto.getId()).orElse(new TblDistributionGroupAllowed()); + TblDistributionGroupAllowed group = distributionGroupAllowedRepository.findById(dto.getId()).orElse(new TblDistributionGroupAllowed()); group.setDistributionGroupId(groupId); group.setAutoSet(dto.isAutoSet()); group.setClassificationId(dto.getClassificationId()); group.setBranchId(dto.getBranchId()); - allowedRepo.save(group); + distributionGroupAllowedRepository.save(group); } } } diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/DistributionTextPlaceholderService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/DistributionTextPlaceholderService.java index 76ec9326..014e43a3 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/DistributionTextPlaceholderService.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/DistributionTextPlaceholderService.java @@ -17,7 +17,6 @@ package org.eclipse.openk.gridfailureinformation.service; import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.log4j.Log4j2; import org.eclipse.openk.gridfailureinformation.viewmodel.DistributionTextPlaceholderDto; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; @@ -32,7 +31,7 @@ public class DistributionTextPlaceholderService { private DistributionTextPlaceholderDto initPlaceholderDto() { try { InputStream inputStream = new ClassPathResource("DistributionTextPlaceholder.json").getInputStream(); - return new ObjectMapper().readValue(inputStream, DistributionTextPlaceholderDto.class); + return new ObjectMapper().readValue(inputStream, DistributionTextPlaceholderDto.class); } catch (IOException e) { log.error("Error importing JSON-Message", e); return null; diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ExportService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ExportService.java index 1416606d..f393aebf 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ExportService.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ExportService.java @@ -78,7 +78,6 @@ import java.util.stream.Collectors; @Validated @EnableConfigurationProperties public class ExportService { - @Lazy private final RabbitMqConfig rabbitMqConfig; private final RabbitMqProperties rabbitMqProperties; @@ -166,7 +165,7 @@ public class ExportService { } public boolean exportFailureInformation(UUID uuid, String[] targetChannels, GfiProcessState processState) { - log.info("Start exporting failureInformation with uuid: " + uuid); + log.info("Start exporting failureInformation with uuid: {}", uuid); countExportedMessages = 0; for (String targetChannel : targetChannels){ RabbitMqChannel rChannel = getAvailableRabbitMqChannel(targetChannel); @@ -181,10 +180,14 @@ public class ExportService { TblFailureInformation existingTblFailureInfo = failureInformationRepository.findByUuid(uuid) .orElseThrow(NotFoundException::new); - //Wenn State mitgeliefert wird dann sende mail (zb. bei Update oder Complete State) - if(!isChannelAlreadyPublished( targetChannel, existingTblFailureInfo) || processState != null) { + //Wenn State mitgeliefert wird, dann sende mail (z.B. bei Update oder Complete State) + if(!isChannelAlreadyPublished(targetChannel, existingTblFailureInfo) || processState != null) { //Nullsafe check + var one = Constants.CHANNEL_TPYE_LONG_MAIL; + var two = rChannel.getName(); + var three = rabbitMqConfig.getChannelNameToTypeMap(); + var equals = one.equals(two); if (Constants.CHANNEL_TPYE_LONG_MAIL.equals(rabbitMqConfig.getChannelNameToTypeMap().get(rChannel.getName())) || Constants.CHANNEL_TPYE_SHORT_MAIL.equals(rabbitMqConfig.getChannelNameToTypeMap().get(rChannel.getName()))) { //Holen der Verteilergruppen (Pro Verteilergruppe eine Message auf RabbitMQ) @@ -192,8 +195,7 @@ public class ExportService { failureInformationDistributionGroupRepository.findByFailureInformationId(existingTblFailureInfo.getId()); if (distributionGroups == null || distributionGroups.isEmpty()) { - log.warn("no distribution group found for failureInfo: " - + existingTblFailureInfo.getUuid().toString()); + log.warn("no distribution group found for failureInfo: {}", existingTblFailureInfo.getUuid().toString()); return false; } @@ -213,7 +215,7 @@ public class ExportService { } } - log.info("Finished exporting failureInformation with uuid: " + uuid); + log.info("Finished exporting failureInformation with uuid: {}", uuid); return countExportedMessages > 0; } @@ -221,14 +223,14 @@ public class ExportService { List<String> channelsToPublishList = failureInformationService.getChannelsToPublishList(uuid, true); for (String targetChannel : channelsToPublishList) { RabbitMqChannel rChannel = getAvailableRabbitMqChannel(targetChannel); - if(getAvailableRabbitMqChannel(targetChannel) == null){ + if (getAvailableRabbitMqChannel(targetChannel) == null){ log.warn(Constants.CHANNEL_NOT_EXISTING); throw new NotFoundException(Constants.CHANNEL_NOT_EXISTING); } rabbitMqConfig.checkExchangeAndQueueOnRabbitMq(rChannel.getExportQueue(), rChannel.getExportKey()); - TblFailureInformation existingTblFailureInfo = failureInformationRepository.findByUuid( uuid ) + TblFailureInformation existingTblFailureInfo = failureInformationRepository.findByUuid(uuid) .orElseThrow(NotFoundException::new); //Holen der Verteilergruppen (Pro Verteilergruppe eine Message auf RabbitMQ) @@ -263,8 +265,8 @@ public class ExportService { .filter( this::hasSITWebComponentChannel) .filter(this::filterByState) // .filter( x -> x.getFailureEndPlanned() == null || x.getFailureEndPlanned().compareTo(new Date()) > 0) - .map( failureInformationMapper::toFailureInformationDto ) - .map( failureInformationService::enrichFailureInfo ) + .map(failureInformationMapper::toFailureInformationDto) + .map(failureInformationService::enrichFailureInfo) .collect(Collectors.toList()); try { @@ -331,7 +333,7 @@ public class ExportService { List<TblFailureInformationPublicationChannel> publicationChannelList = publicationChannelRepository.findByTblFailureInformation(existingTblFailureInfo); Optional<TblFailureInformationPublicationChannel> pubChannelToSave = publicationChannelList.stream() - .filter( x->x.getPublicationChannel().equals(targetChannel)) + .filter(x->x.getPublicationChannel().equals(targetChannel)) .findFirst(); if( pubChannelToSave.isPresent() ) { @@ -355,7 +357,7 @@ public class ExportService { List<RabbitMqChannel> filteredChannelList = rabbitMqChannels.stream().filter(channel -> channel.getName().contains(targetChannel)).toList(); if (!filteredChannelList.isEmpty()){ - return filteredChannelList.get(0); + return filteredChannelList.getFirst(); } else { return null; @@ -363,8 +365,8 @@ public class ExportService { } private void prepareMessage(TblFailureInformation existingTblFailureInfo, TblDistributionGroup distributionGroup, RabbitMqChannel rabbitMqChannel, GfiProcessState processState){ - List<String> mailAddresses= new ArrayList<>(); - List<String> mobilAddresses= new ArrayList<>(); + List<String> mailAddresses = new ArrayList<>(); + List<String> mobilAddresses = new ArrayList<>(); RabbitMqMessageDto rabbitMqMessageDto = new RabbitMqMessageDto(); rabbitMqMessageDto.setFailureInformationDto(failureInformationMapper.toFailureInformationDto(existingTblFailureInfo)); @@ -373,7 +375,7 @@ public class ExportService { rabbitMqMessageDto.setDistributionGroup(distributionGroup.getName()); // der dem Verteiler zugeordneten Personen - List<DistributionGroupMemberDto> memberList = groupMemberPlzFilter.filter( + List<DistributionGroupMemberDto> memberList = groupMemberPlzFilter.filter( distributionGroupMemberService.getMembersByGroupId(distributionGroup.getUuid()), existingTblFailureInfo); @@ -399,8 +401,7 @@ public class ExportService { } if (mailAddresses.isEmpty()) { - log.warn("no mail addresses found for distribution group: " - + distributionGroup.getUuid().toString()); + log.warn("no mail addresses found for distribution group: {}", distributionGroup.getUuid().toString()); return; } sendMessageToRabbitMq(rabbitMqMessageDto, rabbitMqChannel); @@ -457,8 +458,7 @@ public class ExportService { try{ rabbitTemplate.convertAndSend(rabbitMqProperties.getExportExchange(), rabbitMqChannel.getExportKey(), objectMapper.writeValueAsString(rabbitMqMessageDto)); countExportedMessages++; - log.info("RabbitMq: Successfully sent msg: Export-Exchange: " + rabbitMqProperties.getExportExchange() + " Export-Queue: " + rabbitMqChannel.getExportQueue() - + " Export-Key: " + rabbitMqChannel.getExportKey()); + log.info("RabbitMq: Successfully sent msg: Export-Exchange: {} Export-Queue: {} Export-Key: {}", rabbitMqProperties.getExportExchange(), rabbitMqChannel.getExportQueue(), rabbitMqChannel.getExportKey()); } catch (Exception e) { log.error(e.getMessage(), e); throw new InternalServerErrorException("could.not.push.rabbitMqMessage"); diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationService.java index feefe6a6..8450941c 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationService.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationService.java @@ -384,7 +384,7 @@ public class FailureInformationService { public FailureInformationDto enrichFailureInfo(FailureInformationDto failureInformationDto) { // wenn Mittelspannung oder bei definierten Branches dann füge Adress-Polygonpunkte für Kartenanzeige hinzu - if (failureInformationDto.getBranch() != null && polygonBranches.contains((failureInformationDto.getBranch()).toUpperCase()) + if (failureInformationDto.getBranch() != null && polygonBranches != null && polygonBranches.contains((failureInformationDto.getBranch()).toUpperCase()) || (failureInformationDto.getVoltageLevel() != null && failureInformationDto.getVoltageLevel().equals("MS"))) { addPolygonAddressPoints(failureInformationDto); } @@ -425,19 +425,19 @@ public class FailureInformationService { return !filteredList.isEmpty(); } - private void enrichStations( FailureInformationDto dto) { + private void enrichStations(FailureInformationDto dto) { List<UUID> stationList = failureInformationStationRepository.findUuidByFkTblFailureInformation(dto.getUuid()); dto.setStationIds(stationList); } @Transactional public FailureInformationDto condenseFailureInfos(List<UUID> listUuids, Optional<UUID> condensedUuid){ - // pruefen, ob in der uebergebenen Liste unterzuordnender FailureInfos Teile einer anderen Verdichtung sind + // pruefen, ob in der uebergebenen Liste unterzuordnender FailureInfos Teile einer anderen Verdichtung sind if (containsAlienSubordinatedFailureInfos(condensedUuid, listUuids)) { throw new BadRequestException("failure.info.already.subordinated"); } - if(listUuids.isEmpty()){ + if (listUuids.isEmpty()){ throw new BadRequestException("empty.array.for.subordinated.failure.infos"); } @@ -451,7 +451,7 @@ public class FailureInformationService { TblFailureInformation condensedFailureInformation = getOrCreateCondensedFailureInfo(condensedUuid); - condensedFailureInformation.setRefBranch(listNewSubordinatedFailureInfos.get(0).getRefBranch()); + condensedFailureInformation.setRefBranch(listNewSubordinatedFailureInfos.getFirst().getRefBranch()); setCondensedFieldsFromMany(condensedFailureInformation, listNewSubordinatedFailureInfos); condensedFailureInformation.setCondensed(true); @@ -609,7 +609,7 @@ public class FailureInformationService { private void setExpectedReason(List<TblFailureInformation> listFailureInfos, TblFailureInformation condensedFailureInformation){ - RefExpectedReason firstExpReason = listFailureInfos.get(0).getRefExpectedReason(); + RefExpectedReason firstExpReason = listFailureInfos.getFirst().getRefExpectedReason(); UUID firstExpectedReason = firstExpReason != null ? firstExpReason.getUuid() : null; List<TblFailureInformation> filteredList = listFailureInfos @@ -618,7 +618,7 @@ public class FailureInformationService { .filter(f -> f.getRefExpectedReason().getUuid().equals(firstExpectedReason)) .toList(); if (listFailureInfos.size() == filteredList.size()) { - condensedFailureInformation.setRefExpectedReason(listFailureInfos.get(0).getRefExpectedReason()); + condensedFailureInformation.setRefExpectedReason(listFailureInfos.getFirst().getRefExpectedReason()); } else{ condensedFailureInformation.setRefExpectedReason(null); @@ -648,14 +648,14 @@ public class FailureInformationService { } private boolean checkSameBranch(List<TblFailureInformation> listFailureInfos){ - RefBranch firstBranch = listFailureInfos.get(0).getRefBranch(); + RefBranch firstBranch = listFailureInfos.getFirst().getRefBranch(); List<TblFailureInformation> filteredList = listFailureInfos.stream().filter(f -> f.getRefBranch().equals(firstBranch)).toList(); return listFailureInfos.size() == filteredList.size(); } private void setVoltageLevel(List<TblFailureInformation> listFailureInfos, TblFailureInformation condensedFailureInfo){ - String firstVoltageLevel = listFailureInfos.get(0).getVoltageLevel(); + String firstVoltageLevel = listFailureInfos.getFirst().getVoltageLevel(); List<TblFailureInformation> filteredList = listFailureInfos .stream() @@ -743,7 +743,7 @@ public class FailureInformationService { // falls vorhanden wäre polygonStructureList[1] = inneres Polygon // https://de.wikipedia.org/wiki/GeoJSON List<List<List<BigDecimal>>> polygonStructureList = polygon.getGeometry().getCoordinates(); - if (polygonStructureList.get(0) != null) { + if (polygonStructureList.getFirst() != null) { List<List<BigDecimal>> outerPolygonGeoJson = polygonStructureList.get(0); //Transform Latitude und Longitude, SIT erwartet im FE lon,lat, der GEOJson Standard ist lat,lon. // Hinweis, die Menschheit kann sich aktuell nicht entscheiden: https://macwright.com/lonlat/ @@ -841,7 +841,6 @@ public class FailureInformationService { public List<FailureInformationPublicationChannelDto> getPublicationChannelsForFailureInfo(UUID failureInfoUuid){ - TblFailureInformation existingTblFailureInformation = failureInformationRepository .findByUuid(failureInfoUuid) .orElseThrow(() -> new NotFoundException(Constants.FAILURE_INFO_UUID_NOT_EXISTING)); diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationStationService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationStationService.java index 8ad446ba..3d352c3e 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationStationService.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/FailureInformationStationService.java @@ -98,7 +98,6 @@ public class FailureInformationStationService { TblFailinfoStation savedFailureInfoGroup = failureInformationStationRepository.save(assignmentToSave); return failureInformationStationMapper.toFailureInfoStationDto(savedFailureInfoGroup); - } @Transactional diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationStationService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationStationService.java index 7eb43b32..2f01e89f 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationStationService.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/HistFailureInformationStationService.java @@ -15,7 +15,6 @@ package org.eclipse.openk.gridfailureinformation.service; import org.eclipse.openk.gridfailureinformation.exceptions.NotFoundException; -import org.eclipse.openk.gridfailureinformation.mapper.FailureInformationMapper; import org.eclipse.openk.gridfailureinformation.mapper.HistFailureInformationStationMapper; import org.eclipse.openk.gridfailureinformation.mapper.StationMapper; import org.eclipse.openk.gridfailureinformation.model.HtblFailureInformation; @@ -23,14 +22,12 @@ import org.eclipse.openk.gridfailureinformation.model.HtblFailureInformationStat import org.eclipse.openk.gridfailureinformation.model.TblFailinfoStation; import org.eclipse.openk.gridfailureinformation.model.TblFailureInformation; import org.eclipse.openk.gridfailureinformation.model.TblStation; -import org.eclipse.openk.gridfailureinformation.repository.FailureInformationRepository; import org.eclipse.openk.gridfailureinformation.repository.FailureInformationStationRepository; import org.eclipse.openk.gridfailureinformation.repository.HistFailureInformationRepository; import org.eclipse.openk.gridfailureinformation.repository.HistFailureInformationStationRepository; import org.eclipse.openk.gridfailureinformation.repository.StationRepository; import org.eclipse.openk.gridfailureinformation.viewmodel.HistFailureInformationStationDto; import org.eclipse.openk.gridfailureinformation.viewmodel.StationDto; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; @@ -71,7 +68,7 @@ public class HistFailureInformationStationService { throw new NotFoundException(); } - List<HtblFailureInformationStation> htblFailureInfoStationList = histFailureInformationStationRepository.findByFkTblFailureInformationAndVersionNumber(htblFailureInformation.get(0).getId(), versionNumber); + List<HtblFailureInformationStation> htblFailureInfoStationList = histFailureInformationStationRepository.findByFkTblFailureInformationAndVersionNumber(htblFailureInformation.getFirst().getId(), versionNumber); List<TblStation> stationList = new ArrayList<>(); for (HtblFailureInformationStation histFailureInfoStation: htblFailureInfoStationList) { @@ -100,9 +97,7 @@ public class HistFailureInformationStationService { } } return savedFailureInformationStations.stream() - .map( histFailureInformationStationMapper::toHistFailureInfoStationDto ) + .map(histFailureInformationStationMapper::toHistFailureInfoStationDto) .collect(Collectors.toList()); - } - } diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ImportGeoJsonService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ImportGeoJsonService.java index 195c0e4e..3b47eb56 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ImportGeoJsonService.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/ImportGeoJsonService.java @@ -2,6 +2,7 @@ package org.eclipse.openk.gridfailureinformation.service; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import jakarta.annotation.PostConstruct; import org.apache.commons.io.FileUtils; import org.eclipse.openk.gridfailureinformation.model.TblStation; import org.eclipse.openk.gridfailureinformation.repository.StationRepository; @@ -9,9 +10,7 @@ import org.eclipse.openk.gridfailureinformation.util.ResourceLoaderBase; import org.eclipse.openk.gridfailureinformation.viewmodel.geojson.StationGeoJson; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -48,7 +47,7 @@ public class ImportGeoJsonService { this.objectMapper = objectMapper; } - @Bean + @PostConstruct public void initImportGeoJsonService(){ log.info("init initImportGeoJsonService"); pattern = Pattern.compile(filePattern); @@ -62,6 +61,7 @@ public class ImportGeoJsonService { Matcher matcher = pattern.matcher(stringToTest); return matcher.matches(); } + @Transactional public void importGeoJsonFile() { ResourceLoaderBase resourceLoader = new ResourceLoaderBase(); diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/RadiusService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/RadiusService.java index 3f7f8663..f319d6b5 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/RadiusService.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/RadiusService.java @@ -36,7 +36,7 @@ public class RadiusService { public List<RadiusDto> getRadii() { return radiusRepository.findAll().stream() - .map( radiusMapper::toRadiusDto ) + .map(radiusMapper::toRadiusDto) .collect(Collectors.toList()); } diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/StationService.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/StationService.java index 8abdb8da..8cec0585 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/StationService.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/service/StationService.java @@ -20,9 +20,9 @@ import org.eclipse.openk.gridfailureinformation.repository.AddressRepository; import org.eclipse.openk.gridfailureinformation.repository.StationRepository; import org.eclipse.openk.gridfailureinformation.viewmodel.StationDto; import org.eclipse.openk.gridfailureinformation.viewmodel.StationPolygonDto; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.UUID; @@ -49,15 +49,14 @@ public class StationService { public List<StationDto> getStations() { return stationRepository.findAll().stream() .map(stationMapper::toStationDto) - .sorted( (x, y) -> (x.getStationName()+"@"+ x.getStationId()) - .compareTo(y.getStationName()+"@"+y.getStationId())) + .sorted(Comparator.comparing(x -> (x.getStationName() + "@" + x.getStationId()))) .collect(Collectors.toList()); } public StationDto getStationsById(String stationId) { Optional<TblStation> tblStation = stationRepository.findByStationId(stationId); - if( tblStation.isPresent()) { + if (tblStation.isPresent()) { return stationMapper.toStationDto(tblStation.get()); } return null; @@ -77,7 +76,7 @@ public class StationService { .findByUuid(station) .orElse(null); if (tblStation != null) { - count += addressRepository.findByStationId(tblStation.getStationId() + "").size(); + count += addressRepository.findByStationId(tblStation.getStationId()).size(); } } diff --git a/gfsBackendService/src/main/resources/application.yml b/gfsBackendService/src/main/resources/application.yml index b0fe1247..40e96528 100644 --- a/gfsBackendService/src/main/resources/application.yml +++ b/gfsBackendService/src/main/resources/application.yml @@ -517,7 +517,6 @@ spring: url: jdbc:postgresql://localhost:5432/GridFailureInfoDevServer username: ${GFI_DB_USERNAME} password: ${GFI_DB_PASSWORD} - max-active: 5 flyway: enabled: false main: @@ -571,7 +570,7 @@ spring: dataExternInitialVisibility: hide #dataExternInitialVisibility: show - mapTileAttribution: "© <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>" + mapTileAttribution: "© <a href=\"https://www.openstreetmap.org/copyright\">OpenStreetMap</a>" mapTileLayerUrl: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" #mapTileLayerUrl: "http://company1.wms.omniscale.net/mapproxy/service?" #mapWmsLayer: "osm" @@ -723,7 +722,7 @@ services: moduleName: Störungsinformationstool sitCache: name: sitCacheService - url: http://localhost:8080 + url: http://localhost:3000 #feLoginURL: http://entdockergss:4223 feLoginURL: diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/config/TestConfiguration.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/config/TestConfiguration.java index 93f685ad..98d3f7a6 100644 --- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/config/TestConfiguration.java +++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/config/TestConfiguration.java @@ -189,8 +189,7 @@ public class TestConfiguration { distributionGroupRepository, distributionGroupAllowedRepository, Mappers.getMapper(DistributionGroupMapper.class), - distributionGroupMemberRepository, - distributionGroupAllowedRepository + distributionGroupMemberRepository ); } diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/DistributionGroupMemberControllerTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/DistributionGroupMemberControllerTest.java index bdfc730e..39424b60 100644 --- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/DistributionGroupMemberControllerTest.java +++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/controller/DistributionGroupMemberControllerTest.java @@ -24,9 +24,11 @@ import org.eclipse.openk.gridfailureinformation.support.MockDataHelper; import org.eclipse.openk.gridfailureinformation.viewmodel.DistributionGroupMemberDto; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.core.io.Resource; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -57,13 +59,16 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @ContextConfiguration(classes = {TestConfiguration.class}) @ActiveProfiles("test") class DistributionGroupMemberControllerTest { - @Autowired + @Mock private DistributionGroupRepository distributionGroupRepository; - @Autowired - @SpyBean + @Spy + @InjectMocks private DistributionGroupMemberService distributionGroupMemberService; + @Autowired + private ObjectMapper objectMapper; + private static MockMvc mockMvc; @BeforeEach @@ -124,10 +129,10 @@ class DistributionGroupMemberControllerTest { when(distributionGroupRepository.findByUuid(any())).thenReturn(Optional.of(tblDistributionGroup)); doReturn(memberDto).when(distributionGroupMemberService).insertDistributionGroupMember(any(), any()); - mockMvc.perform(post("/distribution-groups/{groupUuid}/members/", memberDto.getDistributionGroupUuid().toString()) + mockMvc.perform(post("/distribution-groups/{groupUuid}/members", memberDto.getDistributionGroupUuid()) .contentType(MediaType.APPLICATION_JSON) - .content(new ObjectMapper().writeValueAsString(memberDto))) - .andExpect(jsonPath("$.contactId", is(memberDto.getContactId().toString()))) + .content(objectMapper.writeValueAsString(memberDto))) + .andExpect(jsonPath("contactId", is(memberDto.getContactId().toString()))) .andExpect(status().is2xxSuccessful()); } @@ -139,7 +144,7 @@ class DistributionGroupMemberControllerTest { mockMvc.perform(put("/distribution-groups/{groupUuid}/members/{uuid}", memberDto.getDistributionGroupUuid().toString(), memberDto.getUuid().toString()) .contentType(MediaType.APPLICATION_JSON) - .content(new ObjectMapper().writeValueAsString(memberDto))) + .content(objectMapper.writeValueAsString(memberDto))) .andExpect(status().is2xxSuccessful()); } @@ -152,7 +157,7 @@ class DistributionGroupMemberControllerTest { mockMvc.perform(put("/distribution-groups/{groupUuid}/members/{uuid}", UUID.randomUUID().toString(), UUID.randomUUID().toString()) .contentType(MediaType.APPLICATION_JSON) - .content(new ObjectMapper().writeValueAsString(memberDto))) + .content(objectMapper.writeValueAsString(memberDto))) .andExpect(status().isBadRequest()); } diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/EmailServiceTest.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/EmailServiceTest.java index 279d2673..9e2626f7 100644 --- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/EmailServiceTest.java +++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/service/EmailServiceTest.java @@ -38,6 +38,7 @@ import jakarta.mail.MessagingException; import jakarta.mail.internet.MimeMessage; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -103,15 +104,17 @@ public class EmailServiceTest { mailServer.stop(); emailConfig.setUseHtmlEmailTemplate(false); RabbitMqMessageDto mailMessageDto = MockDataHelper.mockMailMessageDto(); + assertFalse(mailServer.isRunning()); assertThrows(MessagingException.class, () -> emailService.sendMail(mailMessageDto)); } @Test public void testSendMail_invalidRecipient(CapturedOutput output) throws MessagingException { RabbitMqMessageDto mailMessageDto = MockDataHelper.mockMailMessageDtoWrongRecipientFormat(); + emailService.sendMail(mailMessageDto); - String out = output.getOut(); - assertTrue(output.getOut().contains("Invalid email-addresse: " + mailMessageDto.getMailAddresses().get(0))); + + assertTrue(output.getOut().contains("Invalid email-address: " + mailMessageDto.getMailAddresses().getFirst())); } @Test diff --git a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/support/MockDataHelper.java b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/support/MockDataHelper.java index 61a4cf1a..edcd4f2a 100644 --- a/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/support/MockDataHelper.java +++ b/gfsBackendService/src/test/java/org/eclipse/openk/gridfailureinformation/support/MockDataHelper.java @@ -75,7 +75,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Calendar; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.UUID; @@ -105,7 +104,7 @@ public class MockDataHelper { dto.setUuid(UUID.randomUUID()); dto.setStatusInternId(UUID.randomUUID()); dto.setVersionNumber(3L); - dto.setResponsibility("Vatter Abraham"); + dto.setResponsibility("Vater Abraham"); dto.setVoltageLevel(Constants.VOLTAGE_LEVEL_MS); dto.setPressureLevel(Constants.PRESSURE_LEVEL_HD); dto.setFailureBegin(new java.util.Date(Date.valueOf("2022-12-01").getTime())); @@ -163,7 +162,7 @@ public class MockDataHelper { obj.setId(22L); obj.setUuid(UUID.randomUUID()); obj.setVersionNumber(4L); - obj.setResponsibility("Vatter Abraham"); + obj.setResponsibility("Vater Abraham"); obj.setVoltageLevel(Constants.VOLTAGE_LEVEL_MS); obj.setPressureLevel(Constants.PRESSURE_LEVEL_HD); @@ -177,7 +176,7 @@ public class MockDataHelper { obj.setFailureEndPlanned(date2); obj.setFailureEndResupplied(date3); } - catch(Exception e){ + catch (Exception e){ log.warn("Fehler beim Erstellen von Daten mit DateFormat"); } @@ -275,7 +274,7 @@ public class MockDataHelper { obj.setId(22L); obj.setUuid(UUID.randomUUID()); obj.setVersionNumber(4L); - obj.setResponsibility("Vatter Mousa"); + obj.setResponsibility("Vater Mousa"); obj.setVoltageLevel(Constants.VOLTAGE_LEVEL_NS); obj.setPressureLevel(Constants.PRESSURE_LEVEL_MD); @@ -377,18 +376,18 @@ public class MockDataHelper { public static Page<TblFailureInformation> mockTblFailureInformationPage() { - List<TblFailureInformation> retList = new LinkedList<>(); - retList.add( mockTblFailureInformation() ); - retList.add( mockTblFailureInformation() ); + List<TblFailureInformation> retList = new ArrayList<>(); + retList.add(mockTblFailureInformation()); + retList.add(mockTblFailureInformation()); retList.get(1).setResponsibility("Lionel Lümmelprinz"); return new PageImpl<>(retList, Pageable.unpaged(), retList.size()); } public static List<FailureInformationDto> mockGridFailureInformationDtos() { - List<FailureInformationDto> retList = new LinkedList<>(); - retList.add( mockFailureInformationDto() ); - retList.add( mockFailureInformationDto() ); + List<FailureInformationDto> retList = new ArrayList<>(); + retList.add(mockFailureInformationDto()); + retList.add(mockFailureInformationDto()); retList.get(1).setBranch("W"); //retList.get(1).setStatusExtern("IN_WORK"); retList.get(1).setStatusIntern("IN_WORK"); @@ -694,7 +693,7 @@ public class MockDataHelper { } public static List<HtblFailureInformation> mockHistTblFailureInformationList() { - List<HtblFailureInformation> retList = new LinkedList<>(); + List<HtblFailureInformation> retList = new ArrayList<>(); retList.add( mockHistTblFailureInformation() ); retList.add( mockHistTblFailureInformation2() ); return retList; @@ -801,7 +800,7 @@ public class MockDataHelper { } public static List<FailureInformationDto> mockHistGridFailureInformationDtoList() { - List<FailureInformationDto> retList = new LinkedList<>(); + List<FailureInformationDto> retList = new ArrayList<>(); retList.add( mockHistFailureInformationDto() ); retList.add( mockHistFailureInformationDto2() ); return retList; @@ -1163,7 +1162,7 @@ public class MockDataHelper { public static List<TblStation> mockTblStationList(){ - List<TblStation> stationList = new LinkedList(); + List<TblStation> stationList = new ArrayList<>(); stationList.add(mockTblStation()); stationList.add(mockTblStation2()); return stationList; @@ -1562,7 +1561,7 @@ public class MockDataHelper { } public static List<String> mockPublicationChannelList(){ - List<String> publicationChannels= new LinkedList<String>(); + List<String> publicationChannels= new ArrayList<String>(); publicationChannels.add("MOCKMAIL"); publicationChannels.add("MOCKSMS"); publicationChannels.add("MOCKXY"); @@ -1605,7 +1604,7 @@ public class MockDataHelper { } public static List<TblFailureInformationPublicationChannel> mockTblFailureInformationPublicationChannelList(){ - List<TblFailureInformationPublicationChannel> channelList = new LinkedList<>(); + List<TblFailureInformationPublicationChannel> channelList = new ArrayList<>(); channelList.add(mockTblFailureInformationPublicationChannel()); channelList.add(mockTblFailureInformationPublicationChannel2()); @@ -1613,7 +1612,7 @@ public class MockDataHelper { } public static List<FailureInformationPublicationChannelDto> mockFailureInformationPublicationChanneDtolList(){ - List<FailureInformationPublicationChannelDto> channelList = new LinkedList<>(); + List<FailureInformationPublicationChannelDto> channelList = new ArrayList<>(); channelList.add(mockFailureInformationPublicationChannelDto()); channelList.add(mockFailureInformationPublicationChannelDto2()); @@ -1638,7 +1637,7 @@ public class MockDataHelper { public static List<List<BigDecimal>> mockPolygonCoordinatesList(){ - List<List<BigDecimal>> cordinatesList = new LinkedList<>(); + List<List<BigDecimal>> cordinatesList = new ArrayList<>(); List<BigDecimal> firstCoordinate = new ArrayList<>(); firstCoordinate.add(new BigDecimal("53.5")); diff --git a/mailExport/.gitignore b/mailExport/.gitignore index 22921f07..7f3a0b67 100644 --- a/mailExport/.gitignore +++ b/mailExport/.gitignore @@ -3,6 +3,7 @@ target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/** !**/src/test/** +.env.* ### STS ### .apt_generated diff --git a/mailExport/pom.xml b/mailExport/pom.xml index 1d18184d..1f2d02f3 100644 --- a/mailExport/pom.xml +++ b/mailExport/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>3.2.4</version> + <version>3.4.3</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>org.eclipse.openk</groupId> @@ -35,21 +35,13 @@ <disable.xml.report>true</disable.xml.report> <surefire.useFile>false</surefire.useFile> - <spring-cloud.version>2023.0.0</spring-cloud.version> + <spring-cloud.version>2024.0.0</spring-cloud.version> <powerMockReflect.version>2.0.9</powerMockReflect.version> <sonar-maven-plugin.version>3.2</sonar-maven-plugin.version> <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version> - <asciidoctor-maven-plugin-version>1.5.3</asciidoctor-maven-plugin-version> - <asciidoctorj-pdf-version>1.5.0-alpha.11</asciidoctorj-pdf-version> - <asciidoctorj-version>1.5.4</asciidoctorj-version> - <asciidoctorj-diagram-versions>1.5.4.1</asciidoctorj-diagram-versions> <mapstruct.version>1.5.5.Final</mapstruct.version> - <flyway-core.version>10.10.0</flyway-core.version> - <postgresql.version>42.7.3</postgresql.version> - <jsonwebtoken.version>0.9.1</jsonwebtoken.version> - <openfeign.version>4.1.0</openfeign.version> - <keycloak-core.version>24.0.2</keycloak-core.version> - <rabbitmq.version>5.20.0</rabbitmq.version> + <openfeign.version>4.2.0</openfeign.version> + <rabbitmq.version>5.21.0</rabbitmq.version> </properties> <dependencies> @@ -130,6 +122,22 @@ <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> <version>${openfeign.version}</version> + <exclusions> + <exclusion> + <groupId>org.bouncycastle</groupId> + <artifactId>bcprov-jdk18on</artifactId> + </exclusion> + <exclusion> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.16.1</version> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> @@ -154,7 +162,6 @@ <artifactId>jakarta.mail-api</artifactId> <version>2.1.3</version> </dependency> - </dependencies> <dependencyManagement> diff --git a/stoerungsauskunftInterface/.gitignore b/stoerungsauskunftInterface/.gitignore index 22921f07..7f3a0b67 100644 --- a/stoerungsauskunftInterface/.gitignore +++ b/stoerungsauskunftInterface/.gitignore @@ -3,6 +3,7 @@ target/ !.mvn/wrapper/maven-wrapper.jar !**/src/main/** !**/src/test/** +.env.* ### STS ### .apt_generated diff --git a/stoerungsauskunftInterface/pom.xml b/stoerungsauskunftInterface/pom.xml index d8e71605..5793fbd0 100644 --- a/stoerungsauskunftInterface/pom.xml +++ b/stoerungsauskunftInterface/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>3.2.4</version> + <version>3.4.3</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>org.eclipse.openk</groupId> @@ -36,7 +36,7 @@ <disable.xml.report>true</disable.xml.report> <surefire.useFile>false</surefire.useFile> - <spring-cloud.version>2023.0.0</spring-cloud.version> + <spring-cloud.version>2024.0.0</spring-cloud.version> <powerMockReflect.version>2.0.9</powerMockReflect.version> <sonar-maven-plugin.version>3.2</sonar-maven-plugin.version> <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version> @@ -48,9 +48,9 @@ <mapstruct.version>1.5.5.Final</mapstruct.version> <flyway-core.version>10.10.0</flyway-core.version> <postgresql.version>42.7.3</postgresql.version> - <openfeign.version>4.1.0</openfeign.version> - <keycloak-core.version>24.0.2</keycloak-core.version> - <rabbitmq.version>5.20.0</rabbitmq.version> + <openfeign.version>4.2.0</openfeign.version> + <keycloak-core.version>26.0.8</keycloak-core.version> + <rabbitmq.version>5.21.0</rabbitmq.version> </properties> <dependencies> @@ -138,6 +138,22 @@ <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> <version>${openfeign.version}</version> + <exclusions> + <exclusion> + <groupId>org.bouncycastle</groupId> + <artifactId>bcprov-jdk18on</artifactId> + </exclusion> + <exclusion> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>2.16.1</version> </dependency> <dependency> @@ -145,11 +161,16 @@ <artifactId>spring-cloud-contract-wiremock</artifactId> <scope>test</scope> </dependency> - + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-properties-migrator</artifactId> + <scope>runtime</scope> + </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-stream-test-support</artifactId> <scope>test</scope> + <version>4.2.0</version> </dependency> <dependency> diff --git a/stoerungsauskunftInterface/src/main/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/service/ImportExportService.java b/stoerungsauskunftInterface/src/main/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/service/ImportExportService.java index 06dc16cd..c8d2f690 100644 --- a/stoerungsauskunftInterface/src/main/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/service/ImportExportService.java +++ b/stoerungsauskunftInterface/src/main/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/service/ImportExportService.java @@ -63,7 +63,6 @@ public class ImportExportService { } public void importUserNotifications() { - List<StoerungsauskunftUserNotification> userNotificationList = stoerungsauskunftApi.getUserNotification(1); diff --git a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/config/ImportSchedulerConfigTest.java b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/config/ImportSchedulerConfigTest.java index 0e704085..e24e76c0 100644 --- a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/config/ImportSchedulerConfigTest.java +++ b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/config/ImportSchedulerConfigTest.java @@ -21,6 +21,7 @@ import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.api.Stoer import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.dtos.StoerungsauskunftUserNotification; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.service.ImportExportService; import org.junit.jupiter.api.Test; +import org.mockito.Mock; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.SpyBean; @@ -45,7 +46,7 @@ public class ImportSchedulerConfigTest { @SpyBean private ImportExportService importExportService; - @Autowired + @Mock private StoerungsauskunftApi stoerungsauskunftApi; @Autowired @@ -55,7 +56,7 @@ public class ImportSchedulerConfigTest { private ObjectMapper objectMapper; @Test - public void shoulImportUserNotification() throws IOException { + public void shouldImportUserNotification() throws IOException { InputStream is = new ClassPathResource("UsernotificationJsonResponse.json").getInputStream(); List<StoerungsauskunftUserNotification> userNotificationList = objectMapper.readValue(is, new TypeReference<>() { @@ -63,6 +64,7 @@ public class ImportSchedulerConfigTest { when(stoerungsauskunftApi.getUserNotification(any(Integer.class))).thenReturn(userNotificationList); importSchedulerConfig.scheduleTaskImportUserNotifications(); + verify(importExportService, times(1)).importUserNotifications(); } } diff --git a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/config/TestConfiguration.java b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/config/TestConfiguration.java index 8abd12c0..8552ada4 100644 --- a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/config/TestConfiguration.java +++ b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/config/TestConfiguration.java @@ -15,7 +15,6 @@ package org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.config; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.rabbitmq.client.Channel; import feign.Request; @@ -24,12 +23,9 @@ import feign.Response; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.StoerungsauskunftInterfaceApplication; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.api.StoerungsauskunftApi; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.config.rabbitMq.RabbitMqConfig; -import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.dtos.StoerungsauskunftOutage; -import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.dtos.StoerungsauskunftUserNotification; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.mapper.StoerungsauskunftMapper; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.mapper.StoerungsauskunftMapperImpl; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.service.ImportExportService; -import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.support.MockDataHelper; import org.mapstruct.factory.Mappers; import org.springframework.amqp.rabbit.connection.Connection; import org.springframework.amqp.rabbit.connection.ConnectionFactory; @@ -37,14 +33,11 @@ import org.springframework.amqp.rabbit.test.TestRabbitTemplate; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.context.annotation.Bean; -import org.springframework.core.io.ClassPathResource; import org.springframework.messaging.MessageChannel; +import org.springframework.test.context.TestPropertySource; -import java.io.IOException; -import java.io.InputStream; import java.util.Collection; import java.util.HashMap; -import java.util.List; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.BDDMockito.given; @@ -53,6 +46,8 @@ import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; @EntityScan(basePackageClasses = StoerungsauskunftInterfaceApplication.class) +@org.springframework.boot.test.context.TestConfiguration +@TestPropertySource(locations = "classpath:application-test.yml") public class TestConfiguration { @Bean public ObjectMapper objectMapper() { return new ObjectMapper(); } diff --git a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/controller/ImportExportControllerTest.java b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/controller/ImportExportControllerTest.java index 7875228c..e9564b2a 100644 --- a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/controller/ImportExportControllerTest.java +++ b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/controller/ImportExportControllerTest.java @@ -16,7 +16,6 @@ package org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.controll import com.fasterxml.jackson.databind.ObjectMapper; import feign.Response; -import lombok.With; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.StoerungsauskunftInterfaceApplication; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.api.StoerungsauskunftApi; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.config.SecurityConfig; @@ -27,18 +26,10 @@ import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.support.M import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.SpyBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; import org.springframework.http.MediaType; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.test.context.support.WithAnonymousUser; import org.springframework.security.test.context.support.WithMockUser; -import org.springframework.security.web.SecurityFilterChain; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.web.servlet.MockMvc; @@ -48,6 +39,7 @@ import org.springframework.web.context.WebApplicationContext; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.Mockito.never; +import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -77,6 +69,7 @@ public class ImportExportControllerTest { @BeforeEach public void init() { + reset(importExportService); mockMvc = MockMvcBuilders .webAppContextSetup(context) .apply(springSecurity()) diff --git a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/service/ImportExportServiceTest.java b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/service/ImportExportServiceTest.java index 099da776..663ab1cf 100644 --- a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/service/ImportExportServiceTest.java +++ b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/service/ImportExportServiceTest.java @@ -25,12 +25,16 @@ import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.dtos.Fore import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.dtos.RabbitMqMessageDto; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.dtos.StoerungsauskunftUserNotification; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.exceptions.InternalServerErrorException; +import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.mapper.StoerungsauskunftMapperImpl; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.support.MockDataHelper; import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Spy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.core.io.ClassPathResource; +import org.springframework.messaging.MessageChannel; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; @@ -42,37 +46,49 @@ import java.util.List; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyList; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; @SpringBootTest(classes = StoerungsauskunftInterfaceApplication.class) @ContextConfiguration(classes = {TestConfiguration.class}) @ActiveProfiles("test") public class ImportExportServiceTest { - @Autowired - private ImportExportService importExportService; + @Mock + private StoerungsauskunftApi stoerungsauskunftApi; - @Autowired + @Spy private ObjectMapper objectMapper; + @Spy + private StoerungsauskunftMapperImpl stoerungsauskunftMapper; + + @Mock + private MessageChannel messageChannel; + + @Spy + @InjectMocks + private ImportExportService importExportService; + @Autowired private Response testResponse; - @SpyBean - private StoerungsauskunftApi stoerungsauskunftApi; - @Test public void shouldImportUserNotification() throws IOException { - ImportExportService importExportServicSpy = spy(importExportService); - InputStream is = new ClassPathResource("UsernotificationJsonResponse.json").getInputStream(); List<StoerungsauskunftUserNotification> userNotificationList = objectMapper.readValue(is, new TypeReference<>() { }); when(stoerungsauskunftApi.getUserNotification(anyInt())).thenReturn(userNotificationList); - importExportServicSpy.importUserNotifications(); + importExportService.importUserNotifications(); - verify(importExportServicSpy, times(userNotificationList.size())).pushForeignFailure(any(ForeignFailureMessageDto.class)); + verify(importExportService, times(userNotificationList.size())).pushForeignFailure(any(ForeignFailureMessageDto.class)); } @Test @@ -129,16 +145,14 @@ public class ImportExportServiceTest { @Test public void shouldImportUserNotificationMapperTest1() throws IOException { - ImportExportService importExportServicSpy = spy(importExportService); - InputStream is = new ClassPathResource("UsernotificationJsonResponse.json").getInputStream(); List<StoerungsauskunftUserNotification> userNotificationList = objectMapper.readValue(is, new TypeReference<>() { }); when(stoerungsauskunftApi.getUserNotification(anyInt())).thenReturn(userNotificationList); - importExportServicSpy.importUserNotifications(); + importExportService.importUserNotifications(); - verify(importExportServicSpy, times(userNotificationList.size())).pushForeignFailure(any(ForeignFailureMessageDto.class)); + verify(importExportService, times(userNotificationList.size())).pushForeignFailure(any(ForeignFailureMessageDto.class)); } } diff --git a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/service/MessageConsumerServiceTest.java b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/service/MessageConsumerServiceTest.java index 90283439..11f64c80 100644 --- a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/service/MessageConsumerServiceTest.java +++ b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/service/MessageConsumerServiceTest.java @@ -23,20 +23,18 @@ import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.config.Te import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.dtos.RabbitMqMessageDto; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.support.MockDataHelper; import org.junit.jupiter.api.Test; +import org.mockito.Mock; import org.springframework.amqp.rabbit.test.RabbitListenerTest; -import org.springframework.amqp.rabbit.test.RabbitListenerTestHarness; import org.springframework.amqp.rabbit.test.TestRabbitTemplate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.bean.override.mockito.MockitoBean; +import org.springframework.test.context.bean.override.mockito.MockitoSpyBean; -import java.text.ParseException; - -import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyList; @@ -62,7 +60,7 @@ public class MessageConsumerServiceTest { @Autowired private Response testResponse; - @SpyBean + @Mock private StoerungsauskunftApi stoerungsauskunftApi; @Value("${spring.rabbitmq.exportQueue}") diff --git a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/support/MockDataHelper.java b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/support/MockDataHelper.java index cc19b039..6deb7e90 100644 --- a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/support/MockDataHelper.java +++ b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/support/MockDataHelper.java @@ -14,7 +14,6 @@ */ package org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.support; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.lang3.RandomStringUtils; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.constants.Constants; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.dtos.FailureInformationDto; @@ -22,7 +21,6 @@ import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.dtos.Fore import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.dtos.ForeignFailureMessageDto; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.dtos.RabbitMqMessageDto; import org.eclipse.openk.gridfailureinformation.stoerauskunftinterface.dtos.StoerungsauskunftUserNotification; -import org.springframework.beans.factory.annotation.Autowired; import java.math.BigDecimal; import java.sql.Date; @@ -31,11 +29,9 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import java.util.Random; import java.util.UUID; public class MockDataHelper { - private static final SimpleDateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); private MockDataHelper() {} diff --git a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/util/ResourceLoaderBase.java b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/util/ResourceLoaderBase.java index 01b2455c..8d8bb75a 100644 --- a/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/util/ResourceLoaderBase.java +++ b/stoerungsauskunftInterface/src/test/java/org/eclipse/openk/gridfailureinformation/stoerauskunftinterface/util/ResourceLoaderBase.java @@ -73,7 +73,7 @@ public class ResourceLoaderBase { public String loadFromPath(String path) { try { Path paths = Paths.get(path); - log.debug("paths: " + path); + log.debug("paths: {}", path); try (InputStream inputStream = Files.newInputStream(paths)) { return stream2String(inputStream, paths.getFileName().toString()); } diff --git a/testImportGridFailures/pom.xml b/testImportGridFailures/pom.xml index 5c10e9b6..9ce195ae 100644 --- a/testImportGridFailures/pom.xml +++ b/testImportGridFailures/pom.xml @@ -19,7 +19,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>3.2.4</version> + <version>3.4.3</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>org.eclipse.openk</groupId> @@ -36,22 +36,12 @@ <skip.asciidoc>false</skip.asciidoc> <maven.test.skip>false</maven.test.skip> - <spring-cloud.version>2023.0.0</spring-cloud.version> - <spring-security-test.version>5.2.1.RELEASE</spring-security-test.version> <springdoc.version>2.4.0</springdoc.version> <powerMockReflect.version>2.0.9</powerMockReflect.version> <sonar-maven-plugin.version>3.2</sonar-maven-plugin.version> <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version> - <asciidoctor-maven-plugin-version>1.5.3</asciidoctor-maven-plugin-version> - <asciidoctorj-pdf-version>1.5.0-alpha.11</asciidoctorj-pdf-version> - <asciidoctorj-version>1.5.4</asciidoctorj-version> - <asciidoctorj-diagram-versions>1.5.4.1</asciidoctorj-diagram-versions> <mapstruct.version>1.5.5.Final</mapstruct.version> - <flyway-core.version>10.10.0</flyway-core.version> - <postgresql.version>42.7.3</postgresql.version> - <openfeign.version>4.1.0</openfeign.version> - <keycloak-core.version>24.0.2</keycloak-core.version> - <rabbitmq.version>5.20.0</rabbitmq.version> + <rabbitmq.version>5.21.0</rabbitmq.version> </properties> <dependencies> <dependency> -- GitLab From 44ac14817bec16d1caa3859da6c6eec0973c13c4 Mon Sep 17 00:00:00 2001 From: Lukas Freesemann <lukas.freesemann@worldiety.de> Date: Fri, 28 Feb 2025 22:41:32 +0100 Subject: [PATCH 2/2] WO-192 update rabbitmq and cyclonedx --- SAMO-Interface/pom.xml | 34 ++- SARIS-Interface/pom.xml | 30 +- addressImport/pom.xml | 18 +- gfsBackendService/pom.xml | 279 ++++++------------ .../config/RestTemplateConfig.java | 12 +- mailExport/pom.xml | 29 +- stoerungsauskunftInterface/pom.xml | 28 +- testImportGridFailures/pom.xml | 16 +- 8 files changed, 229 insertions(+), 217 deletions(-) diff --git a/SAMO-Interface/pom.xml b/SAMO-Interface/pom.xml index 4d5a18d9..9742accb 100644 --- a/SAMO-Interface/pom.xml +++ b/SAMO-Interface/pom.xml @@ -38,8 +38,8 @@ <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version> <mapstruct.version>1.5.5.Final</mapstruct.version> <openfeign.version>4.2.0</openfeign.version> - <rabbitmq.version>5.21.0</rabbitmq.version> - <cyclonedx.version>2.9.0</cyclonedx.version> + <rabbitmq.version>5.22.0</rabbitmq.version> + <cyclonedx.version>2.9.1</cyclonedx.version> <springdoc.version>2.4.0</springdoc.version> </properties> @@ -65,6 +65,12 @@ <groupId>org.springframework.integration</groupId> <artifactId>spring-integration-sftp</artifactId> <version>6.3.7</version> + <exclusions> + <exclusion> + <artifactId>commons-io</artifactId> + <groupId>commons-io</groupId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.springframework.batch</groupId> @@ -113,6 +119,24 @@ <groupId>org.cyclonedx</groupId> <artifactId>cyclonedx-maven-plugin</artifactId> <version>${cyclonedx.version}</version> + <exclusions> + <exclusion> + <artifactId>maven-dependency-analyzer</artifactId> + <groupId>org.apache.maven.shared</groupId> + </exclusion> + <exclusion> + <artifactId>cyclonedx-core-java</artifactId> + <groupId>org.cyclonedx</groupId> + </exclusion> + <exclusion> + <artifactId>maven-resolver-api</artifactId> + <groupId>org.apache.maven.resolver</groupId> + </exclusion> + <exclusion> + <artifactId>maven-resolver-util</artifactId> + <groupId>org.apache.maven.resolver</groupId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.mapstruct</groupId> @@ -172,6 +196,12 @@ <artifactId>powermock-reflect</artifactId> <version>${powerMockReflect.version}</version> <scope>test</scope> + <exclusions> + <exclusion> + <artifactId>objenesis</artifactId> + <groupId>org.objenesis</groupId> + </exclusion> + </exclusions> </dependency> </dependencies> diff --git a/SARIS-Interface/pom.xml b/SARIS-Interface/pom.xml index 52d45946..cf77356f 100644 --- a/SARIS-Interface/pom.xml +++ b/SARIS-Interface/pom.xml @@ -24,8 +24,8 @@ <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version> <mapstruct.version>1.5.5.Final</mapstruct.version> <openfeign.version>4.2.0</openfeign.version> - <rabbitmq.version>5.21.0</rabbitmq.version> - <cyclonedx.version>2.9.0</cyclonedx.version> + <rabbitmq.version>5.22.0</rabbitmq.version> + <cyclonedx.version>2.9.1</cyclonedx.version> <springdoc.version>2.4.0</springdoc.version> </properties> @@ -86,7 +86,7 @@ <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> - <version>${springdoc.version}</version + <version>${springdoc.version}</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> @@ -129,6 +129,24 @@ <groupId>org.cyclonedx</groupId> <artifactId>cyclonedx-maven-plugin</artifactId> <version>${cyclonedx.version}</version> + <exclusions> + <exclusion> + <artifactId>maven-dependency-analyzer</artifactId> + <groupId>org.apache.maven.shared</groupId> + </exclusion> + <exclusion> + <artifactId>commons-io</artifactId> + <groupId>commons-io</groupId> + </exclusion> + <exclusion> + <artifactId>maven-resolver-api</artifactId> + <groupId>org.apache.maven.resolver</groupId> + </exclusion> + <exclusion> + <artifactId>maven-resolver-util</artifactId> + <groupId>org.apache.maven.resolver</groupId> + </exclusion> + </exclusions> </dependency> <!-- test dependencies --> <!-- spring --> @@ -177,6 +195,12 @@ <artifactId>powermock-reflect</artifactId> <version>${powerMockReflect.version}</version> <scope>test</scope> + <exclusions> + <exclusion> + <artifactId>objenesis</artifactId> + <groupId>org.objenesis</groupId> + </exclusion> + </exclusions> </dependency> </dependencies> diff --git a/addressImport/pom.xml b/addressImport/pom.xml index 094168ee..dfb072f4 100644 --- a/addressImport/pom.xml +++ b/addressImport/pom.xml @@ -39,12 +39,12 @@ <mapstruct.version>1.5.5.Final</mapstruct.version> <postgresql.version>42.7.3</postgresql.version> - <rabbitmq.version>5.20.0</rabbitmq.version> - <cyclonedx.version>2.9.0</cyclonedx.version> + <rabbitmq.version>5.22.0</rabbitmq.version> + <cyclonedx.version>2.9.1</cyclonedx.version> <springdoc.version>2.4.0</springdoc.version> <opencsv.version>5.9</opencsv.version> <oracle-database.version>19.6.0.0</oracle-database.version> - <hibernate.version>6.3.1.Final</hibernate.version> + <hibernate.version>6.6.9.Final</hibernate.version> </properties> <dependencies> <!-- spring --> @@ -130,6 +130,12 @@ <groupId>org.cyclonedx</groupId> <artifactId>cyclonedx-maven-plugin</artifactId> <version>${cyclonedx.version}</version> + <exclusions> + <exclusion> + <artifactId>maven-dependency-analyzer</artifactId> + <groupId>org.apache.maven.shared</groupId> + </exclusion> + </exclusions> </dependency> <!-- test dependencies --> <!-- spring --> @@ -158,6 +164,12 @@ <artifactId>powermock-reflect</artifactId> <version>${powerMockReflect.version}</version> <scope>test</scope> + <exclusions> + <exclusion> + <artifactId>objenesis</artifactId> + <groupId>org.objenesis</groupId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>com.h2database</groupId> diff --git a/gfsBackendService/pom.xml b/gfsBackendService/pom.xml index 108a9ac6..67fde087 100644 --- a/gfsBackendService/pom.xml +++ b/gfsBackendService/pom.xml @@ -42,9 +42,18 @@ <postgresql.version>42.7.3</postgresql.version> <openfeign.version>4.2.0</openfeign.version> <keycloak-core.version>26.0.8</keycloak-core.version> - <rabbitmq.version>5.21.0</rabbitmq.version> - <cyclonedx.version>2.9.0</cyclonedx.version> + <rabbitmq.version>5.22.0</rabbitmq.version> + <cyclonedx.version>2.9.1</cyclonedx.version> <springdoc.version>2.4.0</springdoc.version> + <oracle-database.version>19.6.0.0</oracle-database.version> + <jakarta.mail.version>2.0.1</jakarta.mail.version> + <greenmail.version>2.0.1</greenmail.version> + <reflections.version>0.9.12</reflections.version> + <dependency-check-maven.version>12.1.0</dependency-check-maven.version> + <plexus-utils.version>4.0.2</plexus-utils.version> + <maven-core.version>3.9.9</maven-core.version> + <spring-context.version>6.2.3</spring-context.version> + <google-guava.version>33.2.1-jre</google-guava.version> </properties> <dependencies> <!-- spring--> @@ -62,13 +71,7 @@ <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> - <version>6.2.1</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context-support</artifactId> - <version>6.2.1</version> - <scope>test</scope> + <version>${spring-context.version}</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> @@ -153,12 +156,6 @@ </exclusion> </exclusions> </dependency> - <!-- https://mvnrepository.com/artifact/commons-io/commons-io --> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>2.16.1</version> - </dependency> <!-- manually import updated excluded dependencies --> <!-- https://mvnrepository.com/artifact/org.bouncycastle/bcprov-jdk18on --> <dependency> @@ -213,33 +210,57 @@ <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> - <version>33.1.0-jre</version> + <version>${google-guava.version}</version> <exclusions> <exclusion> - <groupId>com.google.errorprone</groupId> <artifactId>error_prone_annotations</artifactId> + <groupId>com.google.errorprone</groupId> </exclusion> </exclusions> </dependency> - <dependency> - <groupId>com.oracle.database.jdbc</groupId> - <artifactId>ojdbc8</artifactId> - <version>19.6.0.0</version> - </dependency> <dependency> <groupId>com.oracle.database.jdbc</groupId> <artifactId>ucp</artifactId> - <version>19.6.0.0</version> + <version>${oracle-database.version}</version> + </dependency> + <dependency> + <groupId>com.oracle.database.jdbc</groupId> + <artifactId>ojdbc8</artifactId> + <version>${oracle-database.version}</version> + </dependency> + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <version>${h2.version}</version> + </dependency> + <dependency> + <groupId>org.cyclonedx</groupId> + <artifactId>cyclonedx-maven-plugin</artifactId> + <version>${cyclonedx.version}</version> + <exclusions> + <exclusion> + <artifactId>maven-dependency-analyzer</artifactId> + <groupId>org.apache.maven.shared</groupId> + </exclusion> + <exclusion> + <artifactId>commons-io</artifactId> + <groupId>commons-io</groupId> + </exclusion> + <exclusion> + <artifactId>maven-resolver-util</artifactId> + <groupId>org.apache.maven.resolver</groupId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>com.sun.mail</groupId> <artifactId>jakarta.mail</artifactId> - <version>2.0.1</version> + <version>${jakarta.mail.version}</version> </dependency> <dependency> <groupId>com.icegreen</groupId> <artifactId>greenmail-spring</artifactId> - <version>2.0.1</version> + <version>${greenmail.version}</version> </dependency> <dependency> <groupId>com.rabbitmq</groupId> @@ -247,44 +268,34 @@ <version>${rabbitmq.version}</version> </dependency> <dependency> - <groupId>org.reflections</groupId> - <artifactId>reflections</artifactId> - <version>0.9.12</version> - </dependency> - <dependency> - <groupId>jakarta.inject</groupId> - <artifactId>jakarta.inject-api</artifactId> - <version>2.0.1</version> - </dependency> - <dependency> - <groupId>org.cyclonedx</groupId> - <artifactId>cyclonedx-maven-plugin</artifactId> - <version>${cyclonedx.version}</version> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + <version>${plexus-utils.version}</version> </dependency> - <!-- add test dependencies --> + <!-- https://mvnrepository.com/artifact/org.apache.maven/maven-core --> <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> - <scope>test</scope> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + <version>${maven-core.version}</version> <exclusions> <exclusion> - <groupId>org.junit.vintage</groupId> - <artifactId>junit-vintage-engine</artifactId> + <artifactId>plexus-classworlds</artifactId> + <groupId>org.codehaus.plexus</groupId> </exclusion> <exclusion> - <groupId>junit</groupId> - <artifactId>junit</artifactId> + <artifactId>plexus-utils</artifactId> + <groupId>org.codehaus.plexus</groupId> </exclusion> <exclusion> - <groupId>com.vaadin.external.google</groupId> - <artifactId>android-json</artifactId> + <artifactId>plexus-xml</artifactId> + <groupId>org.codehaus.plexus</groupId> </exclusion> </exclusions> </dependency> + <!-- add test dependencies --> <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <version>${h2.version}</version> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> @@ -292,6 +303,12 @@ <artifactId>spring-security-test</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context-support</artifactId> + <version>${spring-context.version}</version> + <scope>test</scope> + </dependency> <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-reflect</artifactId> @@ -304,159 +321,58 @@ </exclusion> </exclusions> </dependency> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-classworlds</artifactId> - <version>2.8.0</version> - </dependency> <!-- https://mvnrepository.com/artifact/org.mockito/mockito-core --> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> - <version>5.15.2</version> + <version>${mockito.version}</version> <scope>test</scope> </dependency> - <dependency> - <groupId>com.h2database</groupId> - <artifactId>h2</artifactId> - <version>${h2.version}</version> - </dependency> - <dependency> - <groupId>com.oracle.database.jdbc</groupId> - <artifactId>ojdbc8</artifactId> - <version>19.6.0.0</version> - </dependency> - <dependency> - <groupId>com.sun.mail</groupId> - <artifactId>jakarta.mail</artifactId> - <version>2.0.1</version> - </dependency> - <dependency> - <groupId>com.icegreen</groupId> - <artifactId>greenmail-spring</artifactId> - <version>2.0.1</version> - </dependency> - <dependency> - <groupId>com.rabbitmq</groupId> - <artifactId>amqp-client</artifactId> - <version>${rabbitmq.version}</version> - </dependency> - <dependency> - <groupId>org.reflections</groupId> - <artifactId>reflections</artifactId> - <version>0.9.12</version> - </dependency> + <!-- https://mvnrepository.com/artifact/org.owasp/dependency-check-maven --> <dependency> <groupId>org.owasp</groupId> <artifactId>dependency-check-maven</artifactId> - <version>12.0.0</version> + <version>${dependency-check-maven.version}</version> <scope>test</scope> <exclusions> <exclusion> - <groupId>org.apache.commons</groupId> - <artifactId>commons-compress</artifactId> - </exclusion> - <exclusion> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> + <artifactId>dependency-check-core</artifactId> + <groupId>org.owasp</groupId> </exclusion> <exclusion> - <groupId>org.apache.commons</groupId> - <artifactId>commons-jcs3-core</artifactId> + <artifactId>bcprov-jdk18on</artifactId> + <groupId>org.bouncycastle</groupId> </exclusion> <exclusion> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> + <artifactId>commons-io</artifactId> + <groupId>commons-io</groupId> </exclusion> <exclusion> + <artifactId>maven-artifact</artifactId> <groupId>org.apache.maven</groupId> - <artifactId>maven-core</artifactId> </exclusion> - <exclusion> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </exclusion> <exclusion> - <groupId>org.apache.maven</groupId> - <artifactId>maven-artifact</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.maven.shared</groupId> <artifactId>maven-common-artifact-filters</artifactId> + <groupId>org.apache.maven.shared</groupId> </exclusion> <exclusion> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-utils</artifactId> + <artifactId>maven-core</artifactId> + <groupId>org.apache.maven</groupId> </exclusion> <exclusion> - <groupId>org.apache.maven.resolver</groupId> <artifactId>maven-resolver-util</artifactId> + <groupId>org.apache.maven.resolver</groupId> </exclusion> <exclusion> - <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-component-annotations</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-utils</artifactId> - <version>4.0.2</version> - </dependency> - <!-- https://mvnrepository.com/artifact/org.apache.maven/maven-core --> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-core</artifactId> - <version>3.9.9</version> - <exclusions> - <exclusion> - <groupId>com.google.guava</groupId> - <artifactId>guava</artifactId> - </exclusion> - <exclusion> <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-xml</artifactId> </exclusion> <exclusion> - <groupId>org.codehaus.plexus</groupId> <artifactId>plexus-utils</artifactId> - </exclusion> - <exclusion> <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-classworlds</artifactId> </exclusion> </exclusions> </dependency> - <dependency> - <groupId>org.apache.maven.shared</groupId> - <artifactId>maven-common-artifact-filters</artifactId> - <version>3.4.0</version> - <scope>test</scope> - <exclusions> - <exclusion> - <groupId>org.apache.maven.resolver</groupId> - <artifactId>maven-resolver-util</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-jcs3-core</artifactId> - <version>3.2.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - <version>1.3.2</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-compress</artifactId> - <version>1.27.1</version> - <scope>test</scope> - </dependency> <!-- https://mvnrepository.com/artifact/com.google.jimfs/jimfs --> <dependency> <groupId>com.google.jimfs</groupId> @@ -471,9 +387,10 @@ </exclusions> </dependency> <dependency> - <groupId>jakarta.inject</groupId> - <artifactId>jakarta.inject-api</artifactId> - <version>2.0.1</version> + <groupId>org.reflections</groupId> + <artifactId>reflections</artifactId> + <version>${reflections.version}</version> + <scope>test</scope> </dependency> </dependencies> @@ -486,30 +403,6 @@ <snapshots><enabled>false</enabled></snapshots> <releases><enabled>true</enabled></releases> </repository> - <!-- repository for newest apache commons io and bouncy castle version --> - <repository> - <id>central</id> - <name>Maven Repository Central</name> - <url>https://repo1.maven.org/maven2/</url> - <snapshots><enabled>false</enabled></snapshots> - <releases><enabled>true</enabled></releases> - </repository> - <!-- repository for newest keycloak version --> - <repository> - <id>redhat</id> - <name>Maven Repository Redhat</name> - <url>https://maven.repository.redhat.com/ga/</url> - <snapshots><enabled>false</enabled></snapshots> - <releases><enabled>true</enabled></releases> - </repository> - <!-- repository for newest spring openfeign version --> - <repository> - <id>spring</id> - <name>Spring Milestone</name> - <url>https://repo.spring.io/milestone/</url> - <snapshots><enabled>false</enabled></snapshots> - <releases><enabled>true</enabled></releases> - </repository> </repositories> <dependencyManagement> diff --git a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/config/RestTemplateConfig.java b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/config/RestTemplateConfig.java index 9565b19f..0871b6e9 100644 --- a/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/config/RestTemplateConfig.java +++ b/gfsBackendService/src/main/java/org/eclipse/openk/gridfailureinformation/config/RestTemplateConfig.java @@ -1,8 +1,8 @@ package org.eclipse.openk.gridfailureinformation.config; -import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; import java.time.Duration; @@ -11,12 +11,12 @@ import java.time.Duration; public class RestTemplateConfig { @Bean - public RestTemplate restTemplate(RestTemplateBuilder builder) { + public RestTemplate restTemplate() { + var httpRequestFactory = new HttpComponentsClientHttpRequestFactory(); + httpRequestFactory.setConnectTimeout(Duration.ofMillis(3000)); + httpRequestFactory.setReadTimeout(Duration.ofMillis(3000)); - return builder - .setConnectTimeout(Duration.ofMillis(3000)) - .setReadTimeout(Duration.ofMillis(3000)) - .build(); + return new RestTemplate(httpRequestFactory); } } diff --git a/mailExport/pom.xml b/mailExport/pom.xml index 678ab734..13cf3fa9 100644 --- a/mailExport/pom.xml +++ b/mailExport/pom.xml @@ -38,10 +38,9 @@ <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version> <mapstruct.version>1.5.5.Final</mapstruct.version> <openfeign.version>4.2.0</openfeign.version> - <rabbitmq.version>5.21.0</rabbitmq.version> - <cyclonedx.version>2.9.0</cyclonedx.version> + <rabbitmq.version>5.22.0</rabbitmq.version> + <cyclonedx.version>2.9.1</cyclonedx.version> <springdoc.version>2.4.0</springdoc.version> - <jakarta-mail.version>2.1.3</jakarta-mail.version> </properties> <dependencies> @@ -130,6 +129,24 @@ <groupId>org.cyclonedx</groupId> <artifactId>cyclonedx-maven-plugin</artifactId> <version>${cyclonedx.version}</version> + <exclusions> + <exclusion> + <artifactId>maven-dependency-analyzer</artifactId> + <groupId>org.apache.maven.shared</groupId> + </exclusion> + <exclusion> + <artifactId>cyclonedx-core-java</artifactId> + <groupId>org.cyclonedx</groupId> + </exclusion> + <exclusion> + <artifactId>maven-resolver-api</artifactId> + <groupId>org.apache.maven.resolver</groupId> + </exclusion> + <exclusion> + <artifactId>maven-resolver-util</artifactId> + <groupId>org.apache.maven.resolver</groupId> + </exclusion> + </exclusions> </dependency> <!-- test dependencies --> <!-- spring --> @@ -179,6 +196,12 @@ <artifactId>powermock-reflect</artifactId> <version>${powerMockReflect.version}</version> <scope>test</scope> + <exclusions> + <exclusion> + <artifactId>objenesis</artifactId> + <groupId>org.objenesis</groupId> + </exclusion> + </exclusions> </dependency> </dependencies> diff --git a/stoerungsauskunftInterface/pom.xml b/stoerungsauskunftInterface/pom.xml index 027b1f0f..f43e3f76 100644 --- a/stoerungsauskunftInterface/pom.xml +++ b/stoerungsauskunftInterface/pom.xml @@ -38,9 +38,8 @@ <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version> <mapstruct.version>1.5.5.Final</mapstruct.version> <openfeign.version>4.2.0</openfeign.version> - <keycloak-core.version>26.0.8</keycloak-core.version> - <rabbitmq.version>5.21.0</rabbitmq.version> - <cyclonedx.version>2.9.0</cyclonedx.version> + <rabbitmq.version>5.22.0</rabbitmq.version> + <cyclonedx.version>2.9.1</cyclonedx.version> <springdoc.version>2.4.0</springdoc.version> </properties> @@ -120,6 +119,20 @@ <groupId>org.cyclonedx</groupId> <artifactId>cyclonedx-maven-plugin</artifactId> <version>${cyclonedx.version}</version> + <exclusions> + <exclusion> + <artifactId>cyclonedx-core-java</artifactId> + <groupId>org.cyclonedx</groupId> + </exclusion> + <exclusion> + <artifactId>maven-dependency-analyzer</artifactId> + <groupId>org.apache.maven.shared</groupId> + </exclusion> + <exclusion> + <artifactId>maven-dependency-tree</artifactId> + <groupId>org.apache.maven.shared</groupId> + </exclusion> + </exclusions> </dependency> <!-- test dependencies --> <!-- spring --> @@ -148,13 +161,12 @@ <groupId>org.springframework.security</groupId> <artifactId>spring-security-test</artifactId> <scope>test</scope> - <version>4.2.0</version> </dependency> <!-- https://mvnrepository.com/artifact/org.springframework.amqp/spring-rabbit-test --> <dependency> <groupId>org.springframework.amqp</groupId> <artifactId>spring-rabbit-test</artifactId> - <version>3.2.0</version> + <version>3.2.3</version> <scope>test</scope> </dependency> <dependency> @@ -162,6 +174,12 @@ <artifactId>powermock-reflect</artifactId> <version>${powerMockReflect.version}</version> <scope>test</scope> + <exclusions> + <exclusion> + <artifactId>objenesis</artifactId> + <groupId>org.objenesis</groupId> + </exclusion> + </exclusions> </dependency> </dependencies> diff --git a/testImportGridFailures/pom.xml b/testImportGridFailures/pom.xml index 7cdd975e..ca4abee9 100644 --- a/testImportGridFailures/pom.xml +++ b/testImportGridFailures/pom.xml @@ -37,8 +37,8 @@ <sonar-maven-plugin.version>3.2</sonar-maven-plugin.version> <jacoco-maven-plugin.version>0.8.12</jacoco-maven-plugin.version> <mapstruct.version>1.5.5.Final</mapstruct.version> - <rabbitmq.version>5.21.0</rabbitmq.version> - <cyclonedx.version>2.9.0</cyclonedx.version> + <rabbitmq.version>5.22.0</rabbitmq.version> + <cyclonedx.version>2.9.1</cyclonedx.version> <springdoc.version>2.4.0</springdoc.version> </properties> @@ -86,6 +86,12 @@ <groupId>org.cyclonedx</groupId> <artifactId>cyclonedx-maven-plugin</artifactId> <version>${cyclonedx.version}</version> + <exclusions> + <exclusion> + <artifactId>maven-dependency-analyzer</artifactId> + <groupId>org.apache.maven.shared</groupId> + </exclusion> + </exclusions> </dependency> <!-- test dependencies--> <!-- spring --> @@ -118,6 +124,12 @@ <artifactId>powermock-reflect</artifactId> <version>${powerMockReflect.version}</version> <scope>test</scope> + <exclusions> + <exclusion> + <artifactId>objenesis</artifactId> + <groupId>org.objenesis</groupId> + </exclusion> + </exclusions> </dependency> </dependencies> -- GitLab