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);
}
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)));
}
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)));
}
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());
}
Aggregations