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()));
}
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);
}
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);
}
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);
}
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);
}
Aggregations