use of org.eclipse.dataspaceconnector.spi.query.Criterion 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.query.Criterion in project DataSpaceConnector by eclipse-dataspaceconnector.
the class SqlAssetIndexTest method queryAsset_querySpec_nonExistProperty.
@Test
@DisplayName("Query assets with query spec where the property (=leftOperand) does not exist")
void queryAsset_querySpec_nonExistProperty() {
var asset = getAsset("id1");
sqlAssetIndex.accept(asset, getDataAddress());
var qs = QuerySpec.Builder.newInstance().filter(List.of(new Criterion("noexist", "=", "42"))).build();
assertThat(sqlAssetIndex.queryAssets(qs)).isEmpty();
}
use of org.eclipse.dataspaceconnector.spi.query.Criterion in project DataSpaceConnector by eclipse-dataspaceconnector.
the class SqlConditionExpressionTest method toValuePlaceholder.
@Test
void toValuePlaceholder() {
var e = new SqlConditionExpression(new Criterion("key", "=", "value"));
assertThat(e.toValuePlaceholder()).isEqualTo("?");
var e2 = new SqlConditionExpression(new Criterion("key", "in", List.of("item1", "item2")));
assertThat(e2.toValuePlaceholder()).matches("\\(\\?,.*\\?\\)");
}
use of org.eclipse.dataspaceconnector.spi.query.Criterion in project DataSpaceConnector by eclipse-dataspaceconnector.
the class SqlConditionExpressionTest method isValidExpression_whenValid.
@ParameterizedTest
@MethodSource("validArgs")
void isValidExpression_whenValid(String left, String op, Object right) {
var e = new SqlConditionExpression(new Criterion(left, op, right));
assertThat(e.isValidExpression().succeeded()).isTrue();
}
use of org.eclipse.dataspaceconnector.spi.query.Criterion in project DataSpaceConnector by eclipse-dataspaceconnector.
the class CosmosContractDefinitionStoreIntegrationTest method update.
@Test
void update() {
var doc1 = generateDocument(TEST_PARTITION_KEY);
container.createItem(doc1);
var definition = doc1.getWrappedInstance();
// modify the object
definition.getSelectorExpression().getCriteria().add(new Criterion("anotherKey", "NOT EQUAL", "anotherVal"));
store.update(definition);
var updatedDefinition = convert(container.readItem(doc1.getId(), new PartitionKey(doc1.getPartitionKey()), Object.class).getItem());
assertThat(updatedDefinition.getId()).isEqualTo(definition.getId());
assertThat(updatedDefinition.getSelectorExpression().getCriteria()).hasSize(2).anySatisfy(criterion -> {
assertThat(criterion.getOperandLeft()).isNotEqualTo("anotherKey");
assertThat(criterion.getOperator()).isNotEqualTo("NOT EQUAL");
assertThat(criterion.getOperandLeft()).isNotEqualTo("anotherValue");
});
// we modified that earlier
}
Aggregations