Junit for eventhandler (HippoWorkflowEvent)

Hi All,

I want to write Junit test cases for HippoWorkflowEvent and wanted to know if Hippo provides any built in support for unit testing and mocking the HippoWorkflowEvent objects. Any code examples, references would be really appreciated.



In the repository project there are some mock objects, but not workflow. There is also RepositoryTestCase, which basically starts a repository so that you can test your objects directly. This may not be so easy to use and there is no documentation. There are also various test object available in the hst and cms projects (and possibly others). Your best bet is to checkout these projects and look at how they are being used.

However, a partner has developed their own test tools, which I highly suggest you take a look at.

I can second that. We’re using it in a bunch of unit tests. It takes a bit of getting used to, but it can be as straightforward as follows:

final String testRepoContent = new Scanner(Paths.get(mockDataPath)).useDelimiter("\Z").next();
final Node testNode = getImporter().createNodesFromXml(testRepoContent, “”, “hippostd:folder”);

With “mockDataPath” pointing to the relevant xml file.