From e2e84ceeb88c1a981bd75848e5d9e8d0d1e6a1e4 Mon Sep 17 00:00:00 2001 From: Enrico Risa Date: Tue, 30 May 2023 16:44:25 +0200 Subject: [PATCH] fix(TransferProcessApi): fix transfomer for TransferProcessDto (#3122) * fix(TransferProcessApi): fix transfomer for TransferProcessDto * fix(TransferProcessApi): fix test * fix(TransferProcessApi): consistent replace CallbackAddressDto with CallbackAddress --- .../org/eclipse/edc/api/ApiCoreExtension.java | 6 +- .../edc/api/model/CallbackAddressDto.java | 112 ------------------ ...ddressDtoToCallbackAddressTransformer.java | 45 ------- ...onObjectToCallbackAddressTransformer.java} | 14 +-- .../edc/api/model/CallbackAddressDtoTest.java | 47 -------- .../CallbackAddressDtoValidationTest.java | 59 --------- ...ssDtoToCallbackAddressTransformerTest.java | 52 -------- ...jectToCallbackAddressTransformerTest.java} | 6 +- .../model/NegotiationInitiateRequestDto.java | 8 +- ...otiationInitiateRequestDtoTransformer.java | 6 +- ...ateRequestDtoToDataRequestTransformer.java | 9 +- ...tionInitiateRequestDtoTransformerTest.java | 7 +- ...equestDtoToDataRequestTransformerTest.java | 4 +- .../model/TransferProcessDto.java | 8 +- .../model/TransferRequestDto.java | 10 +- ...ObjectToTransferRequestDtoTransformer.java | 9 ++ ...rocessToTransferProcessDtoTransformer.java | 5 +- ...equestDtoToTransferRequestTransformer.java | 6 +- ...FromTransferProcessDtoTransformerTest.java | 6 +- ...ssToTransferProcessDtoTransformerTest.java | 8 +- .../TransferProcessTransformerTestData.java | 3 +- ...stDtoToTransferRequestTransformerTest.java | 4 +- .../contract-negotiation-api.yaml | 34 +----- .../management-api/transfer-process-api.yaml | 15 +-- .../ContractNegotiationApiEndToEndTest.java | 2 +- .../TransferProcessApiEndToEndTest.java | 18 +++ 26 files changed, 78 insertions(+), 425 deletions(-) delete mode 100644 extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/model/CallbackAddressDto.java delete mode 100644 extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/transformer/CallbackAddressDtoToCallbackAddressTransformer.java rename extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/transformer/{JsonObjectToCallbackAddressDtoTransformer.java => JsonObjectToCallbackAddressTransformer.java} (83%) delete mode 100644 extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/model/CallbackAddressDtoTest.java delete mode 100644 extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/model/CallbackAddressDtoValidationTest.java delete mode 100644 extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/transformer/CallbackAddressDtoToCallbackAddressTransformerTest.java rename extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/transformer/{JsonObjectToCallbackAddressDtoTransformerTest.java => JsonObjectToCallbackAddressTransformerTest.java} (93%) diff --git a/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/ApiCoreExtension.java b/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/ApiCoreExtension.java index 4efe8c976fc..8ae6cc0e0b7 100644 --- a/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/ApiCoreExtension.java +++ b/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/ApiCoreExtension.java @@ -15,7 +15,6 @@ package org.eclipse.edc.api; import jakarta.json.Json; -import org.eclipse.edc.api.transformer.CallbackAddressDtoToCallbackAddressTransformer; import org.eclipse.edc.api.transformer.CriterionDtoToCriterionTransformer; import org.eclipse.edc.api.transformer.CriterionToCriterionDtoTransformer; import org.eclipse.edc.api.transformer.DataAddressDtoToDataAddressTransformer; @@ -24,7 +23,7 @@ import org.eclipse.edc.api.transformer.JsonObjectFromCriterionDtoTransformer; import org.eclipse.edc.api.transformer.JsonObjectFromDataAddressDtoTransformer; import org.eclipse.edc.api.transformer.JsonObjectFromIdResponseDtoTransformer; -import org.eclipse.edc.api.transformer.JsonObjectToCallbackAddressDtoTransformer; +import org.eclipse.edc.api.transformer.JsonObjectToCallbackAddressTransformer; import org.eclipse.edc.api.transformer.JsonObjectToCriterionDtoTransformer; import org.eclipse.edc.api.transformer.QuerySpecDtoToQuerySpecTransformer; import org.eclipse.edc.runtime.metamodel.annotation.Extension; @@ -59,7 +58,6 @@ public void initialize(ServiceExtensionContext context) { transformerRegistry.register(new QuerySpecDtoToQuerySpecTransformer()); transformerRegistry.register(new CriterionToCriterionDtoTransformer()); transformerRegistry.register(new CriterionDtoToCriterionTransformer()); - transformerRegistry.register(new CallbackAddressDtoToCallbackAddressTransformer()); transformerRegistry.register(new DataAddressDtoToDataAddressTransformer()); transformerRegistry.register(new DataAddressToDataAddressDtoTransformer()); @@ -71,7 +69,7 @@ public void initialize(ServiceExtensionContext context) { transformerRegistry.register(new JsonObjectFromDataAddressDtoTransformer(jsonFactory)); transformerRegistry.register(new JsonObjectFromIdResponseDtoTransformer(jsonFactory)); - transformerRegistry.register(new JsonObjectToCallbackAddressDtoTransformer()); + transformerRegistry.register(new JsonObjectToCallbackAddressTransformer()); transformerRegistry.register(new JsonObjectToCriterionDtoTransformer()); } } diff --git a/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/model/CallbackAddressDto.java b/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/model/CallbackAddressDto.java deleted file mode 100644 index b15f8f9163e..00000000000 --- a/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/model/CallbackAddressDto.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.api.model; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; - -import java.util.HashSet; -import java.util.Set; - -/** - * DTO for {@link CallbackAddress} - */ -@JsonDeserialize(builder = CallbackAddressDto.Builder.class) -public class CallbackAddressDto extends BaseDto { - - @NotBlank(message = "uri is mandatory") - private String uri; - - @NotNull(message = "events cannot be null") - private Set events = new HashSet<>(); - - private boolean transactional; - - private String authKey; - private String authCodeId; - - private CallbackAddressDto() { - - } - - public boolean isTransactional() { - return transactional; - } - - public Set getEvents() { - return events; - } - - public String getUri() { - return uri; - } - - public String getAuthCodeId() { - return authCodeId; - } - - public String getAuthKey() { - return authKey; - } - - @JsonPOJOBuilder(withPrefix = "") - public static final class Builder { - private final CallbackAddressDto dto; - - private Builder() { - this.dto = new CallbackAddressDto(); - } - - @JsonCreator - public static Builder newInstance() { - return new Builder(); - } - - - public Builder uri(String url) { - dto.uri = url; - return this; - } - - public Builder events(Set events) { - dto.events = events; - return this; - } - - public Builder transactional(boolean transactional) { - dto.transactional = transactional; - return this; - } - - public Builder authKey(String authKey) { - dto.authKey = authKey; - return this; - } - - public Builder authCodeId(String authCodeId) { - dto.authCodeId = authCodeId; - return this; - } - - public CallbackAddressDto build() { - return dto; - } - - } -} diff --git a/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/transformer/CallbackAddressDtoToCallbackAddressTransformer.java b/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/transformer/CallbackAddressDtoToCallbackAddressTransformer.java deleted file mode 100644 index a415e8d4344..00000000000 --- a/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/transformer/CallbackAddressDtoToCallbackAddressTransformer.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - improvements - * - */ - -package org.eclipse.edc.api.transformer; - -import org.eclipse.edc.api.model.CallbackAddressDto; -import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; -import org.eclipse.edc.transform.spi.TransformerContext; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public class CallbackAddressDtoToCallbackAddressTransformer implements DtoTransformer { - - @Override - public Class getInputType() { - return CallbackAddressDto.class; - } - - @Override - public Class getOutputType() { - return CallbackAddress.class; - } - - @Override - public @Nullable CallbackAddress transform(@NotNull CallbackAddressDto object, @NotNull TransformerContext context) { - return CallbackAddress.Builder.newInstance() - .uri(object.getUri()) - .events(object.getEvents()) - .transactional(object.isTransactional()) - .authCodeId(object.getAuthCodeId()) - .authKey(object.getAuthKey()) - .build(); - } -} diff --git a/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/transformer/JsonObjectToCallbackAddressDtoTransformer.java b/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/transformer/JsonObjectToCallbackAddressTransformer.java similarity index 83% rename from extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/transformer/JsonObjectToCallbackAddressDtoTransformer.java rename to extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/transformer/JsonObjectToCallbackAddressTransformer.java index e7a7f2bd5f0..95ca3c92a4a 100644 --- a/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/transformer/JsonObjectToCallbackAddressDtoTransformer.java +++ b/extensions/common/api/api-core/src/main/java/org/eclipse/edc/api/transformer/JsonObjectToCallbackAddressTransformer.java @@ -16,8 +16,8 @@ import jakarta.json.JsonObject; import jakarta.json.JsonValue; -import org.eclipse.edc.api.model.CallbackAddressDto; import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -30,22 +30,22 @@ import static org.eclipse.edc.spi.types.domain.callback.CallbackAddress.IS_TRANSACTIONAL; import static org.eclipse.edc.spi.types.domain.callback.CallbackAddress.URI; -public class JsonObjectToCallbackAddressDtoTransformer extends AbstractJsonLdTransformer { +public class JsonObjectToCallbackAddressTransformer extends AbstractJsonLdTransformer { - public JsonObjectToCallbackAddressDtoTransformer() { - super(JsonObject.class, CallbackAddressDto.class); + public JsonObjectToCallbackAddressTransformer() { + super(JsonObject.class, CallbackAddress.class); } @Override - public @Nullable CallbackAddressDto transform(@NotNull JsonObject jsonObject, @NotNull TransformerContext context) { - var builder = CallbackAddressDto.Builder.newInstance(); + public @Nullable CallbackAddress transform(@NotNull JsonObject jsonObject, @NotNull TransformerContext context) { + var builder = CallbackAddress.Builder.newInstance(); visitProperties(jsonObject, (key, value) -> setProperties(key, value, builder, context)); return builder.build(); } - private void setProperties(String key, JsonValue value, CallbackAddressDto.Builder builder, TransformerContext context) { + private void setProperties(String key, JsonValue value, CallbackAddress.Builder builder, TransformerContext context) { switch (key) { case IS_TRANSACTIONAL: builder.transactional(transformBoolean(value, context)); diff --git a/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/model/CallbackAddressDtoTest.java b/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/model/CallbackAddressDtoTest.java deleted file mode 100644 index d504b86b432..00000000000 --- a/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/model/CallbackAddressDtoTest.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.api.model; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.eclipse.edc.spi.types.TypeManager; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import java.util.Set; - -import static org.assertj.core.api.Assertions.assertThat; - -class CallbackAddressDtoTest { - - private ObjectMapper objectMapper; - - @BeforeEach - void setUp() { - objectMapper = new TypeManager().getMapper(); - } - - @Test - void verifySerialization() throws JsonProcessingException { - var dto = CallbackAddressDto.Builder.newInstance().uri("http://test").events(Set.of("event")).transactional(true).build(); - - var str = objectMapper.writeValueAsString(dto); - - assertThat(str).isNotNull(); - - var deserialized = objectMapper.readValue(str, CallbackAddressDto.class); - assertThat(deserialized).usingRecursiveComparison().isEqualTo(dto); - } -} diff --git a/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/model/CallbackAddressDtoValidationTest.java b/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/model/CallbackAddressDtoValidationTest.java deleted file mode 100644 index 710f1ed734a..00000000000 --- a/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/model/CallbackAddressDtoValidationTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation - * - */ - -package org.eclipse.edc.api.model; - -import jakarta.validation.Validation; -import jakarta.validation.Validator; -import jakarta.validation.ValidatorFactory; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -class CallbackAddressDtoValidationTest { - private Validator validator; - - - @BeforeEach - void setUp() { - try (ValidatorFactory factory = Validation.buildDefaultValidatorFactory()) { - validator = factory.getValidator(); - } - } - - @Test - void validate_validDto() { - - var dto = CallbackAddressDto.Builder.newInstance() - .uri("test") - .build(); - - - assertThat(validator.validate(dto)).isEmpty(); - } - - @Test - void validate_invalidDto() { - - var dto = CallbackAddressDto.Builder.newInstance() - .events(null) - .build(); - - - assertThat(validator.validate(dto)).hasSize(2); - } - - -} diff --git a/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/transformer/CallbackAddressDtoToCallbackAddressTransformerTest.java b/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/transformer/CallbackAddressDtoToCallbackAddressTransformerTest.java deleted file mode 100644 index 89292913fea..00000000000 --- a/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/transformer/CallbackAddressDtoToCallbackAddressTransformerTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0 - * - * SPDX-License-Identifier: Apache-2.0 - * - * Contributors: - * Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - improvements - * - */ - -package org.eclipse.edc.api.transformer; - -import org.eclipse.edc.api.model.CallbackAddressDto; -import org.eclipse.edc.transform.spi.TransformerContext; -import org.junit.jupiter.api.Test; - -import java.util.Set; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; - -class CallbackAddressDtoToCallbackAddressTransformerTest { - - private final CallbackAddressDtoToCallbackAddressTransformer transformer = new CallbackAddressDtoToCallbackAddressTransformer(); - - @Test - void inputOutputType() { - assertThat(transformer.getInputType()).isNotNull(); - assertThat(transformer.getOutputType()).isNotNull(); - } - - @Test - void transform() { - var context = mock(TransformerContext.class); - var dto = CallbackAddressDto.Builder.newInstance() - .uri("http://test") - .events(Set.of("event")) - .transactional(true) - .authCodeId("code") - .authKey("key") - .build(); - - var callback = transformer.transform(dto, context); - - assertThat(callback).usingRecursiveComparison().isEqualTo(dto); - } - -} diff --git a/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/transformer/JsonObjectToCallbackAddressDtoTransformerTest.java b/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/transformer/JsonObjectToCallbackAddressTransformerTest.java similarity index 93% rename from extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/transformer/JsonObjectToCallbackAddressDtoTransformerTest.java rename to extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/transformer/JsonObjectToCallbackAddressTransformerTest.java index b512fd8ef16..1a3ca84a561 100644 --- a/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/transformer/JsonObjectToCallbackAddressDtoTransformerTest.java +++ b/extensions/common/api/api-core/src/test/java/org/eclipse/edc/api/transformer/JsonObjectToCallbackAddressTransformerTest.java @@ -35,14 +35,14 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -class JsonObjectToCallbackAddressDtoTransformerTest { +class JsonObjectToCallbackAddressTransformerTest { private final JsonLd jsonLd = new TitaniumJsonLd(mock(Monitor.class)); - private JsonObjectToCallbackAddressDtoTransformer transformer; + private JsonObjectToCallbackAddressTransformer transformer; @BeforeEach void setUp() { - transformer = new JsonObjectToCallbackAddressDtoTransformer(); + transformer = new JsonObjectToCallbackAddressTransformer(); } @Test diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/model/NegotiationInitiateRequestDto.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/model/NegotiationInitiateRequestDto.java index eecd9bd53a6..93de18d98f9 100644 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/model/NegotiationInitiateRequestDto.java +++ b/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/model/NegotiationInitiateRequestDto.java @@ -17,7 +17,7 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import org.eclipse.edc.api.model.BaseDto; -import org.eclipse.edc.api.model.CallbackAddressDto; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import java.util.ArrayList; import java.util.List; @@ -48,7 +48,7 @@ public class NegotiationInitiateRequestDto extends BaseDto { private String providerId; private String consumerId; - private List callbackAddresses = new ArrayList<>(); + private List callbackAddresses = new ArrayList<>(); private NegotiationInitiateRequestDto() { @@ -79,7 +79,7 @@ public String getProviderId() { return providerId; } - public List getCallbackAddresses() { + public List getCallbackAddresses() { return callbackAddresses; } @@ -124,7 +124,7 @@ public Builder providerId(String providerId) { return this; } - public Builder callbackAddresses(List callbackAddresses) { + public Builder callbackAddresses(List callbackAddresses) { dto.callbackAddresses = callbackAddresses; return this; } diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/JsonObjectToNegotiationInitiateRequestDtoTransformer.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/JsonObjectToNegotiationInitiateRequestDtoTransformer.java index ea796cb70ee..2c40e740c8b 100644 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/JsonObjectToNegotiationInitiateRequestDtoTransformer.java +++ b/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/JsonObjectToNegotiationInitiateRequestDtoTransformer.java @@ -16,10 +16,10 @@ import jakarta.json.JsonObject; import jakarta.json.JsonValue; -import org.eclipse.edc.api.model.CallbackAddressDto; import org.eclipse.edc.connector.api.management.contractnegotiation.model.ContractOfferDescription; import org.eclipse.edc.connector.api.management.contractnegotiation.model.NegotiationInitiateRequestDto; import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -67,8 +67,8 @@ private void setProperties(String key, JsonValue value, NegotiationInitiateReque transformString(value, builder::consumerId, context); break; case CALLBACK_ADDRESSES: - var addresses = new ArrayList(); - transformArrayOrObject(value, CallbackAddressDto.class, addresses::add, context); + var addresses = new ArrayList(); + transformArrayOrObject(value, CallbackAddress.class, addresses::add, context); builder.callbackAddresses(addresses); break; case OFFER: diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/NegotiationInitiateRequestDtoToDataRequestTransformer.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/NegotiationInitiateRequestDtoToDataRequestTransformer.java index 25d223a4499..12b8fb12c2c 100644 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/NegotiationInitiateRequestDtoToDataRequestTransformer.java +++ b/extensions/control-plane/api/management-api/contract-negotiation-api/src/main/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/NegotiationInitiateRequestDtoToDataRequestTransformer.java @@ -19,13 +19,11 @@ import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractRequest; import org.eclipse.edc.connector.contract.spi.types.negotiation.ContractRequestData; import org.eclipse.edc.connector.contract.spi.types.offer.ContractOffer; -import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.time.Clock; -import java.util.stream.Collectors; public class NegotiationInitiateRequestDtoToDataRequestTransformer implements DtoTransformer { @@ -62,8 +60,7 @@ public Class getOutputType() { .providerId(getId(object.getProviderId(), object.getConnectorAddress())) .policy(object.getOffer().getPolicy()) .build(); - - + var requestData = ContractRequestData.Builder.newInstance() .connectorId(object.getConnectorId()) .counterPartyAddress(object.getConnectorAddress()) @@ -71,11 +68,9 @@ public Class getOutputType() { .contractOffer(contractOffer) .build(); - var callbacks = object.getCallbackAddresses().stream().map(c -> context.transform(c, CallbackAddress.class)).collect(Collectors.toList()); - return ContractRequest.Builder.newInstance() .requestData(requestData) - .callbackAddresses(callbacks) + .callbackAddresses(object.getCallbackAddresses()) .build(); } diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/JsonObjectToNegotiationInitiateRequestDtoTransformerTest.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/JsonObjectToNegotiationInitiateRequestDtoTransformerTest.java index 2b3930b2ea1..05778bdeae9 100644 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/JsonObjectToNegotiationInitiateRequestDtoTransformerTest.java +++ b/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/JsonObjectToNegotiationInitiateRequestDtoTransformerTest.java @@ -18,7 +18,6 @@ import jakarta.json.JsonArrayBuilder; import jakarta.json.JsonObject; import jakarta.json.JsonValue; -import org.eclipse.edc.api.model.CallbackAddressDto; import org.eclipse.edc.connector.api.management.contractnegotiation.model.ContractOfferDescription; import org.eclipse.edc.connector.api.management.contractnegotiation.model.NegotiationInitiateRequestDto; import org.eclipse.edc.jsonld.TitaniumJsonLd; @@ -90,11 +89,7 @@ void transform() { .events(Set.of("foo", "bar")) .transactional(true) .build()); - when(context.transform(any(CallbackAddress.class), eq(CallbackAddressDto.class))).thenReturn(CallbackAddressDto.Builder.newInstance() - .uri("http://test.local") - .events(Set.of("foo", "bar")) - .transactional(true) - .build()); + var dto = transformer.transform(jsonLd.expand(jsonObject).getContent(), context); assertThat(dto).isNotNull(); diff --git a/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/NegotiationInitiateRequestDtoToDataRequestTransformerTest.java b/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/NegotiationInitiateRequestDtoToDataRequestTransformerTest.java index 182fd853490..74032873a0d 100644 --- a/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/NegotiationInitiateRequestDtoToDataRequestTransformerTest.java +++ b/extensions/control-plane/api/management-api/contract-negotiation-api/src/test/java/org/eclipse/edc/connector/api/management/contractnegotiation/transform/NegotiationInitiateRequestDtoToDataRequestTransformerTest.java @@ -14,8 +14,8 @@ package org.eclipse.edc.connector.api.management.contractnegotiation.transform; -import org.eclipse.edc.api.model.CallbackAddressDto; import org.eclipse.edc.connector.api.management.contractnegotiation.model.NegotiationInitiateRequestDto; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import org.eclipse.edc.transform.spi.TransformerContext; import org.junit.jupiter.api.Test; @@ -46,7 +46,7 @@ void inputOutputType() { @Test void verify_transform() { - var callback = CallbackAddressDto.Builder.newInstance() + var callback = CallbackAddress.Builder.newInstance() .uri("local://test") .build(); var dto = NegotiationInitiateRequestDto.Builder.newInstance() diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/model/TransferProcessDto.java b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/model/TransferProcessDto.java index 9dbfdc9b9d7..3f7d9f61309 100644 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/model/TransferProcessDto.java +++ b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/model/TransferProcessDto.java @@ -17,9 +17,9 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; -import org.eclipse.edc.api.model.CallbackAddressDto; import org.eclipse.edc.api.model.DataAddressDto; import org.eclipse.edc.api.model.MutableDto; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import java.util.ArrayList; import java.util.HashMap; @@ -48,7 +48,7 @@ public class TransferProcessDto extends MutableDto { private DataRequestDto dataRequest; private DataAddressDto dataDestination; private Map properties = new HashMap<>(); - private List callbackAddresses = new ArrayList<>(); + private List callbackAddresses = new ArrayList<>(); private TransferProcessDto() { } @@ -77,7 +77,7 @@ public DataRequestDto getDataRequest() { return dataRequest; } - public List getCallbackAddresses() { + public List getCallbackAddresses() { return callbackAddresses; } @@ -132,7 +132,7 @@ public Builder properties(Map properties) { return this; } - public Builder callbackAddresses(List callbackAddresses) { + public Builder callbackAddresses(List callbackAddresses) { dto.callbackAddresses = callbackAddresses; return this; } diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/model/TransferRequestDto.java b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/model/TransferRequestDto.java index 124a9bdf05a..f092564719d 100644 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/model/TransferRequestDto.java +++ b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/model/TransferRequestDto.java @@ -18,8 +18,8 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import jakarta.validation.constraints.NotNull; -import org.eclipse.edc.api.model.CallbackAddressDto; import org.eclipse.edc.spi.types.domain.DataAddress; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import java.util.ArrayList; import java.util.HashMap; @@ -43,6 +43,8 @@ public class TransferRequestDto { public static final String EDC_TRANSFER_REQUEST_DTO_PROTOCOL = EDC_NAMESPACE + "protocol"; public static final String EDC_TRANSFER_REQUEST_DTO_CONNECTOR_ID = EDC_NAMESPACE + "connectorId"; public static final String EDC_TRANSFER_REQUEST_DTO_ASSET_ID = EDC_NAMESPACE + "assetId"; + public static final String EDC_TRANSFER_REQUEST_DTO_CALLBACK_ADDRESSES = EDC_NAMESPACE + "callbackAddresses"; + private String id; @NotNull(message = "connectorAddress cannot be null") @@ -63,7 +65,7 @@ public class TransferRequestDto { @NotNull(message = "assetId cannot be null") private String assetId; - private List callbackAddresses = new ArrayList<>(); + private List callbackAddresses = new ArrayList<>(); public String getConnectorAddress() { @@ -106,7 +108,7 @@ public String getAssetId() { return assetId; } - public List getCallbackAddresses() { + public List getCallbackAddresses() { return callbackAddresses; } @@ -173,7 +175,7 @@ public Builder assetId(String assetId) { return this; } - public Builder callbackAddresses(List callbackAddresses) { + public Builder callbackAddresses(List callbackAddresses) { request.callbackAddresses = callbackAddresses; return this; } diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/transform/JsonObjectToTransferRequestDtoTransformer.java b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/transform/JsonObjectToTransferRequestDtoTransformer.java index cb1d3002caa..29a0b017e32 100644 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/transform/JsonObjectToTransferRequestDtoTransformer.java +++ b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/transform/JsonObjectToTransferRequestDtoTransformer.java @@ -20,10 +20,12 @@ import org.eclipse.edc.connector.api.management.transferprocess.model.TransferRequestDto; import org.eclipse.edc.jsonld.spi.transformer.AbstractJsonLdTransformer; import org.eclipse.edc.spi.types.domain.DataAddress; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.function.Consumer; @@ -31,6 +33,7 @@ import static jakarta.json.JsonValue.ValueType.ARRAY; import static jakarta.json.JsonValue.ValueType.OBJECT; import static org.eclipse.edc.connector.api.management.transferprocess.model.TransferRequestDto.EDC_TRANSFER_REQUEST_DTO_ASSET_ID; +import static org.eclipse.edc.connector.api.management.transferprocess.model.TransferRequestDto.EDC_TRANSFER_REQUEST_DTO_CALLBACK_ADDRESSES; import static org.eclipse.edc.connector.api.management.transferprocess.model.TransferRequestDto.EDC_TRANSFER_REQUEST_DTO_CONNECTOR_ADDRESS; import static org.eclipse.edc.connector.api.management.transferprocess.model.TransferRequestDto.EDC_TRANSFER_REQUEST_DTO_CONNECTOR_ID; import static org.eclipse.edc.connector.api.management.transferprocess.model.TransferRequestDto.EDC_TRANSFER_REQUEST_DTO_CONTRACT_ID; @@ -63,6 +66,12 @@ public JsonObjectToTransferRequestDtoTransformer() { return (v) -> builder.managedResources(transformBoolean(v, context)); case EDC_TRANSFER_REQUEST_DTO_PROPERTIES: return (v) -> transformProperties(v, builder::properties, context); + case EDC_TRANSFER_REQUEST_DTO_CALLBACK_ADDRESSES: + return (v) -> { + var addresses = new ArrayList(); + transformArrayOrObject(v, CallbackAddress.class, addresses::add, context); + builder.callbackAddresses(addresses); + }; case EDC_TRANSFER_REQUEST_DTO_PRIVATE_PROPERTIES: return (v) -> transformProperties(v, builder::privateProperties, context); case EDC_TRANSFER_REQUEST_DTO_PROTOCOL: diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferProcessToTransferProcessDtoTransformer.java b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferProcessToTransferProcessDtoTransformer.java index 5f8c73ad0c7..cbd5f040af3 100644 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferProcessToTransferProcessDtoTransformer.java +++ b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferProcessToTransferProcessDtoTransformer.java @@ -14,7 +14,6 @@ package org.eclipse.edc.connector.api.management.transferprocess.transform; -import org.eclipse.edc.api.model.CallbackAddressDto; import org.eclipse.edc.api.model.DataAddressDto; import org.eclipse.edc.api.transformer.DtoTransformer; import org.eclipse.edc.connector.api.management.transferprocess.model.DataRequestDto; @@ -30,8 +29,6 @@ import java.util.Collections; import java.util.Optional; -import static java.util.stream.Collectors.toList; - public class TransferProcessToTransferProcessDtoTransformer implements DtoTransformer { @Override @@ -58,7 +55,7 @@ public Class getOutputType() { .updatedAt(object.getUpdatedAt()) .dataRequest(context.transform(dataRequest, DataRequestDto.class)) .properties(object.getPrivateProperties()) - .callbackAddresses(object.getCallbackAddresses().stream().map(it -> context.transform(it, CallbackAddressDto.class)).collect(toList())) + .callbackAddresses(object.getCallbackAddresses()) .dataDestination( DataAddressDto.Builder.newInstance() .properties(dataRequestProperties) diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferRequestDtoToTransferRequestTransformer.java b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferRequestDtoToTransferRequestTransformer.java index 92e5ff8ce2a..0c85b104452 100644 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferRequestDtoToTransferRequestTransformer.java +++ b/extensions/control-plane/api/management-api/transfer-process-api/src/main/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferRequestDtoToTransferRequestTransformer.java @@ -18,14 +18,12 @@ import org.eclipse.edc.connector.api.management.transferprocess.model.TransferRequestDto; import org.eclipse.edc.connector.transfer.spi.types.DataRequest; import org.eclipse.edc.connector.transfer.spi.types.TransferRequest; -import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.Objects; import java.util.UUID; -import java.util.stream.Collectors; public class TransferRequestDtoToTransferRequestTransformer implements DtoTransformer { @@ -58,11 +56,9 @@ public Class getOutputType() { .dataDestination(object.getDataDestination()) .build(); - var callbacks = object.getCallbackAddresses().stream().map(c -> context.transform(c, CallbackAddress.class)).collect(Collectors.toList()); - return TransferRequest.Builder.newInstance() .dataRequest(dataRequest) - .callbackAddresses(callbacks) + .callbackAddresses(object.getCallbackAddresses()) .privateProperties(object.getPrivateProperties()) .build(); } diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/JsonObjectFromTransferProcessDtoTransformerTest.java b/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/JsonObjectFromTransferProcessDtoTransformerTest.java index 75e49cca925..8c23013ffa3 100644 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/JsonObjectFromTransferProcessDtoTransformerTest.java +++ b/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/JsonObjectFromTransferProcessDtoTransformerTest.java @@ -16,10 +16,10 @@ import jakarta.json.Json; import jakarta.json.JsonObject; -import org.eclipse.edc.api.model.CallbackAddressDto; import org.eclipse.edc.api.model.DataAddressDto; import org.eclipse.edc.connector.api.management.transferprocess.model.DataRequestDto; import org.eclipse.edc.connector.api.management.transferprocess.model.TransferProcessDto; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import org.eclipse.edc.transform.spi.TransformerContext; import org.junit.jupiter.api.Test; @@ -63,7 +63,7 @@ void transform() { var callbackAddresJson = Json.createObjectBuilder().build(); when(context.transform(isA(DataAddressDto.class), any())).thenReturn(dataDestinationJson); when(context.transform(isA(DataRequestDto.class), any())).thenReturn(dataRequestJson); - when(context.transform(isA(CallbackAddressDto.class), any())).thenReturn(callbackAddresJson); + when(context.transform(isA(CallbackAddress.class), any())).thenReturn(callbackAddresJson); var input = TransferProcessDto.Builder.newInstance() .id("transferProcessId") .state("STATE") @@ -72,7 +72,7 @@ void transform() { .type("CONSUMER") .dataDestination(DataAddressDto.Builder.newInstance().properties(Map.of("bar", "foo")).build()) .dataRequest(DataRequestDto.Builder.newInstance().build()) - .callbackAddresses(List.of(CallbackAddressDto.Builder.newInstance().uri("http://any").events(emptySet()).build())) + .callbackAddresses(List.of(CallbackAddress.Builder.newInstance().uri("http://any").events(emptySet()).build())) .errorDetail("an error") .build(); diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferProcessToTransferProcessDtoTransformerTest.java b/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferProcessToTransferProcessDtoTransformerTest.java index 899a5d56c5c..3e158ab9b6f 100644 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferProcessToTransferProcessDtoTransformerTest.java +++ b/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferProcessToTransferProcessDtoTransformerTest.java @@ -14,7 +14,6 @@ package org.eclipse.edc.connector.api.management.transferprocess.transform; -import org.eclipse.edc.api.model.CallbackAddressDto; import org.eclipse.edc.api.model.DataAddressDto; import org.eclipse.edc.connector.api.management.transferprocess.model.DataRequestDto; import org.eclipse.edc.connector.api.management.transferprocess.model.TransferProcessDto; @@ -22,6 +21,7 @@ import org.eclipse.edc.connector.transfer.spi.types.TransferProcess; import org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates; import org.eclipse.edc.spi.types.domain.DataAddress; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import org.eclipse.edc.transform.spi.ProblemBuilder; import org.eclipse.edc.transform.spi.TransformerContext; import org.junit.jupiter.api.Test; @@ -58,7 +58,7 @@ void getOutputType() { @Test void transform() { when(context.transform(any(), eq(DataRequestDto.class))).thenReturn(data.dataRequestDto); - when(context.transform(any(), eq(CallbackAddressDto.class))).thenReturn(data.callbackAddressDto); + when(context.transform(any(), eq(CallbackAddress.class))).thenReturn(data.callbackAddressDto); var result = transformer.transform(data.entity.build(), context); @@ -72,7 +72,7 @@ void transform() { @Test void transform_whenInvalidState() { when(context.transform(any(), eq(DataRequestDto.class))).thenReturn(data.dataRequestDto); - when(context.transform(any(), eq(CallbackAddressDto.class))).thenReturn(data.callbackAddressDto); + when(context.transform(any(), eq(CallbackAddress.class))).thenReturn(data.callbackAddressDto); when(context.problem()).thenReturn(new ProblemBuilder(context)); data.entity.state(invalidStateCode()); @@ -90,7 +90,7 @@ void transform_whenInvalidState() { @Test void transform_whenMinimalData() { when(context.transform(any(), eq(DataRequestDto.class))).thenReturn(data.dataRequestDto); - when(context.transform(any(), eq(CallbackAddressDto.class))).thenReturn(data.callbackAddressDto); + when(context.transform(any(), eq(CallbackAddress.class))).thenReturn(data.callbackAddressDto); data.dto.state(INITIAL.name()); data.dataDestination = DataAddress.Builder.newInstance().type(data.dataDestinationType); diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferProcessTransformerTestData.java b/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferProcessTransformerTestData.java index 781e507efb6..36003cc76b7 100644 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferProcessTransformerTestData.java +++ b/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferProcessTransformerTestData.java @@ -14,7 +14,6 @@ package org.eclipse.edc.connector.api.management.transferprocess.transform; -import org.eclipse.edc.api.model.CallbackAddressDto; import org.eclipse.edc.api.model.DataAddressDto; import org.eclipse.edc.connector.api.management.transferprocess.model.DataRequestDto; import org.eclipse.edc.connector.api.management.transferprocess.model.TransferProcessDto; @@ -55,7 +54,7 @@ public class TransferProcessTransformerTestData { .dataRequest(dataRequest) .callbackAddresses(List.of(callbackAddress)); DataRequestDto dataRequestDto = DataRequestDto.Builder.newInstance().build(); - CallbackAddressDto callbackAddressDto = CallbackAddressDto.Builder.newInstance().uri("local://test").build(); + CallbackAddress callbackAddressDto = CallbackAddress.Builder.newInstance().uri("local://test").build(); TransferProcessDto.Builder dto = TransferProcessDto.Builder.newInstance() .id(id) .type(type.name()) diff --git a/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferRequestDtoToTransferRequestTransformerTest.java b/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferRequestDtoToTransferRequestTransformerTest.java index 96e1ab4db98..f994abdab9d 100644 --- a/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferRequestDtoToTransferRequestTransformerTest.java +++ b/extensions/control-plane/api/management-api/transfer-process-api/src/test/java/org/eclipse/edc/connector/api/management/transferprocess/transform/TransferRequestDtoToTransferRequestTransformerTest.java @@ -15,12 +15,12 @@ package org.eclipse.edc.connector.api.management.transferprocess.transform; -import org.eclipse.edc.api.model.CallbackAddressDto; import org.eclipse.edc.api.transformer.DtoTransformer; import org.eclipse.edc.connector.api.management.transferprocess.model.TransferRequestDto; import org.eclipse.edc.connector.transfer.spi.types.DataRequest; import org.eclipse.edc.connector.transfer.spi.types.TransferRequest; import org.eclipse.edc.spi.types.domain.DataAddress; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import org.eclipse.edc.transform.spi.TransformerContext; import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.Test; @@ -87,7 +87,7 @@ private TransferRequestDto.Builder transferRequestDto() { .protocol("test-protocol") .dataDestination(DataAddress.Builder.newInstance().type("test-type").build()) .connectorId(UUID.randomUUID().toString()) - .callbackAddresses(List.of(CallbackAddressDto.Builder.newInstance().uri("local://test").build())) + .callbackAddresses(List.of(CallbackAddress.Builder.newInstance().uri("local://test").build())) .properties(Map.of("key1", "value1")) .privateProperties(Map.of("privateKey", "privateValue")); } diff --git a/resources/openapi/yaml/management-api/contract-negotiation-api.yaml b/resources/openapi/yaml/management-api/contract-negotiation-api.yaml index ff6d72ca4cb..3995c250630 100644 --- a/resources/openapi/yaml/management-api/contract-negotiation-api.yaml +++ b/resources/openapi/yaml/management-api/contract-negotiation-api.yaml @@ -316,38 +316,6 @@ components: uri: type: string example: null - CallbackAddressDto: - type: object - example: null - properties: - '@context': - type: object - example: null - '@type': - type: string - example: null - authCodeId: - type: string - example: null - authKey: - type: string - example: null - events: - type: array - example: null - items: - type: string - example: null - uniqueItems: true - transactional: - type: boolean - example: null - uri: - type: string - example: null - required: - - events - - uri Constraint: type: object discriminator: @@ -566,7 +534,7 @@ components: type: array example: null items: - $ref: '#/components/schemas/CallbackAddressDto' + $ref: '#/components/schemas/CallbackAddress' connectorAddress: type: string example: null diff --git a/resources/openapi/yaml/management-api/transfer-process-api.yaml b/resources/openapi/yaml/management-api/transfer-process-api.yaml index a112bfe35df..459098f47bd 100644 --- a/resources/openapi/yaml/management-api/transfer-process-api.yaml +++ b/resources/openapi/yaml/management-api/transfer-process-api.yaml @@ -255,16 +255,10 @@ components: type: type: string example: null - CallbackAddressDto: + CallbackAddress: type: object example: null properties: - '@context': - type: object - example: null - '@type': - type: string - example: null authCodeId: type: string example: null @@ -284,9 +278,6 @@ components: uri: type: string example: null - required: - - events - - uri CriterionDto: type: object example: null @@ -463,7 +454,7 @@ components: type: array example: null items: - $ref: '#/components/schemas/CallbackAddressDto' + $ref: '#/components/schemas/CallbackAddress' createdAt: type: integer format: int64 @@ -506,7 +497,7 @@ components: type: array example: null items: - $ref: '#/components/schemas/CallbackAddressDto' + $ref: '#/components/schemas/CallbackAddress' connectorAddress: type: string example: null diff --git a/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/ContractNegotiationApiEndToEndTest.java b/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/ContractNegotiationApiEndToEndTest.java index f5519b571c1..2ad92505b5a 100644 --- a/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/ContractNegotiationApiEndToEndTest.java +++ b/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/ContractNegotiationApiEndToEndTest.java @@ -227,7 +227,7 @@ private ContractAgreement createContractAgreement(String negotiationId) { private JsonArrayBuilder createCallbackAddress() { var builder = Json.createArrayBuilder(); return builder.add(createObjectBuilder() - .add(IS_TRANSACTIONAL, true) + .add(IS_TRANSACTIONAL, false) .add(URI, "http://test.local/") .add(EVENTS, Json.createArrayBuilder().build())); } diff --git a/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/TransferProcessApiEndToEndTest.java b/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/TransferProcessApiEndToEndTest.java index ed4dfd3e970..b4bbbb38214 100644 --- a/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/TransferProcessApiEndToEndTest.java +++ b/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/TransferProcessApiEndToEndTest.java @@ -15,18 +15,23 @@ package org.eclipse.edc.test.e2e.managementapi; import io.restassured.specification.RequestSpecification; +import jakarta.json.Json; +import jakarta.json.JsonArrayBuilder; import org.eclipse.edc.connector.transfer.spi.store.TransferProcessStore; import org.eclipse.edc.connector.transfer.spi.types.DataRequest; import org.eclipse.edc.connector.transfer.spi.types.TransferProcess; import org.eclipse.edc.junit.annotations.EndToEndTest; import org.eclipse.edc.spi.types.domain.DataAddress; +import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; import org.junit.jupiter.api.Test; +import java.util.List; import java.util.UUID; import static io.restassured.RestAssured.given; import static io.restassured.http.ContentType.JSON; import static jakarta.json.Json.createObjectBuilder; +import static java.util.Collections.emptySet; import static org.assertj.core.api.Assertions.assertThat; import static org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates.COMPLETED; import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT; @@ -34,6 +39,9 @@ import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE; import static org.eclipse.edc.spi.CoreConstants.EDC_NAMESPACE; import static org.eclipse.edc.spi.CoreConstants.EDC_PREFIX; +import static org.eclipse.edc.spi.types.domain.callback.CallbackAddress.EVENTS; +import static org.eclipse.edc.spi.types.domain.callback.CallbackAddress.IS_TRANSACTIONAL; +import static org.eclipse.edc.spi.types.domain.callback.CallbackAddress.URI; import static org.hamcrest.CoreMatchers.anyOf; import static org.hamcrest.Matchers.is; @@ -98,6 +106,7 @@ void create() { .build()) .build() ) + .add("callbackAddresses", createCallbackAddress()) .add("protocol", "dataspace-protocol-http") .add("assetId", "assetId") .build(); @@ -149,6 +158,7 @@ private TransferProcess createTransferProcess(String id) { private TransferProcess.Builder createTransferProcessBuilder(String id) { return TransferProcess.Builder.newInstance() .id(id) + .callbackAddresses(List.of(CallbackAddress.Builder.newInstance().uri("http://any").events(emptySet()).build())) .dataRequest(DataRequest.Builder.newInstance() .id(UUID.randomUUID().toString()) .dataDestination(DataAddress.Builder.newInstance() @@ -159,6 +169,14 @@ private TransferProcess.Builder createTransferProcessBuilder(String id) { .build()); } + private JsonArrayBuilder createCallbackAddress() { + var builder = Json.createArrayBuilder(); + return builder.add(createObjectBuilder() + .add(IS_TRANSACTIONAL, false) + .add(URI, "http://test.local/") + .add(EVENTS, Json.createArrayBuilder().build())); + } + private RequestSpecification baseRequest() { return given() .port(PORT)