private QueryType toQueryType(String xml) throws SchemaException { return PrismTestUtil.parseAtomicValue(xml, QueryType.COMPLEX_TYPE); }
private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException, JAXBException { ScriptExpressionEvaluatorType expressionType = PrismTestUtil.parseAtomicValue( new File(TEST_DIR, fileName), ScriptExpressionEvaluatorType.COMPLEX_TYPE); return expressionType; }
private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException, JAXBException { ScriptExpressionEvaluatorType expressionType = PrismTestUtil.parseAtomicValue( new File(TEST_DIR, fileName), ScriptExpressionEvaluatorType.COMPLEX_TYPE); return expressionType; }
private ScriptExpressionEvaluatorType parseScriptType(String fileName) throws SchemaException, IOException { return PrismTestUtil.parseAtomicValue( new File(getTestDir(), fileName), ScriptExpressionEvaluatorType.COMPLEX_TYPE); }
private ObjectDelta<UserType> parseDelta(String filename) throws JAXBException, SchemaException, IOException { ObjectModificationType modElement = PrismTestUtil.parseAtomicValue(new File(filename), ObjectModificationType.COMPLEX_TYPE); return DeltaConvertor.createObjectDelta(modElement, UserType.class, prismContext); }
protected ObjectDelta<UserType> parseDelta(String oid, File file) throws SchemaException, IOException { ObjectModificationType modification = PrismTestUtil.parseAtomicValue(file, ObjectModificationType.COMPLEX_TYPE); ObjectDelta<UserType> delta = DeltaConvertor.createObjectDelta(modification, UserType.class, prismContext); delta.setOid(oid); return delta; }
protected ObjectDelta<OrgType> parseDelta(String oid, File file) throws SchemaException, IOException { ObjectModificationType modification = PrismTestUtil.parseAtomicValue(file, ObjectModificationType.COMPLEX_TYPE); ObjectDelta<OrgType> delta = DeltaConvertor.createObjectDelta(modification, OrgType.class, prismContext); delta.setOid(oid); return delta; }
@Test public void test070ModifyBigUser() throws Exception { ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(FOLDER_BASIC, "t004.xml"), ObjectModificationType.COMPLEX_TYPE); ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, UserType.class, prismContext); repositoryService.modifyObject(UserType.class, userBigOid, delta.getModifications(), new OperationResult("asdf")); }
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); }
@Test public void test030ModifyShadow() throws Exception { ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(FOLDER_BASIC, "t003.xml"), ObjectModificationType.COMPLEX_TYPE); ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, ShadowType.class, prismContext); delta.setOid(userOid); repositoryService.modifyObject(ShadowType.class, shadowOid, delta.getModifications(), new OperationResult("asdf")); }
@Nullable private ObjectQuery getQuery(File file, Class type) throws SchemaException, IOException { QueryType queryType = PrismTestUtil.parseAtomicValue(file, QueryType.COMPLEX_TYPE); LOGGER.info("QUERY TYPE TO CONVERT : {}", ObjectQueryUtil.dump(queryType, prismContext)); ObjectQuery query = null; try { query = getQueryConverter().createObjectQuery(type, queryType); // TODO } catch (Exception ex) { LOGGER.info("error while converting query: " + ex.getMessage(), ex); } return query; }
<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); ModelImplUtils.encrypt((Collection) Arrays.asList(focusDelta), protector, null, new OperationResult("dummy")); return addFocusDeltaToContext(context, focusDelta); } }
@Test(expectedExceptions = ObjectNotFoundException.class) public void test020ModifyNotExistingUser() throws Exception { final String TEST_NAME = "test020ModifyNotExistingUser"; TestUtil.displayTestTitle(TEST_NAME); ObjectModificationType modification = PrismTestUtil.parseAtomicValue( MODIFY_USER_ADD_LINK, ObjectModificationType.COMPLEX_TYPE); Collection<? extends ItemDelta> deltas = DeltaConvertor.toModifications(modification, UserType.class, prismContext); OperationResult result = new OperationResult("MODIFY"); repositoryService.modifyObject(UserType.class, "1234", deltas, getModifyOptions(), result); }
@Test public void testRefWithObject() throws SchemaException, IOException, JAXBException { System.out.println("===[ testRefWithObject ]===="); ObjectModificationType objectChange = PrismTestUtil.parseAtomicValue(new File(TEST_DIR, "user-modify-add-account.xml"), ObjectModificationType.COMPLEX_TYPE); ObjectDelta<UserType> objectDelta = DeltaConvertor.createObjectDelta(objectChange, UserType.class, getPrismContext()); System.out.println("delta: " + objectDelta.debugDump()); assertNotNull("No object delta", objectDelta); objectDelta.checkConsistence(); assertEquals("Wrong OID", "c0c010c0-d34d-b33f-f00d-111111111111", objectDelta.getOid()); ReferenceDelta accoutRefDelta = objectDelta.findReferenceModification(UserType.F_LINK_REF); assertNotNull("No accountRef delta", accoutRefDelta); Collection<PrismReferenceValue> valuesToAdd = accoutRefDelta.getValuesToAdd(); assertEquals("Wrong number of values to add", 1, valuesToAdd.size()); PrismReferenceValue accountRefVal = valuesToAdd.iterator().next(); assertNotNull("No object in accountRef value", accountRefVal.getObject()); objectDelta.assertDefinitions(); }
@Override public LensContext createModelContext(Task task, OperationResult result) throws Exception { 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(); LensProjectionContext accountContext = fillContextWithAccount(context, jackAccountShadowOid, task, result); ObjectModificationType modElement = PrismTestUtil.parseAtomicValue(REQ_SHADOW_MODIFY_ADD_ENTITLEMENT_TESTERS, ObjectModificationType.COMPLEX_TYPE); ObjectDelta shadowDelta = DeltaConvertor.createObjectDelta(modElement, ShadowType.class, prismContext); shadowDelta.setOid(jackAccountShadowOid); accountContext.setPrimaryDelta(shadowDelta); return context; }
@Override public LensContext createModelContext(Task task, OperationResult result) throws Exception { LensContext<UserType> context = createUserLensContext(); fillContextWithUser(context, USER_ELISABETH_OID, result); UserType elisabeth = context.getFocusContext().getObjectCurrent().asObjectable(); AssertJUnit.assertEquals("Elisabeth has wrong number of accounts", 1, elisabeth.getLinkRef().size()); elisabethAccountShadowOid = elisabeth.getLinkRef().get(0).getOid(); LensProjectionContext accountContext = fillContextWithAccount(context, elisabethAccountShadowOid, task, result); ObjectModificationType modElement = PrismTestUtil.parseAtomicValue(REQ_SHADOW_MODIFY_ADD_ENTITLEMENT_TESTERS, ObjectModificationType.COMPLEX_TYPE); ObjectDelta shadowDelta = DeltaConvertor.createObjectDelta(modElement, ShadowType.class, prismContext); shadowDelta.setOid(elisabethAccountShadowOid); accountContext.setPrimaryDelta(shadowDelta); return context; }
private SynchronizationContext<UserType> createSynchronizationContext(File account, String correlationFilter, File resource, Task task, OperationResult result) throws SchemaException, IOException { ShadowType shadow = parseObjectType(account, ShadowType.class); ConditionalSearchFilterType query = PrismTestUtil.parseAtomicValue(new File(correlationFilter), ConditionalSearchFilterType.COMPLEX_TYPE); ResourceType resourceType = parseObjectType(resource, ResourceType.class); resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().clear(); resourceType.getSynchronization().getObjectSynchronization().get(0).getCorrelation().add(query); ObjectSynchronizationType objectSynchronizationType = resourceType.getSynchronization().getObjectSynchronization().get(0); PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(result); assertNotNull("Unexpected null system configuration", systemConfiguration); SynchronizationContext<UserType> syncCtx = new SynchronizationContext<>(shadow.asPrismObject(), shadow.asPrismObject(), resourceType.asPrismObject(), null, task, result); syncCtx.setSystemConfiguration(systemConfiguration); syncCtx.setObjectSynchronization(objectSynchronizationType); syncCtx.setFocusClass(UserType.class); return syncCtx; }
@Test public void test105ApplyDefinitionModifyDelta() throws Exception { final String TEST_NAME = "test105ApplyDefinitionModifyDelta"; displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); ObjectModificationType changeAddRoleCaptain = PrismTestUtil.parseAtomicValue(MODIFY_ACCOUNT_FILE, ObjectModificationType.COMPLEX_TYPE); ObjectDelta<ShadowType> accountDelta = DeltaConvertor.createObjectDelta(changeAddRoleCaptain, ShadowType.class, prismContext); // WHEN provisioningService.applyDefinition(accountDelta, task, result); // THEN assertSuccess(result); accountDelta.checkConsistence(true, true, true); assertSteadyResource(); }
@Test public void testConnectorQuery() throws Exception { displayTestTitle("testConnectorQuery"); SearchFilterType filterType = PrismTestUtil.parseAtomicValue(FILTER_CONNECTOR_BY_TYPE_FILE, SearchFilterType.COMPLEX_TYPE); ObjectQuery query; try { query = getQueryConverter().createObjectQuery(ConnectorType.class, filterType); displayQuery(query); assertNotNull(query); ObjectFilter filter = query.getFilter(); PrismAsserts.assertEqualsFilter(query.getFilter(), ConnectorType.F_CONNECTOR_TYPE, DOMUtil.XSD_STRING, ConnectorType.F_CONNECTOR_TYPE); PrismAsserts.assertEqualsFilterValue((EqualFilter) filter, "org.identityconnectors.ldap.LdapConnector"); QueryType convertedQueryType = toQueryType(query); displayQueryType(convertedQueryType); } catch (Exception ex) { LOGGER.error("Error while converting query: {}", ex.getMessage(), ex); throw ex; } }
@Test public void test020ModifyUser() throws Exception { final String TEST_NAME = "test020ModifyUser"; TestUtil.displayTestTitle(TEST_NAME); OperationResult result = new OperationResult(TEST_NAME); ObjectModificationType modification = PrismTestUtil.parseAtomicValue( new File(FOLDER_BASIC, "t002.xml"), ObjectModificationType.COMPLEX_TYPE); ObjectDelta delta = DeltaConvertor.createObjectDelta(modification, UserType.class, prismContext); delta.setOid(userOid); // WHEN TestUtil.displayWhen(TEST_NAME); repositoryService.modifyObject(UserType.class, userOid, delta.getModifications(), result); // THEN TestUtil.displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess(result); PrismObject<UserType> userAfter = repositoryService.getObject(UserType.class, userOid, null, result); PrismAsserts.assertPropertyValue(userAfter, UserType.F_FULL_NAME, PrismTestUtil.createPolyString(USER_FULLNAME)); PrismAsserts.assertPropertyValue(userAfter, UserType.F_EMPLOYEE_NUMBER, "en1234"); }