Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
import java.util.UUID;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
import static tools.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
import static jakarta.ws.rs.core.HttpHeaders.AUTHORIZATION;
import static tools.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;

public class Dataplane {

Expand Down Expand Up @@ -150,6 +150,7 @@ public Result<DataFlowStatusMessage> start(String controlplaneId, DataFlowStartM
.map(controlPlane -> DataFlow.newInstance()
.id(message.dataFlowId())
.state(DataFlow.State.INITIATING)
.metadata(message.metadata())
.dataAddress(message.dataAddress())
.callbackAddress(controlPlane.getEndpoint())
.profile(message.profile())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.github.tomakehurst.wiremock.WireMockServer;
import org.eclipse.dataplane.domain.Result;
import org.eclipse.dataplane.domain.dataflow.DataFlowPrepareMessage;
import org.eclipse.dataplane.domain.dataflow.DataFlowStartMessage;
import org.eclipse.dataplane.domain.registration.AuthorizationProfile;
import org.eclipse.dataplane.domain.registration.ControlPlaneRegistrationMessage;
import org.eclipse.dataplane.exception.DataFlowNotifyControlPlaneFailed;
Expand Down Expand Up @@ -116,6 +117,30 @@ void shouldTransitionToCompleted_whenControlPlaneRespondCorrectly() {
assertThat(result.succeeded()).isTrue();
assertThat(dataplane.status("dataFlowId").getContent().state()).isEqualTo(COMPLETED.name());
}

@Test
void shouldForwardMetadataToDataFlow() {
var startMessage = createStartMessage();
var expectedMetadata = startMessage.metadata();

var dataplane = Dataplane.newInstance()
.onStart(dataFlow -> {
assertThat(dataFlow.getMetadata())
.isEqualTo(expectedMetadata);

return Result.success(dataFlow);
})
.build();

dataplane.registerControlPlane(new ControlPlaneRegistrationMessage("controlplaneId", URI.create(controlPlane.baseUrl())));
dataplane.start("controlplaneId", startMessage);
controlPlane.stop();

var result = dataplane.notifyCompleted("dataFlowId");

assertThat(result.failed()).isTrue();
assertThatThrownBy(result::orElseThrow).isExactlyInstanceOf(ConnectException.class);
}
}

@Nested
Expand Down Expand Up @@ -228,4 +253,8 @@ void shouldFail_whenStatusIsNot200() {
private DataFlowPrepareMessage createPrepareMessage() {
return MessageFactory.createPrepareMessage("dataFlowId", "Something-PUSH");
}

private DataFlowStartMessage createStartMessage() {
return MessageFactory.createStartMessage("dataFlowId", "Something-PUSH");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.eclipse.dataplane.domain.dataflow.DataFlowStartMessage;
import org.jspecify.annotations.NonNull;

import java.util.Map;

import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap;

Expand All @@ -37,6 +39,6 @@ public interface MessageFactory {
static @NonNull DataFlowStartMessage createStartMessage(String providerProcessId, String profile, DataAddress destinationDataAddress) {
return new DataFlowStartMessage("theMessageId", "theParticipantId", "theCounterPartyId",
"theDataspaceContext", providerProcessId, "theAgreementId", "theDatasetId",
profile, destinationDataAddress, emptyMap(), emptyList(), emptyMap());
profile, destinationDataAddress, emptyMap(), emptyList(), Map.of("the", "metadata"));
}
}