Junit test case for RepositoryJob

Hi All,

I trying to write test case for RepositoryJob. However I am unable to mock ‘Session’ from ‘RepositoryJobExecutionContext’. Can someone please help on how to proceed on that? Requesting any example code snippet if possible.

Thanks
Rahul

Add the following dependencies, and use org.onehippo.repository.mock.MockSession.

    <dependency>
      <groupId>org.onehippo.cms7</groupId>
      <artifactId>hippo-repository-mockutils</artifactId>
      <version>${hippo.repository.version}</version>
      <scope>test</scope>
    </dependency>

For example,

final MockNode root = MockNode.root();
final MockSession session = new MockSession(root);
final Map<String, String> attributes = new HashMap<>();
final RepositoryJobExecutionContext context = new RepositoryJobExecutionContext(session, attributes) {
    @Override
    public Session createSession(Credentials credentials) throws LoginException, RepositoryException {
        return session;
    }
};
// ...

Regards,

Woonsan