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());
}
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));
}
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));
}
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());
}
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));
}
Aggregations