use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ResourceTest method saveWithGroupMappingType.
@Test
public void saveWithGroupMappingType() {
ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
resource.setKey("ws-target-resource-basic-save-invalid");
ConnInstance connector = resourceDAO.find("ws-target-resource-1").getConnector();
resource.setConnector(connector);
Provision provision = entityFactory.newEntity(Provision.class);
provision.setAnyType(anyTypeDAO.findUser());
provision.setObjectClass(ObjectClass.ACCOUNT);
provision.setResource(resource);
resource.add(provision);
Mapping mapping = entityFactory.newEntity(Mapping.class);
mapping.setProvision(provision);
provision.setMapping(mapping);
MappingItem item = entityFactory.newEntity(MappingItem.class);
item.setIntAttrName("fullname");
item.setExtAttrName("fullname");
item.setPurpose(MappingPurpose.BOTH);
mapping.setConnObjectKeyItem(item);
item = entityFactory.newEntity(MappingItem.class);
item.setIntAttrName("icon");
item.setExtAttrName("icon");
item.setPurpose(MappingPurpose.BOTH);
mapping.add(item);
item = entityFactory.newEntity(MappingItem.class);
item.setIntAttrName("mderiveddata");
item.setExtAttrName("mderiveddata");
item.setPurpose(MappingPurpose.PROPAGATION);
mapping.add(item);
// save the resource
ExternalResource actual = resourceDAO.save(resource);
assertNotNull(actual);
assertEquals(3, actual.getProvision(anyTypeDAO.findUser()).get().getMapping().getItems().size());
}
use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ResourceTest method saveVirtualMapping.
@Test
public void saveVirtualMapping() {
ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
resource.setKey("ws-target-resource-virtual-mapping");
resource.setPropagationPriority(2);
Provision provision = entityFactory.newEntity(Provision.class);
provision.setAnyType(anyTypeDAO.findUser());
provision.setObjectClass(ObjectClass.ACCOUNT);
provision.setResource(resource);
resource.add(provision);
Mapping mapping = entityFactory.newEntity(Mapping.class);
mapping.setProvision(provision);
provision.setMapping(mapping);
MappingItem connObjectKey = entityFactory.newEntity(MappingItem.class);
connObjectKey.setExtAttrName("username");
connObjectKey.setIntAttrName("fullname");
connObjectKey.setPurpose(MappingPurpose.BOTH);
mapping.setConnObjectKeyItem(connObjectKey);
MappingItem virtualMapItem = entityFactory.newEntity(MappingItem.class);
virtualMapItem.setIntAttrName("virtualReadOnly");
virtualMapItem.setExtAttrName("TEST");
virtualMapItem.setPurpose(MappingPurpose.PROPAGATION);
virtualMapItem.setMapping(mapping);
mapping.add(virtualMapItem);
ConnInstance connector = resourceDAO.find("ws-target-resource-1").getConnector();
resource.setConnector(connector);
resourceDAO.save(resource);
}
use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ResourceTest method saveInvalidMappingExtAttr.
@Test
public void saveInvalidMappingExtAttr() {
assertThrows(InvalidEntityException.class, () -> {
ExternalResource resource = entityFactory.newEntity(ExternalResource.class);
resource.setKey("ws-target-resource-basic-save-invalid");
ConnInstance connector = resourceDAO.find("ws-target-resource-1").getConnector();
resource.setConnector(connector);
Provision provision = entityFactory.newEntity(Provision.class);
provision.setAnyType(anyTypeDAO.findUser());
provision.setObjectClass(ObjectClass.ACCOUNT);
provision.setResource(resource);
resource.add(provision);
Mapping mapping = entityFactory.newEntity(Mapping.class);
mapping.setProvision(provision);
provision.setMapping(mapping);
MappingItem item = entityFactory.newEntity(MappingItem.class);
item.setConnObjectKey(true);
item.setIntAttrName("fullname");
mapping.add(item);
item = entityFactory.newEntity(MappingItem.class);
item.setIntAttrName("userId");
mapping.add(item);
resourceDAO.save(resource);
});
}
use of org.apache.syncope.core.persistence.api.entity.ConnInstance in project syncope by apache.
the class ConnInstanceTest method delete.
@Test
public void delete() {
ConnInstance connectorInstance = connInstanceDAO.find("88a7a819-dab5-46b4-9b90-0b9769eabdb8");
assertNotNull(connectorInstance);
connInstanceDAO.delete(connectorInstance.getKey());
ConnInstance actual = connInstanceDAO.find("88a7a819-dab5-46b4-9b90-0b9769eabdb8");
assertNull(actual);
}
Aggregations