Skip to content

Commit

Permalink
removed suppliers
Browse files Browse the repository at this point in the history
  • Loading branch information
paullatzelsperger committed Apr 8, 2024
1 parent 1367520 commit d780d8e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import org.junit.jupiter.params.provider.ArgumentsSource;
import org.mockserver.verify.VerificationTimes;

import java.io.IOException;
import java.net.URI;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
Expand Down Expand Up @@ -177,7 +176,7 @@ void transferData_whenContractPolicyFulfilled(JsonObject contractPolicy, String
@DisplayName("Contract policy is NOT fulfilled")
@ParameterizedTest(name = "{1}")
@ArgumentsSource(InvalidContractPolicyProvider.class)
void transferData_whenContractPolicyNotFulfilled(JsonObject contractPolicy, String description) throws IOException {
void transferData_whenContractPolicyNotFulfilled(JsonObject contractPolicy, String description) {
var assetId = "api-asset-1";

var authCodeHeaderName = "test-authkey";
Expand Down Expand Up @@ -230,7 +229,7 @@ void catalogRequest_whenCredentialExpired() {

var did = SOKRATES.getDid();
var bpn = SOKRATES.getBpn();
var newRawVc = createVcBuilder(DATASPACE_ISSUER_PARTICIPANT.didUrl(), "MembershipCredential", () -> membershipSubject(did, bpn));
var newRawVc = createVcBuilder(DATASPACE_ISSUER_PARTICIPANT.didUrl(), "MembershipCredential", membershipSubject(did, bpn));
newRawVc.add("expirationDate", expirationDate.toString());

var newVcString = DATASPACE_ISSUER_PARTICIPANT.createLdpVc(jsonLd, newRawVc.build());
Expand Down Expand Up @@ -285,7 +284,7 @@ void catalogRequest_whenCredentialRevoked() {

var did = SOKRATES.getDid();
var bpn = SOKRATES.getBpn();
var newRawVc = createVcBuilder(DATASPACE_ISSUER_PARTICIPANT.didUrl(), "MembershipCredential", () -> membershipSubject(did, bpn));
var newRawVc = createVcBuilder(DATASPACE_ISSUER_PARTICIPANT.didUrl(), "MembershipCredential", membershipSubject(did, bpn));
newRawVc.add("credentialStatus", Json.createObjectBuilder()
.add("id", "http://localhost:%d/status/list/7#12345".formatted(port))
.add("type", "StatusList2021Entry")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public String verificationId() {
return DATASPACE_ISSUER + "#" + getKeyId();
}

public VerifiableCredentialResource issueCredential(String did, String bpn, JsonLd jsonLd, String type, Supplier<CredentialSubject> credentialSubjectSupplier, Supplier<JsonObject> subjectSupplier) {
public VerifiableCredentialResource issueCredential(String did, String bpn, JsonLd jsonLd, String type, Supplier<CredentialSubject> credentialSubjectSupplier, JsonObject subjectSupplier) {
var credential = VerifiableCredential.Builder.newInstance()
.type(type)
.credentialSubject(credentialSubjectSupplier.get())
Expand All @@ -100,7 +100,7 @@ public VerifiableCredentialResource issueMembershipCredential(String did, String
return issueCredential(did, bpn, jsonLd, "MembershipCredential", () -> CredentialSubject.Builder.newInstance()
.claim("holderIdentifier", bpn)
.build(),
() -> membershipSubject(did, bpn));
membershipSubject(did, bpn));
}

public VerifiableCredentialResource issueDismantlerCredential(String did, String bpn, JsonLd jsonLd) {
Expand All @@ -109,7 +109,7 @@ public VerifiableCredentialResource issueDismantlerCredential(String did, String
.claim("activityType", "vehicleDismantle")
.claim("allowedVehicleBrands", List.of("Moskvich", "Lada"))
.build(),
() -> Json.createObjectBuilder()
Json.createObjectBuilder()
.add("type", "DismantlerCredential")
.add("holderIdentifier", bpn)
.add("activityType", "vehicleDismantle")
Expand All @@ -122,7 +122,7 @@ public VerifiableCredentialResource issueFrameworkCredential(String did, String
return issueCredential(did, bpn, jsonLd, credentialType, () -> CredentialSubject.Builder.newInstance()
.claim("holderIdentifier", bpn)
.build(),
() -> frameworkAgreementSubject(did, bpn, credentialType));
frameworkAgreementSubject(did, bpn, credentialType));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,18 @@
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.function.Supplier;

public class IatpHelperFunctions {
public static JsonObject createVc(String issuer, String type, Supplier<JsonObject> subjectSupplier) {
public static JsonObject createVc(String issuer, String type, JsonObject subjectSupplier) {
return createVcBuilder(issuer, type, subjectSupplier)
.build();
}

public static JsonObjectBuilder createVcBuilder(String issuer, String type, Supplier<JsonObject> subjectSupplier) {
public static JsonObjectBuilder createVcBuilder(String issuer, String type, JsonObject subjectSupplier) {
return Json.createObjectBuilder()
.add("@context", context())
.add("type", types(type))
.add("credentialSubject", subjectSupplier.get())
.add("credentialSubject", subjectSupplier)
.add("issuer", issuer)
.add("issuanceDate", Instant.now().toString());
}
Expand Down

0 comments on commit d780d8e

Please sign in to comment.