Fixed major issues reported by sonar (Simplify Boolean Expression)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63886 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-03-11 09:04:52 +00:00
parent b92d582589
commit c3ac745ffb
156 changed files with 1724 additions and 1724 deletions

View File

@@ -178,7 +178,7 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
AccessStatus accessStatus = capability.hasPermission(filePlanComponent);
Set<Role> roles = filePlanRoleService.getRolesByUser(filePlan, userName);
if (roles.isEmpty() == true)
if (roles.isEmpty())
{
assertEquals("User " + userName + " has no RM role so we expect access to be denied for capability " + capability.getName(),
AccessStatus.DENIED,
@@ -191,7 +191,7 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
List<String> kinds = capability.getKinds();
if (kinds == null ||
kinds.contains(actualKind.toString()) == true)
kinds.contains(actualKind.toString()))
{
Map<String, Boolean> conditions = capability.getConditions();
boolean conditionResult = getConditionResult(filePlanComponent, conditions);
@@ -201,7 +201,7 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase
assertNotNull(role);
Set<Capability> roleCapabilities = role.getCapabilities();
if (roleCapabilities.contains(capability) == true && conditionResult == true)
if (roleCapabilities.contains(capability) && conditionResult)
{
assertEquals("User " + userName + " has the role " + role.getDisplayLabel() +
" so we expect access to be allowed for capability " + capability.getName() + " on the object " +

View File

@@ -31,77 +31,77 @@ import org.json.JSONObject;
* @author Roy Wetherall
*/
public class JSONConversionComponentTest extends BaseRMTestCase
{
{
private JSONConversionComponent converter;
private NodeRef record;
private NodeRef record;
@Override
protected void initServices()
{
super.initServices();
converter = (JSONConversionComponent)applicationContext.getBean("jsonConversionComponent");
}
@Override
protected void setupTestDataImpl()
{
super.setupTestDataImpl();
// Create records
record = utils.createRecord(rmFolder, "testRecord.txt");
}
public void testJSON() throws Exception
{
{
doTestInTransaction(new JSONTest
(
filePlan,
new String[]{"isRmNode", "true", "boolean"},
new String[]{"rmNode.kind", "FILE_PLAN"}
){});
){});
doTestInTransaction(new JSONTest
(
rmContainer,
new String[]{"isRmNode", "true", "boolean"},
new String[]{"rmNode.kind", "RECORD_CATEGORY"}
){});
doTestInTransaction(new JSONTest
(
rmFolder,
new String[]{"isRmNode", "true", "boolean"},
new String[]{"rmNode.kind", "RECORD_FOLDER"}
){});
){});
doTestInTransaction(new JSONTest
(
record,
new String[]{"isRmNode", "true", "boolean"},
new String[]{"rmNode.kind", "RECORD"}
){});
){});
}
class JSONTest extends Test<JSONObject>
{
private NodeRef nodeRef;
private String[][] testValues;
public JSONTest(NodeRef nodeRef, String[] ... testValues)
{
this.nodeRef = nodeRef;
this.testValues = testValues;
}
@Override
public JSONObject run() throws Exception
{
{
String json = converter.toJSON(nodeRef, true);
System.out.println(json);
return new JSONObject(json);
}
@Override
public void test(JSONObject result) throws Exception
{
@@ -112,29 +112,29 @@ public class JSONConversionComponentTest extends BaseRMTestCase
if (testValue.length == 3)
{
type = testValue[2];
}
}
Serializable value = convertValue(testValue[1], type);
Serializable actualValue = (Serializable)getValue(result, key);
assertEquals("The key " + key + " did not have the expected value.", value, actualValue);
}
}
private Serializable convertValue(String stringValue, String type)
{
Serializable value = stringValue;
if (type.equals("boolean") == true)
if (type.equals("boolean"))
{
value = new Boolean(stringValue);
}
}
return value;
}
private Object getValue(JSONObject jsonObject, String key) throws JSONException
{
return getValue(jsonObject, key.split("\\."));
}
private Object getValue(JSONObject jsonObject, String[] key) throws JSONException
{
if (key.length == 1)

View File

@@ -773,7 +773,7 @@ public class DispositionServiceImplTest extends BaseRMTestCase
{
String origEvent = i.next();
if (expectedEvents.contains(origEvent) == true)
if (expectedEvents.contains(origEvent))
{
i.remove();
copy.remove(origEvent);
@@ -804,7 +804,7 @@ public class DispositionServiceImplTest extends BaseRMTestCase
fail(buff.toString());
}
if (CommonRMTestUtils.PERIOD_NONE.equals(strPeriod) == true)
if (CommonRMTestUtils.PERIOD_NONE.equals(strPeriod))
{
assertNull(da.getAsOfDate());
}
@@ -972,7 +972,7 @@ public class DispositionServiceImplTest extends BaseRMTestCase
dispositionService.updateDispositionActionDefinition(
actionDefinition,
adParams );
adParams);
return actionDefinition;
}

View File

@@ -123,7 +123,7 @@ public class ExtendedActionServiceTest extends BaseRMTestCase
for (ActionDefinition actionDefinition : list)
{
if (actionDefinition.getName().equals(actionName) == true)
if (actionDefinition.getName().equals(actionName))
{
result = true;
break;

View File

@@ -42,54 +42,54 @@ import org.alfresco.util.PropertyMap;
/**
* Test of RM Caveat (Admin facing scripts)
*
*
* @author Mark Rogers
*/
public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD5015Model
{
{
protected static StoreRef SPACES_STORE = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
private NodeRef filePlan;
private NodeService nodeService;
private TransactionService transactionService;
private RMCaveatConfigService caveatConfigService;
private MutableAuthenticationService authenticationService;
private PersonService personService;
private AuthorityService authorityService;
// example base test data for supplemental markings list
protected final static String NOFORN = "NOFORN"; // Not Releasable to Foreign Nationals/Governments/Non-US Citizens
protected final static String NOCONTRACT = "NOCONTRACT"; // Not Releasable to Contractors or Contractor/Consultants
protected final static String FOUO = "FOUO"; // For Official Use Only
protected final static String FOUO = "FOUO"; // For Official Use Only
protected final static String FGI = "FGI"; // Foreign Government Information
protected final static String RM_LIST = "rmc:smList"; // existing pre-defined list
protected final static String RM_LIST_ALT = "rmc:anoList";
@Override
protected void onSetUpInTransaction() throws Exception
protected void onSetUpInTransaction() throws Exception
{
super.onSetUpInTransaction();
// Get the service required in the tests
this.nodeService = (NodeService)this.applicationContext.getBean("NodeService"); // use upper 'N'odeService (to test access config interceptor)
this.nodeService = (NodeService)this.applicationContext.getBean("NodeService"); // use upper 'N'odeService (to test access config interceptor)
this.authenticationService = (MutableAuthenticationService)this.applicationContext.getBean("AuthenticationService");
this.personService = (PersonService)this.applicationContext.getBean("PersonService");
this.authorityService = (AuthorityService)this.applicationContext.getBean("AuthorityService");
this.caveatConfigService = (RMCaveatConfigServiceImpl)this.applicationContext.getBean("caveatConfigService");
this.transactionService = (TransactionService)this.applicationContext.getBean("TransactionService");
// Set the current security context as admin
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
// Get the test data
setUpTestData();
}
private void setUpTestData()
{
}
@@ -110,58 +110,58 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
//System.out.println("DID NOT DELETE FILE PLAN!");
}
}
@Override
protected void onTearDownAfterTransaction() throws Exception
{
// TODO Auto-generated method stub
super.onTearDownAfterTransaction();
}
public void testSetup()
{
// NOOP
}
}
/**
* Test of Caveat Config
*
*
* @throws Exception
*/
public void testAddRMConstraintList() throws Exception
{
setComplete();
endTransaction();
cleanCaveatConfigData();
startNewTransaction();
/**
* Now remove the entire list (rma:smList);
*/
logger.debug("test remove entire list rmc:smList");
caveatConfigService.deleteRMConstraint(RM_LIST);
/**
* Now add the list again
*/
logger.debug("test add back rmc:smList");
caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]);
/**
* Negative test - add a list that already exists
*/
logger.debug("try to create duplicate list rmc:smList");
caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]);
/**
* Negative test - remove a list that does not exist
*/
logger.debug("test remove entire list rmc:smList");
caveatConfigService.deleteRMConstraint(RM_LIST);
try
try
{
caveatConfigService.deleteRMConstraint(RM_LIST);
fail("unknown constraint should have thrown an exception");
@@ -170,13 +170,13 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
{
// expect to go here
}
/**
* Negative test - add a constraint to property that does not exist
*/
logger.debug("test property does not exist");
try
try
{
caveatConfigService.addRMConstraint("rma:mer", "", new String[0]);
fail("unknown property should have thrown an exception");
@@ -187,25 +187,25 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
}
endTransaction();
cleanCaveatConfigData();
}
/**
* Test of addRMConstraintListValue
*
*
* @throws Exception
*/
public void testAddRMConstraintListValue() throws Exception
{
setComplete();
endTransaction();
cleanCaveatConfigData();
setupCaveatConfigData();
startNewTransaction();
caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]);
/**
* Add a user to the list
*/
@@ -213,17 +213,17 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
values.add(NOFORN);
values.add(NOCONTRACT);
caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jrogers", values);
/**
* Add another value to that list
*/
caveatConfigService.addRMConstraintListValue(RM_LIST, "jrogers", FGI);
/**
* Negative test - attempt to add a duplicate value
*/
caveatConfigService.addRMConstraintListValue(RM_LIST, "jrogers", FGI);
/**
* Negative test - attempt to add to a list that does not exist
*/
@@ -231,17 +231,17 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
{
caveatConfigService.addRMConstraintListValue(RM_LIST_ALT, "mhouse", FGI);
fail("exception not thrown");
}
}
catch (Exception re)
{
// should go here
}
/**
* Negative test - attempt to add to a list that does exist and user that does not exist
*/
try
try
{
caveatConfigService.addRMConstraintListValue(RM_LIST, "mhouse", FGI);
fail("exception not thrown");
@@ -250,27 +250,27 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
{
// should go here
}
}
/**
* Test of UpdateRMConstraintListAuthority
*
*
* @throws Exception
*/
public void testUpdateRMConstraintListAuthority() throws Exception
{
setComplete();
endTransaction();
cleanCaveatConfigData();
setupCaveatConfigData();
startNewTransaction();
caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]);
/**
* Add a user to the list
*/
@@ -278,7 +278,7 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
values.add(NOFORN);
values.add(NOCONTRACT);
caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jrogers", values);
/**
* Add to a authority that already exists
* Should replace existing authority
@@ -286,103 +286,103 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
List<String> updatedValues = new ArrayList<String>();
values.add(FGI);
caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jrogers", updatedValues);
/**
* Add a group to the list
*/
caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "Engineering", values);
/**
* Add to a list that does not exist
* Should create a new list
*/
caveatConfigService.deleteRMConstraint(RM_LIST);
caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jrogers", values);
/**
* Add to a authority that already exists
* Should replace existing authority
*/
endTransaction();
cleanCaveatConfigData();
}
/**
* Test of RemoveRMConstraintListAuthority
*
*
* @throws Exception
*/
public void testRemoveRMConstraintListAuthority() throws Exception
{
setComplete();
endTransaction();
cleanCaveatConfigData();
setupCaveatConfigData();
startNewTransaction();
caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]);
List<String> values = new ArrayList<String>();
values.add(FGI);
caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jrogers", values);
/**
* Remove a user from a list
*/
caveatConfigService.removeRMConstraintListAuthority(RM_LIST, "jrogers");
/**
* Negative test - remove a user that does not exist
*/
caveatConfigService.removeRMConstraintListAuthority(RM_LIST, "jrogers");
/**
* Negative test - remove a user from a list that does not exist.
* Should create a new list
*/
caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]);
caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "jrogers", values);
endTransaction();
cleanCaveatConfigData();
}
/**
* Test of Caveat Config
*
*
* @throws Exception
*/
public void testRMCaveatConfig() throws Exception
{
setComplete();
endTransaction();
cleanCaveatConfigData();
startNewTransaction();
caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]);
List<String> values = new ArrayList<String>();
values.add(NOFORN);
values.add(FOUO);
caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "dfranco", values);
values.add(FGI);
values.add(NOCONTRACT);
caveatConfigService.updateRMConstraintListAuthority(RM_LIST, "dmartinz", values);
// Test list of allowed values for caveats
List<String> allowedValues = AuthenticationUtil.runAs(new RunAsWork<List<String>>()
{
public List<String> doWork()
@@ -391,12 +391,12 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
return caveatConfigService.getRMAllowedValues(RM_LIST);
}
}, "dfranco");
assertEquals(2, allowedValues.size());
assertTrue(allowedValues.contains(NOFORN));
assertTrue(allowedValues.contains(FOUO));
allowedValues = AuthenticationUtil.runAs(new RunAsWork<List<String>>()
{
public List<String> doWork()
@@ -405,39 +405,39 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
return caveatConfigService.getRMAllowedValues(RM_LIST);
}
}, "dmartinz");
assertEquals(4, allowedValues.size());
assertTrue(allowedValues.contains(NOFORN));
assertTrue(allowedValues.contains(NOCONTRACT));
assertTrue(allowedValues.contains(FOUO));
assertTrue(allowedValues.contains(FGI));
/**
//
* Now remove the entire list (rma:smList);
*/
logger.debug("test remove entire list rmc:smList");
caveatConfigService.deleteRMConstraint(RM_LIST);
/**
* Now add the list again
*/
logger.debug("test add back rmc:smList");
caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]);
/**
* Negative test - add a list that already exists
*/
logger.debug("try to create duplicate list rmc:smList");
caveatConfigService.addRMConstraint(RM_LIST, "my title", new String[0]);
/**
* Negative test - remove a list that does not exist
*/
logger.debug("test remove entire list rmc:smList");
caveatConfigService.deleteRMConstraint(RM_LIST);
try
try
{
caveatConfigService.deleteRMConstraint(RM_LIST);
fail("unknown constraint should have thrown an exception");
@@ -446,13 +446,13 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
{
// expect to go here
}
/**
* Negative test - add a constraint to property that does not exist
*/
logger.debug("test property does not exist");
try
try
{
caveatConfigService.addRMConstraint("rma:mer", "", new String[0]);
fail("unknown property should have thrown an exception");
@@ -464,13 +464,13 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
endTransaction();
cleanCaveatConfigData();
}
private void cleanCaveatConfigData()
{
startNewTransaction();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
deleteUser("jrangel");
deleteUser("dmartinz");
deleteUser("jrogers");
@@ -484,26 +484,26 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
deleteUser("dsandy");
deleteUser("driggs");
deleteUser("test1");
deleteGroup("Engineering");
deleteGroup("Finance");
deleteGroup("test1");
caveatConfigService.updateOrCreateCaveatConfig("{}"); // empty config !
setComplete();
endTransaction();
}
private void setupCaveatConfigData()
{
startNewTransaction();
// Switch to admin
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
// Create test users/groups (if they do not already exist)
createUser("jrangel");
createUser("dmartinz");
createUser("jrogers");
@@ -517,36 +517,36 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
createUser("dsandy");
createUser("driggs");
createUser("test1");
createGroup("Engineering");
createGroup("Finance");
createGroup("test1");
addToGroup("jrogers", "Engineering");
addToGroup("dfranco", "Finance");
// not in grouo to start with - added later
//addToGroup("gsmith", "Engineering");
//URL url = AbstractContentTransformerTest.class.getClassLoader().getResource("testCaveatConfig2.json"); // from test-resources
//assertNotNull(url);
//File file = new File(url.getFile());
//assertTrue(file.exists());
//caveatConfigService.updateOrCreateCaveatConfig(file);
setComplete();
endTransaction();
}
protected void createUser(String userName)
{
if (! authenticationService.authenticationExists(userName))
{
authenticationService.createAuthentication(userName, "PWD".toCharArray());
}
if (! personService.personExists(userName))
{
PropertyMap ppOne = new PropertyMap(4);
@@ -555,11 +555,11 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
ppOne.put(ContentModel.PROP_LASTNAME, "lastName");
ppOne.put(ContentModel.PROP_EMAIL, "email@email.com");
ppOne.put(ContentModel.PROP_JOBTITLE, "jobTitle");
personService.createPerson(ppOne);
}
}
protected void deleteUser(String userName)
{
if (personService.personExists(userName))
@@ -567,12 +567,12 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
personService.deletePerson(userName);
}
}
protected void createGroup(String groupShortName)
{
createGroup(null, groupShortName);
}
protected void createGroup(String parentGroupShortName, String groupShortName)
{
if (parentGroupShortName != null)
@@ -589,24 +589,24 @@ public class RMCaveatConfigServiceImplTest extends BaseSpringTest implements DOD
authorityService.createAuthority(AuthorityType.GROUP, groupShortName, groupShortName, null);
}
}
protected void deleteGroup(String groupShortName)
{
String groupFullName = authorityService.getName(AuthorityType.GROUP, groupShortName);
if (authorityService.authorityExists(groupFullName) == true)
if (authorityService.authorityExists(groupFullName))
{
authorityService.deleteAuthority(groupFullName);
}
}
protected void addToGroup(String authorityName, String groupShortName)
{
authorityService.addAuthority(authorityService.getName(AuthorityType.GROUP, groupShortName), authorityName);
}
protected void removeFromGroup(String authorityName, String groupShortName)
{
authorityService.removeAuthority(authorityService.getName(AuthorityType.GROUP, groupShortName), authorityName);
}
}

View File

@@ -53,10 +53,10 @@ import org.springframework.context.ApplicationContext;
/**
* Records management action service implementation test
*
*
* @author Roy Wetherall
*/
public class RecordsManagementActionServiceImplTest extends TestCase
public class RecordsManagementActionServiceImplTest extends TestCase
implements RecordsManagementModel,
BeforeRMActionExecution,
OnRMActionExecution
@@ -64,9 +64,9 @@ public class RecordsManagementActionServiceImplTest extends TestCase
private static final String[] CONFIG_LOCATIONS = new String[] {
"classpath:alfresco/application-context.xml",
"classpath:test-context.xml"};
private ApplicationContext ctx;
private ServiceRegistry serviceRegistry;
private TransactionService transactionService;
private RetryingTransactionHelper txnHelper;
@@ -76,13 +76,13 @@ public class RecordsManagementActionServiceImplTest extends TestCase
private NodeRef nodeRef;
private List<NodeRef> nodeRefs;
private boolean beforeMarker;
private boolean onMarker;
private boolean inTest;
@Override
protected void setUp() throws Exception
protected void setUp() throws Exception
{
ctx = ApplicationContextHelper.getApplicationContext(CONFIG_LOCATIONS);
@@ -90,13 +90,13 @@ public class RecordsManagementActionServiceImplTest extends TestCase
this.transactionService = serviceRegistry.getTransactionService();
this.txnHelper = transactionService.getRetryingTransactionHelper();
this.nodeService = serviceRegistry.getNodeService();
this.rmActionService = (RecordsManagementActionService)ctx.getBean("RecordsManagementActionService");
this.policyComponent = (PolicyComponent)ctx.getBean("policyComponent");
// Set the current security context as admin
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
RetryingTransactionCallback<Void> setUpCallback = new RetryingTransactionCallback<Void>()
{
public Void execute() throws Throwable
@@ -104,38 +104,38 @@ public class RecordsManagementActionServiceImplTest extends TestCase
// Create a node we can use for the tests
NodeRef rootNodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
nodeRef = nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "temp.txt"),
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "temp.txt"),
ContentModel.TYPE_CONTENT).getChildRef();
// Create nodeRef list
nodeRefs = new ArrayList<NodeRef>(5);
for (int i = 0; i < 5; i++)
{
nodeRefs.add(
nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "temp.txt"),
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "temp.txt"),
ContentModel.TYPE_CONTENT).getChildRef());
}
return null;
}
};
txnHelper.doInTransaction(setUpCallback);
beforeMarker = false;
onMarker = false;
inTest = false;
}
@Override
protected void tearDown()
{
AuthenticationUtil.clearCurrentSecurityContext();
}
public void testGetActions()
{
RetryingTransactionCallback<Void> testCallback = new RetryingTransactionCallback<Void>()
@@ -148,7 +148,7 @@ public class RecordsManagementActionServiceImplTest extends TestCase
};
txnHelper.doInTransaction(testCallback);
}
private void getActionsImpl()
{
List<RecordsManagementAction> result = this.rmActionService.getRecordsManagementActions();
@@ -158,10 +158,10 @@ public class RecordsManagementActionServiceImplTest extends TestCase
{
resultMap.put(action.getName(), action);
}
assertTrue(resultMap.containsKey(TestAction.NAME));
assertTrue(resultMap.containsKey(TestAction2.NAME));
result = this.rmActionService.getDispositionActions();
resultMap = new HashMap<String, RecordsManagementAction>(8);
for (RecordsManagementAction action : result)
@@ -170,22 +170,22 @@ public class RecordsManagementActionServiceImplTest extends TestCase
}
assertTrue(resultMap.containsKey(TestAction.NAME));
assertFalse(resultMap.containsKey(TestAction2.NAME));
// get some specific actions and check the label
RecordsManagementAction cutoff = this.rmActionService.getDispositionAction("cutoff");
assertNotNull(cutoff);
assertEquals("Cut off", cutoff.getLabel());
RecordsManagementAction freeze = this.rmActionService.getRecordsManagementAction("freeze");
assertNotNull(freeze);
assertEquals("Freeze", freeze.getLabel());
assertEquals("Freeze", freeze.getLabel());
// test non-existent actions
assertNull(this.rmActionService.getDispositionAction("notThere"));
assertNull(this.rmActionService.getRecordsManagementAction("notThere"));
}
public void testExecution()
{
RetryingTransactionCallback<Void> testCallback = new RetryingTransactionCallback<Void>()
@@ -198,10 +198,10 @@ public class RecordsManagementActionServiceImplTest extends TestCase
};
txnHelper.doInTransaction(testCallback);
}
public void beforeRMActionExecution(NodeRef nodeRef, String name, Map<String, Serializable> parameters)
{
if (inTest == true)
if (inTest)
{
assertEquals(this.nodeRef, nodeRef);
assertEquals(TestAction.NAME, name);
@@ -214,7 +214,7 @@ public class RecordsManagementActionServiceImplTest extends TestCase
public void onRMActionExecution(NodeRef nodeRef, String name, Map<String, Serializable> parameters)
{
if (inTest == true)
if (inTest)
{
assertEquals(this.nodeRef, nodeRef);
assertEquals(TestAction.NAME, name);
@@ -224,29 +224,29 @@ public class RecordsManagementActionServiceImplTest extends TestCase
onMarker = true;
}
}
private void executionImpl()
{
inTest = true;
try
{
policyComponent.bindClassBehaviour(
RecordsManagementPolicies.BEFORE_RM_ACTION_EXECUTION,
this,
RecordsManagementPolicies.BEFORE_RM_ACTION_EXECUTION,
this,
new JavaBehaviour(this, "beforeRMActionExecution", NotificationFrequency.EVERY_EVENT));
policyComponent.bindClassBehaviour(
RecordsManagementPolicies.ON_RM_ACTION_EXECUTION,
this,
RecordsManagementPolicies.ON_RM_ACTION_EXECUTION,
this,
new JavaBehaviour(this, "onRMActionExecution", NotificationFrequency.EVERY_EVENT));
assertFalse(beforeMarker);
assertFalse(onMarker);
assertFalse(this.nodeService.hasAspect(this.nodeRef, ASPECT_RECORD));
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(TestAction.PARAM, TestAction.PARAM_VALUE);
this.rmActionService.executeRecordsManagementAction(this.nodeRef, TestAction.NAME, params);
assertTrue(beforeMarker);
assertTrue(onMarker);
assertTrue(this.nodeService.hasAspect(this.nodeRef, ASPECT_RECORD));
@@ -256,7 +256,7 @@ public class RecordsManagementActionServiceImplTest extends TestCase
inTest = false;
}
}
public void testBulkExecution()
{
RetryingTransactionCallback<Void> testCallback = new RetryingTransactionCallback<Void>()
@@ -269,18 +269,18 @@ public class RecordsManagementActionServiceImplTest extends TestCase
};
txnHelper.doInTransaction(testCallback);
}
private void bulkExecutionImpl()
{
for (NodeRef nodeRef : this.nodeRefs)
{
assertFalse(this.nodeService.hasAspect(nodeRef, ASPECT_RECORD));
}
Map<String, Serializable> params = new HashMap<String, Serializable>(1);
params.put(TestAction.PARAM, TestAction.PARAM_VALUE);
this.rmActionService.executeRecordsManagementAction(this.nodeRefs, TestAction.NAME, params);
this.rmActionService.executeRecordsManagementAction(this.nodeRefs, TestAction.NAME, params);
for (NodeRef nodeRef : this.nodeRefs)
{
assertTrue(this.nodeService.hasAspect(nodeRef, ASPECT_RECORD));

View File

@@ -116,7 +116,7 @@ public class RecordsManagementEventServiceImplTest extends BaseRMTestCase implem
boolean result = false;
for (RecordsManagementEvent event : events)
{
if (eventName.equals(event.getName()) == true)
if (eventName.equals(event.getName()))
{
result = true;
break;

View File

@@ -429,7 +429,7 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
assertEquals(enabled, vitalRecordIndicator.booleanValue());
assertEquals(enabled, def.isEnabled());
if (enabled == true)
if (enabled)
{
Period reviewPeriod = (Period)nodeService.getProperty(nodeRef, PROP_REVIEW_PERIOD);
assertNotNull(reviewPeriod);
@@ -443,7 +443,7 @@ public class VitalRecordServiceImplTest extends BaseRMTestCase
private void assertVitalRecord(NodeRef nodeRef, boolean enabled, Period period)
{
assertEquals(enabled, nodeService.hasAspect(nodeRef, ASPECT_VITAL_RECORD));
if (enabled == true)
if (enabled)
{
Date reviewAsOf = (Date)nodeService.getProperty(nodeRef, PROP_REVIEW_AS_OF);
assertNotNull(reviewAsOf);

View File

@@ -336,19 +336,19 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
setupTestData();
// Create multi hierarchy data
if (isMultiHierarchyTest() == true)
if (isMultiHierarchyTest())
{
setupMultiHierarchyTestData();
}
// Create collaboration data
if (isCollaborationSiteTest() == true)
if (isCollaborationSiteTest())
{
setupCollaborationSiteTestData();
}
// Create the users here
if (isUserTest() == true)
if (isUserTest())
{
setupTestUsers(filePlan);
}
@@ -431,7 +431,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
filter.disableBehaviour();
try
{
if (filePlan != null && nodeService.exists(filePlan) == true)
if (filePlan != null && nodeService.exists(filePlan))
{
List<NodeRef> holds = holdService.getHoldsInFilePlan(filePlan);
for (NodeRef hold : holds)
@@ -440,7 +440,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
}
}
if (folder != null && nodeService.exists(folder) == true)
if (folder != null && nodeService.exists(folder))
{
// Delete the folder
nodeService.deleteNode(folder);
@@ -453,7 +453,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
}
// delete the collaboration site (if required)
if (isCollaborationSiteTest() == true && siteService.getSite(collabSiteId) != null)
if (isCollaborationSiteTest() && siteService.getSite(collabSiteId) != null)
{
siteService.deleteSite(collabSiteId);
}
@@ -484,7 +484,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
{
setupTestDataImpl();
if (isRecordTest() == true && isRMSiteTest() == true)
if (isRecordTest() && isRMSiteTest())
{
setupTestRecords();
}
@@ -495,9 +495,9 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
@Override
public void test(Void result) throws Exception
{
if (isRMSiteTest() == true)
if (isRMSiteTest())
{
if (isRecordTest() == true)
if (isRecordTest())
{
// declare a record
utils.declareRecord(recordDeclaredOne);
@@ -542,7 +542,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
permissionService.setPermission(folder, "rmadmin", PermissionService.WRITE, true);
permissionService.setPermission(folder, "rmadmin", PermissionService.ADD_CHILDREN, true);
if (isRMSiteTest() == true)
if (isRMSiteTest())
{
siteId = GUID.generate();
siteInfo = siteService.createSite(
@@ -633,7 +633,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
rmAdminName
};
if (isFillingForAllUsers() == true)
if (isFillingForAllUsers())
{
// Give all the users file permission objects
for (String user : testUsers)
@@ -653,7 +653,7 @@ public abstract class BaseRMTestCase extends RetryingTransactionHelperTestCase
*/
protected NodeRef createPerson(String userName, boolean createAuth)
{
if (createAuth == true)
if (createAuth)
{
authenticationService.createAuthentication(userName, "password".toCharArray());
}

View File

@@ -218,7 +218,7 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest
siteService.deleteSite(siteId);
// Delete the collaboration site (if required)
if (isCollaborationSiteTest() == true)
if (isCollaborationSiteTest())
{
siteService.deleteSite(collabSiteId);
}
@@ -300,7 +300,7 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest
assertNotNull("Could not create rm folder 2", recordFolder2);
// Create collaboration data
if (isCollaborationSiteTest() == true)
if (isCollaborationSiteTest())
{
setupCollaborationSiteTestData();
}
@@ -359,7 +359,7 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest
protected void deleteUser(String userName)
{
if (authenticationService.authenticationExists(userName) == true)
if (authenticationService.authenticationExists(userName))
{
personService.deletePerson(userName);
}
@@ -375,7 +375,7 @@ public class BaseRMWebScriptTestCase extends BaseWebScriptTest
protected void deleteGroup(String groupName)
{
if (authorityService.authorityExists(groupName) == true)
if (authorityService.authorityExists(groupName))
{
authorityService.deleteAuthority(groupName, true);
}

View File

@@ -125,7 +125,7 @@ public class CommonRMTestUtils implements RecordsManagementModel
dsProps.put(PROP_RECORD_LEVEL_DISPOSITION, isRecordLevel);
DispositionSchedule dispositionSchedule = dispositionService.createDispositionSchedule(container, dsProps);
if (defaultDispositionActions == true)
if (defaultDispositionActions)
{
Map<QName, Serializable> adParams = new HashMap<QName, Serializable>(3);
adParams.put(PROP_DISPOSITION_ACTION_NAME, CutOffAction.NAME);
@@ -137,7 +137,7 @@ public class CommonRMTestUtils implements RecordsManagementModel
dispositionService.addDispositionActionDefinition(dispositionSchedule, adParams);
if (extendedDispositionSchedule == true)
if (extendedDispositionSchedule)
{
adParams = new HashMap<QName, Serializable>(4);
adParams.put(PROP_DISPOSITION_ACTION_NAME, TransferAction.NAME);