use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.
the class TestObjectQuery method testDontMatchEqualFilter.
@Test
public void testDontMatchEqualFilter() throws Exception {
PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML);
ObjectFilter filter = QueryBuilder.queryFor(UserType.class, PrismTestUtil.getPrismContext()).item(UserType.F_GIVEN_NAME).eq("Jackie").buildFilter();
boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry);
AssertJUnit.assertFalse("filter matches object, but it should not", match);
}
use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.
the class TestObjectQuery method testMatchEqualEmptyAgainstEmptyItem.
@Test
public void testMatchEqualEmptyAgainstEmptyItem() throws Exception {
PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML);
// jack has no locality
ObjectFilter filter = QueryBuilder.queryFor(UserType.class, PrismTestUtil.getPrismContext()).item(UserType.F_LOCALITY).isNull().buildFilter();
boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry);
AssertJUnit.assertTrue("filter does not match object", match);
}
use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.
the class TestObjectQuery method testMatchEqualMultivalue.
@Test
public void testMatchEqualMultivalue() throws Exception {
PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML);
PrismPropertyDefinitionImpl def = new PrismPropertyDefinitionImpl(new QName("indexedString"), DOMUtil.XSD_STRING, PrismTestUtil.getPrismContext());
ObjectFilter filter = QueryBuilder.queryFor(UserType.class, PrismTestUtil.getPrismContext()).item(new ItemPath(UserType.F_EXTENSION, "indexedString"), def).eq("alpha").buildFilter();
boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry);
AssertJUnit.assertTrue("filter does not match object", match);
}
use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.
the class TestObjectQuery method testComplexMatch.
@Test
public void testComplexMatch() throws Exception {
PrismObject user = PrismTestUtil.parseObject(PrismInternalTestUtil.USER_JACK_FILE_XML);
// System.out.println("user given name" + user.asObjectable().getGivenName());
System.out.println("definition: " + user.findItem(UserType.F_FAMILY_NAME).getDefinition().debugDump());
ObjectFilter filter = QueryBuilder.queryFor(UserType.class, PrismTestUtil.getPrismContext()).item(UserType.F_FAMILY_NAME).eq("Sparrow").and().item(UserType.F_FULL_NAME).contains("arr").and().block().item(UserType.F_GIVEN_NAME).eq("Jack").or().item(UserType.F_GIVEN_NAME).eq("Jackie").endBlock().buildFilter();
boolean match = ObjectQuery.match(user, filter, matchingRuleRegistry);
AssertJUnit.assertTrue("filter does not match object", match);
}
use of com.evolveum.midpoint.prism.PrismObject in project midpoint by Evolveum.
the class TestMappingDynamicSysVar method testEmployeeTypeDeltaNullreplaceB.
@Test
public void testEmployeeTypeDeltaNullreplaceB() throws Exception {
final String TEST_NAME = "testEmployeeTypeDeltaNullreplaceB";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
ObjectDelta<UserType> delta = ObjectDelta.createModificationReplaceProperty(UserType.class, evaluator.USER_OLD_OID, UserType.F_EMPLOYEE_TYPE, evaluator.getPrismContext(), "B");
Mapping<PrismPropertyValue<String>, PrismPropertyDefinition<String>> mapping = evaluator.createMapping("mapping-script-system-variables-employee-type.xml", TEST_NAME, "employeeType", delta);
PrismObject<UserType> user = (PrismObject<UserType>) mapping.getSourceContext().getOldObject();
setEmployeeType(user.asObjectable());
mapping.getSourceContext().recompute();
OperationResult opResult = new OperationResult(TEST_NAME);
// WHEN
mapping.evaluate(null, opResult);
// THEN
evaluator.assertResult(opResult);
PrismValueDeltaSetTriple<PrismPropertyValue<String>> outputTriple = mapping.getOutputTriple();
PrismAsserts.assertTripleNoZero(outputTriple);
PrismAsserts.assertTriplePlus(outputTriple, "B");
PrismAsserts.assertTripleNoMinus(outputTriple);
}
Aggregations