use of io.gravitee.am.service.GroupService in project gravitee-access-management by gravitee-io.
the class DomainNotificationServiceTest method shouldNotifyUser_EmailAndUI.
@Test
public void shouldNotifyUser_EmailAndUI() throws Exception {
ReflectionTestUtils.setField(cut, "uiNotifierEnabled", true);
final Membership member = new Membership();
member.setMemberType(MemberType.USER);
member.setMemberId("userid");
when(membershipService.findByCriteria(eq(ReferenceType.DOMAIN), eq(DOMAIN_ID), any())).thenReturn(Flowable.just(member), Flowable.empty());
final User user = new User();
user.setEmail("user@acme.fr");
when(userService.findById(ReferenceType.ORGANIZATION, env.getOrganizationId(), member.getMemberId())).thenReturn(Single.just(user));
when(emailService.getFinalEmail(any(), any(), any(), any(), any())).thenReturn(new Email());
cut.registerCertificateExpiration(certificate);
// wait subscription execution
Thread.sleep(1000);
verify(notifierService).register(argThat(def -> def.getType().equals(TYPE_UI_NOTIFIER)), any(), any());
verify(notifierService).register(argThat(def -> def.getType().equals(TYPE_EMAIL_NOTIFIER)), any(), any());
verify(groupService, never()).findMembers(any(), any(), any(), anyInt(), anyInt());
}
Aggregations