@Test public void test100AddDeleteObject() throws Exception { final String TEST_NAME = "test100AddDeleteObject"; TestUtil.displayTestTile(this, TEST_NAME); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); Collection<ResourceAttribute<?>> identifiers = addSampleResourceObject("john", "John", "Smith"); String uid = null; for (ResourceAttribute<?> resourceAttribute : identifiers) { if (ConnectorFactoryIcfImpl.ICFS_UID.equals(resourceAttribute.getElementName())) { uid = resourceAttribute.getValue(String.class).getValue(); System.out.println("uuuuid:" + uid); assertNotNull(uid); } } ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition( ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME); cc.deleteObject(accountDefinition, null, identifiers, result); ResourceObjectIdentification identification = new ResourceObjectIdentification(accountDefinition, identifiers); PrismObject<ShadowType> resObj = null; try { resObj = cc.fetchObject(ShadowType.class, identification, null, result); Assert.fail(); } catch (ObjectNotFoundException ex) { AssertJUnit.assertNull(resObj); } }
private ResourceAttributeContainer createResourceObject(String dn, String sn, String cn) throws SchemaException { // Account type is hardcoded now ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "AccountObjectClass")); // Determine identifier from the schema ResourceAttributeContainer resourceObject = accountDefinition.instantiate(ShadowType.F_ATTRIBUTES); ResourceAttributeDefinition road = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "sn")); ResourceAttribute roa = road.instantiate(); roa.setValue(new PrismPropertyValue(sn)); resourceObject.add(roa); road = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "cn")); roa = road.instantiate(); roa.setValue(new PrismPropertyValue(cn)); resourceObject.add(roa); road = accountDefinition.findAttributeDefinition(ConnectorFactoryIcfImpl.ICFS_NAME); roa = road.instantiate(); roa.setValue(new PrismPropertyValue(dn)); resourceObject.add(roa); return resourceObject; }
@Test public void testAddDeleteObject() throws Exception { TestUtil.displayTestTile(this, "testDeleteObject"); OperationResult result = new OperationResult(this.getClass().getName() + ".testDelete"); Collection<ResourceAttribute<?>> identifiers = addSampleResourceObject("john", "John", "Smith"); String uid = null; for (ResourceAttribute<?> resourceAttribute : identifiers) { if (ConnectorFactoryIcfImpl.ICFS_UID.equals(resourceAttribute.getElementName())) { uid = resourceAttribute.getValue(String.class).getValue(); System.out.println("uuuuid:" + uid); assertNotNull(uid); } } ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT); cc.deleteObject(accountDefinition, null, identifiers, result); PrismObject<ShadowType> resObj = null; try { resObj = cc.fetchObject(ShadowType.class, accountDefinition, identifiers, null, result); Assert.fail(); } catch (ObjectNotFoundException ex) { AssertJUnit.assertNull(resObj); } }
private String getEntryUuid(Collection<ResourceAttribute<?>> identifiers) { for (ResourceAttribute<?> identifier : identifiers) { if (identifier.getElementName().equals(ConnectorFactoryIcfImpl.ICFS_UID)) { return identifier.getValue(String.class).getValue(); } } return null; }
public void setAttributeValue(String attributeName, String attributeValue) { ResourceAttribute a = getAttribute(attributeName); if (a == null) { attributes.put( attributeName, new ResourceAttribute(gridId, resourceId, attributeName, attributeValue)); } else { a.setValue(attributeValue); a.touchUpdatedDateTime(); } }
private PrismProperty createProperty(String propertyName, String propertyValue) { ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "AccountObjectClass")); ResourceAttributeDefinition propertyDef = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), propertyName)); ResourceAttribute property = propertyDef.instantiate(); property.setValue(new PrismPropertyValue(propertyValue)); return property; }
private Collection<ResourceAttribute<?>> addSampleResourceObject( String name, String givenName, String familyName) throws CommunicationException, GenericFrameworkException, SchemaException, ObjectAlreadyExistsException, ConfigurationException { OperationResult result = new OperationResult(this.getClass().getName() + ".testAdd"); QName objectClassQname = new QName( ResourceTypeUtil.getResourceNamespace(resourceType), ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME); ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition(objectClassQname); assertNotNull("No object class definition " + objectClassQname, accountDefinition); ResourceAttributeContainer resourceObject = accountDefinition.instantiate(ShadowType.F_ATTRIBUTES); ResourceAttributeDefinition<String> attributeDefinition = accountDefinition.findAttributeDefinition( new QName( ResourceTypeUtil.getResourceNamespace(resourceType), ProvisioningTestUtil.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME)); ResourceAttribute<String> attribute = attributeDefinition.instantiate(); attribute.setValue( new PrismPropertyValue<String>("uid=" + name + ",ou=people,dc=example,dc=com")); resourceObject.add(attribute); attributeDefinition = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "sn")); attribute = attributeDefinition.instantiate(); attribute.setValue(new PrismPropertyValue(familyName)); resourceObject.add(attribute); attributeDefinition = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "cn")); attribute = attributeDefinition.instantiate(); attribute.setValue(new PrismPropertyValue(givenName + " " + familyName)); resourceObject.add(attribute); attributeDefinition = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "givenName")); attribute = attributeDefinition.instantiate(); attribute.setValue(new PrismPropertyValue(givenName)); resourceObject.add(attribute); PrismObject<ShadowType> shadow = wrapInShadow(ShadowType.class, resourceObject); Set<Operation> operation = new HashSet<Operation>(); Collection<ResourceAttribute<?>> resourceAttributes = cc.addObject(shadow, operation, result); return resourceAttributes; }
private PrismProperty createProperty(String propertyName, String propertyValue) { ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition( new QName( ResourceTypeUtil.getResourceNamespace(resourceType), ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME)); ResourceAttributeDefinition propertyDef = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), propertyName)); ResourceAttribute property = propertyDef.instantiate(); property.setValue(new PrismPropertyValue(propertyValue)); return property; }
private String getEntryUuid(Collection<ResourceAttribute<?>> identifiers) { for (ResourceAttribute<?> identifier : identifiers) { if (identifier .getElementName() .equals( new QName( ResourceTypeUtil.getResourceNamespace(resourceType), ProvisioningTestUtil.RESOURCE_OPENDJ_PRIMARY_IDENTIFIER_LOCAL_NAME))) { return identifier.getValue(String.class).getValue(); } } return null; }
private ResourceAttributeContainer createResourceObject(String dn, String sn, String cn) throws SchemaException { // Account type is hardcoded now ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findObjectClassDefinition( new QName( ResourceTypeUtil.getResourceNamespace(resourceType), ProvisioningTestUtil.OBJECT_CLASS_INETORGPERSON_NAME)); // Determine identifier from the schema ResourceAttributeContainer resourceObject = accountDefinition.instantiate(ShadowType.F_ATTRIBUTES); ResourceAttributeDefinition road = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "sn")); ResourceAttribute roa = road.instantiate(); roa.setValue(new PrismPropertyValue(sn)); resourceObject.add(roa); road = accountDefinition.findAttributeDefinition( new QName(ResourceTypeUtil.getResourceNamespace(resourceType), "cn")); roa = road.instantiate(); roa.setValue(new PrismPropertyValue(cn)); resourceObject.add(roa); road = accountDefinition.findAttributeDefinition( new QName( ResourceTypeUtil.getResourceNamespace(resourceType), ProvisioningTestUtil.RESOURCE_OPENDJ_SECONDARY_IDENTIFIER_LOCAL_NAME)); roa = road.instantiate(); roa.setValue(new PrismPropertyValue(dn)); resourceObject.add(roa); return resourceObject; }
public void setAttributes(Collection<ResourceAttribute> attributes) { this.attributes.clear(); for (ResourceAttribute a : attributes) { this.attributes.put(a.getName(), a); } }
public void setAttribute(ResourceAttribute attribute) { attributes.put(attribute.getName(), attribute); }