psdi.unittest

Class ActionsUtil

  • java.lang.Object
    • psdi.unittest.ActionsUtil


  • public class ActionsUtil
    extends java.lang.Object
    Utility class for Unit test actions.
    • Constructor Summary

      Constructors 
      Constructor and Description
      ActionsUtil() 
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method and Description
      static void callCron(java.lang.String crontaskName, java.lang.String instanceName, UserInfo userInfo)
      This method would call the cronAction method on the cron task crontaskName instance instanceName.
      static void callWorkflow(java.lang.String wfName, MboRemote mbo)
      Action method to call a Maximo workflow.
      static void commit(MboRemote mbo)
      Commits the MXTransaction for the Mbo mbo.
      static MboRemote commitAndRefetch(MboRemote mbo)
      Commits the MXTransaction for the Mbo mbo and immediately refetches it from the Maximo database.
      static java.lang.String generateRelationName()
      Generates a random temporary relation name
      static boolean getBooleanExpression(MboRemote mbo, java.lang.String expression) 
      static boolean getBooleanProperty(java.lang.String name) 
      static java.util.Date getDateExpression(MboRemote mbo, java.lang.String expression) 
      static java.util.Date getDateProperty(java.lang.String name)
      Return property value for specified property as Date
      static double getDoubleExpression(MboRemote mbo, java.lang.String expression) 
      static java.lang.Double getDoubleProperty(java.lang.String name)
      Return property value for specified property as Double
      static java.lang.Integer getIntegerProperty(java.lang.String name)
      Return property value for specified property as Integer
      static int getIntExpression(MboRemote mbo, java.lang.String expression) 
      static long getLongExpression(MboRemote mbo, java.lang.String expression) 
      static java.lang.Long getLongProperty(java.lang.String name)
      Return proprty value for specified property as Long
      static java.lang.Object getObjectExpression(MboRemote mbo, java.lang.String expression) 
      static java.lang.Object getObjectProperty(java.lang.String propName)
      Deprecated. 
      static java.lang.String getProperty(java.lang.String name) 
      static java.util.List getPropertyAsList(java.lang.String name) 
      static java.util.Date getServerDate()
      Action method to get Maximo server date.
      static java.lang.String getStringExpression(MboRemote mbo, java.lang.String expression) 
      static byte[] getTestDataAsBytes(java.lang.String testdataId)
      This is used the access the test data content as a bytes.
      static org.jdom2.Document getTestDataAsDocument(java.lang.String testdataId)
      This is used the access the test data content as a JDOM document.
      static TestDataSource getTestDataSource()
      Utility method to acccess the TestDataSource object from the unit test context.
      static java.lang.Object getTestVariable(java.lang.String propName) 
      static UserInfo getUserInfo()
      Utility method to acccess the UserInfo object from the unit test context.
      static java.lang.String getXMLValue(java.lang.String xpathExpression, java.util.Map nsPrefixMap, org.jdom2.Document doc) 
      static java.lang.String getXMLValue(java.lang.String xpathExpression, java.util.Map nsPrefixMap, java.lang.String testdataId) 
      static MboRemote load(java.lang.String testdataId)
      loads the Mbo for the testdataId.
      static MboRemote load(java.lang.String mboname, long id) 
      static MboRemote load(java.lang.String testdataId, UserInfo userInfo)
      Loads the Mbo for the testdataId and the UserInfo object passed in parameter would be used for the load.
      static MboSetRemote loadMboSet(java.lang.String mboName)
      loads the MboSet for the given MBONAME
      static MboSetRemote loadMboSet(java.lang.String[] testdataIds)
      loads the Mbo for the testdataId.
      static MboRemote newMbo(java.lang.String mboName)
      Calls .add() on the MboSet returning the Mbo.
      static MboRemote refetch(MboRemote mbo)
      Utility method to refetch mbo from the Maximo database.
      static MboRemote reload(java.lang.String testdataId)
      Reloads the Mbo for the testdataId, meaning it will be fetched from the database again instead of the test data cache.
      static void rollback(MboRemote mbo)
      Rolls back the MXTransaction for the Mbo mbo If a failure happens an assertion error is generated.
      static void setObjectProperty(java.lang.String propName, java.lang.Object value)
      Deprecated. 
      static void setTestVariable(java.lang.String propName, java.lang.Object value) 
      static void updateMaxVar(java.lang.String varName, java.lang.String varValue) 
      static void updateMaxVar(java.lang.String varName, java.lang.String orgId, java.lang.String siteId, java.lang.String varValue) 
      static MaxVarsRemote updateMaxVar(UserInfo userInfo, java.lang.String varName, java.lang.String orgId, java.lang.String siteId, java.lang.String varValue) 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ActionsUtil

        public ActionsUtil()
    • Method Detail

      • load

        public static MboRemote load(java.lang.String mboname,
                                     long id)
                              throws MXException,
                                     java.rmi.RemoteException
        Throws:
        MXException
        java.rmi.RemoteException
      • reload

        public static MboRemote reload(java.lang.String testdataId)
                                throws MXException,
                                       TestSetupException
        Reloads the Mbo for the testdataId, meaning it will be fetched from the database again instead of the test data cache. The context UserInfo would be used for the load.
        Parameters:
        testdataId - the fully qualified test data id.
        Returns:
        the loaded Mbo
        Throws:
        MXException
        TestSetupException
      • load

        public static MboRemote load(java.lang.String testdataId,
                                     UserInfo userInfo)
                              throws MXException,
                                     TestSetupException
        Loads the Mbo for the testdataId and the UserInfo object passed in parameter would be used for the load.
        Parameters:
        testdataId - the fully qualified test data id.
        userInfo - the UserInfo to be used for the load.
        Returns:
        the loaded Mbo
        Throws:
        MXException
        TestSetupException
      • getTestDataAsBytes

        public static byte[] getTestDataAsBytes(java.lang.String testdataId)
                                         throws MXException,
                                                TestSetupException
        This is used the access the test data content as a bytes. This is useful for cases when the test data is used for representing arbitrary xml data which does not necessarily resolve to a Mbo.
        Parameters:
        testdataId - the fully qualified test data id.
        Returns:
        the bytes representing the content of the test data excluding the test data wrapper element.
        Throws:
        MXException
        TestSetupException
      • getXMLValue

        public static java.lang.String getXMLValue(java.lang.String xpathExpression,
                                                   java.util.Map nsPrefixMap,
                                                   org.jdom2.Document doc)
                                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getXMLValue

        public static java.lang.String getXMLValue(java.lang.String xpathExpression,
                                                   java.util.Map nsPrefixMap,
                                                   java.lang.String testdataId)
                                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getTestDataAsDocument

        public static org.jdom2.Document getTestDataAsDocument(java.lang.String testdataId)
                                                        throws MXException,
                                                               TestSetupException
        This is used the access the test data content as a JDOM document. This is useful for cases when the test data is used for representing arbitrary xml data which does not necessarily resolve to a Mbo.
        Parameters:
        testdataId -
        Returns:
        the xml document
        Throws:
        MXException
        TestSetupException
      • callCron

        public static void callCron(java.lang.String crontaskName,
                                    java.lang.String instanceName,
                                    UserInfo userInfo)
                             throws MXException
        This method would call the cronAction method on the cron task crontaskName instance instanceName.
        Parameters:
        crontaskName - the cron task name
        instanceName - the instance name
        userInfo - the user to be used for accessing the cron task Mbo. Note this is need not be the same as the "runas" user configured in the task.
        Throws:
        MXException
      • callWorkflow

        public static void callWorkflow(java.lang.String wfName,
                                        MboRemote mbo)
                                 throws MXException
        Action method to call a Maximo workflow.
        Parameters:
        wfName - the name of the workflow process
        mbo - the mbo for the workflow.
        Throws:
        MXException
      • getServerDate

        public static java.util.Date getServerDate()
        Action method to get Maximo server date.
        Returns:
        the Maximo instance server date.
      • refetch

        public static MboRemote refetch(MboRemote mbo)
                                 throws java.rmi.RemoteException,
                                        MXException
        Utility method to refetch mbo from the Maximo database.
        Parameters:
        mbo - the Mbo to be refetched.
        Returns:
        the refetched Mbo
        Throws:
        java.rmi.RemoteException
        MXException
      • getUserInfo

        public static UserInfo getUserInfo()
        Utility method to acccess the UserInfo object from the unit test context.
        Returns:
        return the user configured for the test case.
      • getTestDataSource

        public static TestDataSource getTestDataSource()
        Utility method to acccess the TestDataSource object from the unit test context.
        Returns:
        the current test data source.
      • setObjectProperty

        @Deprecated
        public static void setObjectProperty(java.lang.String propName,
                                                         java.lang.Object value)
        Deprecated. 
      • getObjectProperty

        @Deprecated
        public static java.lang.Object getObjectProperty(java.lang.String propName)
        Deprecated. 
      • setTestVariable

        public static void setTestVariable(java.lang.String propName,
                                           java.lang.Object value)
      • getTestVariable

        public static java.lang.Object getTestVariable(java.lang.String propName)
      • rollback

        public static void rollback(MboRemote mbo)
        Rolls back the MXTransaction for the Mbo mbo If a failure happens an assertion error is generated.
        Parameters:
        mbo -
      • commitAndRefetch

        public static MboRemote commitAndRefetch(MboRemote mbo)
                                          throws java.rmi.RemoteException,
                                                 MXException
        Commits the MXTransaction for the Mbo mbo and immediately refetches it from the Maximo database.
        Parameters:
        mbo - The MBO to be committed.
        Returns:
        The refetched MBO.
        Throws:
        MXException
        java.rmi.RemoteException
      • commit

        public static void commit(MboRemote mbo)
        Commits the MXTransaction for the Mbo mbo. If a failure happens an assertion error is generated.
        Parameters:
        mbo -
      • generateRelationName

        public static java.lang.String generateRelationName()
        Generates a random temporary relation name
        Returns:
        the name of the relation
      • getObjectExpression

        public static java.lang.Object getObjectExpression(MboRemote mbo,
                                                           java.lang.String expression)
                                                    throws java.lang.Exception
        Parameters:
        mbo -
        expression -
        Returns:
        Throws:
        java.lang.Exception
      • getProperty

        public static java.lang.String getProperty(java.lang.String name)
        Parameters:
        name - property name
        Returns:
        the property string value
      • getBooleanProperty

        public static boolean getBooleanProperty(java.lang.String name)
                                          throws TestSetupException
        Parameters:
        name - property name
        Returns:
        the property string value
        Throws:
        TestSetupException
      • getIntegerProperty

        public static java.lang.Integer getIntegerProperty(java.lang.String name)
                                                    throws TestSetupException
        Return property value for specified property as Integer
        Parameters:
        propName - property name
        Returns:
        property value as Integer
        Throws:
        TestSetupException
      • getLongProperty

        public static java.lang.Long getLongProperty(java.lang.String name)
                                              throws TestSetupException
        Return proprty value for specified property as Long
        Parameters:
        propName - property name
        Returns:
        property value as Long
        Throws:
        TestSetupException
      • getDoubleProperty

        public static java.lang.Double getDoubleProperty(java.lang.String name)
                                                  throws TestSetupException
        Return property value for specified property as Double
        Parameters:
        propName - property name
        Returns:
        property value as Double
        Throws:
        TestSetupException
      • getDateProperty

        public static java.util.Date getDateProperty(java.lang.String name)
                                              throws TestSetupException
        Return property value for specified property as Date
        Parameters:
        propName - property name
        Returns:
        property value as Date
        Throws:
        TestSetupException
      • getPropertyAsList

        public static java.util.List getPropertyAsList(java.lang.String name)
        Parameters:
        name -
        Returns:
      • getBooleanExpression

        public static boolean getBooleanExpression(MboRemote mbo,
                                                   java.lang.String expression)
                                            throws java.lang.Exception
        Parameters:
        mbo -
        expression -
        Returns:
        Throws:
        java.lang.Exception
      • getIntExpression

        public static int getIntExpression(MboRemote mbo,
                                           java.lang.String expression)
                                    throws java.lang.Exception
        Parameters:
        mbo -
        expression -
        Returns:
        Throws:
        java.lang.Exception
      • getDoubleExpression

        public static double getDoubleExpression(MboRemote mbo,
                                                 java.lang.String expression)
                                          throws java.lang.Exception
        Parameters:
        mbo -
        expression -
        Returns:
        Throws:
        java.lang.Exception
      • getLongExpression

        public static long getLongExpression(MboRemote mbo,
                                             java.lang.String expression)
                                      throws java.lang.Exception
        Parameters:
        mbo -
        expression -
        Returns:
        Throws:
        java.lang.Exception
      • getDateExpression

        public static java.util.Date getDateExpression(MboRemote mbo,
                                                       java.lang.String expression)
                                                throws java.lang.Exception
        Parameters:
        mbo -
        expression -
        Returns:
        Throws:
        java.lang.Exception
      • getStringExpression

        public static java.lang.String getStringExpression(MboRemote mbo,
                                                           java.lang.String expression)
                                                    throws java.lang.Exception
        Parameters:
        mbo -
        expression -
        Returns:
        Throws:
        java.lang.Exception
      • updateMaxVar

        public static void updateMaxVar(java.lang.String varName,
                                        java.lang.String varValue)
                                 throws java.rmi.RemoteException,
                                        MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • updateMaxVar

        public static void updateMaxVar(java.lang.String varName,
                                        java.lang.String orgId,
                                        java.lang.String siteId,
                                        java.lang.String varValue)
                                 throws java.rmi.RemoteException,
                                        MXException
        Throws:
        java.rmi.RemoteException
        MXException
      • updateMaxVar

        public static MaxVarsRemote updateMaxVar(UserInfo userInfo,
                                                 java.lang.String varName,
                                                 java.lang.String orgId,
                                                 java.lang.String siteId,
                                                 java.lang.String varValue)
                                          throws java.rmi.RemoteException,
                                                 MXException
        Throws:
        java.rmi.RemoteException
        MXException