use of org.hisp.dhis.dxf2.metadata.sync.MetadataSyncSummary 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.sync.MetadataSyncSummary 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.sync.MetadataSyncSummary in project dhis2-core by dhis2.
the class MetadataSyncTaskTest method testHandleMetadataSyncIsThrowingException.
@Test(expected = MetadataSyncServiceException.class)
public void testHandleMetadataSyncIsThrowingException() throws Exception {
when(metadataSyncService.doMetadataSync(any(MetadataSyncParams.class))).thenThrow(new MetadataSyncServiceException(""));
when(metadataSyncPreProcessor.handleCurrentMetadataVersion(metadataRetryContext)).thenReturn(metadataVersion);
when(metadataSyncPreProcessor.handleMetadataVersionsList(metadataRetryContext, metadataVersion)).thenReturn(metadataVersions);
doNothing().when(metadataRetryContext).updateRetryContext(any(String.class), any(String.class), eq(metadataVersion));
when(metadataSyncService.isSyncRequired(any(MetadataSyncParams.class))).thenReturn(true);
metadataSyncTask.runSyncTask(metadataRetryContext);
verify(metadataSyncPreProcessor).setUp(metadataRetryContext);
verify(metadataSyncPreProcessor).handleAggregateDataPush(metadataRetryContext);
verify(metadataSyncPreProcessor).handleEventDataPush(metadataRetryContext);
verify(metadataSyncPreProcessor).handleCurrentMetadataVersion(metadataRetryContext);
verify(metadataSyncPreProcessor).handleMetadataVersionsList(metadataRetryContext, metadataVersion);
verify(metadataSyncService).doMetadataSync(any(MetadataSyncParams.class));
verify(metadataSyncPostProcessor, never()).handleSyncNotificationsAndAbortStatus(metadataSyncSummary, metadataRetryContext, metadataVersion);
}
use of org.hisp.dhis.dxf2.metadata.sync.MetadataSyncSummary in project dhis2-core by dhis2.
the class MetadataRetryContextTest method testIfSummaryIsNull.
@Test
public void testIfSummaryIsNull() throws Exception {
MetadataSyncSummary metadataSyncSummary = mock(MetadataSyncSummary.class);
metadataRetryContext.updateRetryContext(testKey, testMessage, mockVersion, null);
verify(retryContext).setAttribute(testKey, testMessage);
verify(metadataSyncSummary, never()).getImportReport();
}
use of org.hisp.dhis.dxf2.metadata.sync.MetadataSyncSummary 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());
}
Aggregations