|
1 | 1 | import temporalFeature from "/data-hub/features/temporal.mjs"; |
2 | | -const test = require("/test/test-helper.xqy"); |
3 | 2 | import temporalLib from "/data-hub/5/temporal/hub-temporal.mjs"; |
4 | 3 |
|
| 4 | +import { Matchable } from "/data-hub/5/mastering/matching/matchable.mjs"; |
| 5 | + |
| 6 | +const test = require("/test/test-helper.xqy"); |
| 7 | + |
5 | 8 | const myTempCollection = "koolTest"; |
6 | 9 | function getTemporalCollection(tempCollection) { |
7 | 10 | const temporalCollections = temporalLib.getTemporalCollections().toArray(); |
@@ -37,15 +40,32 @@ const contentArray = []; |
37 | 40 | contentArray.push({ |
38 | 41 | "uri": "/affiliate1.json", |
39 | 42 | "value": { "meta": { "systemStart": "1601-01-01T13:59:00Z", "systemEnd": "9999-12-31T11:59:59Z", "validStart": fn.currentDateTime() , "validEnd": fn.currentDateTime().add(xs.yearMonthDuration('P1Y')) },"customerId": "1"} , |
40 | | - "context": { "collections":[myTempCollection]}}); |
| 43 | + "context": { "collections":[myTempCollection, "AffiliateCustomer"]}}); |
41 | 44 | xdmp.invokeFunction(() =>{ |
42 | | -temporalFeature.onInstanceSave(stepContext, model, contentArray); |
| 45 | + temporalFeature.onInstanceSave(stepContext, model, contentArray); |
43 | 46 | }); |
44 | 47 | xdmp.invokeFunction(() => { |
45 | 48 | assertions.push(test.assertEqual(1, |
46 | 49 | cts.estimate(cts.andQuery([cts.collectionQuery(["koolTest"]), cts.collectionQuery(["latest"])])), |
47 | 50 | `One document must be found with collection: ${myTempCollection}.`)); |
48 | 51 | }); |
| 52 | + |
| 53 | +// Test matching with temporal collection |
| 54 | +xdmp.invokeFunction(() => { |
| 55 | + const matchable = new Matchable({ targetEntityType: "http://example.org/AffiliateCustomer-0.0.1/AffiliateCustomer" }); |
| 56 | + const baselineQuery = matchable.baselineQuery(); |
| 57 | + assertions.push( |
| 58 | + test.assertTrue(baselineQuery instanceof cts.andQuery, `Baseline for temporal query should be a cts.andQuery: ${xdmp.toJsonString(baselineQuery)}.`) |
| 59 | + ); |
| 60 | + const latestQuery = cts.andQueryQueries(baselineQuery).toArray()[1]; |
| 61 | + assertions.push( |
| 62 | + test.assertTrue(latestQuery instanceof cts.collectionQuery, `Second query in cts.andQuery should be a cts.collectionQuery: ${xdmp.toJsonString(latestQuery)}.`), |
| 63 | + test.assertEqual("latest",fn.head(cts.collectionQueryUris(latestQuery))) |
| 64 | + ); |
| 65 | + |
| 66 | +}); |
| 67 | + |
| 68 | + |
49 | 69 | const contentArrayDelete = []; |
50 | 70 | contentArrayDelete.push({ |
51 | 71 | "uri": "/affiliate1.json", |
|
0 commit comments