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
BaseOperationContextimplementation for use with theConnectorTesterjunit tests.All test classes must provide a concrete implementation of this class
-
-
Constructor Summary
Constructors Constructor Description ConnectorTestContext()Creates a new context with the defaultSimpleAtomConfigand 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 voidaddConnectionProperty(String key, Object value)Method to add a connection property to the contextvoidaddCookie(ObjectDefinitionRole role, String cookie)Method to add a cookie to the contextvoidaddOperationProperty(String key, Object value)Method to add an operation property to the contextvoidaddSelectableField(String field)Method to add a selectable field to the contextvoidaddToCache(Object key, Object value)Method to add a key/value pair to the connector cachePayloadMetadatacreateMetadata()APIVersiongetAPIVersion()Get theAPIVersionfor the testBrowseContextgetBrowseContext()Getter for the browse contextPropertyMapgetConnectionProperties()Returns the relevant connection properties if this connector has therequireConnectionForBrowseflag enabled in the connector's descriptor.ConnectorgetConnector()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 theClassof the connector under testStringgetCustomOperationType()Returns the custom type of the operation that is currently being configured.StringgetObjectDefinitionCookie(ObjectDefinitionRole role)Returns an object definition cookie constructed by the object profile retrieval during a browsing request.StringgetObjectTypeId()Returns the id of the object type for which this operation is being executed.PropertyMapgetOperationProperties()Returns any operation properties flagged asincludeInBrowsefor the current OperationType in the connector's descriptor.OperationTypegetOperationType()Returns the currently configured OperationTypeList<String>getSelectedFields()Returns a field list describing the fields to be retrieved.SSLContextgetSSLContext(PublicKeyStore publicKeyStore, PrivateKeyStore privateKeyStore)TODO CON-601 pull up in 2.1 Returns aSSLContext.booleanhasCookie(ObjectDefinitionRole role)Method to determine if the context contains a cookie for anObjectDefinitionRolebooleanisCookieRequired()This flag indicates whether or not the operation under test requires that a cookie be added to the connector cachevoidsetCookieRequired(boolean cookieRequired)Setter method for cookie flagvoidsetObjectTypeId(String objectTypeId)Getter for the object type idvoidsetOperationCustomType(String customOperationType)Setter for the operation custom typevoidsetOperationType(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 defaultSimpleAtomConfigand an instance of the connector specified by the implementing class
-
-
Method Detail
-
getAPIVersion
public APIVersion getAPIVersion()
Get theAPIVersionfor the test- Returns:
APIVersionvalue
-
getConnector
public Connector getConnector()
Description copied from interface:ConnectorContextReturns the connector instance with which this context is associated.- Specified by:
getConnectorin interfaceConnectorContext
-
getConnectorCache
public ConcurrentMap<Object,Object> getConnectorCache()
Description copied from interface:ConnectorContextReturns 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:
getConnectorCachein interfaceConnectorContext
-
getOperationType
public OperationType getOperationType()
Description copied from interface:BrowseContextReturns the currently configured OperationType- Specified by:
getOperationTypein interfaceBrowseContext
-
getCustomOperationType
public String getCustomOperationType()
Description copied from interface:BrowseContextReturns the custom type of the operation that is currently being configured. This is the customTypeId field from the connector descriptor.- Specified by:
getCustomOperationTypein interfaceBrowseContext- Returns:
- customTypeId field from the connector descriptor.
-
getConnectionProperties
public PropertyMap getConnectionProperties()
Description copied from interface:ConnectorContextReturns the relevant connection properties if this connector has therequireConnectionForBrowseflag enabled in the connector's descriptor.- Specified by:
getConnectionPropertiesin interfaceConnectorContext
-
getOperationProperties
public PropertyMap getOperationProperties()
Description copied from interface:BrowseContextReturns any operation properties flagged asincludeInBrowsefor the current OperationType in the connector's descriptor.- Specified by:
getOperationPropertiesin interfaceBrowseContext
-
getObjectTypeId
public String getObjectTypeId()
Description copied from interface:OperationContextReturns the id of the object type for which this operation is being executed.- Specified by:
getObjectTypeIdin interfaceOperationContext
-
getObjectDefinitionCookie
public String getObjectDefinitionCookie(ObjectDefinitionRole role)
Description copied from interface:OperationContextReturns an object definition cookie constructed by the object profile retrieval during a browsing request.- Specified by:
getObjectDefinitionCookiein interfaceOperationContext- Parameters:
role- the role identifying the profile for which the profile is desired- Returns:
- the stored cookie, or
nullif no cookie was stored for the profile
-
getSelectedFields
public List<String> getSelectedFields()
Description copied from interface:OperationContextReturns a field list describing the fields to be retrieved. This may benull, indicating that all fields should be retrieved- Specified by:
getSelectedFieldsin interfaceOperationContext
-
createMetadata
public PayloadMetadata createMetadata()
- Specified by:
createMetadatain interfacePayloadMetadataFactory
-
getSSLContext
public SSLContext getSSLContext(PublicKeyStore publicKeyStore, PrivateKeyStore privateKeyStore) throws GeneralSecurityException
Description copied from interface:BrowseContextTODO CON-601 pull up in 2.1 Returns aSSLContext. Passingnullfor 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:
getSSLContextin 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-ObjectDefinitionRoleassociated 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
-
-