Search in sources :

Example 6 with PrismObject

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);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) UserType(com.evolveum.midpoint.prism.foo.UserType) Test(org.testng.annotations.Test)

Example 7 with PrismObject

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);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) UserType(com.evolveum.midpoint.prism.foo.UserType) Test(org.testng.annotations.Test)

Example 8 with PrismObject

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);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) QName(javax.xml.namespace.QName) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) UserType(com.evolveum.midpoint.prism.foo.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 9 with PrismObject

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);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) Test(org.testng.annotations.Test)

Example 10 with PrismObject

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);
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismPropertyDefinition(com.evolveum.midpoint.prism.PrismPropertyDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue) Test(org.testng.annotations.Test)

Aggregations

PrismObject (com.evolveum.midpoint.prism.PrismObject)696 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)484 Test (org.testng.annotations.Test)317 Task (com.evolveum.midpoint.task.api.Task)307 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)288 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)147 ArrayList (java.util.ArrayList)113 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)92 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)72 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)72 SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)68 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)61 List (java.util.List)61 QName (javax.xml.namespace.QName)60 SystemException (com.evolveum.midpoint.util.exception.SystemException)46 File (java.io.File)46 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)44 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)42 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)40 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)38