use of org.pentaho.platform.repository2.unified.webservices.DefaultUnifiedRepositoryWebService in project pentaho-kettle by pentaho.
the class UnifiedRepositoryPurgeServiceTest method getPurgeService.
// create the necessary mocks for running a full Purge Utility job
private static UnifiedRepositoryPurgeService getPurgeService(IUnifiedRepository mockRepo) {
UnifiedRepositoryPurgeService purgeService = new UnifiedRepositoryPurgeService(mockRepo);
DefaultUnifiedRepositoryWebService mockRepoWs = mock(DefaultUnifiedRepositoryWebService.class);
UnifiedRepositoryPurgeService.repoWs = mockRepoWs;
// Create a mocked tree to be returned
JAXBContext jc;
RepositoryFileTreeDto tree = null;
try {
jc = JAXBContext.newInstance(RepositoryFileTreeDto.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
ByteArrayInputStream xml = new ByteArrayInputStream(treeResponse.getBytes());
tree = (RepositoryFileTreeDto) unmarshaller.unmarshal(xml);
} catch (JAXBException e) {
e.printStackTrace();
fail("Test class has invalid xml representation of tree");
}
when(mockRepoWs.getTreeFromRequest(any(RepositoryRequest.class))).thenReturn(tree);
return purgeService;
}
Aggregations