use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferType in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplIntegrationTest method createUnsavedTransferProcess.
private TransferProcess.Builder createUnsavedTransferProcess() {
String processId = UUID.randomUUID().toString();
var dataRequest = DataRequest.Builder.newInstance().id(processId).transferType(new TransferType()).managedResources(true).destinationType("test-type").contractId(UUID.randomUUID().toString()).build();
return TransferProcess.Builder.newInstance().provisionedResourceSet(ProvisionedResourceSet.Builder.newInstance().build()).type(TransferProcess.Type.CONSUMER).id("test-process-" + processId).state(UNSAVED.code()).dataRequest(dataRequest);
}
use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferType in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplTest method verifyCompleted_noCheckerForSomeResources.
@Test
@DisplayName("checkComplete: should automatically transition process with no managed resources if no checker")
void verifyCompleted_noCheckerForSomeResources() throws InterruptedException {
var process = createTransferProcess(IN_PROGRESS, new TransferType(), false);
process.getProvisionedResourceSet().addResource(provisionedDataDestinationResource());
process.getProvisionedResourceSet().addResource(provisionedDataDestinationResource());
var latch = countDownOnUpdateLatch();
when(transferProcessStore.nextForState(eq(IN_PROGRESS.code()), anyInt())).thenReturn(List.of(process)).thenReturn(emptyList());
when(statusCheckerRegistry.resolve(anyString())).thenReturn(null);
manager.start();
assertThat(latch.await(TIMEOUT, TimeUnit.SECONDS)).isTrue();
verify(statusCheckerRegistry, atLeastOnce()).resolve(any());
verify(transferProcessStore).update(argThat(p -> p.getState() == COMPLETED.code()));
}
use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferType in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplTest method verifyCompletedNonManagedResources.
@Test
@DisplayName("checkComplete: should transition process with no managed resources if checker returns completed")
void verifyCompletedNonManagedResources() throws InterruptedException {
TransferProcess process = createTransferProcess(REQUESTED, new TransferType(), false);
process.getProvisionedResourceSet().addResource(provisionedDataDestinationResource());
process.getProvisionedResourceSet().addResource(provisionedDataDestinationResource());
when(transferProcessStore.nextForState(eq(IN_PROGRESS.code()), anyInt())).thenReturn(List.of(process)).thenReturn(emptyList());
when(statusCheckerRegistry.resolve(anyString())).thenReturn((tp, resources) -> true);
var latch = countDownOnUpdateLatch();
manager.start();
assertThat(latch.await(TIMEOUT, TimeUnit.SECONDS)).isTrue();
verify(statusCheckerRegistry, atLeastOnce()).resolve(any());
verify(transferProcessStore).update(argThat(p -> p.getState() == COMPLETED.code()));
}
use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.TransferType in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplTest method verifyCheckProvisioned_allAreNonFinite.
@Test
@DisplayName("checkProvisioned: all resources belong to non-finite processes")
void verifyCheckProvisioned_allAreNonFinite() throws InterruptedException {
TransferType type = TransferType.Builder.transferType().isFinite(false).build();
TransferProcess process = createTransferProcess(REQUESTED_ACK, type, true);
process.getProvisionedResourceSet().addResource(provisionedDataDestinationResource());
var cdl = new CountDownLatch(1);
when(store.nextForState(eq(REQUESTED_ACK.code()), anyInt())).thenReturn(List.of(process));
doAnswer(i -> {
cdl.countDown();
return null;
}).when(store).update(process);
manager.start();
assertThat(cdl.await(TIMEOUT, TimeUnit.SECONDS)).isTrue();
assertThat(process.getState()).describedAs("State should be STREAMING").isEqualTo(TransferProcessStates.STREAMING.code());
verify(store, atLeastOnce()).nextForState(anyInt(), anyInt());
verify(store, atLeastOnce()).update(process);
}
Aggregations