use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TestObjectConstruction method testObjectTypeConstruction.
@Test
public void testObjectTypeConstruction() throws Exception {
System.out.println("\n\n ===[ testObjectTypeConstruction ]===\n");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
try {
// WHEN
PrismObject<ObjectType> object = prismContext.createObject(ObjectType.class);
fail("unexpected success");
} catch (SchemaException e) {
// This is expected, abstract object types cannot be instantiated
assertTrue(e.getMessage().contains("abstract"));
}
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TestDiffEquals method testAssignmentEquals.
@Test
public void testAssignmentEquals() throws Exception {
System.out.println("\n\n===[ testAssignmentEquals ]===\n");
PrismContext prismContext = PrismTestUtil.getPrismContext();
AssignmentType a1a = new AssignmentType();
prismContext.adopt(a1a);
a1a.setDescription("descr1");
AssignmentType a2 = new AssignmentType();
prismContext.adopt(a2);
a2.setDescription("descr2");
AssignmentType a1b = new AssignmentType();
prismContext.adopt(a1b);
a1b.setDescription("descr1");
AssignmentType a1m = new AssignmentType();
prismContext.adopt(a1m);
a1m.setDescription("descr1");
MetadataType metadata1m = new MetadataType();
metadata1m.setCreateTimestamp(XmlTypeConverter.createXMLGregorianCalendar(System.currentTimeMillis()));
a1m.setMetadata(metadata1m);
AssignmentType a1e = new AssignmentType();
prismContext.adopt(a1e);
a1e.setDescription("descr1");
ActivationType activation1e = new ActivationType();
activation1e.setEffectiveStatus(ActivationStatusType.ENABLED);
a1e.setActivation(activation1e);
// WHEN
assertFalse(a1a.equals(a2));
assertFalse(a1b.equals(a2));
assertFalse(a1m.equals(a2));
assertFalse(a1e.equals(a2));
assertFalse(a2.equals(a1a));
assertFalse(a2.equals(a1b));
assertFalse(a2.equals(a1m));
assertFalse(a2.equals(a1e));
assertTrue(a1a.equals(a1a));
assertTrue(a1b.equals(a1b));
assertTrue(a1m.equals(a1m));
assertTrue(a1e.equals(a1e));
assertTrue(a2.equals(a2));
assertTrue(a1a.equals(a1b));
assertTrue(a1b.equals(a1a));
assertTrue(a1a.equals(a1m));
assertTrue(a1b.equals(a1m));
assertTrue(a1m.equals(a1a));
assertTrue(a1m.equals(a1b));
assertTrue(a1m.equals(a1e));
assertTrue(a1a.equals(a1e));
assertTrue(a1b.equals(a1e));
assertTrue(a1e.equals(a1a));
assertTrue(a1e.equals(a1b));
assertTrue(a1e.equals(a1m));
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TestDiffEquals method testAssignmentHashcode.
@Test
public void testAssignmentHashcode() throws Exception {
LOGGER.info("\n\n===[ testAssignmentHashcode ]===\n");
System.out.println("\n\n===[ testAssignmentHashcode ]===\n");
PrismContext prismContext = PrismTestUtil.getPrismContext();
AssignmentType a1a = new AssignmentType();
prismContext.adopt(a1a);
a1a.setDescription("descr1");
AssignmentType a2 = new AssignmentType();
prismContext.adopt(a2);
a2.setDescription("descr2");
AssignmentType a1b = new AssignmentType();
prismContext.adopt(a1b);
a1b.setDescription("descr1");
AssignmentType a1m = new AssignmentType();
prismContext.adopt(a1m);
a1m.setDescription("descr1");
MetadataType metadata1m = new MetadataType();
metadata1m.setCreateTimestamp(XmlTypeConverter.createXMLGregorianCalendar(System.currentTimeMillis()));
a1m.setMetadata(metadata1m);
AssignmentType a1e = new AssignmentType();
prismContext.adopt(a1e);
a1e.setDescription("descr1");
ActivationType activation1e = new ActivationType();
activation1e.setEffectiveStatus(ActivationStatusType.ENABLED);
a1e.setActivation(activation1e);
// WHEN
assertFalse(a1a.hashCode() == a2.hashCode());
assertFalse(a1b.hashCode() == a2.hashCode());
assertFalse(a1m.hashCode() == a2.hashCode());
assertFalse(a1e.hashCode() == a2.hashCode());
assertFalse(a2.hashCode() == a1a.hashCode());
assertFalse(a2.hashCode() == a1b.hashCode());
assertFalse(a2.hashCode() == a1m.hashCode());
assertFalse(a2.hashCode() == a1e.hashCode());
assertTrue(a1a.hashCode() == a1a.hashCode());
assertTrue(a1b.hashCode() == a1b.hashCode());
assertTrue(a1m.hashCode() == a1m.hashCode());
assertTrue(a1e.hashCode() == a1e.hashCode());
assertTrue(a2.hashCode() == a2.hashCode());
assertTrue(a1a.hashCode() == a1b.hashCode());
assertTrue(a1b.hashCode() == a1a.hashCode());
assertTrue(a1a.hashCode() == a1m.hashCode());
assertTrue(a1b.hashCode() == a1m.hashCode());
assertTrue(a1m.hashCode() == a1a.hashCode());
assertTrue(a1m.hashCode() == a1b.hashCode());
assertTrue(a1m.hashCode() == a1e.hashCode());
assertTrue(a1a.hashCode() == a1e.hashCode());
assertTrue(a1b.hashCode() == a1e.hashCode());
assertTrue(a1e.hashCode() == a1a.hashCode());
assertTrue(a1e.hashCode() == a1b.hashCode());
assertTrue(a1e.hashCode() == a1m.hashCode());
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TestDynamicSchema method parseUserAssignmentContainer.
private PrismContainer<AssignmentType> parseUserAssignmentContainer() throws SchemaException, IOException {
PrismContext prismContext = PrismTestUtil.getPrismContext();
PrismObject<UserType> user = prismContext.parseObject(USER_FILE);
System.out.println("Parsed user:");
System.out.println(user.debugDump());
return user.findContainer(new ItemPath(new NameItemPathSegment(UserType.F_ASSIGNMENT), new IdItemPathSegment(USER_ASSIGNMENT_1_ID), new NameItemPathSegment(AssignmentType.F_EXTENSION)));
}
use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.
the class TestFilterSimplifier method test170OrLevel1Undefined.
@Test
public void test170OrLevel1Undefined() throws Exception {
System.out.println("===[ test170OrLevel1Undefined ]===");
// GIVEN
PrismContext prismContext = PrismTestUtil.getPrismContext();
// WHEN
ObjectFilter filter = OrFilter.createOr(UndefinedFilter.createUndefined());
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);
}
Aggregations