use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.DataRequest in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessManagerImpl method sendConsumerRequest.
@WithSpan
private void sendConsumerRequest(TransferProcess process, DataRequest dataRequest) {
process.transitionRequested();
// update before sending to accommodate synchronous transports; reliability will be managed by retry and idempotency
transferProcessStore.update(process);
observable.invokeForEach(l -> l.requested(process));
dispatcherRegistry.send(Object.class, dataRequest, process::getId).thenApply(o -> {
// TODO: what's the point of this state transition?
transitionToRequestAck(process.getId());
return o;
}).whenComplete((o, throwable) -> {
if (o != null) {
monitor.info("Object received: " + o);
TransferProcess transferProcess = transferProcessStore.find(process.getId());
if (transferProcess == null) {
monitor.severe(format("TransferProcessManager: no TransferProcess found with id %s", process.getId()));
return;
}
transferProcess.transitionInProgressOrStreaming();
transferProcessStore.update(transferProcess);
observable.invokeForEach(l -> l.inProgress(transferProcess));
}
});
}
use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.DataRequest in project DataSpaceConnector by eclipse-dataspaceconnector.
the class HttpDataFlowControllerTest method verifyRetryErrorResponse.
@Test
void verifyRetryErrorResponse() {
Interceptor delegate = chain -> new Response.Builder().request(chain.request()).protocol(HTTP_1_1).code(500).body(ResponseBody.create("", MediaType.get("application/json"))).message("ok").build();
httpClient = testOkHttpClient().newBuilder().addInterceptor(delegate).build();
var dataRequest = createDataRequest();
var contentAddress = DataAddress.Builder.newInstance().type("test").build();
var policy = Policy.Builder.newInstance().build();
assertEquals(ERROR_RETRY, flowController.initiateFlow(dataRequest, contentAddress, policy).getFailure().status());
}
use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.DataRequest in project DataSpaceConnector by eclipse-dataspaceconnector.
the class TransferProcessApiControllerTest method initiateTransfer.
@Test
void initiateTransfer() {
var transferReq = transferRequestDto();
String processId = "processId";
DataRequest request = dataRequest(transferReq);
when(transformerRegistry.transform(isA(TransferRequestDto.class), eq(DataRequest.class))).thenReturn(Result.success(request));
when(service.initiateTransfer(any())).thenReturn(ServiceResult.success(processId));
String result = controller.initiateTransfer(transferReq).getId();
var dataRequestCaptor = ArgumentCaptor.forClass(DataRequest.class);
verify(service).initiateTransfer(dataRequestCaptor.capture());
DataRequest dataRequest = dataRequestCaptor.getValue();
assertThat(dataRequest.getAssetId()).isEqualTo(request.getAssetId());
assertThat(dataRequest.getConnectorAddress()).isEqualTo(request.getConnectorAddress());
assertThat(dataRequest.getConnectorId()).isEqualTo(request.getConnectorId());
assertThat(dataRequest.getDataDestination()).isEqualTo(request.getDataDestination());
assertThat(dataRequest.getDestinationType()).isEqualTo(request.getDataDestination().getType());
assertThat(dataRequest.getContractId()).isEqualTo(request.getContractId());
assertThat(dataRequest.getProtocol()).isEqualTo(request.getProtocol());
assertThat(dataRequest.getProperties()).isEqualTo(request.getProperties());
assertThat(dataRequest.getTransferType()).isEqualTo(request.getTransferType());
assertThat(dataRequest.isManagedResources()).isEqualTo(request.isManagedResources());
assertThat(result).isEqualTo(processId);
}
use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.DataRequest in project DataSpaceConnector by eclipse-dataspaceconnector.
the class HttpDataFlowControllerTest method verifyOkResponse.
@Test
void verifyOkResponse() {
Interceptor delegate = chain -> new Response.Builder().request(chain.request()).protocol(HTTP_1_1).code(200).body(ResponseBody.create("", MediaType.get("application/json"))).message("ok").build();
httpClient = testOkHttpClient().newBuilder().addInterceptor(delegate).build();
var dataRequest = createDataRequest();
var contentAddress = DataAddress.Builder.newInstance().type("test").build();
var policy = Policy.Builder.newInstance().build();
assertThat(flowController.initiateFlow(dataRequest, contentAddress, policy).succeeded()).isTrue();
}
use of org.eclipse.dataspaceconnector.spi.types.domain.transfer.DataRequest in project DataSpaceConnector by eclipse-dataspaceconnector.
the class HttpDataFlowControllerTest method verifyFatalErrorResponse.
@Test
void verifyFatalErrorResponse() {
Interceptor delegate = chain -> new Response.Builder().request(chain.request()).protocol(HTTP_1_1).code(400).body(ResponseBody.create("", MediaType.get("application/json"))).message("ok").build();
httpClient = testOkHttpClient().newBuilder().addInterceptor(delegate).build();
var dataRequest = createDataRequest();
var contentAddress = DataAddress.Builder.newInstance().type("test").build();
var policy = Policy.Builder.newInstance().build();
assertEquals(FATAL_ERROR, flowController.initiateFlow(dataRequest, contentAddress, policy).getFailure().status());
}
Aggregations