use of org.hisp.dhis.organisationunit.OrganisationUnit in project dhis2-core by dhis2.
the class DataApprovalServiceTest method testMayUnapproveLowerLevels.
@Test
@Category(IntegrationTest.class)
public void testMayUnapproveLowerLevels() {
Set<OrganisationUnit> units = newHashSet(organisationUnitB);
CurrentUserService currentUserService = new MockCurrentUserService(units, null, DataApproval.AUTH_APPROVE_LOWER_LEVELS, AUTH_APPR_LEVEL);
userService.addUser(currentUserService.getCurrentUser());
setCurrentUserServiceDependencies(currentUserService);
Date date = new Date();
DataApproval dataApprovalA = new DataApproval(level1, workflow1234, periodA, organisationUnitA, defaultOptionCombo, NOT_ACCEPTED, date, userA);
DataApproval dataApprovalB = new DataApproval(level2, workflow1234, periodA, organisationUnitB, defaultOptionCombo, NOT_ACCEPTED, date, userA);
DataApproval dataApprovalC = new DataApproval(level3, workflow1234, periodA, organisationUnitC, defaultOptionCombo, NOT_ACCEPTED, date, userA);
DataApproval dataApprovalD = new DataApproval(level4, workflow1234, periodA, organisationUnitD, defaultOptionCombo, NOT_ACCEPTED, date, userA);
DataApproval dataApprovalE = new DataApproval(level3, workflow1234, periodA, organisationUnitE, defaultOptionCombo, NOT_ACCEPTED, date, userA);
DataApproval dataApprovalF = new DataApproval(level4, workflow1234, periodA, organisationUnitF, defaultOptionCombo, NOT_ACCEPTED, date, userA);
dataApprovalStore.addDataApproval(dataApprovalD);
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitA, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitB, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitC, defaultOptionCombo).getPermissions().isMayUnapprove());
assertTrue(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitD, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitE, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitF, defaultOptionCombo).getPermissions().isMayUnapprove());
dataApprovalStore.addDataApproval(dataApprovalF);
dataApprovalStore.addDataApproval(dataApprovalE);
dataApprovalStore.addDataApproval(dataApprovalC);
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitA, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitB, defaultOptionCombo).getPermissions().isMayUnapprove());
assertTrue(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitC, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitD, defaultOptionCombo).getPermissions().isMayUnapprove());
assertTrue(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitE, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitF, defaultOptionCombo).getPermissions().isMayUnapprove());
dataApprovalStore.addDataApproval(dataApprovalB);
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitA, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitB, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitC, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitD, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitE, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitF, defaultOptionCombo).getPermissions().isMayUnapprove());
dataApprovalStore.addDataApproval(dataApprovalA);
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitA, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitB, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitC, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitD, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitE, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitF, defaultOptionCombo).getPermissions().isMayUnapprove());
}
use of org.hisp.dhis.organisationunit.OrganisationUnit in project dhis2-core by dhis2.
the class DeletedObjectServiceTest method testDeleteDataElement.
@Test
public void testDeleteDataElement() {
DataElement dataElementA = createDataElement('A');
DataElement dataElementB = createDataElement('B');
DataElement dataElementC = createDataElement('C');
OrganisationUnit organisationUnitA = createOrganisationUnit('A');
OrganisationUnit organisationUnitB = createOrganisationUnit('B');
manager.save(dataElementA);
manager.save(dataElementB);
manager.save(dataElementC);
manager.save(organisationUnitA);
manager.save(organisationUnitB);
manager.delete(dataElementA);
manager.delete(dataElementB);
manager.delete(dataElementC);
manager.delete(organisationUnitA);
manager.delete(organisationUnitB);
// need to flush to make changes happen within the same tx
manager.flush();
assertEquals(5, deletedObjectService.countDeletedObjects());
assertEquals(3, deletedObjectService.getDeletedObjectsByKlass("DataElement").size());
assertEquals(2, deletedObjectService.getDeletedObjectsByKlass("OrganisationUnit").size());
}
use of org.hisp.dhis.organisationunit.OrganisationUnit in project dhis2-core by dhis2.
the class DataApprovalServiceTest method testGetDataApprovalStateAbove.
@Test
@Category(IntegrationTest.class)
public void testGetDataApprovalStateAbove() {
Set<OrganisationUnit> units = newHashSet(organisationUnitA);
CurrentUserService currentUserService = new MockCurrentUserService(units, null, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS);
userService.addUser(currentUserService.getCurrentUser());
setCurrentUserServiceDependencies(currentUserService);
Date date = new Date();
// Approved for organisation unit C
DataApproval dataApprovalC = new DataApproval(level3, workflow3, periodA, organisationUnitC, defaultOptionCombo, NOT_ACCEPTED, date, userA);
dataApprovalService.approveData(newArrayList(dataApprovalC));
assertEquals(DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus(workflow3, periodA, organisationUnitC, defaultOptionCombo).getState());
assertEquals(DataApprovalState.APPROVED_ABOVE, dataApprovalService.getDataApprovalStatus(workflow3, periodA, organisationUnitD, defaultOptionCombo).getState());
}
use of org.hisp.dhis.organisationunit.OrganisationUnit in project dhis2-core by dhis2.
the class DataApprovalServiceTest method testMayUnapproveSameLevel.
@Test
@Category(IntegrationTest.class)
public void testMayUnapproveSameLevel() {
Set<OrganisationUnit> units = newHashSet(organisationUnitB);
CurrentUserService currentUserService = new MockCurrentUserService(units, null, DataApproval.AUTH_APPROVE, AUTH_APPR_LEVEL);
userService.addUser(currentUserService.getCurrentUser());
setCurrentUserServiceDependencies(currentUserService);
Date date = new Date();
DataApproval dataApprovalA = new DataApproval(level1, workflow1234, periodA, organisationUnitA, defaultOptionCombo, NOT_ACCEPTED, date, userA);
DataApproval dataApprovalB = new DataApproval(level2, workflow1234, periodA, organisationUnitB, defaultOptionCombo, NOT_ACCEPTED, date, userA);
DataApproval dataApprovalC = new DataApproval(level3, workflow1234, periodA, organisationUnitC, defaultOptionCombo, NOT_ACCEPTED, date, userA);
DataApproval dataApprovalD = new DataApproval(level4, workflow1234, periodA, organisationUnitD, defaultOptionCombo, NOT_ACCEPTED, date, userA);
DataApproval dataApprovalE = new DataApproval(level3, workflow1234, periodA, organisationUnitE, defaultOptionCombo, NOT_ACCEPTED, date, userA);
DataApproval dataApprovalF = new DataApproval(level4, workflow1234, periodA, organisationUnitF, defaultOptionCombo, NOT_ACCEPTED, date, userA);
dataApprovalStore.addDataApproval(dataApprovalD);
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitA, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitB, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitC, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitD, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitE, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitF, defaultOptionCombo).getPermissions().isMayUnapprove());
dataApprovalStore.addDataApproval(dataApprovalF);
dataApprovalStore.addDataApproval(dataApprovalE);
dataApprovalStore.addDataApproval(dataApprovalC);
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitA, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitB, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitC, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitD, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitE, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitF, defaultOptionCombo).getPermissions().isMayUnapprove());
dataApprovalStore.addDataApproval(dataApprovalB);
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitA, defaultOptionCombo).getPermissions().isMayUnapprove());
assertTrue(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitB, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitC, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitD, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitE, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitF, defaultOptionCombo).getPermissions().isMayUnapprove());
dataApprovalStore.addDataApproval(dataApprovalA);
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitA, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitB, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitC, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitD, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitE, defaultOptionCombo).getPermissions().isMayUnapprove());
assertFalse(dataApprovalService.getDataApprovalStatusAndPermissions(workflow1234, periodA, organisationUnitF, defaultOptionCombo).getPermissions().isMayUnapprove());
}
use of org.hisp.dhis.organisationunit.OrganisationUnit in project dhis2-core by dhis2.
the class MergeServiceTest method mergeOrgUnitGroupSet.
@Test
public void mergeOrgUnitGroupSet() {
OrganisationUnit organisationUnitA = createOrganisationUnit('A');
OrganisationUnit organisationUnitB = createOrganisationUnit('B');
OrganisationUnit organisationUnitC = createOrganisationUnit('C');
OrganisationUnit organisationUnitD = createOrganisationUnit('D');
OrganisationUnitGroup organisationUnitGroupA = createOrganisationUnitGroup('A');
organisationUnitGroupA.getMembers().add(organisationUnitA);
organisationUnitGroupA.getMembers().add(organisationUnitB);
organisationUnitGroupA.getMembers().add(organisationUnitC);
organisationUnitGroupA.getMembers().add(organisationUnitD);
OrganisationUnitGroupSet organisationUnitGroupSetA = createOrganisationUnitGroupSet('A');
OrganisationUnitGroupSet organisationUnitGroupSetB = createOrganisationUnitGroupSet('B');
organisationUnitGroupSetA.addOrganisationUnitGroup(organisationUnitGroupA);
mergeService.merge(new MergeParams<>(organisationUnitGroupSetA, organisationUnitGroupSetB).setMergeMode(MergeMode.REPLACE));
assertFalse(organisationUnitGroupSetB.getOrganisationUnitGroups().isEmpty());
assertEquals(organisationUnitGroupSetA.getName(), organisationUnitGroupSetB.getName());
assertEquals(organisationUnitGroupSetA.getDescription(), organisationUnitGroupSetB.getDescription());
assertEquals(organisationUnitGroupSetA.isCompulsory(), organisationUnitGroupSetB.isCompulsory());
assertEquals(organisationUnitGroupSetA.isIncludeSubhierarchyInAnalytics(), organisationUnitGroupSetB.isIncludeSubhierarchyInAnalytics());
assertEquals(1, organisationUnitGroupSetB.getOrganisationUnitGroups().size());
}
Aggregations