Skip to content

Commit

Permalink
Merge pull request #183 from smartSenseSolutions/development
Browse files Browse the repository at this point in the history
Add test cases
  • Loading branch information
neha-puraswani authored Oct 27, 2023
2 parents 327d7c3 + ed35f30 commit 3b46a67
Show file tree
Hide file tree
Showing 49 changed files with 2,045 additions and 568 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/app-test.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle

name: Java CI with Gradle
name: Test application

on:
push:
Expand Down Expand Up @@ -39,4 +32,4 @@ jobs:
java-version: '17'

- name: Test app
run: gradle test --scan
run: gradle test
16 changes: 1 addition & 15 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ subprojects {
testImplementation "com.github.dasniko:testcontainers-keycloak:${keycloakTestContainerVersion}"
testImplementation "com.github.curious-odd-man:rgxgen:${regexGeneratorVersion}"
testImplementation 'org.mockito:mockito-inline'
testImplementation "org.testcontainers:localstack:1.19.1"
}

dependencyManagement {
Expand All @@ -71,19 +72,4 @@ subprojects {
enabled = false
}

jacocoTestReport {
dependsOn test
}

jacoco {
toolVersion = "${jacocoVersion}"
}

jacocoTestReport {
reports {
xml.required = false
csv.required = false
html.required = true
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

24 changes: 0 additions & 24 deletions wizard-api/src/main/java/eu/gaiax/wizard/api/model/SessionDTO.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package eu.gaiax.wizard.api.model.service_offer;

import eu.gaiax.wizard.api.VerifiableCredential;


public record SignerServiceRequest(
String issuer,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.gaiax.wizard.api;
package eu.gaiax.wizard.api.model.service_offer;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public record AWSSettings(String bucket,
String secretKey,
String hostedZoneId,
String serverIp,
String baseDomain) {
String baseDomain,
String s3Endpoint) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class S3Utils {
* @param file the file
*/
public void uploadFile(String objectName, File file) {
this.s3Client.listBuckets();
this.s3Client.putObject(this.awsSettings.bucket(), objectName, file);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ public class StringPool {

public static final String ERROR = "error";

public static final String CREATE = "CREATE";

public static final String DELETE = "DELETE";

private StringPool() {
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.gaiax.wizard.core.service.participant;
package eu.gaiax.wizard.core.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpMethod;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class DomainService {
private final ParticipantRepository participantRepository;
private final ScheduleService scheduleService;

public void updateTxtRecords(String domainName, String value, ChangeAction action) {
log.info("DomainService(updateTxtRecords) -> Txt update process initiated for domain {} with value {} and action {} ", domainName, value, action.name());
public void updateTxtRecords(String domainName, String value, String action) {
log.info("DomainService(updateTxtRecords) -> Txt update process initiated for domain {} with value {} and action {} ", domainName, value, action);
ResourceRecord resourceRecord = new ResourceRecord();
resourceRecord.setValue("\"" + value + "\"");

Expand All @@ -42,7 +42,7 @@ public void updateTxtRecords(String domainName, String value, ChangeAction actio
recordsSet.setTTL(900L);
recordsSet.setName(domainName);

Change change = new Change(action, recordsSet);
Change change = new Change(ChangeAction.fromValue(action), recordsSet);

ChangeBatch batch = new ChangeBatch(List.of(change));

Expand All @@ -53,7 +53,7 @@ public void updateTxtRecords(String domainName, String value, ChangeAction actio
request.setHostedZoneId(this.awsSettings.hostedZoneId());
ChangeResourceRecordSetsResult result = this.amazonRoute53.changeResourceRecordSets(request);

if (action.name().equalsIgnoreCase("CREATE")) {
if (action.equalsIgnoreCase(StringPool.CREATE)) {
String status = result.getChangeInfo().getStatus();
String changeId = result.getChangeInfo().getId();
int count = 0;
Expand All @@ -77,27 +77,6 @@ public void updateTxtRecords(String domainName, String value, ChangeAction actio
log.info("DomainService(updateTxtRecords) -> Txt record has been updated for {} with result {}", domainName, result);
}

public void deleteTxtRecordForSSLCertificate(String domainName, String value) {
try {
this.updateTxtRecords(domainName, value, ChangeAction.DELETE);
log.info("DomainService(createSubDomain) -> Txt record has been deleted for {}", domainName);
} catch (Exception e) {
log.error("DomainService(createSubDomain) -> Txt record has not been deleted for {}", domainName, e);
//TODO need to check if record is already exist
}
}


public void createTxtRecordForSSLCertificate(String domainName, String value) {
try {
this.updateTxtRecords(domainName, value, ChangeAction.CREATE);
log.info("DomainService(createSubDomain) -> Txt record has been created for {}", domainName);
} catch (Exception e) {
log.error("DomainService(createSubDomain) -> Txt record has not been created for {}", domainName, e);
//TODO need to check if record is already created
}
}

public void createSubDomain(UUID participantId) {
log.info("DomainService(createSubDomain) -> Initiate process for creating sub domain for participant {}.", participantId);
Participant participant = this.participantRepository.findById(participantId).orElseThrow(() -> new EntityNotFoundException("participant.not.found"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package eu.gaiax.wizard.core.service.hashing;

import eu.gaiax.wizard.core.service.participant.InvokeService;
import eu.gaiax.wizard.core.service.InvokeService;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.SneakyThrows;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ protected void executeInternal(JobExecutionContext context) {
this.certificateService.createSSLCertificate(participantId, jobDetail.getKey());
case StringPool.JOB_TYPE_CREATE_INGRESS -> this.k8SService.createIngress(participantId);
case StringPool.JOB_TYPE_CREATE_DID -> this.signerService.createDid(participantId);
case StringPool.JOB_TYPE_CREATE_PARTICIPANT -> this.signerService.createParticipantJson(participantId);
case StringPool.JOB_TYPE_CREATE_PARTICIPANT ->
this.signerService.createSignedLegalParticipant(participantId);
default -> log.error("ScheduledJobBean(executeInternal) -> JobType {} is invalid.", jobType);
}
log.info("ScheduledJobBean(executeInternal) -> Job {} has been executed.", jobType);
Expand Down
Loading

0 comments on commit 3b46a67

Please sign in to comment.