use of org.hisp.dhis.dxf2.metadata.MetadataImportService in project dhis2-core by dhis2.
the class MetadataSyncImportHandlerTest method testShouldThrowExceptionWhenParsingClassListMap.
@Test
public void testShouldThrowExceptionWhenParsingClassListMap() throws IOException {
syncParams.setImportParams(new MetadataImportParams());
syncParams.setVersion(metadataVersion);
importReport.setStatus(Status.OK);
when(renderService.fromMetadata(any(InputStream.class), eq(RenderFormat.JSON))).thenThrow(new IOException());
expectedException.expect(MetadataSyncServiceException.class);
expectedException.expectMessage("Exception occurred while trying to do JSON conversion while parsing class list map");
metadataSyncImportHandler.importMetadata(syncParams, expectedMetadataSnapshot);
verify(renderService).fromMetadata(any(InputStream.class), RenderFormat.JSON);
verify(metadataImportService, never()).importMetadata(syncParams.getImportParams());
verify(metadataVersionDelegate, never()).addNewMetadataVersion(metadataVersion);
verify(metadataVersionDelegate, never()).addNewMetadataVersion(metadataVersion);
}
use of org.hisp.dhis.dxf2.metadata.MetadataImportService in project dhis2-core by dhis2.
the class MetadataSyncImportHandlerTest method testShouldThrowExceptionWhenClassListMapIsNull.
@Test
public void testShouldThrowExceptionWhenClassListMapIsNull() throws IOException {
syncParams.setImportParams(new MetadataImportParams());
syncParams.setVersion(metadataVersion);
importReport.setStatus(Status.OK);
when(renderService.fromMetadata(any(InputStream.class), eq(RenderFormat.JSON))).thenReturn(null);
expectedException.expect(MetadataSyncServiceException.class);
expectedException.expectMessage("ClassListMap can't be null");
metadataSyncImportHandler.importMetadata(syncParams, expectedMetadataSnapshot);
verify(renderService).fromMetadata(any(InputStream.class), RenderFormat.JSON);
verify(metadataImportService, never()).importMetadata(syncParams.getImportParams());
verify(metadataVersionDelegate, never()).addNewMetadataVersion(metadataVersion);
verify(metadataVersionDelegate, never()).addNewMetadataVersion(metadataVersion);
}
Aggregations