use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class AbstractModelImplementationIntegrationTest method addFocusModificationToContext.
protected <O extends ObjectType> ObjectDelta<O> addFocusModificationToContext(LensContext<O> context, File file) throws JAXBException, SchemaException, IOException {
ObjectModificationType modElement = PrismTestUtil.parseAtomicValue(file, ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<O> focusDelta = DeltaConvertor.createObjectDelta(modElement, context.getFocusClass(), prismContext);
return addFocusDeltaToContext(context, focusDelta);
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class XPathTest method xpathTest.
/**
* This is now a proper test yet.
* It does some operations with XPath. If it does not die, then the
* code some somehow consistent.
*
* It should be improved later.
*/
@Test
public void xpathTest() throws JAXBException, FileNotFoundException, IOException, ParserConfigurationException, SchemaException {
ObjectModificationType objectModification = PrismTestUtil.parseAtomicValue(new File(FILENAME_CHANGETYPE), ObjectModificationType.COMPLEX_TYPE);
for (ItemDeltaType change : objectModification.getItemDelta()) {
ItemPathType pathType = change.getPath();
System.out.println(" path=" + pathType + " (" + pathType.getClass().getName() + ") " + pathType.toString());
// NamedNodeMap attributes = path.getAttributes();
// for (int i = 0; i < attributes.getLength(); i++) {
// Node n = attributes.item(i);
// System.out.println(" A: " + n.getClass().getName() + " " + n.getNodeName() + "(" + n.getPrefix() + " : " + n.getLocalName() + ") = " + n.getNodeValue());
// }
// List<Object> any = change.getValue().getAny();
// for (Object e : any) {
// if (e instanceof Element) {
// System.out.println(" E: " + ((Element) e).getLocalName());
// }
// }
ItemPath path = pathType.getItemPath();
XPathHolder xpath = new XPathHolder(path);
AssertJUnit.assertEquals("c:extension/piracy:ship[2]/c:name", xpath.getXPathWithoutDeclarations());
System.out.println("XPATH: " + xpath);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder loader = factory.newDocumentBuilder();
Document doc = loader.newDocument();
Element xpathElement = xpath.toElement("http://elelel/", "path", doc);
Attr nsC = xpathElement.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "c");
Attr nsPiracy = xpathElement.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "piracy");
System.out.println("c: " + nsC);
System.out.println("piracy: " + nsPiracy);
// AssertJUnit.assertEquals("http://midpoint.evolveum.com/xml/ns/public/common/common-3", nsC.getValue());
// AssertJUnit.assertEquals("http://midpoint.evolveum.com/xml/ns/samples/piracy", nsPiracy.getValue());
System.out.println("XPATH Element: " + xpathElement);
XPathHolder xpathFromElement = new XPathHolder(xpathElement);
AssertJUnit.assertEquals(xpath, xpathFromElement);
// attributes = xpathElement.getAttributes();
// for (int i = 0; i < attributes.getLength(); i++) {
// Node n = attributes.item(i);
// System.out.println(" A: " + n.getNodeName() + "(" + n.getPrefix() + " : " + n.getLocalName() + ") = " + n.getNodeValue());
// }
List<XPathSegment> segments = xpath.toSegments();
System.out.println("XPATH segments: " + segments);
XPathHolder xpathFromSegments = new XPathHolder(segments);
System.out.println("XPath from segments: " + xpathFromSegments);
AssertJUnit.assertEquals("c:extension/piracy:ship[2]/c:name", xpathFromSegments.getXPathWithoutDeclarations());
}
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class AbstractWfTestLegacy method encryptAndAddFocusModificationToContext.
<O extends ObjectType> ObjectDelta<O> encryptAndAddFocusModificationToContext(LensContext<O> context, File file) throws JAXBException, SchemaException, IOException {
ObjectModificationType modElement = PrismTestUtil.parseAtomicValue(file, ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<O> focusDelta = DeltaConvertor.createObjectDelta(modElement, context.getFocusClass(), prismContext);
Utils.encrypt((Collection) Arrays.asList(focusDelta), protector, null, new OperationResult("dummy"));
return addFocusDeltaToContext(context, focusDelta);
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class TestAddAssociationLegacy method test100AddJackToGuests.
/**
* Add entitlement for 'guests' to user jack - should be created without starting wf process
*/
@Test
public void test100AddJackToGuests() throws Exception {
final String TEST_NAME = "test100AddJackToGuests";
TestUtil.displayTestTile(this, TEST_NAME);
Task modelTask = taskManager.createTaskInstance(TEST_NAME);
OperationResult result = new OperationResult(TEST_NAME);
modelTask.setOwner(repositoryService.getObject(UserType.class, USER_ADMINISTRATOR_OID, null, result));
LensContext<UserType> context = createUserLensContext();
fillContextWithUser(context, USER_JACK_OID, result);
UserType jack = context.getFocusContext().getObjectCurrent().asObjectable();
AssertJUnit.assertEquals("Jack has wrong number of accounts", 1, jack.getLinkRef().size());
jackAccountShadowOid = jack.getLinkRef().get(0).getOid();
ShadowType accountBefore = getObject(ShadowType.class, jackAccountShadowOid).asObjectable();
assertEquals("Wrong # of jack's account associations", 1, accountBefore.getAssociation().size());
assertHasAssociation(accountBefore, new QName("group"), GROUP_TESTERS_OID);
LensProjectionContext accountContext = fillContextWithAccount(context, jackAccountShadowOid, modelTask, result);
ObjectModificationType modElement = PrismTestUtil.parseAtomicValue(REQ_SHADOW_MODIFY_ADD_ENTITLEMENT_GUESTS, ObjectModificationType.COMPLEX_TYPE);
ObjectDelta shadowDelta = DeltaConvertor.createObjectDelta(modElement, ShadowType.class, prismContext);
shadowDelta.setOid(jackAccountShadowOid);
accountContext.setPrimaryDelta(shadowDelta);
HookOperationMode mode = clockwork.run(context, modelTask, result);
assertEquals("Unexpected state of the context - workflow was started even if it should not", ModelState.FINAL, context.getState());
assertEquals("Wrong mode after clockwork.run in " + context.getState(), HookOperationMode.FOREGROUND, mode);
ShadowType accountAfter = getObject(ShadowType.class, jackAccountShadowOid).asObjectable();
assertEquals("Wrong # of jack's account associations", 2, accountAfter.getAssociation().size());
assertHasAssociation(accountAfter, new QName("group"), GROUP_TESTERS_OID);
assertHasAssociation(accountAfter, new QName("group"), GROUP_GUESTS_OID);
}
use of com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectModificationType in project midpoint by Evolveum.
the class OrgStructTest method test003modifyOrgStructDeleteRef.
@SuppressWarnings("unchecked")
@Test
public void test003modifyOrgStructDeleteRef() throws Exception {
// test modification of org ref - delete org ref
OperationResult opResult = new OperationResult("test003modifyOrgStructDeleteRef");
ObjectModificationType modification = PrismTestUtil.parseAtomicValue(new File(MODIFY_ORG_DELETE_REF_FILENAME), ObjectModificationType.COMPLEX_TYPE);
ObjectDelta<OrgType> delta = DeltaConvertor.createObjectDelta(modification, OrgType.class, prismContext);
Session session = open();
try {
LOGGER.info("==>before modify - delete<==");
List<ROrgClosure> orgClosure = getOrgClosure(ORG_F003_OID, MODIFY_ORG_DELETE_REF_OID, session);
AssertJUnit.assertEquals(1, orgClosure.size());
session.getTransaction().commit();
repositoryService.modifyObject(OrgType.class, MODIFY_ORG_DELETE_REF_OID, delta.getModifications(), opResult);
session.clear();
session.beginTransaction();
LOGGER.info("==>after modify - delete<==");
orgClosure = getOrgClosure(ORG_F003_OID, MODIFY_ORG_DELETE_REF_OID, session);
AssertJUnit.assertEquals(0, orgClosure.size());
} finally {
close(session);
}
}
Aggregations