dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37674
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19234: CollectionUtils, removed obsolete methods
------------------------------------------------------------
revno: 19234
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-06-02 01:57:56 +0200
message:
CollectionUtils, removed obsolete methods
modified:
dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventAnalyticsServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java
dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/util/CollectionUtils.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-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventAnalyticsServiceTest.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventAnalyticsServiceTest.java 2015-05-28 15:04:54 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/test/java/org/hisp/dhis/analytics/event/data/EventAnalyticsServiceTest.java 2015-06-01 23:57:56 +0000
@@ -28,7 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.util.CollectionUtils.asSet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -71,6 +70,8 @@
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import com.google.common.collect.Sets;
+
/**
* @author Lars Helge Overland
*/
@@ -145,7 +146,7 @@
attributeService.addTrackedEntityAttribute( atA );
attributeService.addTrackedEntityAttribute( atB );
- prA = createProgram( 'A', new HashSet<ProgramStage>(), asSet( atA, atB ), asSet( ouA, ouB ) );
+ prA = createProgram( 'A', new HashSet<ProgramStage>(), Sets.newHashSet( atA, atB ), Sets.newHashSet( ouA, ouB ) );
programService.addProgram( prA );
psA = createProgramStage( 'A', 0 );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java 2015-05-28 14:33:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java 2015-06-01 23:57:56 +0000
@@ -51,10 +51,11 @@
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.setting.SystemSettingManager;
-import org.hisp.dhis.util.CollectionUtils;
import org.hisp.dhis.user.CurrentUserService;
import org.springframework.transaction.annotation.Transactional;
+import com.google.common.collect.Sets;
+
/**
* @author Jim Grace
*/
@@ -362,7 +363,7 @@
+ organisationUnit.getName() + ", "
+ ( attributeOptionCombo == null ? "(null)" : attributeOptionCombo.getName() ) + " )" );
- List<DataApprovalStatus> statuses = dataApprovalStore.getDataApprovals( CollectionUtils.asSet( dataSet ),
+ List<DataApprovalStatus> statuses = dataApprovalStore.getDataApprovals( Sets.newHashSet( dataSet ),
periodService.reloadPeriod( period ), organisationUnit, attributeOptionCombo );
if ( statuses != null && !statuses.isEmpty() )
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java 2015-05-28 14:33:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java 2015-06-01 23:57:56 +0000
@@ -36,7 +36,6 @@
import static org.hisp.dhis.dataapproval.DataApprovalState.UNAPPROVED_READY;
import static org.hisp.dhis.dataapproval.DataApprovalState.UNAPPROVED_WAITING;
import static org.hisp.dhis.setting.SystemSettingManager.KEY_ACCEPTANCE_REQUIRED_FOR_APPROVAL;
-import static org.hisp.dhis.util.CollectionUtils.asList;
import static org.hisp.dhis.util.ConversionUtils.getIdentifiers;
import static org.hisp.dhis.util.TextUtils.getCommaDelimitedString;
@@ -80,6 +79,8 @@
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.rowset.SqlRowSet;
+import com.google.inject.internal.Lists;
+
/**
* @author Jim Grace
*/
@@ -218,7 +219,7 @@
if ( period.getPeriodType().equals( dataSetPeriodType ) )
{
- periods = asList( period );
+ periods = Lists.newArrayList( period );
}
else if ( period.getPeriodType().getFrequencyOrder() > dataSetPeriodType.getFrequencyOrder() )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java 2015-05-28 14:33:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceCategoryOptionGroupTest.java 2015-06-01 23:57:56 +0000
@@ -30,7 +30,6 @@
import static org.hisp.dhis.setting.SystemSettingManager.KEY_ACCEPTANCE_REQUIRED_FOR_APPROVAL;
import static org.hisp.dhis.setting.SystemSettingManager.KEY_HIDE_UNAPPROVED_DATA_IN_ANALYTICS;
-import static org.hisp.dhis.util.CollectionUtils.asSet;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -78,6 +77,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
+import com.google.common.collect.Sets;
+
/**
* @author Jim Grace
*/
@@ -208,7 +209,7 @@
private CurrentUserService getMockCurrentUserService( String userName, boolean superUserFlag, OrganisationUnit orgUnit, String... auths )
{
- CurrentUserService mockCurrentUserService = new MockCurrentUserService( superUserFlag, asSet( orgUnit ), asSet( orgUnit ), auths );
+ CurrentUserService mockCurrentUserService = new MockCurrentUserService( superUserFlag, Sets.newHashSet( orgUnit ), Sets.newHashSet( orgUnit ), auths );
User user = mockCurrentUserService.getCurrentUser();
@@ -347,18 +348,18 @@
indiaPartner1User = getMockCurrentUserService( "IndiaPartner1User", false, india, DataApproval.AUTH_APPROVE );
currentMockUserService = null;
- UserGroup globalUsers = getUserGroup( "GlobalUsers", asSet( globalUser.getCurrentUser(), globalConsultant.getCurrentUser(), globalReadEverything.getCurrentUser() ) );
- UserGroup brazilInteragencyUsers = getUserGroup( "BrazilInteragencyUsers", asSet( brazilInteragencyUser.getCurrentUser() ) );
- UserGroup chinaInteragencyUsers = getUserGroup( "ChinaInteragencyUsers", asSet( chinaInteragencyUser.getCurrentUser() ) );
- UserGroup indiaInteragencyUsers = getUserGroup( "IndiaInteragencyUsers", asSet( indiaInteragencyUser.getCurrentUser() ) );
- UserGroup brazilAgencyAUsers = getUserGroup( "BrazilAgencyAUsers", asSet( brazilAgencyAUser.getCurrentUser() ) );
- UserGroup chinaAgencyAUsers = getUserGroup( "ChinaAgencyAUsers", asSet( chinaAgencyAUser.getCurrentUser() ) );
- UserGroup chinaAgencyBUsers = getUserGroup( "ChinaAgencyBUsers", asSet( chinaAgencyBUser.getCurrentUser() ) );
- UserGroup indiaAgencyAUsers = getUserGroup( "IndiaAgencyAUsers", asSet( indiaAgencyAUser.getCurrentUser() ) );
- UserGroup brazilPartner1Users = getUserGroup( "BrazilPartner1Users", asSet( brazilPartner1User.getCurrentUser() ) );
- UserGroup chinaPartner1Users = getUserGroup( "ChinaPartner1Users", asSet( chinaPartner1User.getCurrentUser() ) );
- UserGroup chinaPartner2Users = getUserGroup( "ChinaPartner2Users", asSet( chinaPartner2User.getCurrentUser() ) );
- UserGroup indiaPartner1Users = getUserGroup( "IndiaPartner1Users", asSet( indiaPartner1User.getCurrentUser() ) );
+ UserGroup globalUsers = getUserGroup( "GlobalUsers", Sets.newHashSet( globalUser.getCurrentUser(), globalConsultant.getCurrentUser(), globalReadEverything.getCurrentUser() ) );
+ UserGroup brazilInteragencyUsers = getUserGroup( "BrazilInteragencyUsers", Sets.newHashSet( brazilInteragencyUser.getCurrentUser() ) );
+ UserGroup chinaInteragencyUsers = getUserGroup( "ChinaInteragencyUsers", Sets.newHashSet( chinaInteragencyUser.getCurrentUser() ) );
+ UserGroup indiaInteragencyUsers = getUserGroup( "IndiaInteragencyUsers", Sets.newHashSet( indiaInteragencyUser.getCurrentUser() ) );
+ UserGroup brazilAgencyAUsers = getUserGroup( "BrazilAgencyAUsers", Sets.newHashSet( brazilAgencyAUser.getCurrentUser() ) );
+ UserGroup chinaAgencyAUsers = getUserGroup( "ChinaAgencyAUsers", Sets.newHashSet( chinaAgencyAUser.getCurrentUser() ) );
+ UserGroup chinaAgencyBUsers = getUserGroup( "ChinaAgencyBUsers", Sets.newHashSet( chinaAgencyBUser.getCurrentUser() ) );
+ UserGroup indiaAgencyAUsers = getUserGroup( "IndiaAgencyAUsers", Sets.newHashSet( indiaAgencyAUser.getCurrentUser() ) );
+ UserGroup brazilPartner1Users = getUserGroup( "BrazilPartner1Users", Sets.newHashSet( brazilPartner1User.getCurrentUser() ) );
+ UserGroup chinaPartner1Users = getUserGroup( "ChinaPartner1Users", Sets.newHashSet( chinaPartner1User.getCurrentUser() ) );
+ UserGroup chinaPartner2Users = getUserGroup( "ChinaPartner2Users", Sets.newHashSet( chinaPartner2User.getCurrentUser() ) );
+ UserGroup indiaPartner1Users = getUserGroup( "IndiaPartner1Users", Sets.newHashSet( indiaPartner1User.getCurrentUser() ) );
brazilA1 = new DataElementCategoryOption( "BrazilA1" );
chinaA1_1 = new DataElementCategoryOption( "ChinaA1_1" );
@@ -367,12 +368,12 @@
chinaB2 = new DataElementCategoryOption( "ChinaB2" );
indiaA1 = new DataElementCategoryOption( "IndiaA1" );
- brazilA1.setOrganisationUnits( asSet( brazil ) );
- chinaA1_1.setOrganisationUnits( asSet( china ) );
- chinaA1_2.setOrganisationUnits( asSet( china ) );
- chinaA2.setOrganisationUnits( asSet( china ) );
- chinaB2.setOrganisationUnits( asSet( china ) );
- indiaA1.setOrganisationUnits( asSet( india ) );
+ brazilA1.setOrganisationUnits( Sets.newHashSet( brazil ) );
+ chinaA1_1.setOrganisationUnits( Sets.newHashSet( china ) );
+ chinaA1_2.setOrganisationUnits( Sets.newHashSet( china ) );
+ chinaA2.setOrganisationUnits( Sets.newHashSet( china ) );
+ chinaB2.setOrganisationUnits( Sets.newHashSet( china ) );
+ indiaA1.setOrganisationUnits( Sets.newHashSet( india ) );
categoryService.addDataElementCategoryOption( brazilA1 );
categoryService.addDataElementCategoryOption( chinaA1_1 );
@@ -585,7 +586,7 @@
{
setUser( mockUserService );
- List<DataApprovalStatus> approvals = dataApprovalService.getUserDataApprovalsAndPermissions( asSet( dataSet ), period, orgUnit );
+ List<DataApprovalStatus> approvals = dataApprovalService.getUserDataApprovalsAndPermissions( Sets.newHashSet( dataSet ), period, orgUnit );
List<String> approvalStrings = new ArrayList<>();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java 2015-05-28 14:33:21 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataapproval/DataApprovalServiceTest.java 2015-06-01 23:57:56 +0000
@@ -29,8 +29,7 @@
*/
import static com.google.common.collect.Lists.newArrayList;
-import static org.hisp.dhis.util.CollectionUtils.asList;
-import static org.hisp.dhis.util.CollectionUtils.asSet;
+import static com.google.common.collect.Sets.newHashSet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -443,7 +442,7 @@
organisationUnitB.addDataSet( dataSetA );
organisationUnitB.addDataSet( dataSetB );
- Set<OrganisationUnit> units = asSet( organisationUnitA );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitA );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -531,7 +530,7 @@
organisationUnitA.addDataSet( dataSetA );
- Set<OrganisationUnit> units = asSet( organisationUnitA );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitA );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -541,8 +540,8 @@
DataApproval dataApprovalA = new DataApproval( level1, dataSetA, periodA, organisationUnitA, defaultCombo, NOT_ACCEPTED, date, userA );
DataApproval dataApprovalB = new DataApproval( level1, dataSetA, periodA, organisationUnitA, defaultCombo, NOT_ACCEPTED, date, userA ); // Same
- dataApprovalService.approveData( asList( dataApprovalA ) );
- dataApprovalService.approveData( asList( dataApprovalB ) ); // Redundant, so call is ignored.
+ dataApprovalService.approveData( newArrayList( dataApprovalA ) );
+ dataApprovalService.approveData( newArrayList( dataApprovalB ) ); // Redundant, so call is ignored.
}
@Test
@@ -557,7 +556,7 @@
organisationUnitA.addDataSet( dataSetA );
organisationUnitB.addDataSet( dataSetA );
- Set<OrganisationUnit> units = asSet( organisationUnitA );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitA );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -569,18 +568,18 @@
dataSetA.setApproveData( true );
- dataApprovalService.approveData( asList( dataApprovalB ) );
- dataApprovalService.approveData( asList( dataApprovalA ) );
+ dataApprovalService.approveData( newArrayList( dataApprovalB ) );
+ dataApprovalService.approveData( newArrayList( dataApprovalA ) );
assertTrue( dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, defaultCombo ).getState().isApproved() );
assertTrue( dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState().isApproved() );
- dataApprovalService.unapproveData( asList( dataApprovalA ) ); // Only A should be deleted.
+ dataApprovalService.unapproveData( newArrayList( dataApprovalA ) ); // Only A should be deleted.
assertFalse( dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, defaultCombo ).getState().isApproved() );
assertTrue( dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState().isApproved() );
- dataApprovalService.unapproveData( asList( dataApprovalB ) );
+ dataApprovalService.unapproveData( newArrayList( dataApprovalB ) );
assertFalse( dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, defaultCombo ).getState().isApproved() );
assertFalse( dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState().isApproved() );
@@ -594,7 +593,7 @@
dataApprovalLevelService.addDataApprovalLevel( level3 );
dataApprovalLevelService.addDataApprovalLevel( level4 );
- Set<OrganisationUnit> units = asSet( organisationUnitA );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitA );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -629,7 +628,7 @@
// Approved for organisation unit F
DataApproval dataApprovalF = new DataApproval( level4, dataSetA, periodA, organisationUnitF, defaultCombo, NOT_ACCEPTED, date, userA );
- dataApprovalService.approveData( asList( dataApprovalF ) );
+ dataApprovalService.approveData( newArrayList( dataApprovalF ) );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, defaultCombo ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
@@ -640,7 +639,7 @@
// Also approved also for organisation unit E
DataApproval dataApprovalE = new DataApproval( level3, dataSetA, periodA, organisationUnitE, defaultCombo, NOT_ACCEPTED, date, userA );
- dataApprovalService.approveData( asList( dataApprovalE ) );
+ dataApprovalService.approveData( newArrayList( dataApprovalE ) );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, defaultCombo ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
@@ -651,7 +650,7 @@
// Also approved for organisation unit D
DataApproval dataApprovalD = new DataApproval( level4, dataSetA, periodA, organisationUnitD, defaultCombo, NOT_ACCEPTED, date, userA );
- dataApprovalService.approveData( asList( dataApprovalD ) );
+ dataApprovalService.approveData( newArrayList( dataApprovalD ) );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, defaultCombo ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
@@ -662,7 +661,7 @@
// Also approved for organisation unit C
DataApproval dataApprovalC = new DataApproval( level3, dataSetA, periodA, organisationUnitC, defaultCombo, NOT_ACCEPTED, date, userA );
- dataApprovalService.approveData( asList( dataApprovalC ) );
+ dataApprovalService.approveData( newArrayList( dataApprovalC ) );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, defaultCombo ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
@@ -673,7 +672,7 @@
// Also approved for organisation unit B
DataApproval dataApprovalB = new DataApproval( level2, dataSetA, periodA, organisationUnitB, defaultCombo, NOT_ACCEPTED, date, userA );
- dataApprovalService.approveData( asList( dataApprovalB ) );
+ dataApprovalService.approveData( newArrayList( dataApprovalB ) );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, defaultCombo ).getState() );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
@@ -684,7 +683,7 @@
// Also approved for organisation unit A
DataApproval dataApprovalA = new DataApproval( level1, dataSetA, periodA, organisationUnitA, defaultCombo, NOT_ACCEPTED, date, userA );
- dataApprovalService.approveData( asList( dataApprovalA ) );
+ dataApprovalService.approveData( newArrayList( dataApprovalA ) );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, defaultCombo ).getState() );
assertEquals( DataApprovalState.APPROVED_ABOVE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
@@ -708,7 +707,7 @@
{
dataApprovalLevelService.addDataApprovalLevel( level3 );
- Set<OrganisationUnit> units = asSet( organisationUnitA );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitA );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -723,7 +722,7 @@
// Approved for organisation unit C
DataApproval dataApprovalC = new DataApproval( level3, dataSetA, periodA, organisationUnitC, defaultCombo, NOT_ACCEPTED, date, userA );
- dataApprovalService.approveData( asList( dataApprovalC ) );
+ dataApprovalService.approveData( newArrayList( dataApprovalC ) );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, defaultCombo ).getState() );
assertEquals( DataApprovalState.APPROVED_ABOVE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitD, defaultCombo ).getState() );
@@ -737,7 +736,7 @@
dataApprovalLevelService.addDataApprovalLevel( level3 );
dataApprovalLevelService.addDataApprovalLevel( level4 );
- Set<OrganisationUnit> units = asSet( organisationUnitA );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitA );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -756,7 +755,7 @@
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, defaultCombo ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitF, defaultCombo ).getState() );
- dataApprovalService.approveData( asList( new DataApproval( level4, dataSetA, periodA, organisationUnitF, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level4, dataSetA, periodA, organisationUnitF, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, defaultCombo ).getState() );
@@ -764,7 +763,7 @@
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, defaultCombo ).getState() );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitF, defaultCombo ).getState() );
- dataApprovalService.approveData( asList( new DataApproval( level4, dataSetA, periodA, organisationUnitD, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level4, dataSetA, periodA, organisationUnitD, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, defaultCombo ).getState() );
@@ -772,7 +771,7 @@
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, defaultCombo ).getState() );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitF, defaultCombo ).getState() );
- dataApprovalService.approveData( asList( new DataApproval( level3, dataSetA, periodA, organisationUnitE, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level3, dataSetA, periodA, organisationUnitE, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, defaultCombo ).getState() );
@@ -780,7 +779,7 @@
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, defaultCombo ).getState() );
assertEquals( DataApprovalState.APPROVED_ABOVE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitF, defaultCombo ).getState() );
- dataApprovalService.approveData( asList( new DataApproval( level3, dataSetA, periodA, organisationUnitC, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level3, dataSetA, periodA, organisationUnitC, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, defaultCombo ).getState() );
@@ -797,7 +796,7 @@
dataApprovalLevelService.addDataApprovalLevel( level3 );
dataApprovalLevelService.addDataApprovalLevel( level4 );
- Set<OrganisationUnit> units = asSet( organisationUnitA );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitA );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -834,7 +833,7 @@
organisationUnitE.addDataSet( dataSetA );
organisationUnitF.addDataSet( dataSetA );
- Set<OrganisationUnit> units = asSet( organisationUnitB );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitB );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE, AUTH_APPR_LEVEL );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -853,7 +852,7 @@
// Level 3 (organisationUnitC) and Level 4 (organisationUnitF) ready
try
{
- dataApprovalService.approveData( asList( new DataApproval( level4, dataSetA, periodA, organisationUnitD, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level4, dataSetA, periodA, organisationUnitD, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
fail( "User should not have permission to approve org unit C." );
}
catch ( DataMayNotBeApprovedException ex )
@@ -871,7 +870,7 @@
// Level 2 (organisationUnitB) ready
try
{
- dataApprovalService.approveData( asList( new DataApproval( level4, dataSetA, periodA, organisationUnitF, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level4, dataSetA, periodA, organisationUnitF, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
fail( "User should not have permission to approve org unit F." );
}
catch ( DataMayNotBeApprovedException ex )
@@ -882,7 +881,7 @@
try
{
- dataApprovalService.approveData( asList( new DataApproval( level3, dataSetA, periodA, organisationUnitE, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level3, dataSetA, periodA, organisationUnitE, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
fail( "User should not have permission to approve org unit E." );
}
catch ( DataMayNotBeApprovedException ex )
@@ -893,7 +892,7 @@
try
{
- dataApprovalService.approveData( asList( new DataApproval( level3, dataSetA, periodA, organisationUnitC, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level3, dataSetA, periodA, organisationUnitC, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
fail( "User should not have permission to approve org unit C." );
}
catch ( DataMayNotBeApprovedException ex )
@@ -909,7 +908,7 @@
assertEquals( "APPROVED_ABOVE level=4 approve=F unapprove=F accept=F unaccept=F read=T", statusAndPermissions( dataSetA, periodA, organisationUnitF, defaultCombo) );
// Level 1 (organisationUnitA) ready
- dataApprovalService.approveData( asList( new DataApproval( level2, dataSetA, periodA, organisationUnitB, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level2, dataSetA, periodA, organisationUnitB, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
assertEquals( "APPROVED_HERE level=2 approve=F unapprove=T accept=F unaccept=F read=T", statusAndPermissions( dataSetA, periodA, organisationUnitB, defaultCombo) );
assertEquals( "APPROVED_ABOVE level=3 approve=T unapprove=F accept=F unaccept=F read=T", statusAndPermissions( dataSetA, periodA, organisationUnitC, defaultCombo) );
assertEquals( "APPROVED_ABOVE level=4 approve=F unapprove=F accept=F unaccept=F read=T", statusAndPermissions( dataSetA, periodA, organisationUnitD, defaultCombo) );
@@ -919,7 +918,7 @@
// Level 1 (organisationUnitA) try to approve
try
{
- dataApprovalService.approveData( asList( new DataApproval( level1, dataSetA, periodA, organisationUnitA, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level1, dataSetA, periodA, organisationUnitA, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
fail( "User should not have permission to approve org unit A." );
}
catch ( DataMayNotBeApprovedException ex )
@@ -945,7 +944,7 @@
organisationUnitE.addDataSet( dataSetA );
organisationUnitF.addDataSet( dataSetA );
- Set<OrganisationUnit> units = asSet( organisationUnitB );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitB );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE_LOWER_LEVELS, AUTH_APPR_LEVEL );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -961,7 +960,7 @@
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitF, defaultCombo ).getPermissions().isMayApprove());
// Level 3 (organisationUnitC) and Level 4 (organisationUnitF) ready
- dataApprovalService.approveData( asList( new DataApproval( level4, dataSetA, periodA, organisationUnitD, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level4, dataSetA, periodA, organisationUnitD, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
assertFalse( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitB, defaultCombo ).getPermissions().isMayApprove());
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitC, defaultCombo ).getPermissions().isMayApprove());
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitD, defaultCombo ).getPermissions().isMayApprove());
@@ -969,9 +968,9 @@
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitF, defaultCombo ).getPermissions().isMayApprove());
// Level 2 (organisationUnitB) ready
- dataApprovalService.approveData( asList( new DataApproval( level4, dataSetA, periodA, organisationUnitF, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
- dataApprovalService.approveData( asList( new DataApproval( level3, dataSetA, periodA, organisationUnitE, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
- dataApprovalService.approveData( asList( new DataApproval( level3, dataSetA, periodA, organisationUnitC, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level4, dataSetA, periodA, organisationUnitF, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level3, dataSetA, periodA, organisationUnitE, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level3, dataSetA, periodA, organisationUnitC, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
assertFalse( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitB, defaultCombo ).getPermissions().isMayApprove());
assertFalse( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitC, defaultCombo ).getPermissions().isMayApprove());
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitD, defaultCombo ).getPermissions().isMayApprove());
@@ -981,7 +980,7 @@
// Level 1 (organisationUnitA) ready
try
{
- dataApprovalService.approveData( asList( new DataApproval( level2, dataSetA, periodA, organisationUnitB, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level2, dataSetA, periodA, organisationUnitB, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
fail( "User should not have permission to approve org unit B." );
}
catch ( DataMayNotBeApprovedException ex )
@@ -999,7 +998,7 @@
// Level 1 (organisationUnitA) try to approve
try
{
- dataApprovalService.approveData( asList( new DataApproval( level1, dataSetA, periodA, organisationUnitA, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level1, dataSetA, periodA, organisationUnitA, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
fail( "User should not have permission to approve org unit A." );
}
catch ( DataMayNotBeApprovedException ex )
@@ -1025,7 +1024,7 @@
organisationUnitE.addDataSet( dataSetA );
organisationUnitF.addDataSet( dataSetA );
- Set<OrganisationUnit> units = asSet( organisationUnitB );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitB );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS, AUTH_APPR_LEVEL );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -1041,7 +1040,7 @@
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitF, defaultCombo ).getPermissions().isMayApprove());
// Level 3 (organisationUnitC) and Level 4 (organisationUnitF) ready
- dataApprovalService.approveData( asList( new DataApproval( level4, dataSetA, periodA, organisationUnitD, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level4, dataSetA, periodA, organisationUnitD, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
assertFalse( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitB, defaultCombo ).getPermissions().isMayApprove());
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitC, defaultCombo ).getPermissions().isMayApprove());
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitD, defaultCombo ).getPermissions().isMayApprove());
@@ -1049,9 +1048,9 @@
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitF, defaultCombo ).getPermissions().isMayApprove());
// Level 2 (organisationUnitB) ready
- dataApprovalService.approveData( asList( new DataApproval( level4, dataSetA, periodA, organisationUnitF, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
- dataApprovalService.approveData( asList( new DataApproval( level3, dataSetA, periodA, organisationUnitE, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
- dataApprovalService.approveData( asList( new DataApproval( level3, dataSetA, periodA, organisationUnitC, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level4, dataSetA, periodA, organisationUnitF, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level3, dataSetA, periodA, organisationUnitE, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level3, dataSetA, periodA, organisationUnitC, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitB, defaultCombo ).getPermissions().isMayApprove());
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitC, defaultCombo ).getPermissions().isMayApprove());
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitD, defaultCombo ).getPermissions().isMayApprove());
@@ -1059,7 +1058,7 @@
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitF, defaultCombo ).getPermissions().isMayApprove());
// Level 1 (organisationUnitA) ready
- dataApprovalService.approveData( asList( new DataApproval( level2, dataSetA, periodA, organisationUnitB, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level2, dataSetA, periodA, organisationUnitB, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
assertFalse( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitB, defaultCombo ).getPermissions().isMayApprove());
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitC, defaultCombo ).getPermissions().isMayApprove());
assertTrue( dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitD, defaultCombo ).getPermissions().isMayApprove());
@@ -1069,7 +1068,7 @@
// Level 1 (organisationUnitA) try to approve
try
{
- dataApprovalService.approveData( asList( new DataApproval( level1, dataSetA, periodA, organisationUnitA, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level1, dataSetA, periodA, organisationUnitA, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
fail( "User should not have permission to approve org unit A." );
}
catch ( DataMayNotBeApprovedException ex )
@@ -1093,7 +1092,7 @@
organisationUnitC.addDataSet( dataSetA );
organisationUnitD.addDataSet( dataSetA );
- Set<OrganisationUnit> units = asSet( organisationUnitB );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitB );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, AUTH_APPR_LEVEL );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -1132,7 +1131,7 @@
organisationUnitE.addDataSet( dataSetA );
organisationUnitF.addDataSet( dataSetA );
- Set<OrganisationUnit> units = asSet( organisationUnitB );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitB );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE, AUTH_APPR_LEVEL );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -1204,7 +1203,7 @@
organisationUnitE.addDataSet( dataSetA );
organisationUnitF.addDataSet( dataSetA );
- Set<OrganisationUnit> units = asSet( organisationUnitB );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitB );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE_LOWER_LEVELS, AUTH_APPR_LEVEL );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -1276,7 +1275,7 @@
organisationUnitE.addDataSet( dataSetA );
organisationUnitF.addDataSet( dataSetA );
- Set<OrganisationUnit> units = asSet( organisationUnitB );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitB );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_ACCEPT_LOWER_LEVELS, AUTH_APPR_LEVEL );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -1346,7 +1345,7 @@
organisationUnitD.addDataSet( dataSetA );
organisationUnitE.addDataSet( dataSetA );
- Set<OrganisationUnit> units = asSet( organisationUnitB );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitB );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, AUTH_APPR_LEVEL );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -1415,7 +1414,7 @@
dataApprovalLevelService.addDataApprovalLevel( level2ABCD, 3 );
dataApprovalLevelService.addDataApprovalLevel( level3ABCD, 4 );
- Set<OrganisationUnit> units = asSet( organisationUnitA );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitA );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS, AUTH_APPR_LEVEL );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -1475,7 +1474,7 @@
try
{
- dataApprovalService.approveData( asList( new DataApproval( level2ABCD, dataSetA, periodA, organisationUnitB, optionComboAE, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level2ABCD, dataSetA, periodA, organisationUnitB, optionComboAE, NOT_ACCEPTED, date, userA ) ) );
fail( "organisationUnitB should not be ready for data approval." );
}
catch ( DataMayNotBeApprovedException ex )
@@ -1483,7 +1482,7 @@
// Can't add this approval before approving at a lower level.
}
- dataApprovalService.approveData( asList( new DataApproval( level3ABCD, dataSetA, periodA, organisationUnitC, optionComboAE, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level3ABCD, dataSetA, periodA, organisationUnitC, optionComboAE, NOT_ACCEPTED, date, userA ) ) );
assertEquals( "UNAPPROVABLE level=null approve=F unapprove=F accept=F unaccept=F read=T", statusAndPermissions( dataSetA, periodA, organisationUnitA, null ) );
assertEquals( "UNAPPROVABLE level=null approve=F unapprove=F accept=F unaccept=F read=T", statusAndPermissions( dataSetA, periodA, organisationUnitB, null ) );
@@ -1513,7 +1512,7 @@
assertEquals( "UNAPPROVABLE level=null approve=F unapprove=F accept=F unaccept=F read=T", statusAndPermissions( dataSetA, periodA, organisationUnitB, optionComboCG ) );
assertEquals( "UNAPPROVABLE level=null approve=F unapprove=F accept=F unaccept=F read=T", statusAndPermissions( dataSetA, periodA, organisationUnitC, optionComboCG ) );
- dataApprovalService.approveData( asList( new DataApproval( level2ABCD, dataSetA, periodA, organisationUnitB, optionComboAE, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level2ABCD, dataSetA, periodA, organisationUnitB, optionComboAE, NOT_ACCEPTED, date, userA ) ) );
assertEquals( "UNAPPROVABLE level=null approve=F unapprove=F accept=F unaccept=F read=T", statusAndPermissions( dataSetA, periodA, organisationUnitA, null ) );
assertEquals( "UNAPPROVABLE level=null approve=F unapprove=F accept=F unaccept=F read=T", statusAndPermissions( dataSetA, periodA, organisationUnitB, null ) );
@@ -1555,7 +1554,7 @@
organisationUnitA.addDataSet( dataSetA );
organisationUnitB.addDataSet( dataSetA );
- Set<OrganisationUnit> units = asSet( organisationUnitA );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitA );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS, AUTH_APPR_LEVEL );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
@@ -1566,7 +1565,7 @@
DataApproval dab = new DataApproval( level1EFGH, dataSetA, periodA, organisationUnitA, null, NOT_ACCEPTED, date, userA );
dataApprovalLevelService.addDataApprovalLevel( level1EFGH );
- dataApprovalService.approveData( asList( dab ) );
+ dataApprovalService.approveData( newArrayList( dab ) );
assertEquals( DataApprovalState.UNAPPROVED_ABOVE, dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitA, defaultCombo ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_ABOVE, dataApprovalService.getDataApprovalStatusAndPermissions( dataSetA, periodA, organisationUnitA, null ).getState() );
@@ -1597,7 +1596,7 @@
assertNull( dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, optionComboAE ).getDataApprovalLevel() );
dataApprovalLevelService.addDataApprovalLevel( level1ABCD );
- dataApprovalService.approveData( asList( new DataApproval( level1ABCD, dataSetA, periodA, organisationUnitA, null, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level1ABCD, dataSetA, periodA, organisationUnitA, null, NOT_ACCEPTED, date, userA ) ) );
assertEquals( DataApprovalState.UNAPPROVED_ABOVE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, defaultCombo ).getState() );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, null ).getState() );
@@ -1627,7 +1626,7 @@
assertEquals( level1ABCD, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, null ).getDataApprovalLevel() );
assertEquals( level1ABCD, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, optionComboAE ).getDataApprovalLevel() );
- dataApprovalService.unapproveData( asList( dab ) );
+ dataApprovalService.unapproveData( newArrayList( dab ) );
assertEquals( DataApprovalState.UNAPPROVED_ABOVE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, defaultCombo ).getState() );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, null ).getState() );
@@ -1658,7 +1657,7 @@
assertEquals( level1ABCD, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, optionComboAE ).getDataApprovalLevel() );
dataApprovalLevelService.addDataApprovalLevel( level1 );
- dataApprovalService.approveData( asList( new DataApproval( level1, dataSetA, periodA, organisationUnitA, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level1, dataSetA, periodA, organisationUnitA, defaultCombo, NOT_ACCEPTED, date, userA ) ) );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, defaultCombo ).getState() );
assertEquals( DataApprovalState.APPROVED_ABOVE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitA, null ).getState() );
@@ -1705,16 +1704,16 @@
Date date = new Date();
- Set<OrganisationUnit> units = asSet( organisationUnitA );
+ Set<OrganisationUnit> units = newHashSet( organisationUnitA );
CurrentUserService currentUserService = new MockCurrentUserService( units, null, AUTH_APPR_LEVEL, DataApproval.AUTH_APPROVE, DataApproval.AUTH_APPROVE_LOWER_LEVELS, DataApproval.AUTH_ACCEPT_LOWER_LEVELS );
setDependency( dataApprovalService, "currentUserService", currentUserService, CurrentUserService.class );
setDependency( dataApprovalLevelService, "currentUserService", currentUserService, CurrentUserService.class );
- optionA.setOrganisationUnits( asSet( organisationUnitC ) );
- optionB.setOrganisationUnits( asSet( organisationUnitE ) );
- optionC.setOrganisationUnits( asSet( organisationUnitE ) );
- optionD.setOrganisationUnits( asSet( organisationUnitE ) );
+ optionA.setOrganisationUnits( newHashSet( organisationUnitC ) );
+ optionB.setOrganisationUnits( newHashSet( organisationUnitE ) );
+ optionC.setOrganisationUnits( newHashSet( organisationUnitE ) );
+ optionD.setOrganisationUnits( newHashSet( organisationUnitE ) );
categoryService.updateDataElementCategoryOption( optionA );
categoryService.updateDataElementCategoryOption( optionB );
@@ -1727,7 +1726,7 @@
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, null ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
- dataApprovalService.approveData( asList( new DataApproval( level3ABCD, dataSetA, periodA, organisationUnitC, null, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level3ABCD, dataSetA, periodA, organisationUnitC, null, NOT_ACCEPTED, date, userA ) ) );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, null ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, null ).getState() );
@@ -1735,7 +1734,7 @@
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, null ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
- dataApprovalService.approveData( asList( new DataApproval( level3ABCD, dataSetA, periodA, organisationUnitE, null, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level3ABCD, dataSetA, periodA, organisationUnitE, null, NOT_ACCEPTED, date, userA ) ) );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, null ).getState() );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, null ).getState() );
@@ -1743,7 +1742,7 @@
assertEquals( DataApprovalState.UNAPPROVED_READY, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, null ).getState() );
assertEquals( DataApprovalState.UNAPPROVED_WAITING, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitB, defaultCombo ).getState() );
- dataApprovalService.approveData( asList( new DataApproval( level3ABCD, dataSetA, periodA, organisationUnitE, null, NOT_ACCEPTED, date, userA ) ) );
+ dataApprovalService.approveData( newArrayList( new DataApproval( level3ABCD, dataSetA, periodA, organisationUnitE, null, NOT_ACCEPTED, date, userA ) ) );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitC, null ).getState() );
assertEquals( DataApprovalState.APPROVED_HERE, dataApprovalService.getDataApprovalStatus( dataSetA, periodA, organisationUnitE, null ).getState() );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java 2015-06-01 19:49:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java 2015-06-01 23:57:56 +0000
@@ -28,7 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import static org.hisp.dhis.util.CollectionUtils.asSet;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
@@ -366,13 +365,13 @@
OrganisationUnit unit4 = createOrganisationUnit( '4' );
organisationUnitService.addOrganisationUnit( unit4 );
- assertTrue( unit1.isDescendant( asSet( unit1 ) ) );
- assertTrue( unit2.isDescendant( asSet( unit1 ) ) );
- assertTrue( unit3.isDescendant( asSet( unit1 ) ) );
- assertTrue( unit2.isDescendant( asSet( unit1, unit3 ) ) );
+ assertTrue( unit1.isDescendant( Sets.newHashSet( unit1 ) ) );
+ assertTrue( unit2.isDescendant( Sets.newHashSet( unit1 ) ) );
+ assertTrue( unit3.isDescendant( Sets.newHashSet( unit1 ) ) );
+ assertTrue( unit2.isDescendant( Sets.newHashSet( unit1, unit3 ) ) );
- assertFalse( unit2.isDescendant( asSet( unit3 ) ) );
- assertFalse( unit4.isDescendant( asSet( unit1 ) ) );
+ assertFalse( unit2.isDescendant( Sets.newHashSet( unit3 ) ) );
+ assertFalse( unit4.isDescendant( Sets.newHashSet( unit1 ) ) );
}
@Test
=== modified file 'dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/util/CollectionUtils.java'
--- dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/util/CollectionUtils.java 2015-05-28 18:00:11 +0000
+++ dhis-2/dhis-support/dhis-support-commons/src/main/java/org/hisp/dhis/util/CollectionUtils.java 2015-06-01 23:57:56 +0000
@@ -120,46 +120,6 @@
}
/**
- * Returns the given arguments as an ordered List.
- *
- * @param items the items.
- * @param <T> the type.
- * @return an ordered List of the supplied items.
- */
- @SafeVarargs
- public static <T> List<T> asList( final T... items )
- {
- List<T> list = new ArrayList<>();
-
- for ( T item : items )
- {
- list.add( item );
- }
-
- return list;
- }
-
- /**
- * Returns the given arguments as a Set.
- *
- * @param items the items.
- * @param <T> the type.
- * @return a Set of the supplied items.
- */
- @SafeVarargs
- public static final <T> Set<T> asSet( final T... items )
- {
- Set<T> set = new HashSet<>();
-
- for ( T item : items )
- {
- set.add( item );
- }
-
- return set;
- }
-
- /**
* Constructs a Map Entry (key, value). Used to construct a Map with asMap.
*
* @param key map entry key