dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #29691
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15035: Test fixes in dhis-service core
------------------------------------------------------------
revno: 15035
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-04-28 00:31:59 +0200
message:
Test fixes in dhis-service core
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodStoreTest.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2014-04-27 21:28:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2014-04-27 22:31:59 +0000
@@ -61,6 +61,15 @@
int addOrganisationUnit( OrganisationUnit organisationUnit );
/**
+ * Adds an OrganisationUnit to the hierarchy.
+ *
+ * @param organisationUnit the OrganisationUnit to add.
+ * @param indicates whether to update hierarchy version.
+ * @return a generated unique id of the added OrganisationUnit.
+ */
+ int addOrganisationUnit( OrganisationUnit organisationUnit, boolean updateVersion );
+
+ /**
* Updates an OrganisationUnit.
*
* @param organisationUnit the OrganisationUnit to update.
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2014-04-18 07:35:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2014-04-27 22:31:59 +0000
@@ -114,6 +114,12 @@
@Override
public int addOrganisationUnit( OrganisationUnit organisationUnit )
{
+ return addOrganisationUnit( organisationUnit, true );
+ }
+
+ @Override
+ public int addOrganisationUnit( OrganisationUnit organisationUnit, boolean updateVersion )
+ {
int id = organisationUnitStore.save( organisationUnit );
if ( organisationUnit.getParent() == null && currentUserService.getCurrentUser() != null )
@@ -123,8 +129,11 @@
currentUserService.getCurrentUser().getOrganisationUnits().add( organisationUnit );
}
- versionService.updateVersion( VersionService.ORGANISATIONUNIT_VERSION );
-
+ if ( updateVersion )
+ {
+ versionService.updateVersion( VersionService.ORGANISATIONUNIT_VERSION );
+ }
+
return id;
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java 2014-04-25 10:26:12 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalLevelServiceTest.java 2014-04-27 22:31:59 +0000
@@ -52,7 +52,6 @@
public class DataApprovalLevelServiceTest
extends DhisSpringTest
{
-
@Autowired
private DataApprovalLevelService dataApprovalLevelService;
@@ -190,10 +189,10 @@
organisationUnitJ = createOrganisationUnit( 'J', organisationUnitI );
organisationUnitK = createOrganisationUnit( 'K', organisationUnitJ );
- organisationUnitService.addOrganisationUnit( organisationUnitA );
- organisationUnitService.addOrganisationUnit( organisationUnitB );
- organisationUnitService.addOrganisationUnit( organisationUnitC );
- organisationUnitService.addOrganisationUnit( organisationUnitD );
+ organisationUnitService.addOrganisationUnit( organisationUnitA, false );
+ organisationUnitService.addOrganisationUnit( organisationUnitB, false );
+ organisationUnitService.addOrganisationUnit( organisationUnitC, false );
+ organisationUnitService.addOrganisationUnit( organisationUnitD, false );
}
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodStoreTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodStoreTest.java 2014-03-24 22:27:13 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/period/PeriodStoreTest.java 2014-04-27 22:31:59 +0000
@@ -630,40 +630,6 @@
// -------------------------------------------------------------------------
@Test
- public void testAddPeriodType()
- throws Exception
- {
- Collection<PeriodType> periodTypes = periodStore.getAllPeriodTypes();
- Iterator<PeriodType> it = periodTypes.iterator();
- PeriodType refA = it.next();
- PeriodType refB = it.next();
- PeriodType refC = it.next();
-
- periodStore.deletePeriodType( refA );
- periodStore.deletePeriodType( refB );
- periodStore.deletePeriodType( refC );
-
- int idA = periodStore.addPeriodType( refA );
- int idB = periodStore.addPeriodType( refB );
- int idC = periodStore.addPeriodType( refC );
-
- PeriodType periodTypeA = periodStore.getPeriodType( idA );
- assertNotNull( periodTypeA );
- assertEquals( idA, periodTypeA.getId() );
- assertEquals( refA.getName(), periodTypeA.getName() );
-
- PeriodType periodTypeB = periodStore.getPeriodType( idB );
- assertNotNull( periodTypeB );
- assertEquals( idB, periodTypeB.getId() );
- assertEquals( refB.getName(), periodTypeB.getName() );
-
- PeriodType periodTypeC = periodStore.getPeriodType( idC );
- assertNotNull( periodTypeC );
- assertEquals( idC, periodTypeC.getId() );
- assertEquals( refC.getName(), periodTypeC.getName() );
- }
-
- @Test
public void testDeleteAndGetPeriodType()
throws Exception
{