Skip to content

Commit

Permalink
fix: consider terminated a DataFlow that cannot be terminated because…
Browse files Browse the repository at this point in the history
… it does not exist
  • Loading branch information
ndr-brt committed Aug 21, 2024
1 parent 3353b62 commit 4669ab6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,12 @@ public StatusResult<Void> suspend(TransferProcess transferProcess) {

@Override
public StatusResult<Void> terminate(TransferProcess transferProcess) {
return getClientForDataplane(transferProcess.getDataPlaneId())
var dataPlaneId = transferProcess.getDataPlaneId();
if (dataPlaneId == null) {
return StatusResult.success();
}

return getClientForDataplane(dataPlaneId)
.map(client -> client.terminate(transferProcess.getId()))
.orElse(f -> {
var message = "Failed to select the data plane for terminating the transfer process %s. %s"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;

public class DataPlaneSignalingFlowControllerTest {
Expand Down Expand Up @@ -256,6 +257,20 @@ void shouldFail_whenDataPlaneNotFound() {

assertThat(result).isFailed().detail().contains("Failed to select the data plane for terminating the transfer process");
}

@Test
void shouldReturnSuccess_whenDataPlaneIdIsNull() {
var transferProcess = transferProcessBuilder()
.id("transferProcessId")
.contentDataAddress(testDataAddress())
.dataPlaneId(null)
.build();

var result = flowController.terminate(transferProcess);

assertThat(result).isSucceeded();
verifyNoInteractions(dataPlaneClient, dataPlaneClientFactory, selectorService);
}
}

@Nested
Expand Down

0 comments on commit 4669ab6

Please sign in to comment.