use of org.eclipse.dataspaceconnector.spi.contract.offer.ContractOfferQuery in project DataSpaceConnector by eclipse-dataspaceconnector.
the class ResourceDescriptionRequestHandler method retrieveObject.
protected OfferedAsset retrieveObject(@NotNull IdsId idsId, @NotNull Result<ClaimToken> verificationResult) {
String assetId = idsId.getValue();
Asset asset = assetIndex.findById(assetId);
if (asset == null) {
return null;
}
ContractOfferQuery contractOfferQuery = ContractOfferQuery.Builder.newInstance().claimToken(verificationResult.getContent()).criterion(new Criterion(Asset.PROPERTY_ID, "=", assetId)).build();
List<ContractOffer> targetingContractOffers = contractOfferService.queryContractOffers(contractOfferQuery).collect(toList());
return new OfferedAsset(asset, targetingContractOffers);
}
use of org.eclipse.dataspaceconnector.spi.contract.offer.ContractOfferQuery in project DataSpaceConnector by eclipse-dataspaceconnector.
the class ResourceDescriptionRequestHandler method retrieveObject.
@Override
protected OfferedAsset retrieveObject(@NotNull IdsId idsId, @NotNull ClaimToken claimToken) {
String assetId = idsId.getValue();
Asset asset = assetIndex.findById(assetId);
if (asset == null) {
return null;
}
ContractOfferQuery contractOfferQuery = ContractOfferQuery.Builder.newInstance().claimToken(claimToken).criterion(new Criterion(Asset.PROPERTY_ID, "=", assetId)).build();
List<ContractOffer> targetingContractOffers = contractOfferService.queryContractOffers(contractOfferQuery).collect(toList());
return new OfferedAsset(asset, targetingContractOffers);
}
use of org.eclipse.dataspaceconnector.spi.contract.offer.ContractOfferQuery in project DataSpaceConnector by eclipse-dataspaceconnector.
the class ContractOfferServiceImplTest method testFullFlow.
@Test
void testFullFlow() {
var contractDefinition = ContractDefinition.Builder.newInstance().id("1").accessPolicy(Policy.Builder.newInstance().build()).contractPolicy(Policy.Builder.newInstance().build()).selectorExpression(AssetSelectorExpression.SELECT_ALL).build();
when(agentService.createFor(isA(ClaimToken.class))).thenReturn(new ParticipantAgent(emptyMap(), emptyMap()));
when(contractDefinitionService.definitionsFor(isA(ParticipantAgent.class))).thenReturn(Stream.of(contractDefinition));
var assetStream = Stream.of(Asset.Builder.newInstance().build(), Asset.Builder.newInstance().build());
when(assetIndex.queryAssets(isA(AssetSelectorExpression.class))).thenReturn(assetStream);
ContractOfferQuery query = ContractOfferQuery.builder().claimToken(ClaimToken.Builder.newInstance().build()).build();
assertThat(contractOfferService.queryContractOffers(query)).hasSize(2);
verify(agentService).createFor(isA(ClaimToken.class));
verify(contractDefinitionService).definitionsFor(isA(ParticipantAgent.class));
verify(assetIndex).queryAssets(isA(AssetSelectorExpression.class));
}
Aggregations