Skip to content

Commit d879a6d

Browse files
committed
removed commented out lines and fix some comments
1 parent 2c6a3d0 commit d879a6d

3 files changed

Lines changed: 9 additions & 20 deletions

File tree

src/main/java/io/permit/sdk/api/GroupsApi.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import java.io.IOException;
1313
import java.util.*;
1414

15+
// This is a partial support for the Groups API, some methods are currently missing.
1516
interface IGroupsApi {
16-
// GroupRead[] list(String resource, Boolean includeTotalCount, int page, int perPage, String search) throws IOException, PermitApiError, PermitContextError;
1717
GroupRead[] list(int page, int perPage) throws IOException, PermitApiError, PermitContextError;
1818
GroupRead[] list(int page) throws IOException, PermitApiError, PermitContextError;
1919
GroupRead[] list() throws IOException, PermitApiError, PermitContextError;
@@ -26,16 +26,6 @@ interface IGroupsApi {
2626
GroupRead assignUserToGroup(String userId, String groupInstanceKey, String tenant) throws IOException, PermitApiError, PermitContextError;
2727
void removeRoleFromGroup(String groupInstanceKey, GroupAddRole groupAddRole) throws IOException, PermitApiError, PermitContextError;
2828
void removeUserFromGroup(String userId, String groupInstanceKey, String tenant) throws IOException, PermitApiError, PermitContextError;
29-
30-
31-
// GroupReadSchema getDirectGroup(String projId, String envId, String groupInstanceKey) throws IOException, PermitApiError, PermitContextError;
32-
// PaginatedResultGroupReadSchema listDirectGroup(String projId, String envId, String tenant, String resource, Integer page, Integer perPage, String search) throws IOException, PermitApiError, PermitContextError;
33-
// PaginatedResultGroupReadSchema listGroupChildren(String projId, String envId, String groupInstanceKey, Integer page, Integer perPage) throws IOException, PermitApiError, PermitContextError;
34-
// PaginatedResultGroupReadSchema listGroupParents(String projId, String envId, String groupInstanceKey, Integer page, Integer perPage) throws IOException, PermitApiError, PermitContextError;
35-
// PaginatedResultGroupRoleReadSchema listGroupRoles(String projId, String envId, String groupInstanceKey, Integer page, Integer perPage) throws IOException, PermitApiError, PermitContextError;
36-
// PaginatedResultGroupUserReadSchema listGroupUsers(String projId, String envId, String groupInstanceKey, Integer page, Integer perPage) throws IOException, PermitApiError, PermitContextError;
37-
// GroupRead assignGroupToGroup(String projId, String envId, String groupInstanceKey, GroupAssignment groupAssignment) throws IOException, PermitApiError, PermitContextError;
38-
// void removeGroupFromGroup(String projId, String envId, String groupInstanceKey, GroupAssignment groupAssignment) throws IOException, PermitApiError, PermitContextError;
3929
}
4030

4131
public class GroupsApi extends BaseApi implements IGroupsApi {
@@ -71,7 +61,7 @@ private String getGroupsUrl(String url) {
7161
*
7262
* @param page The page number of the result set to retrieve.
7363
* @param perPage The number of items per page.
74-
* @return A PaginatedResultUserRead object representing the retrieved paginated result of groups.
64+
* @return An array of GroupRead objects representing the retrieved groups.
7565
* @throws IOException If an I/O error occurs during the HTTP request.
7666
* @throws PermitApiError If the Permit API returns a response with an error status code.
7767
* @throws PermitContextError If the configured {@link io.permit.sdk.PermitContext} does not match the required endpoint context.
@@ -86,8 +76,8 @@ public GroupRead[] list(int page, int perPage) throws IOException, PermitApiErro
8676
new Request.Builder()
8777
.url(
8878
urlBuilder
89-
// .addQueryParameter("page", Integer.toString(page))
90-
// .addQueryParameter("per_page", Integer.toString(perPage))
79+
.addQueryParameter("page", Integer.toString(page))
80+
.addQueryParameter("per_page", Integer.toString(perPage))
9181
.build()
9282
)
9383
.get()
@@ -230,7 +220,7 @@ public void delete(String groupInstanceKey) throws IOException, PermitApiError,
230220
* Assign a role to the group, all users in this group will now have this role.
231221
* It will create relation between the group and the resource, relationship between the resource instances and derivation from the member role to this role.
232222
*
233-
* @param groupInstanceKey The key of the group to assign the user.
223+
* @param groupInstanceKey The key of the group to assign the role to.
234224
* @param groupAddRole The {@link GroupAddRole} object containing the assignment data.
235225
* @return The {@link GroupRead} object representing the group after assigning the role.
236226
* @throws IOException If an I/O error occurs during the HTTP request.
@@ -281,7 +271,7 @@ public GroupRead assignUserToGroup(String userId, String groupInstanceKey, Strin
281271
}
282272

283273
/**
284-
* Remove a role to the group, all users in this group will lose this role.
274+
* Remove a role from the group, all users in this group will lose this role.
285275
*
286276
* @param groupInstanceKey The key of the group to assign the user.
287277
* @param groupAddRole The {@link GroupAddRole} object containing the assignment data.

src/test/java/io/permit/sdk/endpoints/GroupsApiE2ETest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.io.IOException;
1313
import java.util.Arrays;
1414
import java.util.HashMap;
15+
import java.util.stream.Collectors;
1516

1617
import static org.junit.jupiter.api.Assertions.*;
1718

@@ -131,8 +132,7 @@ void testGroupsApi() {
131132
assertEquals(groups.length, originalLength + 1);
132133

133134
logger.info("verify can find new group in the new list");
134-
// logger.info(Arrays.stream(groups).map(r -> r.groupInstanceKey).toList().toString());
135-
assertTrue(Arrays.stream(groups).map(r -> r.groupInstanceKey).toList().toString().contains(marketingData.groupInstanceKey));
135+
assertTrue(Arrays.stream(groups).map(r -> r.groupInstanceKey).collect(Collectors.toList()).toString().contains(marketingData.groupInstanceKey));
136136

137137
logger.info("get non existing group -> 404");
138138
PermitApiError notFoundError = assertThrows(PermitApiError.class, () -> {
@@ -203,7 +203,6 @@ void testGroupsApi() {
203203
assertEquals(2, afterAddingRole.assignedRoles.size());
204204

205205
logger.info("Removing role from group");
206-
// String trainingVideoFullKey = groupRoleData.resource + ":" + groupRoleData.resourceInstance;
207206
permit.api.groups.removeRoleFromGroup(GROUP_KEY, groupRoleData);
208207
GroupRead afterRemovingRole = permit.api.groups.get(GROUP_KEY);
209208
for (String role : afterRemovingRole.assignedRoles) {

src/test/java/io/permit/sdk/endpoints/ResourcesApiE2ETest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void testResourcesApi() {
8585
Permit permit = new Permit(this.config);
8686
Gson gson = new Gson();
8787

88-
// users lifecycle
88+
// Resource lifecycle.
8989
try {
9090
logger.info("check original resource length");
9191
int originalLength = permit.api.resources.list().length;

0 commit comments

Comments
 (0)