use of org.hisp.dhis.dxf2.metadata.tasks.MetadataRetryContext in project dhis2-core by dhis2.
the class MetadataSyncPreProcessorTest method testHandleEventDataPushShouldThrowExceptionWhenEventDataPushIsUnsuccessful.
@Test(expected = MetadataSyncServiceException.class)
public void testHandleEventDataPushShouldThrowExceptionWhenEventDataPushIsUnsuccessful() throws Exception {
MetadataRetryContext mockRetryContext = mock(MetadataRetryContext.class);
ImportSummaries expectedSummary = new ImportSummaries();
ImportSummary summary = new ImportSummary();
summary.setStatus(ImportStatus.ERROR);
expectedSummary.addImportSummary(summary);
AvailabilityStatus availabilityStatus = new AvailabilityStatus(true, "test_message", null);
when(synchronizationManager.isRemoteServerAvailable()).thenReturn(availabilityStatus);
when(metadataSyncPreProcessor.handleEventDataPush(mockRetryContext)).thenReturn(expectedSummary);
ImportSummaries actualSummary = metadataSyncPreProcessor.handleEventDataPush(mockRetryContext);
assertEquals(expectedSummary.getImportSummaries().get(0).getStatus(), actualSummary.getImportSummaries().get(0).getStatus());
}
use of org.hisp.dhis.dxf2.metadata.tasks.MetadataRetryContext in project dhis2-core by dhis2.
the class MetadataSyncPreProcessorTest method testHandleCurrentMetadataVersionShouldReturnCurrentVersionOfSystem.
@Test
public void testHandleCurrentMetadataVersionShouldReturnCurrentVersionOfSystem() throws Exception {
MetadataRetryContext mockRetryContext = mock(MetadataRetryContext.class);
MetadataVersion currentVersion = new MetadataVersion();
currentVersion.setType(VersionType.BEST_EFFORT);
currentVersion.setName("test_version");
currentVersion.setCreated(new Date());
currentVersion.setHashCode("samplehashcode");
when(metadataVersionService.getCurrentVersion()).thenReturn(currentVersion);
MetadataVersion actualVersion = metadataSyncPreProcessor.handleCurrentMetadataVersion(mockRetryContext);
assertEquals(currentVersion, actualVersion);
}
Aggregations