mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
ACS-5506 PMD fixes
This commit is contained in:
@@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.rest.model;
|
package org.alfresco.rest.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.List;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
@@ -46,9 +46,9 @@ public class RestGroupsModel extends TestModel implements IRestModel<RestGroupsM
|
|||||||
private Boolean hasSubgroups;
|
private Boolean hasSubgroups;
|
||||||
|
|
||||||
@JsonProperty("parentIds")
|
@JsonProperty("parentIds")
|
||||||
private ArrayList<String> parentIds;
|
private List<String> parentIds;
|
||||||
@JsonProperty("zones")
|
@JsonProperty("zones")
|
||||||
private ArrayList<String> zones;
|
private List<String> zones;
|
||||||
|
|
||||||
@JsonProperty(value = "entry")
|
@JsonProperty(value = "entry")
|
||||||
RestGroupsModel model;
|
RestGroupsModel model;
|
||||||
@@ -105,22 +105,22 @@ public class RestGroupsModel extends TestModel implements IRestModel<RestGroupsM
|
|||||||
this.isRoot = isRoot;
|
this.isRoot = isRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getParentIds()
|
public List<String> getParentIds()
|
||||||
{
|
{
|
||||||
return parentIds;
|
return parentIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentIds(ArrayList<String> parentIds)
|
public void setParentIds(List<String> parentIds)
|
||||||
{
|
{
|
||||||
this.parentIds = parentIds;
|
this.parentIds = parentIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getZones()
|
public List<String> getZones()
|
||||||
{
|
{
|
||||||
return zones;
|
return zones;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setZones(ArrayList<String> zones)
|
public void setZones(List<String> zones)
|
||||||
{
|
{
|
||||||
this.zones = zones;
|
this.zones = zones;
|
||||||
}
|
}
|
||||||
|
@@ -31,10 +31,9 @@ public class GroupsTests extends RestTest
|
|||||||
@Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY })
|
@Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY })
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY,
|
@TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY,
|
||||||
description = "Verify creation, listing, updating and deletion of groups.")
|
description = "Verify creation, listing, updating and deletion of groups.")
|
||||||
public void createListUpdateAndDeleteGroup() throws Exception
|
public void createListUpdateAndDeleteGroup() {
|
||||||
{
|
String groupName = "ZtestGroup" + UUID.randomUUID();
|
||||||
String groupName = "ZtestGroup" + UUID.randomUUID().toString();
|
String groupDescription = "ZtestGroup description" + UUID.randomUUID();
|
||||||
String groupDescription = "ZtestGroup description" + UUID.randomUUID().toString();
|
|
||||||
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).add("description", groupDescription).build();
|
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).add("description", groupDescription).build();
|
||||||
String groupBodyCreate = groupBody.toString();
|
String groupBodyCreate = groupBody.toString();
|
||||||
|
|
||||||
@@ -88,10 +87,9 @@ public class GroupsTests extends RestTest
|
|||||||
@Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY })
|
@Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY })
|
||||||
@TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY,
|
@TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY,
|
||||||
description = "Verify creation, listing(only for person) and deletion of group memberships. ")
|
description = "Verify creation, listing(only for person) and deletion of group memberships. ")
|
||||||
public void createListDeleteGroupMembership() throws Exception
|
public void createListDeleteGroupMembership() {
|
||||||
{
|
String groupName = "ZtestGroup" + UUID.randomUUID();
|
||||||
String groupName = "ZtestGroup" + UUID.randomUUID().toString();
|
String subGroupName = "ZtestSubgroup" + UUID.randomUUID();
|
||||||
String subGroupName = "ZtestSubgroup" + UUID.randomUUID().toString();
|
|
||||||
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build();
|
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build();
|
||||||
JsonObject subgroupBody = Json.createObjectBuilder().add("id", subGroupName).add("displayName", subGroupName).build();
|
JsonObject subgroupBody = Json.createObjectBuilder().add("id", subGroupName).add("displayName", subGroupName).build();
|
||||||
String groupBodyCreate = groupBody.toString();
|
String groupBodyCreate = groupBody.toString();
|
||||||
@@ -150,7 +148,7 @@ public class GroupsTests extends RestTest
|
|||||||
description = "Verify listing of group memberships.")
|
description = "Verify listing of group memberships.")
|
||||||
public void listGroupMembership() throws Exception
|
public void listGroupMembership() throws Exception
|
||||||
{
|
{
|
||||||
String groupName = "testGroup" + UUID.randomUUID().toString();
|
String groupName = "testGroup" + UUID.randomUUID();
|
||||||
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build();
|
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build();
|
||||||
String groupBodyCreate = groupBody.toString();
|
String groupBodyCreate = groupBody.toString();
|
||||||
|
|
||||||
@@ -169,12 +167,10 @@ public class GroupsTests extends RestTest
|
|||||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||||
|
|
||||||
//ListGroupMembership
|
//ListGroupMembership
|
||||||
RetryOperation op = new RetryOperation(){
|
RetryOperation op = () -> {
|
||||||
public void execute() throws Exception{
|
restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+groupName)
|
||||||
restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+groupName)
|
.assertThat().entriesListContains("id", userModel.getUsername());
|
||||||
.assertThat().entriesListContains("id", userModel.getUsername());
|
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Utility.sleep(500, 35000, op);// Allow indexing to complete.
|
Utility.sleep(500, 35000, op);// Allow indexing to complete.
|
||||||
}
|
}
|
||||||
|
@@ -107,9 +107,9 @@ public class GroupsImpl implements Groups
|
|||||||
}
|
}
|
||||||
|
|
||||||
// List groups filtering (via where clause)
|
// List groups filtering (via where clause)
|
||||||
private final static Set<String> LIST_GROUPS_EQUALS_QUERY_PROPERTIES = new HashSet<>(Arrays.asList(new String[] { PARAM_IS_ROOT }));
|
private final static Set<String> LIST_GROUPS_EQUALS_QUERY_PROPERTIES = new HashSet<>(List.of(PARAM_IS_ROOT));
|
||||||
|
|
||||||
private final static Set<String> LIST_GROUP_MEMBERS_QUERY_PROPERTIES = new HashSet<>(Arrays.asList(new String[] { PARAM_MEMBER_TYPE }));
|
private final static Set<String> LIST_GROUP_MEMBERS_QUERY_PROPERTIES = new HashSet<>(List.of(PARAM_MEMBER_TYPE));
|
||||||
|
|
||||||
protected AuthorityService authorityService;
|
protected AuthorityService authorityService;
|
||||||
protected NodeService nodeService;
|
protected NodeService nodeService;
|
||||||
@@ -241,7 +241,7 @@ public class GroupsImpl implements Groups
|
|||||||
|
|
||||||
private List<Group> createGroupsResponse(final List<AuthorityInfo> page, final List<String> includeParam, final Set<String> rootAuthorities)
|
private List<Group> createGroupsResponse(final List<AuthorityInfo> page, final List<String> includeParam, final Set<String> rootAuthorities)
|
||||||
{
|
{
|
||||||
List<Group> groups = new AbstractList<Group>()
|
List<Group> groups = new AbstractList<>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public Group get(int index)
|
public Group get(int index)
|
||||||
@@ -656,7 +656,7 @@ public class GroupsImpl implements Groups
|
|||||||
Pair<String, Boolean> sortProp;
|
Pair<String, Boolean> sortProp;
|
||||||
List<SortColumn> sortCols = parameters.getSorting();
|
List<SortColumn> sortCols = parameters.getSorting();
|
||||||
|
|
||||||
if ((sortCols != null) && (sortCols.size() > 0))
|
if (sortCols != null && !sortCols.isEmpty())
|
||||||
{
|
{
|
||||||
if (sortCols.size() > 1)
|
if (sortCols.size() > 1)
|
||||||
{
|
{
|
||||||
@@ -671,7 +671,7 @@ public class GroupsImpl implements Groups
|
|||||||
throw new InvalidArgumentException("Invalid sort field: " + sortCol.column);
|
throw new InvalidArgumentException("Invalid sort field: " + sortCol.column);
|
||||||
}
|
}
|
||||||
|
|
||||||
sortProp = new Pair<>(sortPropName, (sortCol.asc ? Boolean.TRUE : Boolean.FALSE));
|
sortProp = new Pair<>(sortPropName, sortCol.asc ? Boolean.TRUE : Boolean.FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -887,7 +887,7 @@ public class GroupsImpl implements Groups
|
|||||||
|
|
||||||
// Verify if groupMemberId is member of groupId
|
// Verify if groupMemberId is member of groupId
|
||||||
AuthorityType authorityType = AuthorityType.getAuthorityType(groupMemberId);
|
AuthorityType authorityType = AuthorityType.getAuthorityType(groupMemberId);
|
||||||
Set<String> parents = authorityService.getContainingAuthorities(AuthorityType.GROUP, groupMemberId, true);
|
Set<String> parents = authorityService.getContainingAuthorities(authorityType, groupMemberId, true);
|
||||||
if (!parents.contains(groupId))
|
if (!parents.contains(groupId))
|
||||||
{
|
{
|
||||||
throw new NotFoundException(groupMemberId + " is not member of " + groupId);
|
throw new NotFoundException(groupMemberId + " is not member of " + groupId);
|
||||||
@@ -1093,7 +1093,7 @@ public class GroupsImpl implements Groups
|
|||||||
{
|
{
|
||||||
String name = inferPrefix ? authorityService.getName(authorityType, authorityName) : authorityName;
|
String name = inferPrefix ? authorityService.getName(authorityType, authorityName) : authorityName;
|
||||||
|
|
||||||
return (name != null && authorityService.authorityExists(name));
|
return name != null && authorityService.authorityExists(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isGroupAuthority(String authorityName)
|
private boolean isGroupAuthority(String authorityName)
|
||||||
|
@@ -181,6 +181,6 @@ public class Group implements Comparable<Group>
|
|||||||
public boolean wasSet(String fieldName)
|
public boolean wasSet(String fieldName)
|
||||||
{
|
{
|
||||||
Boolean b = setFields.get(fieldName);
|
Boolean b = setFields.get(fieldName);
|
||||||
return (b != null ? b : false);
|
return b != null ? b : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
@@ -51,7 +51,11 @@ import org.mockito.Mock;
|
|||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,13 +71,13 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
|
|||||||
|
|
||||||
protected AuthorityService authorityService;
|
protected AuthorityService authorityService;
|
||||||
|
|
||||||
private String rootGroupName = null;
|
private String rootGroupName;
|
||||||
private Group rootGroup = null;
|
private Group rootGroup;
|
||||||
private Group groupA = null;
|
private Group groupA;
|
||||||
private Group groupB = null;
|
private Group groupB;
|
||||||
private GroupMember groupMemberA = null;
|
private GroupMember groupMemberA;
|
||||||
private GroupMember groupMemberB = null;
|
private GroupMember groupMemberB;
|
||||||
private GroupMember personMember = null;
|
private GroupMember personMember;
|
||||||
@Mock
|
@Mock
|
||||||
private ResultSetRow groupAResultSetRow;
|
private ResultSetRow groupAResultSetRow;
|
||||||
@Mock
|
@Mock
|
||||||
@@ -955,7 +959,7 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
|
|||||||
expected.retainAll(respPostProcess.getList());
|
expected.retainAll(respPostProcess.getList());
|
||||||
|
|
||||||
// If this assertion fails, then the tests aren't providing any value - change them!
|
// If this assertion fails, then the tests aren't providing any value - change them!
|
||||||
assertTrue("List doesn't contain enough items for test to be conclusive.", expected.size() > 0);
|
assertTrue("List doesn't contain enough items for test to be conclusive.", !expected.isEmpty());
|
||||||
checkList(expected, respPostProcess.getPaging(), respPostProcess);
|
checkList(expected, respPostProcess.getPaging(), respPostProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -976,7 +980,7 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
|
|||||||
expected.retainAll(respPostProcess.getList());
|
expected.retainAll(respPostProcess.getList());
|
||||||
|
|
||||||
// If this assertion fails, then the tests aren't providing any value - change them!
|
// If this assertion fails, then the tests aren't providing any value - change them!
|
||||||
assertTrue("List doesn't contain enough items for test to be conclusive.", expected.size() > 0);
|
assertTrue("List doesn't contain enough items for test to be conclusive.", !expected.isEmpty());
|
||||||
checkList(expected, respPostProcess.getPaging(), respPostProcess);
|
checkList(expected, respPostProcess.getPaging(), respPostProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1153,7 +1157,6 @@ public class GroupsTest extends AbstractSingleNetworkSiteTest
|
|||||||
|
|
||||||
// -ve test: invalid zones clause
|
// -ve test: invalid zones clause
|
||||||
{
|
{
|
||||||
Paging paging = getPaging(0, Integer.MAX_VALUE);
|
|
||||||
Map<String, String> otherParams = new HashMap<>();
|
Map<String, String> otherParams = new HashMap<>();
|
||||||
otherParams.put("include", org.alfresco.rest.api.Groups.PARAM_INCLUDE_ZONES);
|
otherParams.put("include", org.alfresco.rest.api.Groups.PARAM_INCLUDE_ZONES);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user