Search in sources :

Example 11 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.

the class TestDiffEquals method testAssignmentEquivalent.

@Test
public void testAssignmentEquivalent() throws Exception {
    System.out.println("\n\n===[ testAssignmentEquivalent ]===\n");
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    AssignmentType a1 = new AssignmentType(prismContext);
    ActivationType a1a = new ActivationType(prismContext);
    a1a.setValidFrom(XmlTypeConverter.createXMLGregorianCalendar(new Date()));
    a1a.setEffectiveStatus(ActivationStatusType.ENABLED);
    a1.setActivation(a1a);
    AssignmentType a2 = new AssignmentType(prismContext);
    ActivationType a2a = new ActivationType(prismContext);
    a2a.setEffectiveStatus(ActivationStatusType.ENABLED);
    a2.setActivation(a2a);
    // WHEN
    assertFalse(a1.equals(a2));
    // a bit redundant
    assertFalse(a1.asPrismContainerValue().equivalent(a2.asPrismContainerValue()));
    assertFalse(a2.equals(a1));
    // a bit redundant
    assertFalse(a2.asPrismContainerValue().equivalent(a1.asPrismContainerValue()));
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 12 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.

the class TestDiffEquals method testDiffShadow.

@Test
public void testDiffShadow() throws Exception {
    System.out.println("\n\n===[ testDiffShadow ]===\n");
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    PrismObject<ShadowType> shadow1 = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ShadowType.class).instantiate();
    ShadowType shadow1Type = shadow1.asObjectable();
    shadow1Type.setName(new PolyStringType("Whatever"));
    shadow1Type.setFailedOperationType(FailedOperationTypeType.ADD);
    shadow1Type.getAuxiliaryObjectClass().add(new QName(NS_TEST_RI, "foo"));
    PrismContainer<Containerable> shadow1Attrs = shadow1.findOrCreateContainer(ShadowType.F_ATTRIBUTES);
    ShadowType shadow2Type = new ShadowType();
    PrismObject<ShadowType> shadow2 = shadow2Type.asPrismObject();
    prismContext.adopt(shadow2Type);
    shadow2Type.setName(new PolyStringType("Whatever"));
    shadow2Type.getAuxiliaryObjectClass().add(new QName(NS_TEST_RI, "foo"));
    shadow2Type.getAuxiliaryObjectClass().add(new QName(NS_TEST_RI, "bar"));
    PrismContainer<Containerable> shadow2Attrs = shadow2.findOrCreateContainer(ShadowType.F_ATTRIBUTES);
    PrismProperty<String> attrEntryUuid = new PrismProperty<>(new QName(NS_TEST_RI, "entryUuid"), prismContext);
    PrismPropertyDefinition<String> attrEntryUuidDef = new PrismPropertyDefinitionImpl<>(new QName(NS_TEST_RI, "entryUuid"), DOMUtil.XSD_STRING, prismContext);
    attrEntryUuid.setDefinition(attrEntryUuidDef);
    shadow2Attrs.add(attrEntryUuid);
    attrEntryUuid.addRealValue("1234-5678-8765-4321");
    PrismProperty<String> attrDn = new PrismProperty<>(new QName(NS_TEST_RI, "dn"), prismContext);
    PrismPropertyDefinition<String> attrDnDef = new PrismPropertyDefinitionImpl<>(new QName(NS_TEST_RI, "dn"), DOMUtil.XSD_STRING, prismContext);
    attrDn.setDefinition(attrDnDef);
    shadow2Attrs.add(attrDn);
    attrDn.addRealValue("uid=foo,o=bar");
    System.out.println("Shadow 1");
    System.out.println(shadow1.debugDump(1));
    System.out.println("Shadow 2");
    System.out.println(shadow2.debugDump(1));
    // WHEN
    ObjectDelta<ShadowType> delta = shadow1.diff(shadow2);
    // THEN
    assertNotNull("No delta", delta);
    System.out.println("Delta");
    System.out.println(delta.debugDump(1));
    PrismAsserts.assertIsModify(delta);
    PrismAsserts.assertPropertyDelete(delta, ShadowType.F_FAILED_OPERATION_TYPE, FailedOperationTypeType.ADD);
    PrismAsserts.assertPropertyAdd(delta, ShadowType.F_AUXILIARY_OBJECT_CLASS, new QName(NS_TEST_RI, "bar"));
    PrismAsserts.assertContainerAdd(delta, ShadowType.F_ATTRIBUTES, shadow2Attrs.getValue().clone());
    PrismAsserts.assertModifications(delta, 3);
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) PrismContext(com.evolveum.midpoint.prism.PrismContext) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) QName(javax.xml.namespace.QName) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) PrismPropertyDefinitionImpl(com.evolveum.midpoint.prism.PrismPropertyDefinitionImpl) Containerable(com.evolveum.midpoint.prism.Containerable) Test(org.testng.annotations.Test)

Example 13 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.

the class TestFilterSimplifier method test200AndLevel2.

@Test
public void test200AndLevel2() throws Exception {
    System.out.println("===[ test200AndLevel2 ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    ObjectFilter filter = QueryBuilder.queryFor(UserType.class, prismContext).all().and().undefined().and().block().none().or().none().endBlock().and().block().none().or().none().endBlock().buildFilter();
    System.out.println("Original filter:\n" + filter.debugDump());
    // THEN
    ObjectFilter simplified = ObjectQueryUtil.simplify(filter);
    System.out.println("Simplified filter:\n" + DebugUtil.debugDump(simplified));
    assertTrue("Wrong simplified filter: " + simplified, simplified instanceof NoneFilter);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) Test(org.testng.annotations.Test)

Example 14 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.

the class TestFilterSimplifier method test010All.

@Test
public void test010All() throws Exception {
    System.out.println("===[ test010All ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    ObjectFilter filter = QueryBuilder.queryFor(UserType.class, prismContext).all().buildFilter();
    System.out.println("Original filter:\n" + filter.debugDump());
    // THEN
    ObjectFilter simplified = ObjectQueryUtil.simplify(filter);
    System.out.println("Simplified filter:\n" + DebugUtil.debugDump(simplified));
    assertTrue("Wrong simplified filter: " + simplified, simplified == null || simplified instanceof AllFilter);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) Test(org.testng.annotations.Test)

Example 15 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.

the class TestFilterSimplifier method test120AndEmpty.

@Test
public void test120AndEmpty() throws Exception {
    System.out.println("===[ test120AndEmpty ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    ObjectFilter filter = AndFilter.createAnd();
    System.out.println("Original filter:\n" + filter.debugDump());
    // THEN
    ObjectFilter simplified = ObjectQueryUtil.simplify(filter);
    System.out.println("Simplified filter:\n" + DebugUtil.debugDump(simplified));
    assertTrue("Wrong simplified filter: " + simplified, simplified == null || simplified instanceof AllFilter);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) Test(org.testng.annotations.Test)

Aggregations

PrismContext (com.evolveum.midpoint.prism.PrismContext)104 Test (org.testng.annotations.Test)59 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 QName (javax.xml.namespace.QName)15 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)13 Task (com.evolveum.midpoint.task.api.Task)11 SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)10 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)10 PrismObject (com.evolveum.midpoint.prism.PrismObject)9 SystemException (com.evolveum.midpoint.util.exception.SystemException)9 File (java.io.File)8 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)7 ArrayList (java.util.ArrayList)7 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)6 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)6 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)6 Protector (com.evolveum.midpoint.prism.crypto.Protector)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)5