Skip to content

Commit

Permalink
carries out CR
Browse files Browse the repository at this point in the history
  • Loading branch information
zub4t committed Jun 26, 2024
1 parent 788ead1 commit a022b3e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import static org.eclipse.edc.spi.persistence.StateEntityStore.hasState;
import static org.eclipse.edc.spi.response.ResponseStatus.ERROR_RETRY;
import static org.eclipse.edc.spi.response.ResponseStatus.FATAL_ERROR;
import static org.eclipse.edc.spi.result.StoreFailure.Reason.GENERAL_ERROR;
import static org.mockito.AdditionalMatchers.aryEq;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
Expand Down Expand Up @@ -373,7 +374,7 @@ void shouldStartTransferAndTransitionToFailed_whenTransferFails() {

await().untilAsserted(() -> {
verify(transferService).transfer(isA(DataFlowStartMessage.class));
verify(store, atLeastOnce()).save(argThat(it -> it.getState() == FAILED.code() && it.getErrorDetail().equals("an error")));
verify(store, atLeastOnce()).save(argThat(it -> it.getState() == FAILED.code() && it.getErrorDetail().equals(GENERAL_ERROR + ": an error")));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates.COMPLETED;
import static org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcessStates.TERMINATED;
import static org.eclipse.edc.connector.dataplane.spi.pipeline.StreamFailure.Reason.GENERAL_ERROR;
import static org.eclipse.edc.util.io.Ports.getFreePort;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -124,7 +125,7 @@ void shouldCallTransferProcessApiWithFailed(TransferProcessStore store, DataPlan
var transferProcess = store.findById("tp-id");
assertThat(transferProcess).isNotNull().satisfies(process -> {
assertThat(process.getState()).isGreaterThanOrEqualTo(TERMINATED.code());
assertThat(process.getErrorDetail()).isEqualTo("error");
assertThat(process.getErrorDetail()).isEqualTo(GENERAL_ERROR + "error");
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import static java.util.concurrent.CompletableFuture.completedFuture;
import static java.util.concurrent.CompletableFuture.failedFuture;
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.connector.dataplane.spi.pipeline.StreamFailure.Reason.GENERAL_ERROR;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -92,7 +93,7 @@ void should_returnForbidden_if_tokenValidationFails() {
@Test
void should_returnInternalServerError_if_transferFails() {
var token = UUID.randomUUID().toString();
var errorMsg = UUID.randomUUID().toString();
var errorMsg = GENERAL_ERROR + ": " + UUID.randomUUID().toString();
when(dataAddressResolver.resolve(any())).thenReturn(Result.success(testDestAddress()));
when(pipelineService.transfer(any(), any()))
.thenReturn(completedFuture(StreamResult.error(errorMsg)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,17 @@
import static org.eclipse.edc.connector.dataplane.spi.pipeline.StreamFailure.Reason.NOT_FOUND;

public class StreamFailureTest {
private static final String failureMessage = "failure message";
private static final String FAILURE_MESSAGE = "failure message";

@Test
void verify_with_failureDetail_message_starts_with_reason() {
assertThat(new StreamFailure(List.of(failureMessage), NOT_FOUND)
.getFailureDetail()
.startsWith(NOT_FOUND.toString())
).isTrue();
var failure = new StreamFailure(List.of(FAILURE_MESSAGE), NOT_FOUND);
assertThat(failure.getFailureDetail()).startsWith(NOT_FOUND.toString());
}

@Test
void verify_with_failureDetail_message_only_contains_reason_when_message_is_empty() {
assertThat(new StreamFailure(Collections.emptyList(), NOT_FOUND)
.getFailureDetail()
.equals(NOT_FOUND.toString())
).isTrue();
var failure = new StreamFailure(Collections.emptyList(), NOT_FOUND);
assertThat(failure.getFailureDetail()).startsWith(NOT_FOUND.toString());
}
}

0 comments on commit a022b3e

Please sign in to comment.