Skip to content

Commit c8d3d8e

Browse files
committed
test: add TCK tests
1 parent 95aac1f commit c8d3d8e

18 files changed

Lines changed: 318 additions & 36 deletions

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ version = "0.0.11-SNAPSHOT"
1212

1313
repositories {
1414
mavenCentral()
15+
mavenLocal()
1516
}
1617

1718
dependencies {
1819
implementation("com.fasterxml.jackson.core:jackson-databind:2.21.3")
1920
implementation("com.nimbusds:nimbus-jose-jwt:10.9")
2021
implementation("jakarta.ws.rs:jakarta.ws.rs-api:4.0.0")
22+
runtimeOnly("org.eclipse.parsson:parsson:1.1.9")
2123

2224
testImplementation(platform("org.junit:junit-bom:6.1.0"))
2325
testImplementation("org.junit.jupiter:junit-jupiter")
@@ -37,6 +39,7 @@ dependencies {
3739
testImplementation("org.testcontainers:testcontainers-junit-jupiter:2.0.5")
3840
testImplementation("org.testcontainers:testcontainers-postgresql:2.0.5")
3941
testImplementation("org.postgresql:postgresql:42.7.11")
42+
testImplementation("org.eclipse.dataspacetck.dps:dps-tck:1.1.0")
4043
}
4144

4245
tasks.test {

src/main/java/org/eclipse/dataplane/Dataplane.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@
6363
import java.util.Set;
6464
import java.util.UUID;
6565

66+
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
6667
import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
6768
import static jakarta.ws.rs.core.HttpHeaders.AUTHORIZATION;
68-
import static java.util.Collections.emptyMap;
6969

7070
public class Dataplane {
7171

72-
private final ObjectMapper objectMapper = new ObjectMapper().configure(FAIL_ON_UNKNOWN_PROPERTIES, false);
72+
private final ObjectMapper objectMapper = new ObjectMapper()
73+
.configure(FAIL_ON_UNKNOWN_PROPERTIES, false)
74+
.setDefaultPropertyInclusion(NON_NULL);
7375
private DataFlowStore dataFlowStore = new InMemoryDataFlowStore(objectMapper);
7476
private ControlPlaneStore controlPlaneStore = new InMemoryControlPlaneStore(objectMapper);
7577
private String id;
@@ -274,8 +276,8 @@ public Result<Void> notifyCompleted(String dataFlowId) {
274276
return dataFlowStore.findById(dataFlowId)
275277
.compose(dataFlow -> {
276278
dataFlow.transitionToCompleted();
277-
278-
return notifyControlPlane("completed", dataFlow, emptyMap());
279+
var message = new DataFlowStatusMessage(dataFlowId, dataFlow.getState().name(), null, null);
280+
return notifyControlPlane("completed", dataFlow, message);
279281
});
280282
}
281283

@@ -374,7 +376,7 @@ private Result<Void> notifyControlPlane(String action, DataFlow dataFlow, Object
374376
})
375377
.onSuccess(authorizationHeader -> requestBuilder.header(AUTHORIZATION, authorizationHeader));
376378

377-
return httpClient.send(requestBuilder.build(), HttpResponse.BodyHandlers.discarding());
379+
return httpClient.send(requestBuilder.build(), HttpResponse.BodyHandlers.ofString());
378380
})
379381
.compose(response -> {
380382
var successful = response.statusCode() >= 200 && response.statusCode() < 300;

src/main/java/org/eclipse/dataplane/domain/DataAddress.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@
1414

1515
package org.eclipse.dataplane.domain;
1616

17+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1718
import com.fasterxml.jackson.annotation.JsonProperty;
1819

1920
import java.util.List;
2021

22+
@JsonIgnoreProperties(value = {"@type"})
2123
public record DataAddress(
22-
@JsonProperty("@type") String type,
2324
String endpointType,
2425
String endpoint,
2526
List<EndpointProperty> endpointProperties
2627
) {
2728

28-
public DataAddress(String endpointType, String endpoint, List<EndpointProperty> endpointProperties) {
29-
this("DataAddress", endpointType, endpoint, endpointProperties);
29+
@JsonProperty("@type")
30+
public String getType() {
31+
return "DataAddress";
3032
}
3133

3234
public record EndpointProperty(

src/main/java/org/eclipse/dataplane/domain/dataflow/DataFlow.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ public void transitionToTerminated(String reason) {
132132
}
133133

134134
public boolean isPush() {
135-
return transferType.split("-")[1].equalsIgnoreCase("PUSH");
135+
return transferType.substring(transferType.lastIndexOf('-') + 1).equalsIgnoreCase("push");
136+
}
137+
138+
public boolean isPull() {
139+
return !isPush();
136140
}
137141

138142
public boolean isInitiating() {
@@ -147,10 +151,6 @@ public boolean isStarted() {
147151
return state == State.STARTED;
148152
}
149153

150-
public boolean isPull() {
151-
return transferType.split("-")[1].equalsIgnoreCase("PULL");
152-
}
153-
154154
public void setDataAddress(DataAddress dataAddress) {
155155
this.dataAddress = dataAddress;
156156
}

src/main/java/org/eclipse/dataplane/domain/dataflow/DataFlowStartedNotificationMessage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.eclipse.dataplane.domain.DataAddress;
1818

1919
public record DataFlowStartedNotificationMessage(
20+
String messageId,
2021
DataAddress dataAddress
2122
) {
2223
}

src/main/java/org/eclipse/dataplane/domain/dataflow/DataFlowStatusMessage.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,16 @@
1717

1818
import org.eclipse.dataplane.domain.DataAddress;
1919

20+
import java.util.UUID;
21+
2022
public record DataFlowStatusMessage(
23+
String messageId,
2124
String dataFlowId,
2225
String state,
2326
DataAddress dataAddress,
2427
String error
2528
) {
29+
public DataFlowStatusMessage(String dataFlowId, String state, DataAddress dataAddress, String error) {
30+
this(UUID.randomUUID().toString(), dataFlowId, state, dataAddress, error);
31+
}
2632
}

src/main/java/org/eclipse/dataplane/domain/dataflow/DataFlowStatusResponseMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package org.eclipse.dataplane.domain.dataflow;
1616

1717
public record DataFlowStatusResponseMessage(
18-
String dataflowId,
18+
String dataFlowId,
1919
String state
2020
) {
2121
}

src/main/java/org/eclipse/dataplane/domain/dataflow/DataFlowSuspendMessage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package org.eclipse.dataplane.domain.dataflow;
1616

1717
public record DataFlowSuspendMessage(
18+
String messageId,
1819
String reason
1920
) {
2021
}

src/main/java/org/eclipse/dataplane/domain/dataflow/DataFlowTerminateMessage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package org.eclipse.dataplane.domain.dataflow;
1616

1717
public record DataFlowTerminateMessage(
18+
String messageId,
1819
String reason
1920
) {
2021
}

src/main/java/org/eclipse/dataplane/port/exception/DataFlowNotifyControlPlaneFailed.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818

1919
public class DataFlowNotifyControlPlaneFailed extends Exception {
2020
private final String action;
21-
private final HttpResponse<Void> response;
21+
private final HttpResponse<String> response;
2222

23-
public DataFlowNotifyControlPlaneFailed(String action, HttpResponse<Void> response) {
24-
super("control-plane responded with %s".formatted(response.statusCode()));
23+
public DataFlowNotifyControlPlaneFailed(String action, HttpResponse<String> response) {
24+
super("control-plane responded with %s: %s".formatted(response.statusCode(), response.body()));
2525
this.action = action;
2626
this.response = response;
2727
}
2828

29-
public HttpResponse<Void> getResponse() {
29+
public HttpResponse<String> getResponse() {
3030
return response;
3131
}
3232

0 commit comments

Comments
 (0)