use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.PROVISIONING in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplTest method provisioning_shouldContinueOnRetryProvisionError.
@Test
void provisioning_shouldContinueOnRetryProvisionError() throws InterruptedException {
var process = createTransferProcess(PROVISIONING).toBuilder().resourceManifest(ResourceManifest.Builder.newInstance().definitions(List.of(new TestResourceDefinition())).build()).build();
var provisionResult = StatusResult.<ProvisionResponse>failure(ResponseStatus.ERROR_RETRY, "test error");
when(policyArchive.findPolicyForContract(anyString())).thenReturn(Policy.Builder.newInstance().build());
when(provisionManager.provision(any(), isA(Policy.class))).thenReturn(completedFuture(List.of(provisionResult)));
when(transferProcessStore.nextForState(eq(PROVISIONING.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() == PROVISIONING.code()));
}
use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferProcessStates.PROVISIONING in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplTest method provisioning_shouldTransitionToErrorOnProvisionError.
@Test
void provisioning_shouldTransitionToErrorOnProvisionError() throws InterruptedException {
var process = createTransferProcess(PROVISIONING).toBuilder().resourceManifest(ResourceManifest.Builder.newInstance().definitions(List.of(new TestResourceDefinition())).build()).build();
when(policyArchive.findPolicyForContract(anyString())).thenReturn(Policy.Builder.newInstance().build());
when(provisionManager.provision(any(), isA(Policy.class))).thenReturn(failedFuture(new EdcException("provision failed")));
when(transferProcessStore.nextForState(eq(PROVISIONING.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.PROVISIONING in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplTest method provisioning_shouldTransitionToErrorOnFatalProvisionError.
@Test
void provisioning_shouldTransitionToErrorOnFatalProvisionError() throws InterruptedException {
var process = createTransferProcess(PROVISIONING).toBuilder().resourceManifest(ResourceManifest.Builder.newInstance().definitions(List.of(new TestResourceDefinition())).build()).build();
var provisionResult = StatusResult.<ProvisionResponse>failure(ResponseStatus.FATAL_ERROR, "test error");
when(policyArchive.findPolicyForContract(anyString())).thenReturn(Policy.Builder.newInstance().build());
when(provisionManager.provision(any(), isA(Policy.class))).thenReturn(completedFuture(List.of(provisionResult)));
when(transferProcessStore.nextForState(eq(PROVISIONING.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.PROVISIONING in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplTest method provisioning_shouldTransitionToProvisionedOnDataDestination.
@Test
void provisioning_shouldTransitionToProvisionedOnDataDestination() throws InterruptedException {
var process = createTransferProcess(PROVISIONING).toBuilder().resourceManifest(ResourceManifest.Builder.newInstance().definitions(List.of(new TestResourceDefinition())).build()).build();
var provisionResult = StatusResult.success(ProvisionResponse.Builder.newInstance().resource(provisionedDataDestinationResource()).build());
when(policyArchive.findPolicyForContract(anyString())).thenReturn(Policy.Builder.newInstance().build());
when(provisionManager.provision(any(), isA(Policy.class))).thenReturn(completedFuture(List.of(provisionResult)));
when(transferProcessStore.nextForState(eq(PROVISIONING.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() == PROVISIONED.code()));
}
Aggregations