Search in sources :

Example 81 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.

the class AbstractLdapHierarchyTest method createOrg.

private PrismObject<OrgType> createOrg(String name, String parentOrgOid) throws SchemaException {
    PrismObject<OrgType> org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate();
    OrgType orgType = org.asObjectable();
    orgType.setName(new PolyStringType(name));
    orgType.getOrgType().add(ORG_TYPE_FUNCTIONAL);
    AssignmentType metaRoleAssignment = new AssignmentType();
    ObjectReferenceType metaRoleAssignmentTargetRef = new ObjectReferenceType();
    metaRoleAssignmentTargetRef.setOid(ROLE_META_ORG_OID);
    metaRoleAssignmentTargetRef.setType(RoleType.COMPLEX_TYPE);
    metaRoleAssignment.setTargetRef(metaRoleAssignmentTargetRef);
    orgType.getAssignment().add(metaRoleAssignment);
    if (parentOrgOid != null) {
        AssignmentType parentAssignment = new AssignmentType();
        ObjectReferenceType parentAssignmentTargetRef = new ObjectReferenceType();
        parentAssignmentTargetRef.setOid(parentOrgOid);
        parentAssignmentTargetRef.setType(OrgType.COMPLEX_TYPE);
        parentAssignment.setTargetRef(parentAssignmentTargetRef);
        orgType.getAssignment().add(parentAssignment);
    }
    return org;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 82 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.

the class TestLdapDependency method createOrg.

private PrismObject<OrgType> createOrg(String name, String parentOrgOid) throws SchemaException {
    PrismObject<OrgType> org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate();
    OrgType orgType = org.asObjectable();
    orgType.setName(new PolyStringType(name));
    orgType.getOrgType().add(ORG_TYPE_FUNCTIONAL);
    if (parentOrgOid != null) {
        AssignmentType parentAssignment = new AssignmentType();
        ObjectReferenceType parentAssignmentTargetRef = new ObjectReferenceType();
        parentAssignmentTargetRef.setOid(parentOrgOid);
        parentAssignmentTargetRef.setType(OrgType.COMPLEX_TYPE);
        parentAssignment.setTargetRef(parentAssignmentTargetRef);
        orgType.getAssignment().add(parentAssignment);
    }
    return org;
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 83 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.

the class TestDiffEquals method testContextlessAssignmentEquals.

@Test
public void testContextlessAssignmentEquals() throws Exception {
    System.out.println("\n\n===[ testContextlessAssignmentEquals ]===\n");
    // no prismContext here
    AssignmentType a1 = new AssignmentType();
    a1.setDescription("descr1");
    // no prismContext here
    AssignmentType a2 = new AssignmentType();
    a2.setDescription("descr2");
    // no prismContext here
    AssignmentType a3 = new AssignmentType();
    a3.setDescription("descr1");
    // this should work even without prismContext
    assertFalse(a1.equals(a2));
    // this should work even without prismContext
    assertTrue(a1.equals(a3));
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    prismContext.adopt(a1);
    prismContext.adopt(a2);
    prismContext.adopt(a3);
    // this should work as well
    assertFalse(a1.equals(a2));
    assertTrue(a1.equals(a3));
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) Test(org.testng.annotations.Test)

Example 84 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType 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));
}
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) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) Test(org.testng.annotations.Test)

Example 85 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType 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());
}
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) MetadataType(com.evolveum.midpoint.xml.ns._public.common.common_3.MetadataType) Test(org.testng.annotations.Test)

Aggregations

AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)121 Test (org.testng.annotations.Test)61 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)55 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)42 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)41 Task (com.evolveum.midpoint.task.api.Task)39 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)33 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)25 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)24 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)21 QName (javax.xml.namespace.QName)20 PrismObject (com.evolveum.midpoint.prism.PrismObject)19 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)17 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)17 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)17 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)17 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)17 ArrayList (java.util.ArrayList)17 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)15 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)14