use of com.evolveum.midpoint.repo.sqale.qmodel.lookuptable.QLookupTableRow in project midpoint by Evolveum.
the class SqaleRepoAddDeleteObjectTest method test808LookupTable.
@Test
public void test808LookupTable() throws Exception {
OperationResult result = createOperationResult();
given("lookup table with a couple of rows");
String objectName = "ltable" + getTestNumber();
LookupTableType lookupTable = new LookupTableType(prismContext).name(objectName).row(new LookupTableRowType().key("row1").value("value1").label("label-1").lastChangeTimestamp(MiscUtil.asXMLGregorianCalendar(1L))).row(new LookupTableRowType().key("row2").value("value2").lastChangeTimestamp(MiscUtil.asXMLGregorianCalendar(2L))).row(new LookupTableRowType().key("row3"));
when("adding it to the repository");
repositoryService.addObject(lookupTable.asPrismObject(), null, result);
then("it is stored with its persisted trigger containers");
assertThatOperationResult(result).isSuccess();
QLookupTableRow ltRow = aliasFor(QLookupTableRow.class);
List<MLookupTableRow> rows = select(ltRow, ltRow.ownerOid.eq(UUID.fromString(lookupTable.getOid())));
assertThat(rows).hasSize(3);
rows.sort(comparing(tr -> tr.cid));
MLookupTableRow containerRow = rows.get(0);
assertThat(containerRow.cid).isEqualTo(1);
assertThat(containerRow.key).isEqualTo("row1");
assertThat(containerRow.value).isEqualTo("value1");
assertThat(containerRow.labelOrig).isEqualTo("label-1");
assertThat(containerRow.labelNorm).isEqualTo("label1");
assertThat(containerRow.lastChangeTimestamp).isEqualTo(Instant.ofEpochMilli(1));
containerRow = rows.get(1);
assertThat(containerRow.cid).isEqualTo(2);
assertThat(containerRow.key).isEqualTo("row2");
assertThat(containerRow.value).isEqualTo("value2");
assertThat(containerRow.lastChangeTimestamp).isEqualTo(Instant.ofEpochMilli(2));
containerRow = rows.get(2);
assertThat(containerRow.cid).isEqualTo(3);
assertThat(containerRow.key).isEqualTo("row3");
}
Aggregations