Class StructureHelper
- java.lang.Object
-
- lumis.lptf.portal.structure.StructureHelper
-
@StableMinor(version="15.0", sinceVersion="5.6") public class StructureHelper extends java.lang.Object
Helper class that provides common functionalities needed to perform tests with Service Interfaces.Possible operations:
- Create pages
- Create channels
- Create service instances
- Create service interface instances
- Cleanup the structure created
All the methods use the current session and the current transaction. The exception to this rule is the cleanup method that starts and ends its own transaction and session. So, if the client code needs to commit the current transaction during the test it is not a problem, since the cleanup will run using a new transaction.
The recommended way to use the StructureHelper is instantiate a new helper, create and start a new transaction and session and create the needed structure to the tests using the helper (since it uses the current transaction and session). When the created structure is no longer necessary, the client code should ends the transaction and the session and call the
cleanup()
method.When using JUnit, the StructureHelper instance may be stored as an attribute, initialized during the
setUp
(or@Before
), and thecleanup
method may be called from thetearDown
(or@After
).- Since:
- 5.6.0
- Version:
- $Revision: 25304 $ $Date: 2022-10-22 22:51:05 -0300 (Sat, 22 Oct 2022) $
-
-
Constructor Summary
Constructors Constructor Description StructureHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
Deletes structure elements created by this StructureHelper, such as channels, pages and service interface instances.ChannelConfig
createChannel()
Creates a channel.ChannelConfig
createChannel(ChannelConfig parent)
Creates a channel within the given parent channel.ChannelConfig
createChannelTemplate()
Creates a channel template.ChannelConfig
createChannelTemplate(ChannelConfig parent)
Creates a channel template within the given parent channel.PageConfig
createPage()
Creates a page.PageConfig
createPage(ChannelConfig channelConfig)
Creates a page.PageConfig
createPageTemplate()
Creates a page template.PageConfig
createPageTemplate(ChannelConfig channelConfig)
Creates a page template.ServiceInstanceConfig
createServiceInstance(java.lang.String serviceId)
Creates a service instance.ServiceInstanceConfig
createServiceInstance(ChannelConfig channelConfig, java.lang.String serviceId)
Creates a service instance.ServiceInstanceConfig
createServiceInstance(ChannelConfig channelConfig, java.lang.String serviceId, java.lang.String serviceInstanceName)
Creates a service instance.ServiceInterfaceInstanceConfig
createServiceInterfaceInstance(java.lang.String serviceId, java.lang.String serviceInterfaceId)
Creates a service interface instance.ServiceInterfaceInstanceConfig
createServiceInterfaceInstance(PageConfig pageConfig, ServiceInstanceConfig serviceInstanceConfig, java.lang.String serviceInterfaceId)
Creates a service interface instance.ServiceInterfaceInstanceConfig
createServiceInterfaceInstance(ServiceInstanceConfig serviceInstanceConfig, java.lang.String serviceInterfaceId)
Creates a service interface instance.ServiceInstanceDependencyConfig
makeDependency(ServiceInstanceConfig serviceInstance, ServiceInstanceConfig dependentServiceInstance, java.lang.String dependencyType)
Creates a dependency between the given service instances and returns the dependency configuration.
Uses the givendependencyType
parameter to set the dependency type.
-
-
-
Method Detail
-
createChannel
public ChannelConfig createChannel() throws PortalException
Creates a channel.cleanup()
will delete the created channel.- Returns:
- the created channel.
- Throws:
PortalException
- if the channel could not be created.
-
createChannelTemplate
public ChannelConfig createChannelTemplate() throws PortalException
Creates a channel template.cleanup()
will delete the created channel template.- Returns:
- the created channel template.
- Throws:
PortalException
- if the channel template could not be created.
-
createChannel
public ChannelConfig createChannel(ChannelConfig parent) throws PortalException
Creates a channel within the given parent channel.cleanup()
will delete the created channel.- Parameters:
parent
- the parent channel where the newly created one will be placed.- Returns:
- the created channel.
- Throws:
PortalException
- if the channel could not be created.
-
createChannelTemplate
public ChannelConfig createChannelTemplate(ChannelConfig parent) throws PortalException
Creates a channel template within the given parent channel.cleanup()
will delete the created channel template.- Parameters:
parent
- the parent channel where the newly created channel template will be placed.- Returns:
- the created channel template.
- Throws:
PortalException
- if the channel template could not be created.
-
createPage
public PageConfig createPage(ChannelConfig channelConfig) throws PortalException
Creates a page.cleanup()
will delete the created page.- Parameters:
channelConfig
- the channel where the page will be created in.- Returns:
- the created page.
- Throws:
PortalException
- if the page could not be created.
-
createPageTemplate
public PageConfig createPageTemplate(ChannelConfig channelConfig) throws PortalException
Creates a page template.cleanup()
will delete the created page template.- Parameters:
channelConfig
- the channel where the page template will be created in.- Returns:
- the created page template.
- Throws:
PortalException
- if the page template could not be created.- Since:
- 9.0.0
-
createPage
public PageConfig createPage() throws PortalException
Creates a page.cleanup()
will delete the created page.- Returns:
- the created page.
- Throws:
PortalException
- if the page could not be created.
-
createPageTemplate
public PageConfig createPageTemplate() throws PortalException
Creates a page template.cleanup()
will delete the created page templates.- Returns:
- the created page template.
- Throws:
PortalException
- if the page template could not be created.
-
createServiceInstance
public ServiceInstanceConfig createServiceInstance(ChannelConfig channelConfig, java.lang.String serviceId) throws PortalException
Creates a service instance.cleanup()
will delete the created service instance.- Parameters:
channelConfig
- the channel where the service instance will be created in.serviceId
- the identifier of the service the service instance is of.- Returns:
- the created service instance.
- Throws:
PortalException
- if the service instance could not be created.
-
createServiceInstance
public ServiceInstanceConfig createServiceInstance(ChannelConfig channelConfig, java.lang.String serviceId, java.lang.String serviceInstanceName) throws PortalException
Creates a service instance.cleanup()
will delete the created service instance.- Parameters:
channelConfig
- the channel where the service instance will be created in.serviceId
- the identifier of the service the service instance is of.serviceInstanceName
- the name of the service the service instance, ornull
to be auto-generated.- Returns:
- the created service instance.
- Throws:
PortalException
- if the service instance could not be created.
-
createServiceInstance
public ServiceInstanceConfig createServiceInstance(java.lang.String serviceId) throws PortalException
Creates a service instance.cleanup()
will delete the created service instance.- Parameters:
serviceId
- the identifier of the service the service instance is of.- Returns:
- the created service instance.
- Throws:
PortalException
- if the service instance could not be created.
-
createServiceInterfaceInstance
public ServiceInterfaceInstanceConfig createServiceInterfaceInstance(java.lang.String serviceId, java.lang.String serviceInterfaceId) throws PortalException
Creates a service interface instance.cleanup()
will delete the created service interface instance.- Parameters:
serviceId
- the identifier of the service the service interface instance is of.serviceInterfaceId
- the identifier of the interface the service interface instance is of. Does not include the service identifier in it.- Returns:
- the created service interface instance.
- Throws:
PortalException
- if the service interface instance could not be created.- Since:
- 5.6.0
-
createServiceInterfaceInstance
public ServiceInterfaceInstanceConfig createServiceInterfaceInstance(ServiceInstanceConfig serviceInstanceConfig, java.lang.String serviceInterfaceId) throws PortalException
Creates a service interface instance.cleanup()
will delete the created service interface instance.- Parameters:
serviceInstanceConfig
- the service instance the service interface instance is to belong to.serviceInterfaceId
- the identifier of the interface the service interface instance is of. Does not include the service identifier in it.- Returns:
- the created service interface instance.
- Throws:
PortalException
- if the service interface instance could not be created.- Since:
- 5.6.0
-
createServiceInterfaceInstance
public ServiceInterfaceInstanceConfig createServiceInterfaceInstance(PageConfig pageConfig, ServiceInstanceConfig serviceInstanceConfig, java.lang.String serviceInterfaceId) throws PortalException
Creates a service interface instance.cleanup()
will delete the created service interface instance.- Parameters:
pageConfig
- the page the service interface is to belong to.serviceInstanceConfig
- the service instance the service interface instance is to belong to.serviceInterfaceId
- the identifier of the interface the service interface instance is of. Does not include the service identifier in it.- Returns:
- the created service interface instance.
- Throws:
PortalException
- if the service interface instance could not be created.- Since:
- 5.6.0
-
makeDependency
public ServiceInstanceDependencyConfig makeDependency(ServiceInstanceConfig serviceInstance, ServiceInstanceConfig dependentServiceInstance, java.lang.String dependencyType) throws PortalException
Creates a dependency between the given service instances and returns the dependency configuration.
Uses the givendependencyType
parameter to set the dependency type.- Parameters:
serviceInstance
- the service instance.dependentServiceInstance
- the dependent service instance.dependencyType
- the dependency type.- Returns:
- the service instance dependency configuration.
- Throws:
PortalException
- if the dependency couldn't be created.- Since:
- 9.0.0
-
cleanup
public void cleanup()
Deletes structure elements created by this StructureHelper, such as channels, pages and service interface instances.The objects are deleted in the inverse order which they were created by this helper. This have to be taken into account if your test has some dependencies in its structure.
- Since:
- 5.6.0
-
-