Class TestHelpers


  • public final class TestHelpers
    extends Object
    Bag of utility methods useful to connector tests.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.identityconnectors.framework.common.objects.ConnectorMessages createDummyMessages()
      Creates an dummy message catalog ideal for unit testing.
      static org.identityconnectors.framework.api.APIConfiguration createTestConfiguration​(Class<? extends org.identityconnectors.framework.spi.Connector> clazz, org.identityconnectors.framework.spi.Configuration config)
      Method for convenient testing of local connectors.
      static org.identityconnectors.framework.api.APIConfiguration createTestConfiguration​(Class<? extends org.identityconnectors.framework.spi.Connector> clazz, PropertyBag configData, String prefix)
      Method for convenient testing of local connectors.
      static void fillConfiguration​(org.identityconnectors.framework.spi.Configuration config, Map<String,​? extends Object> configData)
      Fills a configuration bean with data from the given map.
      static PropertyBag getProperties​(Class<?> clazz)
      Loads Property bag for the specified class.
      static PropertyBag getProperties​(Class<?> clazz, String environment)
      Loads Property bag for the specified class.
      static void search​(org.identityconnectors.framework.spi.operations.SearchOp<?> search, org.identityconnectors.framework.common.objects.ObjectClass objectClass, org.identityconnectors.framework.common.objects.filter.Filter filter, org.identityconnectors.framework.common.objects.ResultsHandler handler, org.identityconnectors.framework.common.objects.OperationOptions options)
      Performs a raw, unfiltered search at the SPI level, eliminating duplicates from the result set.
      static List<org.identityconnectors.framework.common.objects.ConnectorObject> searchToList​(org.identityconnectors.framework.api.operations.SearchApiOp search, org.identityconnectors.framework.common.objects.ObjectClass objectClass, org.identityconnectors.framework.common.objects.filter.Filter filter)  
      static List<org.identityconnectors.framework.common.objects.ConnectorObject> searchToList​(org.identityconnectors.framework.api.operations.SearchApiOp search, org.identityconnectors.framework.common.objects.ObjectClass objectClass, org.identityconnectors.framework.common.objects.filter.Filter filter, org.identityconnectors.framework.common.objects.OperationOptions options)  
      static List<org.identityconnectors.framework.common.objects.ConnectorObject> searchToList​(org.identityconnectors.framework.spi.operations.SearchOp<?> search, org.identityconnectors.framework.common.objects.ObjectClass objectClass, org.identityconnectors.framework.common.objects.filter.Filter filter)
      Performs a raw, unfiltered search at the SPI level, eliminating duplicates from the result set.
      static List<org.identityconnectors.framework.common.objects.ConnectorObject> searchToList​(org.identityconnectors.framework.spi.operations.SearchOp<?> search, org.identityconnectors.framework.common.objects.ObjectClass objectClass, org.identityconnectors.framework.common.objects.filter.Filter filter, org.identityconnectors.framework.common.objects.OperationOptions options)
      Performs a raw, unfiltered search at the SPI level, eliminating duplicates from the result set.
    • Method Detail

      • createTestConfiguration

        public static org.identityconnectors.framework.api.APIConfiguration createTestConfiguration​(Class<? extends org.identityconnectors.framework.spi.Connector> clazz,
                                                                                                    org.identityconnectors.framework.spi.Configuration config)
        Method for convenient testing of local connectors.
      • createTestConfiguration

        public static org.identityconnectors.framework.api.APIConfiguration createTestConfiguration​(Class<? extends org.identityconnectors.framework.spi.Connector> clazz,
                                                                                                    PropertyBag configData,
                                                                                                    String prefix)
        Method for convenient testing of local connectors.
      • fillConfiguration

        public static void fillConfiguration​(org.identityconnectors.framework.spi.Configuration config,
                                             Map<String,​? extends Object> configData)
        Fills a configuration bean with data from the given map. The map keys are configuration property names and the values are configuration property values.
        Parameters:
        config - the configuration bean.
        configData - the map with configuration data.
      • createDummyMessages

        public static org.identityconnectors.framework.common.objects.ConnectorMessages createDummyMessages()
        Creates an dummy message catalog ideal for unit testing. All messages are formatted as follows:

        message-key: arg0.toString(), ..., argn.toString

        Returns:
        A dummy message catalog.
      • searchToList

        public static List<org.identityconnectors.framework.common.objects.ConnectorObject> searchToList​(org.identityconnectors.framework.api.operations.SearchApiOp search,
                                                                                                         org.identityconnectors.framework.common.objects.ObjectClass objectClass,
                                                                                                         org.identityconnectors.framework.common.objects.filter.Filter filter)
      • searchToList

        public static List<org.identityconnectors.framework.common.objects.ConnectorObject> searchToList​(org.identityconnectors.framework.api.operations.SearchApiOp search,
                                                                                                         org.identityconnectors.framework.common.objects.ObjectClass objectClass,
                                                                                                         org.identityconnectors.framework.common.objects.filter.Filter filter,
                                                                                                         org.identityconnectors.framework.common.objects.OperationOptions options)
      • searchToList

        public static List<org.identityconnectors.framework.common.objects.ConnectorObject> searchToList​(org.identityconnectors.framework.spi.operations.SearchOp<?> search,
                                                                                                         org.identityconnectors.framework.common.objects.ObjectClass objectClass,
                                                                                                         org.identityconnectors.framework.common.objects.filter.Filter filter)
        Performs a raw, unfiltered search at the SPI level, eliminating duplicates from the result set.
        Parameters:
        search - The search SPI
        objectClass - The object class - passed through to connector so it may be null if the connecor allowing it to be null. (This is convenient for unit tests, but will not be the case in general)
        filter - The filter to search on
        Returns:
        The list of results.
      • searchToList

        public static List<org.identityconnectors.framework.common.objects.ConnectorObject> searchToList​(org.identityconnectors.framework.spi.operations.SearchOp<?> search,
                                                                                                         org.identityconnectors.framework.common.objects.ObjectClass objectClass,
                                                                                                         org.identityconnectors.framework.common.objects.filter.Filter filter,
                                                                                                         org.identityconnectors.framework.common.objects.OperationOptions options)
        Performs a raw, unfiltered search at the SPI level, eliminating duplicates from the result set.
        Parameters:
        search - The search SPI
        objectClass - The object class - passed through to connector so it may be null if the connecor allowing it to be null. (This is convenient for unit tests, but will not be the case in general)
        filter - The filter to search on
        options - The options - may be null - will be cast to an empty OperationOptions
        Returns:
        The list of results.
      • search

        public static void search​(org.identityconnectors.framework.spi.operations.SearchOp<?> search,
                                  org.identityconnectors.framework.common.objects.ObjectClass objectClass,
                                  org.identityconnectors.framework.common.objects.filter.Filter filter,
                                  org.identityconnectors.framework.common.objects.ResultsHandler handler,
                                  org.identityconnectors.framework.common.objects.OperationOptions options)
        Performs a raw, unfiltered search at the SPI level, eliminating duplicates from the result set.
        Parameters:
        search - The search SPI
        objectClass - The object class - passed through to connector so it may be null if the connecor allowing it to be null. (This is convenient for unit tests, but will not be the case in general)
        filter - The filter to search on
        handler - The result handler
        options - The options - may be null - will be cast to an emptyOperationOptions
      • getProperties

        public static PropertyBag getProperties​(Class<?> clazz)
        Loads Property bag for the specified class. The properties are loaded as classpath resources using the class argument as root prefix. Optional system property 'testConfig' is used to specify another configuration path for properties. The following algorithm is used to load the properties in bag
        • loader.getResource(prefix + "/config/config.groovy")
        • loader.getResource(prefix + "/config/" + cfg + "/config.groovy") optionally where cfg is passed configuration
        • loader.getResource(prefix + "/config-private/config.groovy")
        • loader.getResource(prefix + "/config-private/" + cfg + "/config.groovy") optionally where cfg is passed configuration
        Context classloader is used to load the resources.
        Parameters:
        clazz - Class which FQN is used as root prefix for loading of properties
        Returns:
        Bag of properties for specified class and optionally passed configuration
        Throws:
        IllegalStateException - if context classloader is null
      • getProperties

        public static PropertyBag getProperties​(Class<?> clazz,
                                                String environment)
        Loads Property bag for the specified class. The properties are loaded as classpath resources using the class argument as root prefix. Optional system property 'testConfig' is used to specify another configuration path for properties. The following algorithm is used to load the properties in bag
        • loader.getResource(prefix + "/config/config.groovy")
        • loader.getResource(prefix + "/config/" + cfg + "/config.groovy") optionally where cfg is passed configuration
        • loader.getResource(prefix + "/config-private/config.groovy")
        • loader.getResource(prefix + "/config-private/" + cfg + "/config.groovy") optionally where cfg is passed configuration
        Context classloader is used to load the resources.
        Parameters:
        clazz - Class which FQN is used as root prefix for loading of properties
        environment - Environment name (Optional)
        Returns:
        Bag of properties for specified class and optionally passed configuration
        Throws:
        IllegalStateException - if context classloader is null