Class ConnectorHelper


  • public class ConnectorHelper
    extends Object
    Class holding various helper methods used by contract test suite
    Author:
    Dan Vernon, Tomas Knappek, Zdenek Louzensky
    • Constructor Detail

      • ConnectorHelper

        public ConnectorHelper()
    • Method Detail

      • createDataProvider

        public static DataProvider createDataProvider()
      • 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.
      • 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
      • 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 by qualifier
        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 by qualifier
        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
      • 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.
      • getObjectClassFromObjectClassInfo

        public static ObjectClass getObjectClassFromObjectClassInfo​(ObjectClassInfo objectClassInfo)
        Returns object class based on object class info.