dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16060
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5996: Added test
------------------------------------------------------------
revno: 5996
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2012-02-16 19:48:14 +0100
message:
Added test
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLockExceptionStore.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetServiceTest.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-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLockExceptionStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLockExceptionStore.java 2012-02-16 18:13:44 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLockExceptionStore.java 2012-02-16 18:48:14 +0000
@@ -95,7 +95,7 @@
@Override
public Collection<LockException> getCombinations()
- {
+ {
final String sql = "SELECT DISTINCT datasetid, periodid FROM LockException";
final Collection<LockException> lockExceptions = new ArrayList<LockException>();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetServiceTest.java 2012-02-16 17:57:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataset/DataSetServiceTest.java 2012-02-16 18:48:14 +0000
@@ -308,7 +308,7 @@
}
@Test
- public void testIsLocked()
+ public void testIsLockedDataElement()
{
OrganisationUnit unit = createOrganisationUnit( 'A' );
Period period = createPeriod( periodType, getDate( 2000, 3, 1 ), getDate( 2000, 3, 31 ) );
@@ -353,5 +353,46 @@
assertFalse( dataSetService.isLocked( dataElementA, period, unit, getDate( 2000, 4, 15 ) ) );
assertFalse( dataSetService.isLocked( dataElementA, period, unit, getDate( 2000, 4, 25 ) ) );
assertFalse( dataSetService.isLocked( dataElementB, period, unit, getDate( 2000, 4, 25 ) ) );
- }
+ }
+
+ @Test
+ public void testIsLockedDataSet()
+ {
+ OrganisationUnit unit = createOrganisationUnit( 'A' );
+ Period period = createPeriod( periodType, getDate( 2000, 3, 1 ), getDate( 2000, 3, 31 ) );
+ DataSet dataSetA = createDataSet( 'A', periodType );
+ DataSet dataSetB = createDataSet( 'B', periodType );
+ dataSetA.setExpiryDays( 10 );
+ dataSetB.setExpiryDays( 15 );
+
+ organisationUnitService.addOrganisationUnit( unit );
+ periodService.addPeriod( period );
+ dataSetService.addDataSet( dataSetA );
+ dataSetService.addDataSet( dataSetB );
+
+ // ---------------------------------------------------------------------
+ // Expiry days
+ // ---------------------------------------------------------------------
+
+ assertFalse( dataSetService.isLocked( dataSetA, period, unit, getDate( 2000, 4, 1 ) ) );
+ assertFalse( dataSetService.isLocked( dataSetA, period, unit, getDate( 2000, 4, 5 ) ) );
+ assertTrue( dataSetService.isLocked( dataSetA, period, unit, getDate( 2000, 4, 15 ) ) );
+ assertTrue( dataSetService.isLocked( dataSetA, period, unit, getDate( 2000, 4, 25 ) ) );
+ assertFalse( dataSetService.isLocked( dataSetB, period, unit, getDate( 2000, 4, 10 ) ) );
+ assertTrue( dataSetService.isLocked( dataSetB, period, unit, getDate( 2000, 4, 25 ) ) );
+
+ // ---------------------------------------------------------------------
+ // Lock exception
+ // ---------------------------------------------------------------------
+
+ LockException lockException = new LockException( period, unit, dataSetA );
+ dataSetService.addLockException( lockException );
+
+ assertFalse( dataSetService.isLocked( dataSetA, period, unit, getDate( 2000, 4, 1 ) ) );
+ assertFalse( dataSetService.isLocked( dataSetA, period, unit, getDate( 2000, 4, 5 ) ) );
+ assertFalse( dataSetService.isLocked( dataSetA, period, unit, getDate( 2000, 4, 15 ) ) );
+ assertFalse( dataSetService.isLocked( dataSetA, period, unit, getDate( 2000, 4, 25 ) ) );
+ assertFalse( dataSetService.isLocked( dataSetB, period, unit, getDate( 2000, 4, 10 ) ) );
+ assertTrue( dataSetService.isLocked( dataSetB, period, unit, getDate( 2000, 4, 25 ) ) );
+ }
}