setExpectedCountsForMatch("match4", 2, 0, 0, 0, 0, 0, 0, 0); // ns:Alpha
verifyMatchResultCounts();
// Update non-versioned fields
updateMatchTestRecords(new QName(NS, "nvmatch1"), "nvmatch1");
setExpectedCountsForMatch("nvmatch1", 0, 0, 0, 0, 2, 2, 2, 2);
verifyMatchResultCounts();
updateMatchTestRecords(new QName(NS, "nvmatch2"), "nvmatch2");
setExpectedCountsForMatch("nvmatch2", 0, 0, 0, 0, 2, 2, 0, 0);
verifyMatchResultCounts();
updateMatchTestRecords(new QName(NS, "nvmatch3"), "nvmatch3");
setExpectedCountsForMatch("nvmatch3", 0, 0, 0, 0, 2, 0, 2, 0);
verifyMatchResultCounts();
updateMatchTestRecords(new QName(NS, "nvmatch4"), "nvmatch4");
setExpectedCountsForMatch("nvmatch4", 0, 0, 0, 0, 2, 0, 0, 0);
verifyMatchResultCounts();
// Update versioned fields
updateMatchTestRecords(new QName(NS2, "match1"), "match1");
setExpectedCountsForMatch("match1", 1, 1, 1, 1, 1, 1, 1, 1);
verifyMatchResultCounts();
updateMatchTestRecords(new QName(NS2, "match2"), "match2");
setExpectedCountsForMatch("match2", 1, 1, 0, 0, 1, 1, 0, 0);
verifyMatchResultCounts();
updateMatchTestRecords(new QName(NS2, "match3"), "match3");
setExpectedCountsForMatch("match3", 1, 0, 1, 0, 1, 0, 1, 0);
verifyMatchResultCounts();
updateMatchTestRecords(new QName(NS2, "match4"), "match4");
setExpectedCountsForMatch("match4", 1, 0, 0, 0, 1, 0, 0, 0);
verifyMatchResultCounts();
//
// Test match on field conditions using non versioned fields
// Note: the lines marked with /*hasfield*/ test for a feature we don't support yet, hence commented out
//
defaultTable.recordBuilder().id("match_nvfield")
.recordType(new QName(NS, "Alpha"))
.field(nvfield1.getName(), "jupiter")
.field(nvfield2.getName(), "pancake")
.field(previewTag.getName(), new Long(0))
.create();
commitIndex();
/*hasfield*/// verifyResultCount("nvmatch5:jupiter", 2); // vfield2 is present
verifyResultCount("nvmatch6:jupiter", 2); // nvfield2=specialvalue
defaultTable.recordBuilder().id("match_nvfield")
.field(nvfield1.getName(), "waffle")
.update();
commitIndex();
verifyResultCount("nvmatch6:jupiter", 0); // nvfield2=specialvalue
/*hasfield*/// verifyResultCount("nvmatch5:jupiter", 2); // nvfield2 is present
/*hasfield*/// Record record = repository.read(repository.getIdGenerator().newRecordId("match_nvfield"));
/*hasfield*/// record.delete(nvfield2.getName(), true);
/*hasfield*/// commitIndex();
/*hasfield*/// verifyResultCount("nvmatch5:jupiter", 0); // nvfield2 is present
/*hasfield*/// verifyResultCount("nvmatch6:jupiter", 0); // nvfield2=specialvalue
//
// Test match on field conditions (has field, field equals) using non versioned fields
//
defaultTable.recordBuilder().id("match_vfield")
.recordType(new QName(NS, "Alpha"))
.field(vfield1.getName(), "apollo")
.field(vfield2.getName(), "bacon")
.field(previewTag.getName(), new Long(1))
.create();
commitIndex();
/*hasfield*/// verifyResultCount("match5:apollo", 2); // vfield2 is present
verifyResultCount("match6:apollo", 2); // vfield2=specialvalue
defaultTable.recordBuilder().id("match_vfield")
.field(vfield1.getName(), "eggs")
.update();
commitIndex();
/*hasfield*/// verifyResultCount("match5:apollo", 2); // vfield2 is present in preview and last
verifyResultCount("match6:apollo", 1); // vfield2=specialvalue (version tagged with preview still matches)
/*hasfield*/// record = repository.read(repository.getIdGenerator().newRecordId("match_vfield"));
/*hasfield*/// record.delete(vfield2.getName(), true);
/*hasfield*/// commitIndex();
/*hasfield*/// verifyResultCount("match5:apollo", 1); // vfield2 is present
/*hasfield*/// verifyResultCount("match6:apollo", 1); // vfield2=specialvalue
//
// TODO: match on variant properties
//
for (String lang : new String[]{"en", "fr"}) {
defaultTable.recordBuilder().id("match_varprops_cupid", vprops("lang", lang))
.recordType(new QName(NS, "Alpha"))
.field(vfield1.getName(), "cupido_" + lang + "_nobranch")
.create();
defaultTable.recordBuilder().id("match_varprops_merc", vprops("lang", lang))
.recordType(new QName(NS, "Alpha"))
.field(nvfield1.getName(), "mercurius_" + lang + "_nobranch")
.create();
for (String branch : new String[]{"dev", "prod"}) {
defaultTable.recordBuilder().id("match_varprops_cupid", vprops("lang", lang, "branch", branch))
.recordType(new QName(NS, "Alpha"))
.field(vfield1.getName(), "cupido_" + lang + "_" + branch)
.create();
defaultTable.recordBuilder().id("match_varprops_merc", vprops("lang", lang, "branch", branch))
.recordType(new QName(NS, "Alpha"))
.field(nvfield1.getName(), "mercurius_" + lang + "_" + branch)
.create();
}
}
commitIndex();