Package com.boomi.connector.testutil
Class ConnectorTestContext
- java.lang.Object
-
- com.boomi.connector.testutil.SimpleAtomContext
-
- com.boomi.connector.testutil.ConnectorTestContext
-
- All Implemented Interfaces:
AtomContext
,BrowseContext
,ConnectorContext
,OperationContext
,PayloadMetadataFactory
public abstract class ConnectorTestContext extends SimpleAtomContext implements OperationContext
BaseOperationContext
implementation for use with theConnectorTester
junit tests.All test classes must provide a concrete implementation of this class
-
-
Constructor Summary
Constructors Constructor Description ConnectorTestContext()
Creates a new context with the defaultSimpleAtomConfig
and an instance of the connector specified by the implementing class
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addConnectionProperty(String key, Object value)
Method to add a connection property to the contextvoid
addCookie(ObjectDefinitionRole role, String cookie)
Method to add a cookie to the contextvoid
addOperationProperty(String key, Object value)
Method to add an operation property to the contextvoid
addSelectableField(String field)
Method to add a selectable field to the contextvoid
addToCache(Object key, Object value)
Method to add a key/value pair to the connector cachePayloadMetadata
createMetadata()
APIVersion
getAPIVersion()
Get theAPIVersion
for the testBrowseContext
getBrowseContext()
Getter for the browse contextPropertyMap
getConnectionProperties()
Returns the relevant connection properties if this connector has therequireConnectionForBrowse
flag enabled in the connector's descriptor.Connector
getConnector()
Returns the connector instance with which this context is associated.ConcurrentMap<Object,Object>
getConnectorCache()
Returns the current connector cache.protected abstract Class<? extends Connector>
getConnectorClass()
This method should return theClass
of the connector under testString
getCustomOperationType()
Returns the custom type of the operation that is currently being configured.String
getObjectDefinitionCookie(ObjectDefinitionRole role)
Returns an object definition cookie constructed by the object profile retrieval during a browsing request.String
getObjectTypeId()
Returns the id of the object type for which this operation is being executed.PropertyMap
getOperationProperties()
Returns any operation properties flagged asincludeInBrowse
for the current OperationType in the connector's descriptor.OperationType
getOperationType()
Returns the currently configured OperationTypeList<String>
getSelectedFields()
Returns a field list describing the fields to be retrieved.SSLContext
getSSLContext(PublicKeyStore publicKeyStore, PrivateKeyStore privateKeyStore)
TODO CON-601 pull up in 2.1 Returns aSSLContext
.boolean
hasCookie(ObjectDefinitionRole role)
Method to determine if the context contains a cookie for anObjectDefinitionRole
boolean
isCookieRequired()
This flag indicates whether or not the operation under test requires that a cookie be added to the connector cachevoid
setCookieRequired(boolean cookieRequired)
Setter method for cookie flagvoid
setObjectTypeId(String objectTypeId)
Getter for the object type idvoid
setOperationCustomType(String customOperationType)
Setter for the operation custom typevoid
setOperationType(OperationType operationType)
Setter for the operation type-
Methods inherited from class com.boomi.connector.testutil.SimpleAtomContext
createSSLContext, createTempOutputStream, getConfig, tempOutputStreamToInputStream, tempOutputStreamToPayload
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.boomi.connector.api.AtomContext
createTempOutputStream, getConfig, tempOutputStreamToInputStream, tempOutputStreamToPayload
-
-
-
-
Constructor Detail
-
ConnectorTestContext
public ConnectorTestContext()
Creates a new context with the defaultSimpleAtomConfig
and an instance of the connector specified by the implementing class
-
-
Method Detail
-
getAPIVersion
public APIVersion getAPIVersion()
Get theAPIVersion
for the test- Returns:
APIVersion
value
-
getConnector
public Connector getConnector()
Description copied from interface:ConnectorContext
Returns the connector instance with which this context is associated.- Specified by:
getConnector
in interfaceConnectorContext
-
getConnectorCache
public ConcurrentMap<Object,Object> getConnectorCache()
Description copied from interface:ConnectorContext
Returns the current connector cache. This is the preferred means for caching any Connector resources for use across operation calls. This cache is Boomi account specific, so login/credential based information may be put in this cache. Note, however that a given Boomi account may still have multiple connector service accounts, so the cache information should take that into account (e.g. by caching information based on the service username). The lifetime of this cache is defined by the lifetime of the Connector instance (so, essentially indefinite), and, among other things, the objects in this cache must be used in a thread-safe manner.- Specified by:
getConnectorCache
in interfaceConnectorContext
-
getOperationType
public OperationType getOperationType()
Description copied from interface:BrowseContext
Returns the currently configured OperationType- Specified by:
getOperationType
in interfaceBrowseContext
-
getCustomOperationType
public String getCustomOperationType()
Description copied from interface:BrowseContext
Returns the custom type of the operation that is currently being configured. This is the customTypeId field from the connector descriptor.- Specified by:
getCustomOperationType
in interfaceBrowseContext
- Returns:
- customTypeId field from the connector descriptor.
-
getConnectionProperties
public PropertyMap getConnectionProperties()
Description copied from interface:ConnectorContext
Returns the relevant connection properties if this connector has therequireConnectionForBrowse
flag enabled in the connector's descriptor.- Specified by:
getConnectionProperties
in interfaceConnectorContext
-
getOperationProperties
public PropertyMap getOperationProperties()
Description copied from interface:BrowseContext
Returns any operation properties flagged asincludeInBrowse
for the current OperationType in the connector's descriptor.- Specified by:
getOperationProperties
in interfaceBrowseContext
-
getObjectTypeId
public String getObjectTypeId()
Description copied from interface:OperationContext
Returns the id of the object type for which this operation is being executed.- Specified by:
getObjectTypeId
in interfaceOperationContext
-
getObjectDefinitionCookie
public String getObjectDefinitionCookie(ObjectDefinitionRole role)
Description copied from interface:OperationContext
Returns an object definition cookie constructed by the object profile retrieval during a browsing request.- Specified by:
getObjectDefinitionCookie
in interfaceOperationContext
- Parameters:
role
- the role identifying the profile for which the profile is desired- Returns:
- the stored cookie, or
null
if no cookie was stored for the profile
-
getSelectedFields
public List<String> getSelectedFields()
Description copied from interface:OperationContext
Returns a field list describing the fields to be retrieved. This may benull
, indicating that all fields should be retrieved- Specified by:
getSelectedFields
in interfaceOperationContext
-
createMetadata
public PayloadMetadata createMetadata()
- Specified by:
createMetadata
in interfacePayloadMetadataFactory
-
getSSLContext
public SSLContext getSSLContext(PublicKeyStore publicKeyStore, PrivateKeyStore privateKeyStore) throws GeneralSecurityException
Description copied from interface:BrowseContext
TODO CON-601 pull up in 2.1 Returns aSSLContext
. Passingnull
for public and private key stores will make an attempt to configure it to use trusted JVM and deployed atom certificates if called during an operation execution.- Specified by:
getSSLContext
in interfaceBrowseContext
- Throws:
GeneralSecurityException
-
getBrowseContext
public BrowseContext getBrowseContext()
Getter for the browse context- Returns:
- the browseContext
-
setOperationType
public void setOperationType(OperationType operationType)
Setter for the operation type- Parameters:
operationType
- the operationType to set
-
setOperationCustomType
public void setOperationCustomType(String customOperationType)
Setter for the operation custom type- Parameters:
customOperationType
- the custom operation id to set
-
setObjectTypeId
public void setObjectTypeId(String objectTypeId)
Getter for the object type id- Parameters:
objectTypeId
- the objectTypeId to set
-
hasCookie
public boolean hasCookie(ObjectDefinitionRole role)
Method to determine if the context contains a cookie for anObjectDefinitionRole
- Parameters:
role
- the role to verify- Returns:
- true if the context contains the role, false otherwise
-
addCookie
public void addCookie(ObjectDefinitionRole role, String cookie)
Method to add a cookie to the context- Parameters:
role
-ObjectDefinitionRole
associated to the cookiecookie
- the cookie
-
addToCache
public void addToCache(Object key, Object value)
Method to add a key/value pair to the connector cache- Parameters:
key
- the key for the entryvalue
- the value for the entry
-
addConnectionProperty
public void addConnectionProperty(String key, Object value)
Method to add a connection property to the context- Parameters:
key
- the key for the propertyvalue
- the value for the property
-
addOperationProperty
public void addOperationProperty(String key, Object value)
Method to add an operation property to the context- Parameters:
key
- the key for the propertyvalue
- the value for the property
-
addSelectableField
public void addSelectableField(String field)
Method to add a selectable field to the context- Parameters:
field
- the name of the field
-
isCookieRequired
public boolean isCookieRequired()
This flag indicates whether or not the operation under test requires that a cookie be added to the connector cache- Returns:
- the cookieRequired
-
setCookieRequired
public void setCookieRequired(boolean cookieRequired)
Setter method for cookie flag- Parameters:
cookieRequired
- the cookieRequired to set
-
-