Search in sources :

Example 11 with GroupEntity

use of io.gravitee.rest.api.model.GroupEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiService_FindPrimaryOwnerTest method defineGroup.

private void defineGroup(String groupId) {
    GroupEntity groupEntity = new GroupEntity();
    groupEntity.setId(groupId);
    when(groupService.findById(groupId)).thenReturn(groupEntity);
}
Also used : GroupEntity(io.gravitee.rest.api.model.GroupEntity)

Example 12 with GroupEntity

use of io.gravitee.rest.api.model.GroupEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiService_FindPrimaryOwnerTest method setCurrentUserInNoPOGroup.

private void setCurrentUserInNoPOGroup() {
    GroupEntity aNonPoGroup = new GroupEntity();
    aNonPoGroup.setId("aNonPoGroup");
    aNonPoGroup.setApiPrimaryOwner(null);
    GroupEntity anotherNonPoGroup = new GroupEntity();
    anotherNonPoGroup.setId("anotherNonPoGroup");
    anotherNonPoGroup.setApiPrimaryOwner(null);
    when(groupService.findByUser(CURRENT_USER)).thenReturn(new HashSet<>(Arrays.asList(aNonPoGroup, anotherNonPoGroup)));
}
Also used : GroupEntity(io.gravitee.rest.api.model.GroupEntity)

Example 13 with GroupEntity

use of io.gravitee.rest.api.model.GroupEntity in project gravitee-management-rest-api by gravitee-io.

the class ApiService_FindPrimaryOwnerTest method addUserInPOGroup.

private void addUserInPOGroup(String username, String poGroup) {
    GroupEntity userPoGroup = new GroupEntity();
    userPoGroup.setId(poGroup);
    userPoGroup.setApiPrimaryOwner("PO-of-current_user-po-group");
    GroupEntity aNonPoGroup = new GroupEntity();
    aNonPoGroup.setId("aNonPoGroup");
    aNonPoGroup.setApiPrimaryOwner(null);
    when(groupService.findByUser(username)).thenReturn(new HashSet<>(Arrays.asList(userPoGroup, aNonPoGroup)));
}
Also used : GroupEntity(io.gravitee.rest.api.model.GroupEntity)

Example 14 with GroupEntity

use of io.gravitee.rest.api.model.GroupEntity in project gravitee-management-rest-api by gravitee-io.

the class MembershipService_FindUserMembershipTest method shouldGetApiWithOnlyGroups.

@Test
public void shouldGetApiWithOnlyGroups() throws Exception {
    when(mockRoleService.findByScope(any())).thenReturn(Collections.emptyList());
    Membership mGroup = mock(Membership.class);
    when(mGroup.getReferenceId()).thenReturn("api-id2");
    when(mockMembershipRepository.findByMemberIdAndMemberTypeAndReferenceType(eq(USER_ID), eq(MembershipMemberType.USER), eq(MembershipReferenceType.API))).thenReturn(Collections.emptySet());
    when(mockMembershipRepository.findByMemberIdAndMemberTypeAndReferenceType(eq("GROUP"), eq(MembershipMemberType.GROUP), eq(MembershipReferenceType.API))).thenReturn(Collections.singleton(mGroup));
    GroupEntity group1 = mock(GroupEntity.class);
    doReturn("GROUP").when(group1).getId();
    doReturn(new HashSet<>(asList(group1))).when(mockGroupService).findByUser(USER_ID);
    List<UserMembership> references = membershipService.findUserMembership(io.gravitee.rest.api.model.MembershipReferenceType.API, USER_ID);
    assertFalse(references.isEmpty());
    assertEquals(1, references.size());
    assertEquals("api-id2", references.get(0).getReference());
    assertEquals("API", references.get(0).getType());
}
Also used : GroupEntity(io.gravitee.rest.api.model.GroupEntity) Membership(io.gravitee.repository.management.model.Membership) UserMembership(io.gravitee.rest.api.model.UserMembership) UserMembership(io.gravitee.rest.api.model.UserMembership) Test(org.junit.Test)

Aggregations

GroupEntity (io.gravitee.rest.api.model.GroupEntity)14 Test (org.junit.Test)5 Permissions (io.gravitee.rest.api.management.rest.security.Permissions)3 Group (io.gravitee.repository.management.model.Group)2 GroupEventRule (io.gravitee.repository.management.model.GroupEventRule)2 Membership (io.gravitee.repository.management.model.Membership)2 ApplicationEntity (io.gravitee.rest.api.model.ApplicationEntity)2 UpdateGroupEntity (io.gravitee.rest.api.model.UpdateGroupEntity)2 UserMembership (io.gravitee.rest.api.model.UserMembership)2 Permission (io.gravitee.rest.api.management.rest.security.Permission)1 NewGroupEntity (io.gravitee.rest.api.model.NewGroupEntity)1 PrimaryOwnerEntity (io.gravitee.rest.api.model.PrimaryOwnerEntity)1 RoleEntity (io.gravitee.rest.api.model.RoleEntity)1 UserEntity (io.gravitee.rest.api.model.UserEntity)1 ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)1 ApplicationListItem (io.gravitee.rest.api.model.application.ApplicationListItem)1 GroupInvitationForbiddenException (io.gravitee.rest.api.service.exceptions.GroupInvitationForbiddenException)1 GroupMembersLimitationExceededException (io.gravitee.rest.api.service.exceptions.GroupMembersLimitationExceededException)1 ApiOperation (io.swagger.annotations.ApiOperation)1 Principal (java.security.Principal)1