use of org.apache.syncope.common.lib.to.ResourceTO in project syncope by apache.
the class ResourceITCase method updateWithException.
@Test
public void updateWithException() {
try {
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey("resourcenotfound");
resourceService.update(resourceTO);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
}
}
use of org.apache.syncope.common.lib.to.ResourceTO in project syncope by apache.
the class ResourceITCase method issueSYNCOPE645.
public void issueSYNCOPE645() {
ResourceTO resource = new ResourceTO();
resource.setKey("ws-target-resource-basic-save-invalid");
String connector = resourceService.read("ws-target-resource-1").getConnector();
resource.setConnector(connector);
ProvisionTO provision = new ProvisionTO();
provision.setAnyType(AnyTypeKind.USER.name());
provision.setObjectClass("__ACCOUNT__");
resource.getProvisions().add(provision);
MappingTO mapping = new MappingTO();
provision.setMapping(mapping);
ItemTO item = new ItemTO();
item.setIntAttrName("icon");
item.setExtAttrName("icon");
item.setPurpose(MappingPurpose.BOTH);
mapping.setConnObjectKeyItem(item);
// save the resource
try {
resourceService.create(resource);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidMapping, e.getType());
}
}
use of org.apache.syncope.common.lib.to.ResourceTO in project syncope by apache.
the class ResourceITCase method create.
@Test
public void create() {
String resourceKey = "ws-target-resource-create";
ResourceTO resourceTO = buildResourceTO(resourceKey);
Response response = resourceService.create(resourceTO);
resourceTO = getObject(response.getLocation(), ResourceService.class, ResourceTO.class);
assertNotNull(resourceTO);
// check for existence
resourceTO = resourceService.read(resourceKey);
assertNotNull(resourceTO);
}
use of org.apache.syncope.common.lib.to.ResourceTO in project syncope by apache.
the class ResourceITCase method buildResourceTO.
private ResourceTO buildResourceTO(final String resourceKey) {
ResourceTO resourceTO = new ResourceTO();
resourceTO.setKey(resourceKey);
resourceTO.setConnector("5ffbb4ac-a8c3-4b44-b699-11b398a1ba08");
ProvisionTO provisionTO = new ProvisionTO();
provisionTO.setAnyType(AnyTypeKind.USER.name());
provisionTO.setObjectClass(ObjectClass.ACCOUNT_NAME);
resourceTO.getProvisions().add(provisionTO);
MappingTO mapping = new MappingTO();
provisionTO.setMapping(mapping);
ItemTO item = new ItemTO();
item.setExtAttrName("userId");
item.setIntAttrName("userId");
item.setPurpose(MappingPurpose.BOTH);
mapping.add(item);
item = new ItemTO();
item.setExtAttrName("username");
item.setIntAttrName("key");
item.setPurpose(MappingPurpose.BOTH);
mapping.setConnObjectKeyItem(item);
item = new ItemTO();
item.setExtAttrName("fullname");
item.setIntAttrName("cn");
item.setConnObjectKey(false);
item.setPurpose(MappingPurpose.PROPAGATION);
mapping.add(item);
return resourceTO;
}
use of org.apache.syncope.common.lib.to.ResourceTO in project syncope by apache.
the class ResourceITCase method read.
@Test
public void read() {
ResourceTO resource = resourceService.read(RESOURCE_NAME_DBVIRATTR);
assertNotNull(resource);
Optional<ProvisionTO> provision = resource.getProvision(AnyTypeKind.USER.name());
assertTrue(provision.isPresent());
assertFalse(provision.get().getMapping().getItems().isEmpty());
assertFalse(provision.get().getMapping().getLinkingItems().isEmpty());
}
Aggregations