use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.StatusCheckerRegistry in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplIntegrationTest method setup.
@SuppressWarnings("unchecked")
@BeforeEach
void setup() {
var resourceManifest = ResourceManifest.Builder.newInstance().definitions(List.of(new TestResourceDefinition())).build();
when(manifestGenerator.generateConsumerResourceManifest(any(DataRequest.class), any(Policy.class))).thenReturn(resourceManifest);
var policyArchive = mock(PolicyArchive.class);
when(policyArchive.findPolicyForContract(anyString())).thenReturn(Policy.Builder.newInstance().build());
transferProcessManager = TransferProcessManagerImpl.Builder.newInstance().provisionManager(provisionManager).dataFlowManager(mock(DataFlowManager.class)).waitStrategy(mock(ExponentialWaitStrategy.class)).batchSize(TRANSFER_MANAGER_BATCHSIZE).dispatcherRegistry(mock(RemoteMessageDispatcherRegistry.class)).manifestGenerator(manifestGenerator).monitor(mock(Monitor.class)).commandQueue(mock(CommandQueue.class)).commandRunner(mock(CommandRunner.class)).typeManager(new TypeManager()).statusCheckerRegistry(mock(StatusCheckerRegistry.class)).observable(mock(TransferProcessObservable.class)).transferProcessStore(store).policyArchive(policyArchive).addressResolver(mock(DataAddressResolver.class)).build();
}
use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.StatusCheckerRegistry 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.StatusCheckerRegistry 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()));
}
Aggregations