use of io.gravitee.rest.api.management.rest.model.ApplicationMembership in project gravitee-management-rest-api by gravitee-io.
the class ApplicationMembersResourceTest method shouldCreateMember.
@Test
public void shouldCreateMember() {
Mockito.reset(membershipService);
ApplicationMembership applicationMembership = new ApplicationMembership();
applicationMembership.setId(MEMBER_1);
applicationMembership.setRole("my-application-membership-role");
final Response response = envTarget(APPLICATION).path("members").request().post(Entity.json(applicationMembership));
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(APPLICATION, memberShipRefCaptor.getValue().getId());
assertEquals("my-application-membership-role", memberShipRoleCaptor.getValue().getName());
assertEquals(MEMBER_1, memberShipUserCaptor.getValue().getMemberId());
}
Aggregations