Class OperationTest
- java.lang.Object
-
- com.boomi.connector.testutil.junit.ConnectorTest
-
- com.boomi.connector.testutil.junit.OperationTest
-
- Direct Known Subclasses:
CreateOperationTest
,DeleteOperationTest
,ExecuteOperationTest
,GetOperationTest
,QueryOperationTest
,UpdateOperationTest
,UpsertOperationTest
public abstract class OperationTest extends ConnectorTest
Base test class for testing connector operations withConnectorTester
. All implementing classes will execute a single test to verify successful execution of the operation.To create tests for specific operations, you should extend the operation specific subclasses instead of implementing this directly.
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
EXPECTED_RESULT_COUNT
-
Fields inherited from class com.boomi.connector.testutil.junit.ConnectorTest
connectorTester, testContext
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
OperationTest(OperationType operationType, String objectTypeId)
Creates an instance of an operation test.protected
OperationTest(OperationType operationType, String objectTypeId, OptionalTestInput optionalTestInput)
Creates an instance of an operation test.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
afterOperation(SimpleOperationResult result)
This method can be overridden to provide additional verification beyond the base verifications performed bytestOperation()
.protected void
afterOperation(List<SimpleOperationResult> results)
This method can be overridden to provide additional verification beyond the base verifications performed bytestOperation()
.protected abstract List<SimpleOperationResult>
executeOperation()
This method should perform the actual operation being testedvoid
prepareForOperation()
Setup method for operation testsvoid
testOperation()
Test method to verify the successful execution of the target operation-
Methods inherited from class com.boomi.connector.testutil.junit.ConnectorTest
browseProfile, browseTypes, clearObjectDefinitionCache, getBrowseContext, getConnectorTestContext, getOperationContext, setupConnectorTester
-
-
-
-
Field Detail
-
EXPECTED_RESULT_COUNT
protected static final int EXPECTED_RESULT_COUNT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OperationTest
protected OperationTest(OperationType operationType, String objectTypeId)
Creates an instance of an operation test.Intended to be used as part of a
Parameterized
test but can be run as a single test instance by invoking this constructor from the no argument constructor of the implementing class.- Parameters:
operationType
- the operation under testobjectTypeId
- the object type id under test
-
OperationTest
protected OperationTest(OperationType operationType, String objectTypeId, OptionalTestInput optionalTestInput)
Creates an instance of an operation test.Intended to be used as part of a
Parameterized
test but can be run as a single test instance by invoking this constructor from the no argument constructor of the implementing class.- Parameters:
operationType
- the operation under testobjectTypeId
- the object type id under testoptionalTestInput
- optional input for the test
-
-
Method Detail
-
prepareForOperation
public final void prepareForOperation()
Setup method for operation testsThis method will set the object type and object type id in the test context. It will also verify that any
ObjectDefinitionRole
cookies have been loaded.
-
testOperation
public final void testOperation() throws Exception
Test method to verify the successful execution of the target operationThe test will execute the operation specified by the implementing class and verify the
SimpleOperationResult
. Successful operations are assumed to have only a single result as the test only supports a single input value. The operation status and presence of payloads will be verified againstexpectedOperationStatus
andexpectedEmptyPayloads
. The expected values are specified byOptionalTestInput
and default toOperationStatus.SUCCESS
andfalse
, respectively. If payloads are expected, they should not benull
.- Throws:
Exception
- exception testing the operation
-
afterOperation
protected void afterOperation(List<SimpleOperationResult> results) throws Exception
This method can be overridden to provide additional verification beyond the base verifications performed bytestOperation()
. This method will only execute after other verifications have passed. The default behavior of this method is to pass the first item in the list toafterOperation(SimpleOperationResult)
.- Parameters:
results
- list of results created by executing the operation- Throws:
Exception
- execption validating the operation results
-
afterOperation
protected void afterOperation(SimpleOperationResult result) throws Exception
This method can be overridden to provide additional verification beyond the base verifications performed bytestOperation()
. This method will only execute after other verifications have passed. IfafterOperation(SimpleOperationResult)
has also been overridden, then it is the responsibility of the overriding class to ensure that this method is called (if needed).- Parameters:
result
-SimpleOperationResult
created by executing the operation- Throws:
Exception
- exception validating the operation result
-
executeOperation
protected abstract List<SimpleOperationResult> executeOperation()
This method should perform the actual operation being tested- Returns:
List
ofSimpleOperationResult
representing the result of the operation
-
-