Skip to content

Commit

Permalink
ACS-5506 PMD fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalKinas committed Jan 17, 2024
1 parent 0ec9d1a commit 8cd2416
Show file tree
Hide file tree
Showing 6 changed files with 1,136 additions and 1,137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
package org.alfresco.rest.model;

import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

Expand All @@ -46,9 +46,9 @@ public class RestGroupsModel extends TestModel implements IRestModel<RestGroupsM
private Boolean hasSubgroups;

@JsonProperty("parentIds")
private ArrayList<String> parentIds;
private List<String> parentIds;
@JsonProperty("zones")
private ArrayList<String> zones;
private List<String> zones;

@JsonProperty(value = "entry")
RestGroupsModel model;
Expand Down Expand Up @@ -105,22 +105,22 @@ public void setIsRoot(Boolean isRoot)
this.isRoot = isRoot;
}

public ArrayList<String> getParentIds()
public List<String> getParentIds()
{
return parentIds;
}

public void setParentIds(ArrayList<String> parentIds)
public void setParentIds(List<String> parentIds)
{
this.parentIds = parentIds;
}

public ArrayList<String> getZones()
public List<String> getZones()
{
return zones;
}

public void setZones(ArrayList<String> zones)
public void setZones(List<String> zones)
{
this.zones = zones;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ public void dataPreparation() throws Exception
@Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY })
@TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY,
description = "Verify creation, listing, updating and deletion of groups.")
public void createListUpdateAndDeleteGroup() throws Exception
{
String groupName = "ZtestGroup" + UUID.randomUUID().toString();
String groupDescription = "ZtestGroup description" + UUID.randomUUID().toString();
public void createListUpdateAndDeleteGroup() {
String groupName = "ZtestGroup" + UUID.randomUUID();
String groupDescription = "ZtestGroup description" + UUID.randomUUID();
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).add("description", groupDescription).build();
String groupBodyCreate = groupBody.toString();

Expand Down Expand Up @@ -88,10 +87,9 @@ public void createListUpdateAndDeleteGroup() throws Exception
@Test(groups = { TestGroup.REST_API, TestGroup.GROUPS, TestGroup.SANITY })
@TestRail(section = { TestGroup.REST_API, TestGroup.NODES }, executionType = ExecutionType.SANITY,
description = "Verify creation, listing(only for person) and deletion of group memberships. ")
public void createListDeleteGroupMembership() throws Exception
{
String groupName = "ZtestGroup" + UUID.randomUUID().toString();
String subGroupName = "ZtestSubgroup" + UUID.randomUUID().toString();
public void createListDeleteGroupMembership() {
String groupName = "ZtestGroup" + UUID.randomUUID();
String subGroupName = "ZtestSubgroup" + UUID.randomUUID();
JsonObject groupBody = Json.createObjectBuilder().add("id", groupName).add("displayName", groupName).build();
JsonObject subgroupBody = Json.createObjectBuilder().add("id", subGroupName).add("displayName", subGroupName).build();
String groupBodyCreate = groupBody.toString();
Expand Down Expand Up @@ -150,7 +148,7 @@ public void createListDeleteGroupMembership() throws Exception
description = "Verify listing of group memberships.")
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();
String groupBodyCreate = groupBody.toString();

Expand All @@ -169,12 +167,10 @@ public void listGroupMembership() throws Exception
restClient.assertStatusCodeIs(HttpStatus.CREATED);

//ListGroupMembership
RetryOperation op = new RetryOperation(){
public void execute() throws Exception{
restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+groupName)
.assertThat().entriesListContains("id", userModel.getUsername());
restClient.assertStatusCodeIs(HttpStatus.OK);
}
RetryOperation op = () -> {
restClient.withCoreAPI().usingGroups().listGroupMemberships("GROUP_"+groupName)
.assertThat().entriesListContains("id", userModel.getUsername());
restClient.assertStatusCodeIs(HttpStatus.OK);
};
Utility.sleep(500, 35000, op);// Allow indexing to complete.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ public class GroupsImpl implements Groups
}

// 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 NodeService nodeService;
Expand Down Expand Up @@ -241,7 +241,7 @@ public CollectionWithPagingInfo<Group> getGroups(final Parameters parameters)

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
public Group get(int index)
Expand Down Expand Up @@ -656,7 +656,7 @@ private Pair<String, Boolean> getGroupsSortProp(Parameters parameters)
Pair<String, Boolean> sortProp;
List<SortColumn> sortCols = parameters.getSorting();

if ((sortCols != null) && (sortCols.size() > 0))
if (sortCols != null && !sortCols.isEmpty())
{
if (sortCols.size() > 1)
{
Expand All @@ -671,7 +671,7 @@ private Pair<String, Boolean> getGroupsSortProp(Parameters parameters)
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
{
Expand Down Expand Up @@ -887,7 +887,7 @@ public void deleteGroupMembership(String groupId, String groupMemberId)

// Verify if groupMemberId is member of groupId
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))
{
throw new NotFoundException(groupMemberId + " is not member of " + groupId);
Expand Down Expand Up @@ -1093,7 +1093,7 @@ private boolean authorityExists(AuthorityType authorityType, String authorityNam
{
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,6 @@ public String toString()
public boolean wasSet(String fieldName)
{
Boolean b = setFields.get(fieldName);
return (b != null ? b : false);
return b != null ? b : false;
}
}
Loading

0 comments on commit 8cd2416

Please sign in to comment.