Skip to content

Commit

Permalink
feat: supports filtering by createdAt
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Jul 5, 2024
1 parent 2cf9bf2 commit 3584271
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ public EndpointDataReferenceEntryMapping(EndpointDataReferenceEntryStatements st
add("transferProcessId", statements.getTransferProcessIdColumn());
add("providerId", statements.getProviderIdColumn());
add("contractNegotiationId", statements.getContractNegotiationIdColumn());
add("createdAt", statements.getCreatedAtColumn());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.eclipse.edc.edr.spi.types.EndpointDataReferenceEntry;
import org.eclipse.edc.spi.query.Criterion;
import org.eclipse.edc.spi.query.QuerySpec;
import org.eclipse.edc.spi.query.SortOrder;
import org.eclipse.edc.spi.result.StoreFailure;
import org.eclipse.edc.spi.result.StoreResult;
import org.junit.jupiter.api.Test;
Expand All @@ -27,6 +28,7 @@
import org.junit.jupiter.params.provider.ArgumentsProvider;
import org.junit.jupiter.params.provider.ArgumentsSource;

import java.util.Comparator;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -119,6 +121,20 @@ void query_withQuerySpec(String field, Function<EndpointDataReferenceEntry, Stri

}

@Test
void query_withOrderBy() {
IntStream.range(0, 10)
.mapToObj(i -> TestFunctions.edrEntry("assetId" + i, "agreementId" + i, "tpId" + i, "cnId" + i))
.forEach(entry -> getStore().save(entry));

var results = getStore().query(QuerySpec.Builder.newInstance().sortField("createdAt").sortOrder(SortOrder.DESC).build());

assertThat(results.succeeded()).isTrue();
assertThat(results.getContent())
.isSortedAccordingTo(Comparator.comparing(EndpointDataReferenceEntry::getCreatedAt).reversed());

}

@Test
void delete_shouldDelete_WhenFound() {

Expand Down

0 comments on commit 3584271

Please sign in to comment.