use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class MetadataSyncImportHandlerTest method testShouldImportMetadataWhenBestEffortWithWarnings.
@Test
public void testShouldImportMetadataWhenBestEffortWithWarnings() throws IOException {
syncParams.setImportParams(new MetadataImportParams());
syncParams.setVersion(metadataVersion);
MetadataSyncSummary metadataSyncSummary = new MetadataSyncSummary();
importReport.setStatus(Status.WARNING);
metadataVersion.setType(VersionType.BEST_EFFORT);
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 MetadataSyncImportHandlerTest method testShouldReturnDefaultSummaryWhenImportStatusIsError.
@Test
public void testShouldReturnDefaultSummaryWhenImportStatusIsError() {
syncParams.setImportParams(new MetadataImportParams());
syncParams.setVersion(metadataVersion);
MetadataSyncSummary metadataSyncSummary = new MetadataSyncSummary();
metadataSyncSummary.setImportReport(new ImportReport());
metadataSyncSummary.setMetadataVersion(metadataVersion);
importReport.setStatus(Status.ERROR);
when(metadataImportService.importMetadata(syncParams.getImportParams())).thenReturn(importReport);
MetadataSyncSummary actualMetadataSyncSummary = metadataSyncImportHandler.importMetadata(syncParams, expectedMetadataSnapshot);
verify(metadataVersionDelegate, never()).addNewMetadataVersion(metadataVersion);
assertEquals(metadataSyncSummary.getImportReport().toString(), actualMetadataSyncSummary.getImportReport().toString());
assertEquals(metadataSyncSummary.getImportSummary(), actualMetadataSyncSummary.getImportSummary());
assertEquals(metadataSyncSummary.getMetadataVersion(), actualMetadataSyncSummary.getMetadataVersion());
}
use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class MetadataSyncImportHandlerTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
metadataVersion = new MetadataVersion("testVersion", VersionType.ATOMIC);
expectedMetadataSnapshot = "{\"date\":\"2016-05-24T05:27:25.128+0000\"}";
syncParams = new MetadataSyncParams();
importReport = new ImportReport();
}
use of org.hisp.dhis.dxf2.metadata.feedback.ImportReport in project dhis2-core by dhis2.
the class MetadataSyncPostProcessorTest method testShouldSendSuccessEmailIfSyncSummaryIsOk.
@Test
public void testShouldSendSuccessEmailIfSyncSummaryIsOk() throws Exception {
metadataSyncSummary.setImportReport(new ImportReport());
metadataSyncSummary.getImportReport().setStatus(Status.OK);
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 testShouldSendEmailToAdminWithProperSubjectAndBody.
@Test
public void testShouldSendEmailToAdminWithProperSubjectAndBody() throws Exception {
ImportReport importReport = mock(ImportReport.class);
when(importReport.getTypeReportMap()).thenReturn(new HashMap<>());
metadataSyncSummary.setImportReport(importReport);
metadataSyncSummary.getImportReport().setStatus(Status.OK);
metadataSyncSummary.setMetadataVersion(dataVersion);
MetadataRetryContext mockRetryContext = mock(MetadataRetryContext.class);
boolean status = metadataSyncPostProcessor.handleSyncNotificationsAndAbortStatus(metadataSyncSummary, mockRetryContext, dataVersion);
assertFalse(status);
}
Aggregations