Search in sources :

Example 6 with MembershipPayload

use of io.gravitee.cockpit.api.command.membership.MembershipPayload in project gravitee-management-rest-api by gravitee-io.

the class MembershipCommandHandlerTest method handleWithUnknownUser.

@Test
public void handleWithUnknownUser() {
    MembershipPayload membershipPayload = new MembershipPayload();
    membershipPayload.setUserId("user#1");
    membershipPayload.setOrganizationId("orga#1");
    membershipPayload.setReferenceType(MembershipReferenceType.ENVIRONMENT.name());
    membershipPayload.setReferenceId("env#1");
    membershipPayload.setRole("UNKNOWN");
    MembershipCommand command = new MembershipCommand(membershipPayload);
    when(userService.findBySource(COCKPIT_SOURCE, membershipPayload.getUserId(), false)).thenThrow(new UserNotFoundException(membershipPayload.getUserId()));
    TestObserver<MembershipReply> obs = cut.handle(command).test();
    obs.awaitTerminalEvent();
    obs.assertNoErrors();
    obs.assertValue(reply -> reply.getCommandId().equals(command.getId()) && reply.getCommandStatus().equals(CommandStatus.ERROR));
    verifyZeroInteractions(roleService);
    verifyZeroInteractions(membershipService);
}
Also used : UserNotFoundException(io.gravitee.rest.api.service.exceptions.UserNotFoundException) MembershipReply(io.gravitee.cockpit.api.command.membership.MembershipReply) MembershipPayload(io.gravitee.cockpit.api.command.membership.MembershipPayload) MembershipCommand(io.gravitee.cockpit.api.command.membership.MembershipCommand) Test(org.junit.Test)

Aggregations

MembershipPayload (io.gravitee.cockpit.api.command.membership.MembershipPayload)6 MembershipReply (io.gravitee.cockpit.api.command.membership.MembershipReply)6 MembershipCommand (io.gravitee.cockpit.api.command.membership.MembershipCommand)5 RoleEntity (io.gravitee.rest.api.model.RoleEntity)5 UserEntity (io.gravitee.rest.api.model.UserEntity)5 Test (org.junit.Test)5 MembershipService (io.gravitee.rest.api.service.MembershipService)4 List (java.util.List)3 MembershipReferenceType (io.gravitee.rest.api.model.MembershipReferenceType)1 RoleScope (io.gravitee.rest.api.model.permissions.RoleScope)1 RoleNotFoundException (io.gravitee.rest.api.service.exceptions.RoleNotFoundException)1 UserNotFoundException (io.gravitee.rest.api.service.exceptions.UserNotFoundException)1