String resourceName = RESOURCE_NAME_UPDATE;
ResourceTO resourceTO = new ResourceTO();
resourceTO.setName(resourceName);
resourceTO.setConnectorId(101L);
MappingTO mapping = new MappingTO();
// Update with an existing and already assigned mapping
MappingItemTO item = new MappingItemTO();
item.setId(112L);
item.setExtAttrName("test3");
item.setIntAttrName("fullname");
item.setIntMappingType(IntMappingType.UserSchema);
item.setPurpose(MappingPurpose.BOTH);
mapping.addItem(item);
// Update defining new mappings
for (int i = 4; i < 6; i++) {
item = new MappingItemTO();
item.setExtAttrName("test" + i);
item.setIntAttrName("fullname");
item.setIntMappingType(IntMappingType.UserSchema);
item.setPurpose(MappingPurpose.BOTH);
mapping.addItem(item);
}
item = new MappingItemTO();
item.setExtAttrName("username");
item.setIntAttrName("fullname");
item.setIntMappingType(IntMappingType.UserId);
item.setAccountid(true);
item.setPurpose(MappingPurpose.BOTH);
mapping.setAccountIdItem(item);
resourceTO.setUmapping(mapping);
resourceService.update(resourceTO.getName(), resourceTO);
ResourceTO actual = resourceService.read(resourceTO.getName());