public class ElementTestUtils extends Object
Constructor and Description |
---|
ElementTestUtils() |
Modifier and Type | Method and Description |
---|---|
static XMessageContext |
getBasicMessageContext(org.springframework.context.ApplicationContext applicationContext)
This method can be used to retrieve an instance of
XMessageContext with only the global scope and
XPlatform set. |
static XMessage |
getEmptyMessage()
This method can be used to retrieve an instance of
XMessage with empty payload |
static Optional<String> |
getMessageProperty(XMessageView messageView,
String propertyKey)
This method can be used to retrieve the message property with the given
propertyKey from the given
messageView |
static IntegrationFlow |
getMockIntegrationFlow(org.springframework.context.ApplicationContext context)
Returns a mock instance of
IntegrationFlow with the flow name "sample-flow" and belongs to a mock project
created with getMockProject(ApplicationContext) method |
static IntegrationFlow |
getMockIntegrationFlow(Project project)
Returns a mock instance of
IntegrationFlow with the flow name "sample-flow" and belongs to the provided
project |
static IntegrationFlow |
getMockIntegrationFlow(Project project,
String flowName)
Returns a mock instance of
IntegrationFlow with the provided name and belongs to the provided project |
static Project |
getMockProject(org.springframework.context.ApplicationContext context)
Returns a mock instance of
Project with the following basic properties set
Project ID : 1
Project Name : sample-project
Project Version : 1.0
|
static ProjectConfig |
getMockProjectConfig() |
static Optional<String> |
getTransportHeader(XMessageView messageView,
String headerKey)
This method can be used to retrieve the transport header with the given
headerKey from the given
messageView |
static boolean |
hasMessageProperty(XMessageView messageView,
String propertyKey)
This method can be used to check whether the given
messageView has a message property with the given
propertyKey |
static boolean |
hasTransportHeader(XMessageView messageView,
String headerKey)
This method can be used to check whether the given
messageView has a transport header with the given
headerKey |
static File |
readFileFromClassPath(ClassLoader classLoader,
String filePath)
Utility method to read a file from the classpath to be used in tests
|
public static XMessageContext getBasicMessageContext(org.springframework.context.ApplicationContext applicationContext)
XMessageContext
with only the global scope and
XPlatform
set. It also contains an instance of XMessage
with empty payload.
The concrete test class is responsible for setting all the necessary properties to both XMessageContext and XMessage before using them in a test.
applicationContext
- the spring application context to create a new message contextXMessageContext
public static XMessage getEmptyMessage()
XMessage
with empty payload
The concrete test class is responsible for setting all the necessary properties to the XMessage before using it in a test.
XMessage
public static boolean hasTransportHeader(XMessageView messageView, String headerKey)
messageView
has a transport header with the given
headerKey
messageView
- instance of XMessageView
to be checked for the transport headerheaderKey
- key of the header as String
to be checkedtrue
if present, false
otherwisepublic static Optional<String> getTransportHeader(XMessageView messageView, String headerKey)
headerKey
from the given
messageView
messageView
- instance of XMessageView
from which the transport header should be retrievedheaderKey
- key of the header as String
to be retrievedOptional
of type String
containing the header value if present,
Optional.EMPTY
otherwisepublic static boolean hasMessageProperty(XMessageView messageView, String propertyKey)
messageView
has a message property with the given
propertyKey
messageView
- instance of XMessageView
to be checked for the message propertypropertyKey
- key of the message property as String
to be checkedtrue
if present, false
otherwisepublic static Optional<String> getMessageProperty(XMessageView messageView, String propertyKey)
propertyKey
from the given
messageView
messageView
- instance of XMessageView
from which the message property should be retrievedpropertyKey
- key of the message property as String
to be retrievedOptional
of type String
containing the message property value if present,
Optional.EMPTY
otherwisepublic static Project getMockProject(org.springframework.context.ApplicationContext context)
Project
with the following basic properties set
context
- ApplicationContext
to be usedProject
public static ProjectConfig getMockProjectConfig()
public static IntegrationFlow getMockIntegrationFlow(org.springframework.context.ApplicationContext context)
IntegrationFlow
with the flow name "sample-flow" and belongs to a mock project
created with getMockProject(ApplicationContext)
methodcontext
- ApplicationContext
to be usedIntegrationFlow
belongs to a mock projectpublic static IntegrationFlow getMockIntegrationFlow(Project project)
IntegrationFlow
with the flow name "sample-flow" and belongs to the provided
projectproject
- instance of Project
to which this integration flow should belong toIntegrationFlow
belongs to the given projectpublic static IntegrationFlow getMockIntegrationFlow(Project project, String flowName)
IntegrationFlow
with the provided name and belongs to the provided projectproject
- instance of Project
to which this integration flow should belong toflowName
- name of the integration flowIntegrationFlow
with the given name and belongs to the given projectpublic static File readFileFromClassPath(ClassLoader classLoader, String filePath) throws URISyntaxException
classLoader
- classloader to be used to read the file as a classpath resourcefilePath
- path to the file locationFile
instance if the resource was foundURISyntaxException
- if the provided file path is not validIllegalArgumentException
- if a resource with the provided file path cannot be foundCopyright © 2016–2019 AdroitLogic. All rights reserved.