use of org.eclipse.dataspaceconnector.spi.command.CommandRunner in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImplTest method setup.
@BeforeEach
void setup() {
var resourceManifest = ResourceManifest.Builder.newInstance().definitions(List.of(new TestResourceDefinition())).build();
when(manifestGenerator.generateResourceManifest(any(TransferProcess.class))).thenReturn(resourceManifest);
manager = TransferProcessManagerImpl.Builder.newInstance().provisionManager(provisionManager).dataFlowManager(mock(DataFlowManager.class)).waitStrategy(mock(ExponentialWaitStrategy.class)).batchSize(TRANSFER_MANAGER_BATCHSIZE).dispatcherRegistry(dispatcherRegistry).manifestGenerator(manifestGenerator).monitor(mock(Monitor.class)).commandQueue(mock(CommandQueue.class)).commandRunner(mock(CommandRunner.class)).typeManager(new TypeManager()).statusCheckerRegistry(statusCheckerRegistry).observable(mock(TransferProcessObservable.class)).store(store).build();
}
use of org.eclipse.dataspaceconnector.spi.command.CommandRunner 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.command.CommandRunner in project DataSpaceConnector by eclipse-dataspaceconnector.
the class ContractServiceExtension method registerServices.
private void registerServices(ServiceExtensionContext context) {
var definitionService = new ContractDefinitionServiceImpl(monitor, contractDefinitionStore, policyEngine, policyStore);
context.registerService(ContractDefinitionService.class, definitionService);
var contractOfferService = new ContractOfferServiceImpl(agentService, definitionService, assetIndex, policyStore);
context.registerService(ContractOfferService.class, contractOfferService);
var validationService = new ContractValidationServiceImpl(agentService, definitionService, assetIndex, policyStore);
context.registerService(ContractValidationService.class, validationService);
var waitStrategy = context.hasService(NegotiationWaitStrategy.class) ? context.getService(NegotiationWaitStrategy.class) : new ExponentialWaitStrategy(DEFAULT_ITERATION_WAIT);
CommandQueue<ContractNegotiationCommand> commandQueue = new BoundedCommandQueue<>(10);
CommandRunner<ContractNegotiationCommand> commandRunner = new CommandRunner<>(commandHandlerRegistry, monitor);
var telemetry = context.getTelemetry();
var observable = new ContractNegotiationObservableImpl();
context.registerService(ContractNegotiationObservable.class, observable);
context.registerService(PolicyArchive.class, new PolicyArchiveImpl(store, policyStore));
consumerNegotiationManager = ConsumerContractNegotiationManagerImpl.Builder.newInstance().waitStrategy(waitStrategy).dispatcherRegistry(dispatcherRegistry).monitor(monitor).validationService(validationService).commandQueue(commandQueue).commandRunner(commandRunner).observable(observable).telemetry(telemetry).executorInstrumentation(context.getService(ExecutorInstrumentation.class)).store(store).policyStore(policyStore).batchSize(context.getSetting(NEGOTIATION_CONSUMER_STATE_MACHINE_BATCH_SIZE, 5)).build();
providerNegotiationManager = ProviderContractNegotiationManagerImpl.Builder.newInstance().waitStrategy(waitStrategy).dispatcherRegistry(dispatcherRegistry).monitor(monitor).validationService(validationService).commandQueue(commandQueue).commandRunner(commandRunner).observable(observable).telemetry(telemetry).executorInstrumentation(context.getService(ExecutorInstrumentation.class)).store(store).policyStore(policyStore).batchSize(context.getSetting(NEGOTIATION_PROVIDER_STATE_MACHINE_BATCH_SIZE, 5)).build();
context.registerService(ConsumerContractNegotiationManager.class, consumerNegotiationManager);
context.registerService(ProviderContractNegotiationManager.class, providerNegotiationManager);
}
use of org.eclipse.dataspaceconnector.spi.command.CommandRunner in project DataSpaceConnector by eclipse-dataspaceconnector.
the class AbstractContractNegotiationIntegrationTest method setUp.
/**
* Prepares the test setup
*/
@BeforeEach
void setUp() {
// Create contract validation service mock, method mocking has to be done in test methods
validationService = mock(ContractValidationService.class);
// Create a monitor that logs to the console
Monitor monitor = new ConsoleMonitor();
// Create CommandQueue mock
CommandQueue<ContractNegotiationCommand> queue = (CommandQueue<ContractNegotiationCommand>) mock(CommandQueue.class);
when(queue.dequeue(anyInt())).thenReturn(new ArrayList<>());
// Create CommandRunner mock
CommandRunner<ContractNegotiationCommand> runner = (CommandRunner<ContractNegotiationCommand>) mock(CommandRunner.class);
providerStore = new InMemoryContractNegotiationStore();
consumerStore = new InMemoryContractNegotiationStore();
providerManager = ProviderContractNegotiationManagerImpl.Builder.newInstance().dispatcherRegistry(new FakeProviderDispatcherRegistry()).monitor(monitor).validationService(validationService).waitStrategy(() -> 1000).commandQueue(queue).commandRunner(runner).observable(providerObservable).store(providerStore).policyStore(policyStore).build();
consumerManager = ConsumerContractNegotiationManagerImpl.Builder.newInstance().dispatcherRegistry(new FakeConsumerDispatcherRegistry()).monitor(monitor).validationService(validationService).waitStrategy(() -> 1000).commandQueue(queue).commandRunner(runner).observable(consumerObservable).store(consumerStore).policyStore(policyStore).build();
countDownLatch = new CountDownLatch(2);
}
Aggregations