Search in sources :

Example 1 with OrgUnitSplitRequest

use of org.hisp.dhis.split.orgunit.OrgUnitSplitRequest in project dhis2-core by dhis2.

the class MetadataOrgUnitSplitHandlerTest method testSplitDataSets.

@Test
void testSplitDataSets() {
    DataSet dsA = createDataSet('A');
    dsA.addOrganisationUnit(ouA);
    DataSet dsB = createDataSet('B');
    dsB.addOrganisationUnit(ouA);
    OrgUnitSplitRequest request = new OrgUnitSplitRequest.Builder().withSource(ouA).addTarget(ouB).addTarget(ouC).withPrimaryTarget(ouB).build();
    assertEquals(2, ouA.getDataSets().size());
    assertEquals(0, ouB.getDataSets().size());
    assertEquals(0, ouC.getDataSets().size());
    handler.splitDataSets(request);
    assertEquals(0, ouA.getDataSets().size());
    assertEquals(2, ouB.getDataSets().size());
    assertEquals(2, ouC.getDataSets().size());
}
Also used : DataSet(org.hisp.dhis.dataset.DataSet) DhisConvenienceTest.createDataSet(org.hisp.dhis.DhisConvenienceTest.createDataSet) OrgUnitSplitRequest(org.hisp.dhis.split.orgunit.OrgUnitSplitRequest) Test(org.junit.jupiter.api.Test)

Example 2 with OrgUnitSplitRequest

use of org.hisp.dhis.split.orgunit.OrgUnitSplitRequest in project dhis2-core by dhis2.

the class DataOrgUnitSplitHandlerTest method testMergeDataApprovals.

@Test
void testMergeDataApprovals() {
    addDataApprovals(new DataApproval(dlA, dwA, peA, ouA, cocA, false, date(2021, 1, 1), usA), new DataApproval(dlA, dwA, peB, ouA, cocA, false, date(2021, 3, 1), usA));
    assertEquals(2, getDataApprovalCount(ouA));
    assertEquals(0, getDataApprovalCount(ouB));
    assertEquals(0, getDataApprovalCount(ouC));
    OrgUnitSplitRequest request = new OrgUnitSplitRequest.Builder().withSource(ouA).addTarget(ouB).addTarget(ouC).withPrimaryTarget(ouB).build();
    handler.splitData(request);
    assertEquals(0, getDataApprovalCount(ouA));
    assertEquals(2, getDataApprovalCount(ouB));
    assertEquals(0, getDataApprovalCount(ouC));
}
Also used : DataApproval(org.hisp.dhis.dataapproval.DataApproval) OrgUnitSplitRequest(org.hisp.dhis.split.orgunit.OrgUnitSplitRequest) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 3 with OrgUnitSplitRequest

use of org.hisp.dhis.split.orgunit.OrgUnitSplitRequest in project dhis2-core by dhis2.

the class AnalyticalObjectOrgUnitSplitHandlerTest method testSplitVisualizations.

@Test
void testSplitVisualizations() {
    Visualization vA = createVisualization('A');
    vA.addDataDimensionItem(deA);
    vA.getOrganisationUnits().add(ouA);
    Visualization vB = createVisualization('B');
    vB.addDataDimensionItem(deA);
    vB.getOrganisationUnits().add(ouA);
    idObjectManager.save(vA);
    idObjectManager.save(vB);
    assertEquals(2, getVisualizationCount(ouA));
    assertEquals(0, getVisualizationCount(ouB));
    assertEquals(0, getVisualizationCount(ouC));
    OrgUnitSplitRequest request = new OrgUnitSplitRequest.Builder().withSource(ouA).addTarget(ouB).addTarget(ouC).withPrimaryTarget(ouB).build();
    handler.splitAnalyticalObjects(request);
    idObjectManager.update(ouC);
    assertEquals(0, getVisualizationCount(ouA));
    assertEquals(2, getVisualizationCount(ouB));
    assertEquals(2, getVisualizationCount(ouC));
}
Also used : Visualization(org.hisp.dhis.visualization.Visualization) OrgUnitSplitRequest(org.hisp.dhis.split.orgunit.OrgUnitSplitRequest) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 4 with OrgUnitSplitRequest

use of org.hisp.dhis.split.orgunit.OrgUnitSplitRequest in project dhis2-core by dhis2.

the class MetadataOrgUnitSplitHandlerTest method testSplitPrograms.

@Test
void testSplitPrograms() {
    Program prA = createProgram('A');
    prA.addOrganisationUnit(ouA);
    Program prB = createProgram('B');
    prB.addOrganisationUnit(ouA);
    OrgUnitSplitRequest request = new OrgUnitSplitRequest.Builder().withSource(ouA).addTarget(ouB).addTarget(ouC).withPrimaryTarget(ouB).build();
    assertEquals(2, ouA.getPrograms().size());
    assertEquals(0, ouB.getPrograms().size());
    assertEquals(0, ouC.getPrograms().size());
    handler.splitPrograms(request);
    assertEquals(0, ouA.getPrograms().size());
    assertEquals(2, ouB.getPrograms().size());
    assertEquals(2, ouC.getPrograms().size());
}
Also used : Program(org.hisp.dhis.program.Program) DhisConvenienceTest.createProgram(org.hisp.dhis.DhisConvenienceTest.createProgram) OrgUnitSplitRequest(org.hisp.dhis.split.orgunit.OrgUnitSplitRequest) Test(org.junit.jupiter.api.Test)

Example 5 with OrgUnitSplitRequest

use of org.hisp.dhis.split.orgunit.OrgUnitSplitRequest in project dhis2-core by dhis2.

the class DataOrgUnitSplitHandlerTest method testMergeDataValues.

@Test
void testMergeDataValues() {
    addDataValues(createDataValue(deA, peA, ouA, cocA, cocA, "10", date(2021, 1, 1), date(2021, 1, 1)), createDataValue(deA, peB, ouA, cocA, cocA, "11", date(2021, 2, 1), date(2021, 2, 1)));
    assertEquals(2, getDataValueCount(ouA));
    assertEquals(0, getDataValueCount(ouB));
    assertEquals(0, getDataValueCount(ouC));
    OrgUnitSplitRequest request = new OrgUnitSplitRequest.Builder().withSource(ouA).addTarget(ouB).addTarget(ouC).withPrimaryTarget(ouB).build();
    handler.splitData(request);
    assertEquals(0, getDataValueCount(ouA));
    assertEquals(2, getDataValueCount(ouB));
    assertEquals(0, getDataValueCount(ouC));
}
Also used : OrgUnitSplitRequest(org.hisp.dhis.split.orgunit.OrgUnitSplitRequest) Test(org.junit.jupiter.api.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Aggregations

OrgUnitSplitRequest (org.hisp.dhis.split.orgunit.OrgUnitSplitRequest)5 Test (org.junit.jupiter.api.Test)5 DhisSpringTest (org.hisp.dhis.DhisSpringTest)3 DhisConvenienceTest.createDataSet (org.hisp.dhis.DhisConvenienceTest.createDataSet)1 DhisConvenienceTest.createProgram (org.hisp.dhis.DhisConvenienceTest.createProgram)1 DataApproval (org.hisp.dhis.dataapproval.DataApproval)1 DataSet (org.hisp.dhis.dataset.DataSet)1 Program (org.hisp.dhis.program.Program)1 Visualization (org.hisp.dhis.visualization.Visualization)1