public ShadowType name(com.evolveum.prism.xml.ns._public.types_3.PolyStringType value) { setName(value); return this; }
currentShadow.setOid(repoShadow.getOid()); currentShadow.asObjectable().setName(new PolyStringType(ShadowUtil.determineShadowName(currentShadow))); return currentShadow;
private ShadowType createShadow(UserType user, String resourceOid, int resourceId) throws SchemaException { ShadowType shadow = new ShadowType(); shadow.setOid(UUID.randomUUID().toString()); final String DN = "cn=" + user.getName().getOrig() + ",ou=resource" + resourceId + ",dc=example,dc=com"; shadow.setName(createPoly(DN)); shadow.setResourceRef(createRef(resourceOid, ResourceType.COMPLEX_TYPE)); shadow.setKind(ShadowKindType.ACCOUNT); shadow.setIntent("standardAccount"); shadow.setObjectClass(new QName("http://midpoint.evolveum.com/xml/ns/public/resource/instance/" + resourceOid, "AccountObjectClass")); PrismObject<ShadowType> prism = shadow.asPrismObject(); prismContext.adopt(prism); PrismContainer attributes = prism.findOrCreateContainer(ShadowType.F_ATTRIBUTES); PrismProperty property = attributes.findOrCreateProperty(SchemaConstants.ICFS_UID); property.setRealValue(UUID.randomUUID().toString()); property = attributes.findOrCreateProperty(SchemaConstants.ICFS_NAME); property.setRealValue(DN); return shadow; }
.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")); 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"));
protected PrismObject<ShadowType> createShadow(PrismObject<ResourceType> resource, String uid, String name) throws SchemaException { PrismObject<ShadowType> shadow = getShadowDefinition().instantiate(); ShadowType shadowType = shadow.asObjectable(); if (name != null) { shadowType.setName(PrismTestUtil.createPolyStringType(name)); } ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resource.getOid()); shadowType.setResourceRef(resourceRef); shadowType.setKind(ShadowKindType.ACCOUNT); RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); RefinedObjectClassDefinition objectClassDefinition = refinedSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); shadowType.setObjectClass(objectClassDefinition.getTypeName()); ResourceAttributeContainer attrContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, objectClassDefinition); if (uid != null) { RefinedAttributeDefinition uidAttrDef = objectClassDefinition.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA,"uid")); ResourceAttribute<String> uidAttr = uidAttrDef.instantiate(); uidAttr.setRealValue(uid); attrContainer.add(uidAttr); } if (name != null) { RefinedAttributeDefinition nameAttrDef = objectClassDefinition.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA,"name")); ResourceAttribute<String> nameAttr = nameAttrDef.instantiate(); nameAttr.setRealValue(name); attrContainer.add(nameAttr); } return shadow; }
@Test public void addGetSyncDescription() throws Exception { PrismObjectDefinition accDef = prismContext.getSchemaRegistry() .findObjectDefinitionByCompileTimeClass(ShadowType.class); PrismObject<ShadowType> shadow = accDef.instantiate(); final Date TIME = new Date(); ShadowType shadowType = shadow.asObjectable(); shadowType.setName(new PolyStringType("sync desc test")); SynchronizationSituationDescriptionType desc = new SynchronizationSituationDescriptionType(); desc.setChannel("channel"); desc.setSituation(SynchronizationSituationType.LINKED); desc.setTimestamp(XMLGregorianCalendarType.asXMLGregorianCalendar(TIME)); shadowType.getSynchronizationSituationDescription().add(desc); OperationResult result = new OperationResult("sync desc test"); String oid = repositoryService.addObject(shadowType.asPrismObject(), null, result); shadow = repositoryService.getObject(ShadowType.class, oid, null, result); shadowType = shadow.asObjectable(); desc = shadowType.getSynchronizationSituationDescription().get(0); AssertJUnit.assertEquals("Times don't match", TIME, XMLGregorianCalendarType.asDate(desc.getTimestamp())); }
@Test public void test040AddAccount() throws Exception { final String TEST_NAME = "test040AddAccount"; TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition defaultAccountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); ShadowType shadowType = new ShadowType(); PrismTestUtil.getPrismContext().adopt(shadowType); shadowType.setName(PrismTestUtil.createPolyStringType(ACCOUNT_JACK_USERNAME)); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resource.getOid()); shadowType.setResourceRef(resourceRef); shadowType.setObjectClass(defaultAccountDefinition.getTypeName()); PrismObject<ShadowType> shadow = shadowType.asPrismObject(); ResourceAttributeContainer attributesContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, defaultAccountDefinition); ResourceAttribute<String> icfsNameProp = attributesContainer.findOrCreateAttribute(SchemaConstants.ICFS_NAME); icfsNameProp.setRealValue(ACCOUNT_JACK_USERNAME); // WHEN cc.addObject(shadow, null, null, result); // THEN DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_JACK_USERNAME); assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" was not created", dummyAccount); assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" has no username", dummyAccount.getName()); }
@Test public void test100AddAccount() throws Exception { final String TEST_NAME = "test100AddAccount"; TestUtil.displayTestTitle(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); ObjectClassComplexTypeDefinition defaultAccountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); ShadowType shadowType = new ShadowType(); PrismTestUtil.getPrismContext().adopt(shadowType); shadowType.setName(PrismTestUtil.createPolyStringType(ACCOUNT_JACK_USERNAME)); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resource.getOid()); shadowType.setResourceRef(resourceRef); shadowType.setObjectClass(defaultAccountDefinition.getTypeName()); PrismObject<ShadowType> shadow = shadowType.asPrismObject(); ResourceAttributeContainer attributesContainer = ShadowUtil.getOrCreateAttributesContainer(shadow, defaultAccountDefinition); ResourceAttribute<String> icfsNameProp = attributesContainer.findOrCreateAttribute(SchemaConstants.ICFS_NAME); icfsNameProp.setRealValue(ACCOUNT_JACK_USERNAME); // WHEN cc.addObject(shadow, null, null, result); // THEN DummyAccount dummyAccount = dummyResource.getAccountByUsername(ACCOUNT_JACK_USERNAME); assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" was not created", dummyAccount); assertNotNull("Account "+ACCOUNT_JACK_USERNAME+" has no username", dummyAccount.getName()); }
private String testIterationToken(String token) throws Exception { PrismObjectDefinition accDef = prismContext.getSchemaRegistry() .findObjectDefinitionByCompileTimeClass(ShadowType.class); PrismObject<ShadowType> shadow = accDef.instantiate(); ShadowType shadowType = shadow.asObjectable(); shadowType.setName(new PolyStringType("testIterationToken")); shadowType.setIterationToken(token); OperationResult result = new OperationResult("sync desc test"); final String oid = repositoryService.addObject(shadowType.asPrismObject(), null, result); shadow = repositoryService.getObject(ShadowType.class, oid, null, result); shadowType = shadow.asObjectable(); token = shadowType.getIterationToken(); repositoryService.deleteObject(ShadowType.class, oid, result); return token; }
resultShadowType = resultShadow.asObjectable(); resultShadowType.setExists(true); resultShadowType.setName(shadowType.getName()); List<PendingOperationType> newPendingOperations = resultShadowType.getPendingOperation(); for (PendingOperationType pendingOperation2: shadowType.getPendingOperation()) {
private PrismObject<ShadowType> createAccountShadow(String username) throws SchemaException { ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); ObjectClassComplexTypeDefinition defaultAccountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); ShadowType shadowType = new ShadowType(); PrismTestUtil.getPrismContext().adopt(shadowType); shadowType.setName(PrismTestUtil.createPolyStringType(username)); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resource.getOid()); shadowType.setResourceRef(resourceRef); shadowType.setObjectClass(defaultAccountDefinition.getTypeName()); PrismObject<ShadowType> shadow = shadowType.asPrismObject(); PrismContainer<Containerable> attrsCont = shadow.findOrCreateContainer(ShadowType.F_ATTRIBUTES); PrismProperty<String> icfsNameProp = attrsCont.findOrCreateProperty(SchemaConstants.ICFS_NAME); icfsNameProp.setRealValue(username); return shadow; }
accountType.setName(PrismTestUtil.createPolyStringType(ACCOUNT_NAME)); ObjectReferenceType resourceRefType = new ObjectReferenceType(); resourceRefType.setOid(FAUX_RESOURCE_OID);
resultShadowType.setName(new PolyStringType(ShadowUtil.determineShadowName(resourceShadow))); if (resultShadowType.getObjectClass() == null) { resultShadowType.setObjectClass(resourceAttributesContainer.getDefinition().getTypeName());
repoShadowType.setName(new PolyStringType(ShadowUtil.determineShadowName(shadow)));