diff --git a/.github/workflow/app-test.yml b/.github/workflow/app-test.yml deleted file mode 100644 index 56a55a5..0000000 --- a/.github/workflow/app-test.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Test application (test + coverage) - -on: - workflow_dispatch: - pull_request: - paths: - - 'src/**' - -permissions: - id-token: write - statuses: write - checks: write - # may also be read - contents: write - pull-requests: write - actions: write - -jobs: - test-app: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Java 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - - name: Setup .NET Core # Required to execute ReportGenerator - uses: actions/setup-dotnet@v3 - if: success() || failure() - with: - dotnet-version: 6.x - dotnet-quality: 'ga' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - - name: Test app - run: ./gradlew test - - - name: Get coverage - if: success() || failure() - run: ./gradlew jacocoTestReport - - - name: Generate test report - uses: dorny/test-reporter@v1.6.0 - if: success() || failure() - with: - name: Test results - path: 'build/test-results/test/*.xml' - reporter: java-junit - fail-on-error: false - - - name: Generate code coverage report - uses: danielpalme/ReportGenerator-GitHub-Action@5.1.25 - if: success() || failure() - with: - reports: build/reports/xml/jacoco - targetdir: coveragereport - reporttypes: MarkdownSummaryGithub - sourcedirs: src/main/java - title: 'Code Coverage' - - - name: Publish code coverage report as job summary - if: success() || failure() - run: cat coveragereport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY - - - name: Publish code coverage report as PR comment - uses: madrapps/jacoco-report@v1.6.1 - if: github.event_name == 'pull_request' && (success() || failure()) - with: - paths: | - ${{ github.workspace }}/build/reports/xml/jacoco - min-coverage-overall: 80 - min-coverage-changed-files: 80 - title: Coverage Report \ No newline at end of file diff --git a/.github/workflows/app-test.yml b/.github/workflows/app-test.yml new file mode 100644 index 0000000..797daa4 --- /dev/null +++ b/.github/workflows/app-test.yml @@ -0,0 +1,35 @@ +name: Test application + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +permissions: + id-token: write + statuses: write + checks: write + # may also be read + contents: write + pull-requests: write + actions: write + +jobs: + test-app: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Java 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + + - name: Test app + run: gradle test \ No newline at end of file diff --git a/.github/workflows/test-application.yml b/.github/workflows/test-application.yml deleted file mode 100644 index b15a121..0000000 --- a/.github/workflows/test-application.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: Test application - -on: - workflow_dispatch: - pull_request: - paths: - - 'src/**' - -permissions: - id-token: write - statuses: write - checks: write - # may also be read - contents: write - pull-requests: write - actions: write - -jobs: - test-app: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Set up Java 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - - - name: Setup .NET Core # Required to execute ReportGenerator - uses: actions/setup-dotnet@v3 - if: success() || failure() - with: - dotnet-version: 6.x - dotnet-quality: 'ga' - - - name: Setup Gradle - uses: gradle/gradle-build-action@v2 - - - name: Test app - run: ./gradlew test - -# - name: Get coverage -# if: success() || failure() -# run: ./gradlew jacocoTestReport -# -# - name: Generate test report -# uses: dorny/test-reporter@v1.6.0 -# if: success() || failure() -# with: -# name: Test results -# path: 'build/test-results/test/*.xml' -# reporter: java-junit -# fail-on-error: false -# -# - name: Generate code coverage report -# uses: danielpalme/ReportGenerator-GitHub-Action@5.1.25 -# if: success() || failure() -# with: -# reports: build/reports/xml/jacoco -# targetdir: coveragereport -# reporttypes: MarkdownSummaryGithub -# sourcedirs: src/main/java -# title: 'Code Coverage' -# -# - name: Publish code coverage report as job summary -# if: success() || failure() -# run: cat coveragereport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY -# -# - name: Publish code coverage report as PR comment -# uses: madrapps/jacoco-report@v1.6.1 -# if: github.event_name == 'pull_request' && (success() || failure()) -# with: -# paths: | -# ${{ github.workspace }}/build/reports/xml/jacoco -# min-coverage-overall: 80 -# min-coverage-changed-files: 80 -# title: Coverage Report \ No newline at end of file diff --git a/wizard-core/src/main/java/eu/gaiax/wizard/core/service/service_offer/PublishService.java b/wizard-core/src/main/java/eu/gaiax/wizard/core/service/service_offer/PublishService.java index 721a3f4..d2f4b8d 100644 --- a/wizard-core/src/main/java/eu/gaiax/wizard/core/service/service_offer/PublishService.java +++ b/wizard-core/src/main/java/eu/gaiax/wizard/core/service/service_offer/PublishService.java @@ -19,25 +19,25 @@ @RequiredArgsConstructor @Slf4j public class PublishService { - + private final ObjectMapper objectMapper; private final MessagingQueueClient messagingQueueClient; private final ServiceOfferRepository serviceOfferRepository; @Value("${wizard.host.wizard}") private String wizardHost; - + public void publishServiceComplianceToMessagingQueue(UUID serviceOfferId, String complianceCredential) throws JsonProcessingException { PublishToQueueRequest publishToQueueRequest = new PublishToQueueRequest(); publishToQueueRequest.setSource(this.wizardHost); publishToQueueRequest.setData((Map) this.objectMapper.readValue(complianceCredential, Map.class).get("complianceCredential")); - + try { ResponseEntity publishServiceComplianceResponse = this.messagingQueueClient.publishServiceCompliance(publishToQueueRequest); if (publishServiceComplianceResponse.getStatusCode().equals(HttpStatus.CREATED)) { if (publishServiceComplianceResponse.getHeaders().containsKey("location")) { String rawMessageId = publishServiceComplianceResponse.getHeaders().get("location").get(0); String messageReferenceId = rawMessageId.substring(rawMessageId.lastIndexOf("/") + 1); - + this.serviceOfferRepository.updateMessageReferenceId(serviceOfferId, messageReferenceId); log.info("Service offer published to messaging queue. Message Reference ID: {}", messageReferenceId); } else { diff --git a/wizard-web/src/test/java/eu/gaiax/wizard/util/ContainerContextInitializer.java b/wizard-web/src/test/java/eu/gaiax/wizard/util/ContainerContextInitializer.java index e458525..38cc7a2 100644 --- a/wizard-web/src/test/java/eu/gaiax/wizard/util/ContainerContextInitializer.java +++ b/wizard-web/src/test/java/eu/gaiax/wizard/util/ContainerContextInitializer.java @@ -99,6 +99,48 @@ public void initialize(ConfigurableApplicationContext applicationContext) { } catch (Exception e) { throw new RuntimeException(e); } + + properties.put("server.compression.enabled", "true"); + properties.put("wizard.application.name", "gaia-x-wizard"); + properties.put("wizard.database.postgres.connection-timeout", "120000"); + properties.put("wizard.database.postgres.pool-size", "10"); + properties.put("wizard.keycloak.webAuthRedirectUrl", "http://localhost:8189/*"); + properties.put("wizard.keycloak.actionTokenLifespan", "300"); + properties.put("wizard.keycloak.requiredActionsEmailRedirectionUrl", "http://localhost:8189"); + + properties.put("wizard.security.corsOrigins", "*"); + properties.put("wizard.signer-policies", "integrityCheck,holderSignature,complianceSignature,complianceCheck"); + properties.put("wizard.host.signer", "http://localhost:8080/"); + properties.put("wizard.host.wizard", "http://localhost:8080/"); + properties.put("wizard.host.messagingQueue", "http://localhost:8080/"); + properties.put("wizard.quartz.scheduler.instanceName", "smartSense"); + properties.put("wizard.quartz.scheduler.instanceId", "AUTO"); + properties.put("wizard.quartz.scheduler.batchTriggerAcquisitionMaxCount", "10"); + properties.put("wizard.management.port", "8090"); + properties.put("wizard.gaia-x.registryService", "https://registry.gaia-x.eu/v1"); + properties.put("wizard.context.participant", "https://www.w3.org/2018/credentials/v1,https://w3id.org/security/suites/jws-2020/v1,https://registry.lab.gaia-x.eu/development/api/trusted-shape-registry/v1/shapes/jsonld/trustframework#"); + properties.put("wizard.context.registrationNumber", "https://registry.lab.gaia-x.eu/development/api/trusted-shape-registry/v1/shapes/jsonld/participant"); + properties.put("wizard.context.tnc", "https://www.w3.org/2018/credentials/v1,https://w3id.org/security/suites/jws-2020/v1,https://registry.lab.gaia-x.eu/development/api/trusted-shape-registry/v1/shapes/jsonld/trustframework#"); + properties.put("wizard.context.serviceOffer", "https://www.w3.org/2018/credentials/v1,https://w3id.org/security/suites/jws-2020/v1"); + properties.put("wizard.context.ODRLPolicy", "http://www.w3.org/ns/odrl.jsonld,https://www.w3.org/ns/odrl/2/ODRL22.json"); + properties.put("wizard.context.labelLevel", "https://www.w3.org/2018/credentials/v1,https://w3id.org/security/suites/jws-2020/v1,https://registry.lab.gaia-x.eu/development/api/trusted-shape-registry/v1/shapes/jsonld/trustframework#"); + properties.put("wizard.context.resource", "https://www.w3.org/2018/credentials/v1,https://registry.lab.gaia-x.eu/development/api/trusted-shape-registry/v1/shapes/jsonld/trustframework#"); + properties.put("wizard.gaiax.tnc", "In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface without relying on meaningful content."); + properties.put("spring.liquibase.change-log", "classpath:/db/changelog/changelog-master.xml"); + properties.put("spring.main.allow-bean-definition-overriding", "true"); + properties.put("spring.application.name", "gaia-x-wizard"); + properties.put("spring.datasource.initialization-mode", "always"); + properties.put("spring.quartz.job-store-type", "jdbc"); + properties.put("spring.quartz.properties.org.quartz.scheduler.instanceName", "smartSense"); + properties.put("spring.quartz.properties.org.quartz.scheduler.instanceId", "AUTO"); + properties.put("spring.quartz.properties.org.quartz.scheduler.batchTriggerAcquisitionMaxCount", "10"); + properties.put("spring.quartz.properties.org.quartz.scheduler.batchTriggerAcquisitionFireAheadTimeWindow", "1000"); + properties.put("spring.quartz.properties.org.quartz.jobStore.isClustered", "true"); + properties.put("spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval", "10000"); + properties.put("spring.quartz.properties.org.quartz.jobStore.acquireTriggersWithinLock", "true"); + properties.put("spring.quartz.properties.org.quartz.jobStore.driverDelegateClass", "org.quartz.impl.jdbcjobstore.PostgreSQLDelegate"); + properties.put("spring.quartz.properties.org.quartz.threadPool.threadCount", "10"); + TestPropertyValues testProperties = TestPropertyValues.empty(); testProperties.and(properties).applyTo(applicationContext.getEnvironment()); } diff --git a/wizard-web/src/test/java/eu/gaiax/wizard/web/DataMasterControllerTest.java b/wizard-web/src/test/java/eu/gaiax/wizard/web/DataMasterControllerTest.java index 1b8bb62..8dcae28 100644 --- a/wizard-web/src/test/java/eu/gaiax/wizard/web/DataMasterControllerTest.java +++ b/wizard-web/src/test/java/eu/gaiax/wizard/web/DataMasterControllerTest.java @@ -37,7 +37,7 @@ @ContextConfiguration(initializers = {ContainerContextInitializer.class}) @TestInstance(TestInstance.Lifecycle.PER_CLASS) class DataMasterControllerTest { - + @Autowired private AccessTypeMasterRepository accessTypeMasterRepository; @Autowired @@ -60,59 +60,59 @@ class DataMasterControllerTest { private TestRestTemplate restTemplate; @Autowired private ObjectMapper mapper; - + @MockBean @Autowired private PolicyService policyService; - + @Test void fetch_access_master_200() { final String type = "access"; this.request_master_data(this.accessTypeMasterRepository.count(), type); } - + @Test void fetch_entity_master_200() { final String type = "entity"; this.request_master_data(this.entityTypeMasterRepository.count(), type); } - + @Test void fetch_format_master_200() { final String type = "format"; this.request_master_data(this.formatTypeMasterRepository.count(), type); } - + @Test void fetch_registration_master_200() { final String type = "registration"; this.request_master_data(this.registrationTypeMasterRepository.count(), type); } - + @Test void fetch_request_master_200() { final String type = "request"; this.request_master_data(this.requestTypeMasterRepository.count(), type); } - + @Test void fetch_standard_master_200() { final String type = "standard"; this.request_master_data(this.standardTypeMasterRepository.count(), type); } - + @Test void fetch_subdivision_master_200() { final String type = "subdivision"; this.request_master_data(this.subdivisionCodeMasterRepository.count(), type); } - + @Test void fetch_spdx_master_200() { final String type = "spdxLicense"; this.request_master_data(this.spdxLicenseMasterRepository.count(), type); } - + private void request_master_data(Long count, String type) { FilterRequest request = HelperService.prepareDefaultFilterRequest(); ResponseEntity response = this.restTemplate.exchange("/public/master-data/" + type + "/filter", HttpMethod.POST, new HttpEntity<>(request), CommonResponse.class); @@ -121,7 +121,7 @@ private void request_master_data(Long count, String type) { assertEquals(count, pageResponse.getPageable().getTotalElements()); assertTrue(((Collection) pageResponse.getContent()).size() > 0); } - + @Test void fetch_subdivision_name_200() { final String type = "subdivisionMaster"; @@ -132,7 +132,7 @@ void fetch_subdivision_name_200() { Map payload = (Map) response.getBody().getPayload(); assertEquals(Collections.singletonList("Brussels Hoofdstedelijk Gewest"), payload.get("serviceAvailabilityLocation")); } - + @Test void fetch_subdivision_master_400() { final String type = "subdivisionMaster"; @@ -140,11 +140,11 @@ void fetch_subdivision_master_400() { ResponseEntity response = this.restTemplate.exchange("/public/master-data/" + type + "/filter", HttpMethod.POST, new HttpEntity<>(request), CommonResponse.class); assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode()); } - + @Test void fetch_label_level_list_200() { List labelLevelTypeAndQuestionList = this.labelLevelService.getLabelLevelTypeAndQuestionList(); assertThat(labelLevelTypeAndQuestionList).isNotNull(); } - + }