|
34 | 34 | import static org.assertj.core.api.Assertions.assertThat; |
35 | 35 | import static org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractRequest.CALLBACK_ADDRESSES; |
36 | 36 | import static org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractRequest.CONTRACT_REQUEST_COUNTER_PARTY_ADDRESS; |
| 37 | +import static org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractRequest.CONTRACT_REQUEST_PROFILE; |
37 | 38 | import static org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractRequest.POLICY; |
38 | 39 | import static org.eclipse.edc.connector.controlplane.contract.spi.types.negotiation.ContractRequest.PROTOCOL; |
39 | 40 | import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; |
@@ -90,6 +91,34 @@ void transform() { |
90 | 91 | assertThat(request.getContractOffer()).isSameAs(offer); |
91 | 92 | } |
92 | 93 |
|
| 94 | + @Test |
| 95 | + void transform_withProfile() { |
| 96 | + var jsonObject = Json.createObjectBuilder() |
| 97 | + .add(TYPE, ContractRequest.CONTRACT_REQUEST_TYPE) |
| 98 | + .add(CONTRACT_REQUEST_COUNTER_PARTY_ADDRESS, "test-address") |
| 99 | + .add(CONTRACT_REQUEST_PROFILE, "test-profile") |
| 100 | + .add(CALLBACK_ADDRESSES, createCallbackAddress()) |
| 101 | + .add(POLICY, createPolicy()) |
| 102 | + .build(); |
| 103 | + when(context.transform(any(JsonObject.class), eq(CallbackAddress.class))).thenReturn(CallbackAddress.Builder.newInstance() |
| 104 | + .uri("http://test.local") |
| 105 | + .events(Set.of("foo", "bar")) |
| 106 | + .transactional(true) |
| 107 | + .build()); |
| 108 | + var offer = createContractOffer("test-provider-id"); |
| 109 | + when(context.transform(any(JsonValue.class), eq(ContractOffer.class))).thenReturn(offer); |
| 110 | + |
| 111 | + var request = transformer.transform(jsonLd.expand(jsonObject).getContent(), context); |
| 112 | + |
| 113 | + assertThat(request).isNotNull(); |
| 114 | + assertThat(request.getProviderId()).isEqualTo("test-provider-id"); |
| 115 | + assertThat(request.getCallbackAddresses()).isNotEmpty(); |
| 116 | + assertThat(request.getProfile()).isEqualTo("test-profile"); |
| 117 | + assertThat(request.getCounterPartyAddress()).isEqualTo("test-address"); |
| 118 | + assertThat(request.getContractOffer()).isSameAs(offer); |
| 119 | + } |
| 120 | + |
| 121 | + |
93 | 122 | @Test |
94 | 123 | void transform_shouldSetProviderIdAsCounterPartyAddress_whenProviderIdNotDefined() { |
95 | 124 | var jsonObject = Json.createObjectBuilder() |
|
0 commit comments