MailTemplate { public Notification compose(VariableContext context) { NotificationComposer notificationComposer = this.templateType.composer(template, context); return notificationComposer.compose(); } MailTemplate(String template, TemplateType templateType); Notification compose(VariableContext context);  }
@Test public void should_compose_nomination_notification_given_ticket_and_nominator_and_nominee() { Nominator nominator = createNominator(); Nominee nominee = createNominee(); TrainingId trainingId = TrainingId.next(); Training training = createTraining(trainingId); ValidDate validDate = createValidDate(trainingId); Ticket ticket = createTicket(); String template = buildTemplate(); VariableContext context = buildVariableContext(nominator, nominee, validDate, training, ticket); MailTemplate mailTemplate = new MailTemplate(template, TemplateType.Nomination); Notification notification = mailTemplate.compose(context); assertThat(notification.from()).isEqualTo("admin@eas.com"); assertThat(notification.to()).isEqualTo(nominee.email()); assertThat(notification.subject()).isEqualTo("Ticket Nomination Notification"); assertNotificationBody(nominator, nominee, validDate, training, ticket, notification); }