Search in sources :

Example 1 with DefaultUnifiedRepositoryWebService

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;
}
Also used : DefaultUnifiedRepositoryWebService(org.pentaho.platform.repository2.unified.webservices.DefaultUnifiedRepositoryWebService) ByteArrayInputStream(java.io.ByteArrayInputStream) RepositoryFileTreeDto(org.pentaho.platform.repository2.unified.webservices.RepositoryFileTreeDto) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) RepositoryRequest(org.pentaho.platform.api.repository2.unified.RepositoryRequest) Unmarshaller(javax.xml.bind.Unmarshaller)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 RepositoryRequest (org.pentaho.platform.api.repository2.unified.RepositoryRequest)1 DefaultUnifiedRepositoryWebService (org.pentaho.platform.repository2.unified.webservices.DefaultUnifiedRepositoryWebService)1 RepositoryFileTreeDto (org.pentaho.platform.repository2.unified.webservices.RepositoryFileTreeDto)1