use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class MetadataSyncPostProcessorTest method testShouldSendSuccessEmailIfSyncSummaryIsWarning.
@Test
public void testShouldSendSuccessEmailIfSyncSummaryIsWarning() throws Exception {
metadataSyncSummary.setImportReport(new ImportReport());
metadataSyncSummary.getImportReport().setStatus(Status.WARNING);
metadataSyncSummary.setMetadataVersion(dataVersion);
MetadataRetryContext mockRetryContext = mock(MetadataRetryContext.class);
boolean status = metadataSyncPostProcessor.handleSyncNotificationsAndAbortStatus(metadataSyncSummary, mockRetryContext, dataVersion);
assertFalse(status);
}
use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class MetadataSyncPostProcessorTest method testShouldSendSuccessEmailIfSyncSummaryIsError.
@Test
public void testShouldSendSuccessEmailIfSyncSummaryIsError() throws Exception {
metadataSyncSummary.setImportReport(new ImportReport());
metadataSyncSummary.getImportReport().setStatus(Status.ERROR);
metadataSyncSummary.setMetadataVersion(dataVersion);
MetadataRetryContext mockMetadataRetryContext = mock(MetadataRetryContext.class);
RetryContext mockRetryContext = mock(RetryContext.class);
when(mockMetadataRetryContext.getRetryContext()).thenReturn(mockRetryContext);
boolean status = metadataSyncPostProcessor.handleSyncNotificationsAndAbortStatus(metadataSyncSummary, mockMetadataRetryContext, dataVersion);
assertTrue(status);
}
use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class MetadataRetryContextTest method testIfSummaryIsNotNull.
@Test
public void testIfSummaryIsNotNull() throws Exception {
MetadataSyncSummary testSummary = new MetadataSyncSummary();
ImportReport importReport = new ImportReport();
importReport.setStatus(Status.ERROR);
testSummary.setImportReport(importReport);
metadataRetryContext.updateRetryContext(testKey, testMessage, mockVersion, testSummary);
verify(retryContext).setAttribute(testKey, testMessage);
}
use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class MetadataSyncImportHandlerTest method testShouldImportMetadata.
@Test
public void testShouldImportMetadata() {
syncParams.setImportParams(new MetadataImportParams());
syncParams.setVersion(metadataVersion);
MetadataSyncSummary metadataSyncSummary = new MetadataSyncSummary();
importReport.setStatus(Status.OK);
when(metadataImportService.importMetadata(syncParams.getImportParams())).thenReturn(importReport);
metadataSyncSummary.setImportReport(importReport);
metadataSyncSummary.setMetadataVersion(metadataVersion);
doNothing().when(metadataVersionDelegate).addNewMetadataVersion(metadataVersion);
MetadataSyncSummary actualMetadataSyncSummary = metadataSyncImportHandler.importMetadata(syncParams, expectedMetadataSnapshot);
verify(metadataVersionDelegate).addNewMetadataVersion(metadataVersion);
assertEquals(metadataSyncSummary.getImportReport(), actualMetadataSyncSummary.getImportReport());
assertEquals(metadataSyncSummary.getImportSummary(), actualMetadataSyncSummary.getImportSummary());
assertEquals(metadataSyncSummary.getMetadataVersion(), actualMetadataSyncSummary.getMetadataVersion());
assertEquals(metadataSyncSummary.getMetadataVersion().getType(), actualMetadataSyncSummary.getMetadataVersion().getType());
assertEquals(metadataSyncSummary.getImportReport().getStatus(), actualMetadataSyncSummary.getImportReport().getStatus());
}
use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class MetadataImportController method postJsonMetadata.
@RequestMapping(value = "", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public void postJsonMetadata(HttpServletRequest request, HttpServletResponse response) throws IOException {
MetadataImportParams params = metadataImportService.getParamsFromMap(contextService.getParameterValuesMap());
params.setObjects(renderService.fromMetadata(StreamUtils.wrapAndCheckCompressionFormat(request.getInputStream()), RenderFormat.JSON));
if (params.hasTaskId()) {
startAsync(params);
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
} else {
ImportReport importReport = metadataImportService.importMetadata(params);
renderService.toJson(response.getOutputStream(), importReport);
}
}
Aggregations