assertEquals(resourceTOs, Arrays.asList(actual));
}
@Test
public void issue42() {
USchema userId = schemaDAO.find("userId", USchema.class);
Set<AbstractMappingItem> beforeUserIdMappings = new HashSet<AbstractMappingItem>();
for (ExternalResource res : resourceDAO.findAll()) {
if (res.getUmapping() != null) {
for (AbstractMappingItem mapItem : res.getUmapping().getItems()) {
if (userId.getName().equals(mapItem.getIntAttrName())) {
beforeUserIdMappings.add(mapItem);
}
}
}
}
ResourceTO resourceTO = new ResourceTO();
resourceTO.setName("resource-issue42");
resourceTO.setConnectorId(100L);
resourceTO.setPropagationMode(PropagationMode.ONE_PHASE);
resourceTO.setEnforceMandatoryCondition(true);
MappingTO mapping = new MappingTO();
resourceTO.setUmapping(mapping);
MappingItemTO item = new MappingItemTO();
item.setIntAttrName("userId");
item.setIntMappingType(IntMappingType.UserSchema);
item.setExtAttrName("campo1");
item.setAccountid(true);
item.setMandatoryCondition("false");
item.setPurpose(MappingPurpose.BOTH);
mapping.setAccountIdItem(item);
ExternalResource resource = resourceDataBinder.create(resourceTO);
resource = resourceDAO.save(resource);
assertNotNull(resource);
assertNotNull(resource.getUmapping());
assertEquals(1, resource.getUmapping().getItems().size());
resourceDAO.flush();
ExternalResource actual = resourceDAO.find("resource-issue42");
assertNotNull(actual);
assertEquals(resource, actual);
userId = schemaDAO.find("userId", USchema.class);
Set<AbstractMappingItem> afterUserIdMappings = new HashSet<AbstractMappingItem>();
for (ExternalResource res : resourceDAO.findAll()) {
if (res.getUmapping() != null) {
for (AbstractMappingItem mapItem : res.getUmapping().getItems()) {
if (userId.getName().equals(mapItem.getIntAttrName())) {
afterUserIdMappings.add(mapItem);
}
}
}
}