Created separate Test classes for the fixed bugs

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@72353 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-05-30 15:05:46 +00:00
parent ee8b88dd52
commit 0a057d8741
5 changed files with 330 additions and 194 deletions

View File

@@ -0,0 +1,118 @@
/*
* Copyright (C) 2005-2014 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.test.service.HoldServiceImplTest;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Unit test for https://issues.alfresco.com/jira/browse/RM-1424
*
* @author Tuna Aksoy
* @since 2.2
* @version 1.0
*/
public class RM1424Test extends HoldServiceImplTest
{
public void testGettingHolds()
{
final List<NodeRef> listWithTwoHolds = new ArrayList<NodeRef>(2);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
// No holds
List<NodeRef> emptyHoldList = holdService.getHolds(filePlan);
assertNotNull(emptyHoldList);
assertTrue(emptyHoldList.isEmpty());
// Create 2 holds
createAndCheckHolds();
// Check the list of holds
listWithTwoHolds.addAll(holdService.getHolds(filePlan));
assertNotNull(listWithTwoHolds);
assertEquals(2, listWithTwoHolds.size());
// Check the first hold
NodeRef hold1 = listWithTwoHolds.get(0);
assertEquals(RecordsManagementModel.TYPE_HOLD, nodeService.getType(hold1));
assertEquals(HOLD1_NAME, (String) nodeService.getProperty(hold1, PROP_NAME));
assertEquals(HOLD1_REASON, (String) nodeService.getProperty(hold1, PROP_HOLD_REASON));
assertEquals(HOLD1_DESC, (String) nodeService.getProperty(hold1, PROP_DESCRIPTION));
// Add the user to the RM Manager role
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName);
return null;
}
});
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
// Get the holds the test user without having any permissions on the holds
List<NodeRef> holds = holdService.getHolds(filePlan);
assertNotNull(holds);
assertEquals(0, holds.size());
return null;
}
}, userName);
final NodeRef hold2 = listWithTwoHolds.get(1);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
// Give the user read permissions on the hold
permissionService.setPermission(hold2, userName, RMPermissionModel.FILING, true);
return null;
}
});
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
List<NodeRef> holds = holdService.getHolds(filePlan);
assertNotNull(holds);
assertEquals(1, holds.size());
assertEquals(RecordsManagementModel.TYPE_HOLD, nodeService.getType(hold2));
assertEquals(HOLD2_NAME, (String) nodeService.getProperty(hold2, PROP_NAME));
assertEquals(HOLD2_REASON, (String) nodeService.getProperty(hold2, PROP_HOLD_REASON));
assertEquals(HOLD2_DESC, (String) nodeService.getProperty(hold2, PROP_DESCRIPTION));
return null;
}
}, userName);
}
}

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2005-2014 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.test.service.HoldServiceImplTest;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Unit test for https://issues.alfresco.com/jira/browse/RM-1429
*
* @author Tuna Aksoy
* @since 2.2
* @version 1.0
*/
public class RM1429 extends HoldServiceImplTest
{
public void testDeleteHoldWithoutPermissionsOnChildren()
{
// Create the test hold
final NodeRef hold = createAndCheckHold();
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
// Add the user to the RM Manager role
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName);
// Give the user filing permissions on the hold
permissionService.setPermission(hold, userName, RMPermissionModel.FILING, true);
// Give the user read permissions on the record folder
permissionService.setPermission(rmFolder, userName, RMPermissionModel.READ_RECORDS, true);
// Add record folder to the hold
holdService.addToHold(hold, rmFolder);
return null;
}
});
doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class)
{
@Override
public void run()
{
holdService.deleteHold(hold);
}
}, userName);
}
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C) 2005-2014 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.test.service.HoldServiceImplTest;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Unit test for https://issues.alfresco.com/jira/browse/RM-1463
*
* @author Tuna Aksoy
* @since 2.2
* @version 1.0
*/
public class RM1463Test extends HoldServiceImplTest
{
public void testAddRecordFolderToHoldWithoutFilingPermissionOnRecordFolder()
{
// Create hold
final NodeRef hold = createAndCheckHold();
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
// Add the user to the RM Manager role
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName);
// Give the user filing permissions on the hold
permissionService.setPermission(hold, userName, RMPermissionModel.FILING, true);
// Give the user only read permissions on the record folder
permissionService.setPermission(rmFolder, userName, RMPermissionModel.READ_RECORDS, true);
return null;
}
});
doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class)
{
@Override
public void run()
{
holdService.addToHold(hold, rmFolder);
}
}, userName);
}
}

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C) 2005-2014 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.module.org_alfresco_module_rm.test.integration.issue;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.test.service.HoldServiceImplTest;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Unit test for https://issues.alfresco.com/jira/browse/RM-1464
*
* @author Tuna Aksoy
* @since 2.2
* @version 1.0
*/
public class RM1464Test extends HoldServiceImplTest
{
public void testAddRecordFolderToHoldWithoutFilingPermissionOnHold()
{
// Create hold
final NodeRef hold = createAndCheckHold();
doTestInTransaction(new Test<Void>()
{
@Override
public Void run()
{
// Add the user to the RM Manager role
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName);
// Give the user read permissions on the hold
permissionService.setPermission(hold, userName, RMPermissionModel.READ_RECORDS, true);
// Give the user filing permissions on the record folder
permissionService.setPermission(rmFolder, userName, RMPermissionModel.FILING, true);
return null;
}
});
doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class)
{
@Override
public void run()
{
holdService.addToHold(hold, rmFolder);
}
}, userName);
}
}

View File

@@ -21,9 +21,6 @@ package org.alfresco.module.org_alfresco_module_rm.test.service;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.capability.RMPermissionModel;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.module.org_alfresco_module_rm.test.util.BaseRMTestCase;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -36,12 +33,12 @@ import org.alfresco.service.cmr.repository.NodeRef;
public class HoldServiceImplTest extends BaseRMTestCase
{
/** Constants for the holds */
private static final String HOLD1_NAME = "hold one";
private static final String HOLD2_NAME = "hold two";
private static final String HOLD1_REASON = "I have my reasons";
private static final String HOLD2_REASON = "secrets are everything";
private static final String HOLD1_DESC = "but I'll not describe them here!";
private static final String HOLD2_DESC = "no then! that's just not on!";
protected static final String HOLD1_NAME = "hold one";
protected static final String HOLD2_NAME = "hold two";
protected static final String HOLD1_REASON = "I have my reasons";
protected static final String HOLD2_REASON = "secrets are everything";
protected static final String HOLD1_DESC = "but I'll not describe them here!";
protected static final String HOLD2_DESC = "no then! that's just not on!";
@Override
protected boolean isRecordTest()
@@ -60,7 +57,7 @@ public class HoldServiceImplTest extends BaseRMTestCase
*
* @return {@link NodeRef} Node reference of the hold.
*/
private NodeRef createAndCheckHold()
protected NodeRef createAndCheckHold()
{
NodeRef hold = holdService.createHold(filePlan, HOLD1_NAME, HOLD1_REASON, HOLD1_DESC);
assertNotNull(hold);
@@ -72,7 +69,7 @@ public class HoldServiceImplTest extends BaseRMTestCase
*
* @return List of {@link NodeRef}s of the holds.
*/
private List<NodeRef> createAndCheckHolds()
protected List<NodeRef> createAndCheckHolds()
{
List<NodeRef> holds = new ArrayList<NodeRef>(2);
holds.add(createAndCheckHold());
@@ -183,153 +180,6 @@ public class HoldServiceImplTest extends BaseRMTestCase
});
}
public void testAddRecordFolderToHoldWithoutFilingPermissionOnRecordFolder()
{
// Create hold
final NodeRef hold = createAndCheckHold();
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
// Add the user to the RM Manager role
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName);
// Give the user filing permissions on the hold
permissionService.setPermission(hold, userName, RMPermissionModel.FILING, true);
// Give the user only read permissions on the record folder
permissionService.setPermission(rmFolder, userName, RMPermissionModel.READ_RECORDS, true);
return null;
}
});
doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class)
{
@Override
public void run() throws Exception
{
holdService.addToHold(hold, rmFolder);
}
}, userName);
}
public void testAddRecordFolderToHoldWithoutFilingPermissionOnHold()
{
// Create hold
final NodeRef hold = createAndCheckHold();
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
// Add the user to the RM Manager role
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName);
// Give the user read permissions on the hold
permissionService.setPermission(hold, userName, RMPermissionModel.READ_RECORDS, true);
// Give the user filing permissions on the record folder
permissionService.setPermission(rmFolder, userName, RMPermissionModel.FILING, true);
return null;
}
});
doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class)
{
@Override
public void run() throws Exception
{
holdService.addToHold(hold, rmFolder);
}
}, userName);
}
public void testGettingHolds()
{
final List<NodeRef> listWithTwoHolds = new ArrayList<NodeRef>(2);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
// No holds
List<NodeRef> emptyHoldList = holdService.getHolds(filePlan);
assertNotNull(emptyHoldList);
assertTrue(emptyHoldList.isEmpty());
// Create 2 holds
createAndCheckHolds();
// Check the list of holds
listWithTwoHolds.addAll(holdService.getHolds(filePlan));
assertNotNull(listWithTwoHolds);
assertEquals(2, listWithTwoHolds.size());
// Check the first hold
NodeRef hold1 = listWithTwoHolds.get(0);
assertEquals(RecordsManagementModel.TYPE_HOLD, nodeService.getType(hold1));
assertEquals(HOLD1_NAME, (String) nodeService.getProperty(hold1, PROP_NAME));
assertEquals(HOLD1_REASON, (String) nodeService.getProperty(hold1, PROP_HOLD_REASON));
assertEquals(HOLD1_DESC, (String) nodeService.getProperty(hold1, PROP_DESCRIPTION));
// Add the user to the RM Manager role
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName);
return null;
}
});
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
// Get the holds the test user without having any permissions on the holds
List<NodeRef> holds = holdService.getHolds(filePlan);
assertNotNull(holds);
assertEquals(0, holds.size());
return null;
}
}, userName);
final NodeRef hold2 = listWithTwoHolds.get(1);
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
// Give the user read permissions on the hold
permissionService.setPermission(hold2, userName, RMPermissionModel.FILING, true);
return null;
}
});
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
List<NodeRef> holds = holdService.getHolds(filePlan);
assertNotNull(holds);
assertEquals(1, holds.size());
assertEquals(RecordsManagementModel.TYPE_HOLD, nodeService.getType(hold2));
assertEquals(HOLD2_NAME, (String) nodeService.getProperty(hold2, PROP_NAME));
assertEquals(HOLD2_REASON, (String) nodeService.getProperty(hold2, PROP_HOLD_REASON));
assertEquals(HOLD2_DESC, (String) nodeService.getProperty(hold2, PROP_DESCRIPTION));
return null;
}
}, userName);
}
public void testHeldByNothing()
{
doTestInTransaction(new Test<Void>()
@@ -360,40 +210,4 @@ public class HoldServiceImplTest extends BaseRMTestCase
}
});
}
public void testDeleteHoldWithoutPermissionsOnChildren()
{
// Create the test hold
final NodeRef hold = createAndCheckHold();
doTestInTransaction(new Test<Void>()
{
@Override
public Void run() throws Exception
{
// Add the user to the RM Manager role
filePlanRoleService.assignRoleToAuthority(filePlan, ROLE_NAME_RECORDS_MANAGER, userName);
// Give the user filing permissions on the hold
permissionService.setPermission(hold, userName, RMPermissionModel.FILING, true);
// Give the user read permissions on the record folder
permissionService.setPermission(rmFolder, userName, RMPermissionModel.READ_RECORDS, true);
// Add record folder to the hold
holdService.addToHold(hold, rmFolder);
return null;
}
});
doTestInTransaction(new FailureTest(AlfrescoRuntimeException.class)
{
@Override
public void run() throws Exception
{
holdService.deleteHold(hold);
}
}, userName);
}
}