use of io.gravitee.rest.api.management.rest.model.ApiMembership in project gravitee-management-rest-api by gravitee-io.
the class ApiMembersResourceTest method shouldCreateMember.
@Test
public void shouldCreateMember() {
ApiMembership apiMembership = new ApiMembership();
apiMembership.setId(MEMBER_1);
apiMembership.setRole("my-api-membership-role");
final Response response = envTarget(API).path("members").request().post(Entity.json(apiMembership));
assertEquals(HttpStatusCode.CREATED_201, response.getStatus());
assertNull(response.getHeaders().getFirst(HttpHeaders.LOCATION));
ArgumentCaptor<MembershipService.MembershipReference> memberShipRefCaptor = ArgumentCaptor.forClass(MembershipService.MembershipReference.class);
ArgumentCaptor<MembershipService.MembershipRole> memberShipRoleCaptor = ArgumentCaptor.forClass(MembershipService.MembershipRole.class);
ArgumentCaptor<MembershipService.MembershipMember> memberShipUserCaptor = ArgumentCaptor.forClass(MembershipService.MembershipMember.class);
Mockito.verify(membershipService).addRoleToMemberOnReference(memberShipRefCaptor.capture(), memberShipUserCaptor.capture(), memberShipRoleCaptor.capture());
assertEquals(API, memberShipRefCaptor.getValue().getId());
assertEquals("my-api-membership-role", memberShipRoleCaptor.getValue().getName());
assertEquals(MEMBER_1, memberShipUserCaptor.getValue().getMemberId());
}
Aggregations