use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.DEPROVISIONING in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplTest method deprovisioning_shouldTransitionToDeprovisioned.
@Test
void deprovisioning_shouldTransitionToDeprovisioned() throws InterruptedException {
var manifest = ResourceManifest.Builder.newInstance().definitions(List.of(new TestResourceDefinition())).build();
var resourceSet = ProvisionedResourceSet.Builder.newInstance().resources(List.of(new TokenTestProvisionResource("test", PROVISIONED_RESOURCE_ID))).build();
var process = createTransferProcess(DEPROVISIONING).toBuilder().resourceManifest(manifest).provisionedResourceSet(resourceSet).build();
var deprovisionResult = StatusResult.success(DeprovisionedResource.Builder.newInstance().provisionedResourceId(PROVISIONED_RESOURCE_ID).build());
when(policyArchive.findPolicyForContract(anyString())).thenReturn(Policy.Builder.newInstance().build());
when(vault.deleteSecret(any())).thenReturn(Result.success());
when(provisionManager.deprovision(any(), isA(Policy.class))).thenReturn(completedFuture(List.of(deprovisionResult)));
when(transferProcessStore.nextForState(eq(DEPROVISIONING.code()), anyInt())).thenReturn(List.of(process)).thenReturn(emptyList());
when(transferProcessStore.find(process.getId())).thenReturn(process);
var latch = countDownOnUpdateLatch();
manager.start();
assertThat(latch.await(TIMEOUT, TimeUnit.SECONDS)).isTrue();
verify(policyArchive, atLeastOnce()).findPolicyForContract(anyString());
verify(transferProcessStore).update(argThat(p -> p.getState() == DEPROVISIONED.code()));
verify(vault).deleteSecret(any());
}
use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.DEPROVISIONING in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplTest method deprovisioning_shouldTransitionToErrorOnDeprovisionException.
@Test
void deprovisioning_shouldTransitionToErrorOnDeprovisionException() throws InterruptedException {
var process = createTransferProcess(DEPROVISIONING).toBuilder().resourceManifest(ResourceManifest.Builder.newInstance().definitions(List.of(new TestResourceDefinition())).build()).build();
when(policyArchive.findPolicyForContract(anyString())).thenReturn(Policy.Builder.newInstance().build());
when(provisionManager.deprovision(any(), isA(Policy.class))).thenReturn(failedFuture(new EdcException("provision failed")));
when(transferProcessStore.nextForState(eq(DEPROVISIONING.code()), anyInt())).thenReturn(List.of(process)).thenReturn(emptyList());
when(transferProcessStore.find(process.getId())).thenReturn(process);
var latch = countDownOnUpdateLatch();
manager.start();
assertThat(latch.await(TIMEOUT, TimeUnit.SECONDS)).isTrue();
verify(policyArchive, atLeastOnce()).findPolicyForContract(anyString());
verify(transferProcessStore).update(argThat(p -> p.getState() == ERROR.code()));
}
use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.DEPROVISIONING in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplTest method deprovisioning_shouldTransitionToErrorOnFatalDeprovisionError.
@Test
void deprovisioning_shouldTransitionToErrorOnFatalDeprovisionError() throws InterruptedException {
var manifest = ResourceManifest.Builder.newInstance().definitions(List.of(new TestResourceDefinition())).build();
var resourceSet = ProvisionedResourceSet.Builder.newInstance().resources(List.of(new TestProvisionedDataDestinationResource("test", PROVISIONED_RESOURCE_ID))).build();
var process = createTransferProcess(DEPROVISIONING).toBuilder().resourceManifest(manifest).provisionedResourceSet(resourceSet).build();
var deprovisionResult = StatusResult.<DeprovisionedResource>failure(ResponseStatus.FATAL_ERROR, "test error");
when(policyArchive.findPolicyForContract(anyString())).thenReturn(Policy.Builder.newInstance().build());
when(provisionManager.deprovision(any(), isA(Policy.class))).thenReturn(completedFuture(List.of(deprovisionResult)));
when(transferProcessStore.nextForState(eq(DEPROVISIONING.code()), anyInt())).thenReturn(List.of(process)).thenReturn(emptyList());
when(transferProcessStore.find(process.getId())).thenReturn(process);
var latch = countDownOnUpdateLatch();
manager.start();
assertThat(latch.await(TIMEOUT, TimeUnit.SECONDS)).isTrue();
verify(policyArchive, atLeastOnce()).findPolicyForContract(anyString());
verify(transferProcessStore).update(argThat(p -> p.getState() == ERROR.code()));
}
use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.DEPROVISIONING in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplTest method deprovisioning_shouldNotTransitionOnRetriableDeprovisionError.
@Test
void deprovisioning_shouldNotTransitionOnRetriableDeprovisionError() throws InterruptedException {
var manifest = ResourceManifest.Builder.newInstance().definitions(List.of(new TestResourceDefinition())).build();
var resourceSet = ProvisionedResourceSet.Builder.newInstance().resources(List.of(new TestProvisionedDataDestinationResource("test", PROVISIONED_RESOURCE_ID))).build();
var process = createTransferProcess(DEPROVISIONING).toBuilder().resourceManifest(manifest).provisionedResourceSet(resourceSet).build();
var deprovisionResult = StatusResult.<DeprovisionedResource>failure(ResponseStatus.ERROR_RETRY, "test error");
when(policyArchive.findPolicyForContract(anyString())).thenReturn(Policy.Builder.newInstance().build());
when(provisionManager.deprovision(any(), isA(Policy.class))).thenReturn(completedFuture(List.of(deprovisionResult)));
when(transferProcessStore.nextForState(eq(DEPROVISIONING.code()), anyInt())).thenReturn(List.of(process)).thenReturn(emptyList());
when(transferProcessStore.find(process.getId())).thenReturn(process);
var latch = countDownOnUpdateLatch();
manager.start();
assertThat(latch.await(TIMEOUT, TimeUnit.SECONDS)).isTrue();
verify(transferProcessStore).update(argThat(p -> p.getState() == DEPROVISIONING.code()));
verify(policyArchive, atLeastOnce()).findPolicyForContract(anyString());
}
Aggregations