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