Class ConnectorHelper
- java.lang.Object
-
- org.identityconnectors.contract.test.ConnectorHelper
-
public class ConnectorHelper extends Object
Class holding various helper methods used by contract test suite- Author:
- Dan Vernon, Tomas Knappek, Zdenek Louzensky
-
-
Constructor Summary
Constructors Constructor Description ConnectorHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
checkObject(ObjectClassInfo objectClassInfo, ConnectorObject connectorObj, Set<Attribute> requestedAttributes)
Checks if object has expected attributes and values.static boolean
checkObject(ObjectClassInfo objectClassInfo, ConnectorObject connectorObj, Set<Attribute> requestedAttributes, boolean checkNotReturnedByDefault)
Checks if object has expected attributes and values.static boolean
checkObjectByAttrDelta(ObjectClassInfo objectClassInfo, ConnectorObject connectorObj, Set<AttributeDelta> requestedAttributesDelta)
Checks if object has expected attributesDelta and values.static boolean
checkObjectByAttrDelta(ObjectClassInfo objectClassInfo, ConnectorObject connectorObj, Set<AttributeDelta> requestedAttributesDelta, boolean checkNotReturnedByDefault)
Checks if object has expected attributesDelta and values.static void
checkSyncDelta(ObjectClassInfo ocInfo, SyncDelta delta, Uid uid, Set<Attribute> attributes, SyncDeltaType deltaType, boolean checkNotReturnedByDefault)
Check that passed SyncDelta has exptected values.static ConnectorFacade
createConnectorFacade(DataProvider dataProvider)
Creates connector facade, initializes connector configuration from dataProvider and validates configuration and/or tests connection.static ConnectorFacade
createConnectorFacadeWithWrongConfiguration(DataProvider dataProvider, Map<?,?> wrongPropertyMap)
Creates connector facade with wrong configuration.static DataProvider
createDataProvider()
static Uid
createObject(ConnectorFacade connectorFacade, DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, int sequenceNumber, OperationOptions opOptions)
gets the attributes for youstatic Uid
createObject(ConnectorFacade connectorFacade, DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, String qualifier, int sequenceNumber, OperationOptions opOptions)
gets the attributes for you, appending the qualifier to the attribute namestatic boolean
deleteObject(ConnectorFacade connectorFacade, ObjectClass objClass, Uid uid, boolean failOnError, OperationOptions opOptions)
Performs deletion of object specified by uid.static Object
get(DataProvider dataProvider, String componentName, Class<?> dataTypeName, String name, String objectClassName, int sequenceNumber, boolean isMultivalue)
static Object
get(DataProvider dataProvider, String componentName, Class<?> dataTypeName, String name, String qualifier, String objectClassName, int sequenceNumber, boolean isMultivalue)
static Set<Attribute>
getAttributes(DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, String qualifier, int sequenceNumber, boolean checkRequired, boolean onlyMultiValue, boolean onlyCreateable, boolean onlyUpdateable)
get attribute values (concatenates the qualifier with the name)static Set<AttributeDelta>
getAttributesDelta(DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, String qualifier, int sequenceNumber, boolean checkRequired, boolean isMultiValue, boolean isAddValues, boolean onlyCreateable, boolean onlyUpdateable)
Get attributeDelta values (concatenates the qualifier with the name).static ConfigurationProperties
getConfigurationProperties(DataProvider dataProvider)
GetsConfigurationProperties
for the connectorstatic Set<Attribute>
getCreateableAttributes(DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, int sequenceNumber, boolean checkRequired, boolean onlyMultiValue)
Get createable attributes' values.static APIConfiguration
getDefaultConfigurationProperties(DataProvider dataProvider, ConnectorInfoManager manager)
static ConnectorInfoManager
getInfoManager(DataProvider dataProvider)
Tries to create remote or local manager.static ObjectClass
getObjectClassFromObjectClassInfo(ObjectClassInfo objectClassInfo)
Returns object class based on object class info.static Set<String>
getReadableAttributesNames(ObjectClassInfo ocInfo)
Returns set of attributes' names which are readable.static String
getString(DataProvider dataProvider, String componentName, String name, String objectClassName)
no sequence number or qualifier, appends objectclass to namestatic Set<Attribute>
getUpdateableAttributes(DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, String qualifier, int sequenceNumber, boolean checkRequired, boolean onlyMultiValue)
Get updateable attributes' values.static Set<AttributeDelta>
getUpdateableAttributesDelta(DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, String qualifier, int sequenceNumber, boolean checkRequired, boolean isMultiValue, boolean isAddOrRemoveValues)
Get updateable attributes' values.static boolean
isAttrSupported(ObjectClassInfo oinfo, String attribute)
Whether is attribute supported.static boolean
isCreateable(ObjectClassInfo objectClassInfo, Attribute attribute)
Whether is attribute Createable.static boolean
isCRU(ObjectClassInfo oinfo, String attribute)
Whether is attribute creatable, updateable and readable.static boolean
isMultiValue(ObjectClassInfo objectClassInfo, String attribute)
Whether is attribute multiValue.static boolean
isReadable(ObjectClassInfo oinfo, String attribute)
Whether is attribute readable.static boolean
isReadable(ObjectClassInfo objectClassInfo, Attribute attribute)
Whether is attribute readable.static boolean
isRequired(ObjectClassInfo objectClassInfo, Attribute attribute)
Whether is attribute required.static boolean
isReturnedByDefault(ObjectClassInfo objectClassInfo, Attribute attribute)
Whether is attribute returnedByDefault.static boolean
isUpdateable(ObjectClassInfo objectClassInfo, Attribute attribute)
Whether is attribute readable.static boolean
operationsSupported(ConnectorFacade connectorFacade, Set<Class<? extends APIOperation>> operations)
check to see if ANY objectclass supports a particular operationsstatic boolean
operationsSupported(ConnectorFacade connectorFacade, ObjectClass oClass, Set<Class<? extends APIOperation>> operations)
check to see if a particular objectclass supports a particular operations To succeed all the operations must be supported.static boolean
operationSupported(ConnectorFacade connectorFacade, Class<? extends APIOperation> operation)
check to see if ANY objectclass supports a particular operationstatic boolean
operationSupported(ConnectorFacade connectorFacade, Class<? extends APIOperation> operations1, Class<? extends APIOperation> operations2)
check to see if ANY objectclass supports a particular operationstatic boolean
operationSupported(ConnectorFacade connectorFacade, ObjectClass oClass, Class<? extends APIOperation> operation)
check to see if a particular objectclass supports a particular operationstatic boolean
operationSupported(ConnectorFacade connectorFacade, ObjectClass oClass, Class<? extends APIOperation> operation1, Class<? extends APIOperation> operation2)
check to see if a particular objectclass supports a particular operationsstatic List<ConnectorObject>
search(ConnectorFacade connectorFacade, ObjectClass objClass, Filter filter, OperationOptions opOptions)
Performs search on connector facade with specified object class, filter and operation options.static Map<Uid,ConnectorObject>
search2Map(ConnectorFacade connectorFacade, ObjectClass objClass, Filter filter, OperationOptions opOptions)
Performs search on connector facade with specified object class, filter and operation options.static List<SyncDelta>
sync(ConnectorFacade connectorFacade, ObjectClass objClass, SyncToken token, OperationOptions opOptions)
Performs sync on connector facade.
-
-
-
Method Detail
-
createDataProvider
public static DataProvider createDataProvider()
-
getConfigurationProperties
public static ConfigurationProperties getConfigurationProperties(DataProvider dataProvider)
GetsConfigurationProperties
for the connector- Parameters:
dataProvider
-- Returns:
-
createConnectorFacadeWithWrongConfiguration
public static ConnectorFacade createConnectorFacadeWithWrongConfiguration(DataProvider dataProvider, Map<?,?> wrongPropertyMap)
Creates connector facade with wrong configuration.- Parameters:
wrongPropertyMap
- wrong configuration
-
createConnectorFacade
public static ConnectorFacade createConnectorFacade(DataProvider dataProvider)
Creates connector facade, initializes connector configuration from dataProvider and validates configuration and/or tests connection.
-
search
public static List<ConnectorObject> search(ConnectorFacade connectorFacade, ObjectClass objClass, Filter filter, OperationOptions opOptions)
Performs search on connector facade with specified object class, filter and operation options.- Returns:
- list of found objects.
-
search2Map
public static Map<Uid,ConnectorObject> search2Map(ConnectorFacade connectorFacade, ObjectClass objClass, Filter filter, OperationOptions opOptions)
Performs search on connector facade with specified object class, filter and operation options.- Returns:
- Map of
Uid
s toConnectorObject
s that were found.
-
sync
public static List<SyncDelta> sync(ConnectorFacade connectorFacade, ObjectClass objClass, SyncToken token, OperationOptions opOptions)
Performs sync on connector facade.
-
deleteObject
public static boolean deleteObject(ConnectorFacade connectorFacade, ObjectClass objClass, Uid uid, boolean failOnError, OperationOptions opOptions)
Performs deletion of object specified by uid. Fails in case failOnError is true and object wasn't deleted during delete call.
-
checkObject
public static boolean checkObject(ObjectClassInfo objectClassInfo, ConnectorObject connectorObj, Set<Attribute> requestedAttributes)
Checks if object has expected attributes and values. All readable or non-special attributes are checked.
-
checkObject
public static boolean checkObject(ObjectClassInfo objectClassInfo, ConnectorObject connectorObj, Set<Attribute> requestedAttributes, boolean checkNotReturnedByDefault)
Checks if object has expected attributes and values. All readable or non-special attributes are checked.- Parameters:
checkNotReturnedByDefault
- if true then also attributes not returned by default are checked
-
checkObjectByAttrDelta
public static boolean checkObjectByAttrDelta(ObjectClassInfo objectClassInfo, ConnectorObject connectorObj, Set<AttributeDelta> requestedAttributesDelta)
Checks if object has expected attributesDelta and values. All readable or non-special attributesDelta are checked.
-
checkObjectByAttrDelta
public static boolean checkObjectByAttrDelta(ObjectClassInfo objectClassInfo, ConnectorObject connectorObj, Set<AttributeDelta> requestedAttributesDelta, boolean checkNotReturnedByDefault)
Checks if object has expected attributesDelta and values. All readable or non-special attributes are checked.- Parameters:
checkNotReturnedByDefault
- if true then also attributes not returned by default are checked
-
checkSyncDelta
public static void checkSyncDelta(ObjectClassInfo ocInfo, SyncDelta delta, Uid uid, Set<Attribute> attributes, SyncDeltaType deltaType, boolean checkNotReturnedByDefault)
Check that passed SyncDelta has exptected values.
-
isReadable
public static boolean isReadable(ObjectClassInfo objectClassInfo, Attribute attribute)
Whether is attribute readable.
-
isRequired
public static boolean isRequired(ObjectClassInfo objectClassInfo, Attribute attribute)
Whether is attribute required.
-
isCreateable
public static boolean isCreateable(ObjectClassInfo objectClassInfo, Attribute attribute)
Whether is attribute Createable.
-
isUpdateable
public static boolean isUpdateable(ObjectClassInfo objectClassInfo, Attribute attribute)
Whether is attribute readable.
-
isReturnedByDefault
public static boolean isReturnedByDefault(ObjectClassInfo objectClassInfo, Attribute attribute)
Whether is attribute returnedByDefault.
-
isMultiValue
public static boolean isMultiValue(ObjectClassInfo objectClassInfo, String attribute)
Whether is attribute multiValue.
-
isCRU
public static boolean isCRU(ObjectClassInfo oinfo, String attribute)
Whether is attribute creatable, updateable and readable.
-
isReadable
public static boolean isReadable(ObjectClassInfo oinfo, String attribute)
Whether is attribute readable.
-
isAttrSupported
public static boolean isAttrSupported(ObjectClassInfo oinfo, String attribute)
Whether is attribute supported.
-
getUpdateableAttributes
public static Set<Attribute> getUpdateableAttributes(DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, String qualifier, int sequenceNumber, boolean checkRequired, boolean onlyMultiValue)
Get updateable attributes' values. Generate new values for updateable attributes based on contract test properties prefixed byqualifier
- Parameters:
qualifier
- the prefix for values used in update.
-
getUpdateableAttributesDelta
public static Set<AttributeDelta> getUpdateableAttributesDelta(DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, String qualifier, int sequenceNumber, boolean checkRequired, boolean isMultiValue, boolean isAddOrRemoveValues)
Get updateable attributes' values. Generate new values for updateable attributes based on contract test properties prefixed byqualifier
- Parameters:
qualifier
- the prefix for values used in update.
-
getCreateableAttributes
public static Set<Attribute> getCreateableAttributes(DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, int sequenceNumber, boolean checkRequired, boolean onlyMultiValue)
Get createable attributes' values.
-
getReadableAttributesNames
public static Set<String> getReadableAttributesNames(ObjectClassInfo ocInfo)
Returns set of attributes' names which are readable.
-
getAttributes
public static Set<Attribute> getAttributes(DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, String qualifier, int sequenceNumber, boolean checkRequired, boolean onlyMultiValue, boolean onlyCreateable, boolean onlyUpdateable) throws ObjectNotFoundException
get attribute values (concatenates the qualifier with the name)- Parameters:
dataProvider
-objectClassInfo
-testName
-qualifier
-sequenceNumber
-checkRequired
-- Returns:
- Throws:
ObjectNotFoundException
-
getAttributesDelta
public static Set<AttributeDelta> getAttributesDelta(DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, String qualifier, int sequenceNumber, boolean checkRequired, boolean isMultiValue, boolean isAddValues, boolean onlyCreateable, boolean onlyUpdateable) throws ObjectNotFoundException
Get attributeDelta values (concatenates the qualifier with the name).- Parameters:
dataProvider
-objectClassInfo
-testName
-qualifier
-sequenceNumber
-checkRequired
-- Returns:
- Throws:
ObjectNotFoundException
-
createObject
public static Uid createObject(ConnectorFacade connectorFacade, DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, String qualifier, int sequenceNumber, OperationOptions opOptions) throws ObjectNotFoundException
gets the attributes for you, appending the qualifier to the attribute name- Parameters:
connectorFacade
-dataProvider
-objectClassInfo
-testName
-qualifier
-sequenceNumber
-- Returns:
- Throws:
ObjectNotFoundException
-
createObject
public static Uid createObject(ConnectorFacade connectorFacade, DataProvider dataProvider, ObjectClassInfo objectClassInfo, String testName, int sequenceNumber, OperationOptions opOptions) throws ObjectNotFoundException
gets the attributes for you- Parameters:
connectorFacade
-dataProvider
-objectClassInfo
-testName
-sequenceNumber
-- Returns:
- Throws:
ObjectNotFoundException
-
operationSupported
public static boolean operationSupported(ConnectorFacade connectorFacade, ObjectClass oClass, Class<? extends APIOperation> operation)
check to see if a particular objectclass supports a particular operation- Parameters:
connectorFacade
-oClass
-operation
-- Returns:
-
operationSupported
public static boolean operationSupported(ConnectorFacade connectorFacade, ObjectClass oClass, Class<? extends APIOperation> operation1, Class<? extends APIOperation> operation2)
check to see if a particular objectclass supports a particular operations- Parameters:
connectorFacade
-oClass
-operation1
-operation2
-- Returns:
-
operationsSupported
public static boolean operationsSupported(ConnectorFacade connectorFacade, ObjectClass oClass, Set<Class<? extends APIOperation>> operations)
check to see if a particular objectclass supports a particular operations To succeed all the operations must be supported.- Parameters:
connectorFacade
-oClass
-operations
-- Returns:
-
operationSupported
public static boolean operationSupported(ConnectorFacade connectorFacade, Class<? extends APIOperation> operation)
check to see if ANY objectclass supports a particular operation- Parameters:
connectorFacade
-operation
-- Returns:
-
operationSupported
public static boolean operationSupported(ConnectorFacade connectorFacade, Class<? extends APIOperation> operations1, Class<? extends APIOperation> operations2)
check to see if ANY objectclass supports a particular operation- Parameters:
connectorFacade
-operations1
-operations2
-- Returns:
-
operationsSupported
public static boolean operationsSupported(ConnectorFacade connectorFacade, Set<Class<? extends APIOperation>> operations)
check to see if ANY objectclass supports a particular operations- Parameters:
connectorFacade
-operations
-- Returns:
-
getInfoManager
public static ConnectorInfoManager getInfoManager(DataProvider dataProvider)
Tries to create remote or local manager. Remote manager is created in case all connectorserver properties are set. If connectorserver properties are missing or remote manager creation fails then tries to create local manager.
-
getDefaultConfigurationProperties
public static APIConfiguration getDefaultConfigurationProperties(DataProvider dataProvider, ConnectorInfoManager manager) throws ObjectNotFoundException
- Throws:
ObjectNotFoundException
-
getString
public static String getString(DataProvider dataProvider, String componentName, String name, String objectClassName) throws ObjectNotFoundException
no sequence number or qualifier, appends objectclass to name- Parameters:
dataProvider
-componentName
-name
-objectClassName
-- Returns:
- Throws:
ObjectNotFoundException
-
get
public static Object get(DataProvider dataProvider, String componentName, Class<?> dataTypeName, String name, String objectClassName, int sequenceNumber, boolean isMultivalue) throws ObjectNotFoundException
- Throws:
ObjectNotFoundException
-
get
public static Object get(DataProvider dataProvider, String componentName, Class<?> dataTypeName, String name, String qualifier, String objectClassName, int sequenceNumber, boolean isMultivalue) throws ObjectNotFoundException
- Throws:
ObjectNotFoundException
-
getObjectClassFromObjectClassInfo
public static ObjectClass getObjectClassFromObjectClassInfo(ObjectClassInfo objectClassInfo)
Returns object class based on object class info.
-
-