Skip to content

Commit

Permalink
chore(dsp-transfer-process-transform): fix unit Test Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
janpmeyer committed Apr 26, 2023
1 parent f3762b6 commit 6e29d95
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.Map;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.CONTEXT;
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.TYPE;
Expand All @@ -40,8 +42,6 @@ class JsonObjectToTransferTerminationMessageTransformerTest {

private final String code = "testCode";

private final String reason = "testReason";

private TransformerContext context = mock(TransformerContext.class);

private JsonObjectToTransferTerminationMessageTransformer transformer;
Expand All @@ -53,13 +53,14 @@ void setUp() {

@Test
void jsonObjectToTransferTerminationMessage() {
var reason = Json.createBuilderFactory(Map.of()).createObjectBuilder().add("foo", "bar");

var json = Json.createObjectBuilder()
.add(CONTEXT, DSPACE_SCHEMA)
.add(TYPE, DSPACE_TRANSFER_TERMINATION_TYPE)
.add(DSPACE_PROCESSID_TYPE, processId)
.add(DSPACE_CODE_TYPE, code)
.add(DSPACE_REASON_TYPE, reason)
.add(DSPACE_REASON_TYPE, Json.createBuilderFactory(Map.of()).createArrayBuilder().add(reason).build())
.build();

var result = transformer.transform(json, context);
Expand All @@ -68,7 +69,7 @@ void jsonObjectToTransferTerminationMessage() {

assertThat(result.getProcessId()).isEqualTo(processId);
assertThat(result.getProtocol()).isEqualTo(HttpMessageProtocol.DATASPACE_PROTOCOL_HTTP);
assertThat(result.getReason()).isEqualTo(reason);
assertThat(result.getReason()).isEqualTo("{\"foo\":\"bar\"}");
assertThat(result.getCode()).isEqualTo(code);

verify(context, never()).reportProblem(anyString());
Expand Down

0 comments on commit 6e29d95

Please sign in to comment.