Skip to content

Commit

Permalink
Merge pull request #186 from smartSenseSolutions/test-service-offer
Browse files Browse the repository at this point in the history
Test service offer
  • Loading branch information
neha-puraswani authored Oct 27, 2023
2 parents b3f0cf4 + 1b9d523 commit ed35f30
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 183 deletions.
82 changes: 0 additions & 82 deletions .github/workflow/app-test.yml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/app-test.yml
Original file line number Diff line number Diff line change
@@ -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
82 changes: 0 additions & 82 deletions .github/workflows/test-application.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object>) this.objectMapper.readValue(complianceCredential, Map.class).get("complianceCredential"));

try {
ResponseEntity<Object> 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
@ContextConfiguration(initializers = {ContainerContextInitializer.class})
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class DataMasterControllerTest {

@Autowired
private AccessTypeMasterRepository accessTypeMasterRepository;
@Autowired
Expand All @@ -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<CommonResponse> response = this.restTemplate.exchange("/public/master-data/" + type + "/filter", HttpMethod.POST, new HttpEntity<>(request), CommonResponse.class);
Expand All @@ -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";
Expand All @@ -132,19 +132,19 @@ void fetch_subdivision_name_200() {
Map<String, Object> payload = (Map<String, Object>) response.getBody().getPayload();
assertEquals(Collections.singletonList("Brussels Hoofdstedelijk Gewest"), payload.get("serviceAvailabilityLocation"));
}

@Test
void fetch_subdivision_master_400() {
final String type = "subdivisionMaster";
FilterRequest request = HelperService.prepareDefaultFilterRequest();
ResponseEntity<CommonResponse> 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<LabelLevelTypeInterface> labelLevelTypeAndQuestionList = this.labelLevelService.getLabelLevelTypeAndQuestionList();
assertThat(labelLevelTypeAndQuestionList).isNotNull();
}

}

0 comments on commit ed35f30

Please sign in to comment.