use of io.gravitee.am.common.email.Email in project gravitee-access-management by gravitee-io.
the class EmailServiceImpl method send.
@Override
public void send(Domain domain, Application client, io.gravitee.am.model.Template template, User user) {
if (enabled) {
// get raw email template
io.gravitee.am.model.Email emailTemplate = getEmailTemplate(template, user);
// prepare email
Email email = prepareEmail(domain, client, template, emailTemplate, user);
// send email
sendEmail(email, user);
}
}
use of io.gravitee.am.common.email.Email 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());
}
use of io.gravitee.am.common.email.Email in project gravitee-access-management by gravitee-io.
the class DomainNotificationServiceTest method shouldNotifyUser_EmailOnly.
@Test
public void shouldNotifyUser_EmailOnly() throws Exception {
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(any(), any(), any());
verify(groupService, never()).findMembers(any(), any(), any(), anyInt(), anyInt());
}
Aggregations