Search in sources :

Example 21 with MetadataSyncSummary

use of org.hisp.dhis.dxf2.metadata.sync.MetadataSyncSummary in project dhis2-core by dhis2.

the class MetadataSyncImportHandlerTest method testShouldReturnDefaultSummaryWhenImportStatusIsError.

@Test
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());
}
Also used : MetadataImportParams(org.hisp.dhis.dxf2.metadata.MetadataImportParams) ImportReport(org.hisp.dhis.dxf2.metadata.feedback.ImportReport) Test(org.junit.jupiter.api.Test)

Example 22 with MetadataSyncSummary

use of org.hisp.dhis.dxf2.metadata.sync.MetadataSyncSummary in project dhis2-core by dhis2.

the class MetadataSyncPostProcessorTest method testShouldSendSuccessEmailIfSyncSummaryIsOk.

@Test
void testShouldSendSuccessEmailIfSyncSummaryIsOk() {
    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);
}
Also used : ImportReport(org.hisp.dhis.dxf2.metadata.feedback.ImportReport) MetadataRetryContext(org.hisp.dhis.dxf2.metadata.jobs.MetadataRetryContext) Test(org.junit.jupiter.api.Test)

Example 23 with MetadataSyncSummary

use of org.hisp.dhis.dxf2.metadata.sync.MetadataSyncSummary in project dhis2-core by dhis2.

the class MetadataSyncPostProcessorTest method testShouldSendEmailToAdminWithProperSubjectAndBody.

@Test
void testShouldSendEmailToAdminWithProperSubjectAndBody() {
    ImportReport importReport = mock(ImportReport.class);
    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);
}
Also used : ImportReport(org.hisp.dhis.dxf2.metadata.feedback.ImportReport) MetadataRetryContext(org.hisp.dhis.dxf2.metadata.jobs.MetadataRetryContext) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)11 ImportReport (org.hisp.dhis.dxf2.metadata.feedback.ImportReport)10 MetadataImportParams (org.hisp.dhis.dxf2.metadata.MetadataImportParams)9 MetadataSyncSummary (org.hisp.dhis.dxf2.metadata.sync.MetadataSyncSummary)9 MetadataSyncParams (org.hisp.dhis.dxf2.metadata.sync.MetadataSyncParams)7 MetadataSyncServiceException (org.hisp.dhis.dxf2.metadata.sync.exception.MetadataSyncServiceException)6 DhisSpringTest (org.hisp.dhis.DhisSpringTest)5 MetadataVersion (org.hisp.dhis.metadata.version.MetadataVersion)5 MetadataRetryContext (org.hisp.dhis.dxf2.metadata.jobs.MetadataRetryContext)4 DhisVersionMismatchException (org.hisp.dhis.dxf2.metadata.sync.exception.DhisVersionMismatchException)4 Test (org.junit.Test)3 MetadataSyncImportException (org.hisp.dhis.dxf2.metadata.sync.exception.MetadataSyncImportException)2 IOException (java.io.IOException)1 List (java.util.List)1 IntegrationTest (org.hisp.dhis.IntegrationTest)1 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)1 RemoteServerUnavailableException (org.hisp.dhis.dxf2.metadata.sync.exception.RemoteServerUnavailableException)1 MetadataVersionServiceException (org.hisp.dhis.dxf2.metadata.version.exception.MetadataVersionServiceException)1 Email (org.hisp.dhis.email.Email)1 Stats (org.hisp.dhis.feedback.Stats)1