}
@Test
public void update() {
final String resourceName = "ws-target-resource-update";
ResourceTO resourceTO = new ResourceTO();
resourceTO.setName(resourceName);
resourceTO.setConnectorId(101L);
List<SchemaMappingTO> schemaMappingTOs = new ArrayList<SchemaMappingTO>();
// Update with an existing and already assigned mapping
SchemaMappingTO schemaMappingTO = new SchemaMappingTO();
schemaMappingTO.setId(112L);
schemaMappingTO.setExtAttrName("test3");
schemaMappingTO.setIntAttrName("fullname");
schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
schemaMappingTOs.add(schemaMappingTO);
// Update defining new mappings
for (int i = 4; i < 6; i++) {
schemaMappingTO = new SchemaMappingTO();
schemaMappingTO.setExtAttrName("test" + i);
schemaMappingTO.setIntAttrName("fullname");
schemaMappingTO.setIntMappingType(IntMappingType.UserSchema);
schemaMappingTOs.add(schemaMappingTO);
}
schemaMappingTO = new SchemaMappingTO();
schemaMappingTO.setExtAttrName("username");
schemaMappingTO.setIntAttrName("fullname");
schemaMappingTO.setIntMappingType(IntMappingType.SyncopeUserId);
schemaMappingTO.setAccountid(true);
schemaMappingTOs.add(schemaMappingTO);
resourceTO.setMappings(schemaMappingTOs);
ResourceTO actual = restTemplate.postForObject(BASE_URL + "resource/update.json", resourceTO, ResourceTO.class);
assertNotNull(actual);
// check the existence
List<SchemaMappingTO> mappings = actual.getMappings();
assertNotNull(mappings);
assertEquals(4, mappings.size());
}