use of org.hisp.dhis.merge.orgunit.OrgUnitMergeRequest in project dhis2-core by dhis2.
the class DataOrgUnitMergeHandlerTest method testMergeDataValues.
@Test
void testMergeDataValues() {
addDataValues(createDataValue(deA, peA, ouA, cocA, cocA, "10", date(2021, 1, 1), date(2021, 1, 1)), createDataValue(deA, peA, ouB, cocA, cocA, "11", date(2021, 2, 1), date(2021, 2, 1)), createDataValue(deB, peA, ouA, cocA, cocA, "12", date(2021, 3, 1), date(2021, 3, 1)), createDataValue(deB, peA, ouB, cocA, cocA, "13", date(2021, 4, 1), date(2021, 4, 1)));
assertEquals(2, getDataValueCount(ouA));
assertEquals(2, getDataValueCount(ouB));
assertEquals(0, getDataValueCount(ouC));
OrgUnitMergeRequest request = new OrgUnitMergeRequest.Builder().addSource(ouA).addSource(ouB).withTarget(ouC).withDataValueMergeStrategy(DataMergeStrategy.LAST_UPDATED).build();
handler.mergeDataValues(request);
assertEquals(0, getDataValueCount(ouA));
assertEquals(0, getDataValueCount(ouB));
assertEquals(2, getDataValueCount(ouC));
}
use of org.hisp.dhis.merge.orgunit.OrgUnitMergeRequest in project dhis2-core by dhis2.
the class MetadataOrgUnitMergeHandlerTest method testMergePrograms.
@Test
void testMergePrograms() {
Program prA = createProgram('A');
prA.addOrganisationUnit(ouA);
prA.addOrganisationUnit(ouB);
Program prB = createProgram('B');
prB.addOrganisationUnit(ouA);
OrgUnitMergeRequest request = new OrgUnitMergeRequest.Builder().addSource(ouA).addSource(ouB).withTarget(ouC).build();
assertEquals(2, ouA.getPrograms().size());
assertEquals(1, ouB.getPrograms().size());
assertEquals(0, ouC.getPrograms().size());
handler.mergePrograms(request);
assertEquals(0, ouA.getPrograms().size());
assertEquals(0, ouB.getPrograms().size());
assertEquals(2, ouC.getPrograms().size());
}
use of org.hisp.dhis.merge.orgunit.OrgUnitMergeRequest in project dhis2-core by dhis2.
the class MetadataOrgUnitMergeHandlerTest method testMergeDataSets.
@Test
void testMergeDataSets() {
DataSet dsA = createDataSet('A');
dsA.addOrganisationUnit(ouA);
dsA.addOrganisationUnit(ouB);
DataSet dsB = createDataSet('B');
dsB.addOrganisationUnit(ouA);
OrgUnitMergeRequest request = new OrgUnitMergeRequest.Builder().addSource(ouA).addSource(ouB).withTarget(ouC).build();
assertEquals(2, ouA.getDataSets().size());
assertEquals(1, ouB.getDataSets().size());
assertEquals(0, ouC.getDataSets().size());
handler.mergeDataSets(request);
assertEquals(0, ouA.getDataSets().size());
assertEquals(0, ouB.getDataSets().size());
assertEquals(2, ouC.getDataSets().size());
}
use of org.hisp.dhis.merge.orgunit.OrgUnitMergeRequest in project dhis2-core by dhis2.
the class TrackerOrgUnitMergeHandlerTest method testMigrateProgramInstances.
@Test
void testMigrateProgramInstances() {
assertEquals(2, getProgramInstanceCount(ouA));
assertEquals(1, getProgramInstanceCount(ouB));
assertEquals(0, getProgramInstanceCount(ouC));
OrgUnitMergeRequest request = new OrgUnitMergeRequest.Builder().addSource(ouA).addSource(ouB).withTarget(ouC).build();
mergeHandler.mergeProgramInstances(request);
assertEquals(0, getProgramInstanceCount(ouA));
assertEquals(0, getProgramInstanceCount(ouB));
assertEquals(3, getProgramInstanceCount(ouC));
}
use of org.hisp.dhis.merge.orgunit.OrgUnitMergeRequest in project dhis2-core by dhis2.
the class AnalyticalObjectOrgUnitMergeHandlerTest method testMergeVisualizations.
@Test
void testMergeVisualizations() {
Visualization vA = createVisualization('A');
vA.addDataDimensionItem(deA);
vA.getOrganisationUnits().add(ouA);
vA.getOrganisationUnits().add(ouB);
Visualization vB = createVisualization('B');
vB.addDataDimensionItem(deA);
vB.getOrganisationUnits().add(ouA);
vB.getOrganisationUnits().add(ouB);
idObjectManager.save(vA);
idObjectManager.save(vB);
assertEquals(2, getVisualizationCount(ouA));
assertEquals(2, getVisualizationCount(ouB));
assertEquals(0, getVisualizationCount(ouC));
OrgUnitMergeRequest request = new OrgUnitMergeRequest.Builder().addSource(ouA).addSource(ouB).withTarget(ouC).build();
handler.mergeAnalyticalObjects(request);
idObjectManager.update(ouC);
assertEquals(0, getVisualizationCount(ouA));
assertEquals(0, getVisualizationCount(ouB));
assertEquals(2, getVisualizationCount(ouC));
}
Aggregations