mapping.setResource(resource);
resource.setUmapping(mapping);
// specify mappings
for (int i = 0; i < 3; i++) {
UMappingItem item = new UMappingItem();
item.setExtAttrName("test" + i);
item.setIntAttrName("nonexistent" + i);
item.setIntMappingType(IntMappingType.UserSchema);
item.setMandatoryCondition("false");
item.setPurpose(MappingPurpose.SYNCHRONIZATION);
mapping.addItem(item);
item.setMapping(mapping);
}
UMappingItem accountId = new UMappingItem();
accountId.setExtAttrName("username");
accountId.setIntAttrName("username");
accountId.setIntMappingType(IntMappingType.UserId);
accountId.setPurpose(MappingPurpose.PROPAGATION);
mapping.setAccountIdItem(accountId);
accountId.setMapping(mapping);
// map a derived attribute
UMappingItem derived = new UMappingItem();
derived.setAccountid(false);
derived.setExtAttrName("fullname");
derived.setIntAttrName("cn");
derived.setIntMappingType(IntMappingType.UserDerivedSchema);
derived.setPurpose(MappingPurpose.PROPAGATION);
mapping.addItem(derived);
derived.setMapping(mapping);
// save the resource
ExternalResource actual = resourceDAO.save(resource);
assertNotNull(actual);
assertNotNull(actual.getUmapping());