@Test public void userShouldReceiveEmailWithSubject() { sendMail(TO_ADDRESS, FROM_ADDRESS, MAIL_SUBJECT, MAIL_BODY); emailSteps.userShouldReceiveEmailWithSubject(MAIL_SUBJECT, TO_ADDRESS); }
@Then("^" + Phrases.SUBJECT + " should receive an email containing subject (.+) for (.+)$") public void userShouldReceiveEmailWithSubject(String subject, String address) { boolean receivedExpectedMessage = false; String resolvedAddress = placeholderResolver.resolve(address); String resolvedSubject = placeholderResolver.resolve(subject); for (WiserMessage message : smtpServer.getMessages()) { if (message.getEnvelopeReceiver().equals(resolvedAddress)) { try { if (message.getMimeMessage().getSubject().contains(resolvedSubject)) { receivedExpectedMessage = true; } } catch (MessagingException e) { } } } assertTrue("Did not receive email for " + resolvedAddress + " with subject containing " + resolvedSubject, receivedExpectedMessage); }
EmailSteps { @Then("^" + Phrases.SUBJECT + " should receive an email containing subject (.+) for (.+)$") public void userShouldReceiveEmailWithSubject(String subject, String address) { boolean receivedExpectedMessage = false; String resolvedAddress = placeholderResolver.resolve(address); String resolvedSubject = placeholderResolver.resolve(subject); for (WiserMessage message : smtpServer.getMessages()) { if (message.getEnvelopeReceiver().equals(resolvedAddress)) { try { if (message.getMimeMessage().getSubject().contains(resolvedSubject)) { receivedExpectedMessage = true; } } catch (MessagingException e) { } } } assertTrue("Did not receive email for " + resolvedAddress + " with subject containing " + resolvedSubject, receivedExpectedMessage); } }
EmailSteps { @Then("^" + Phrases.SUBJECT + " should receive an email containing subject (.+) for (.+)$") public void userShouldReceiveEmailWithSubject(String subject, String address) { boolean receivedExpectedMessage = false; String resolvedAddress = placeholderResolver.resolve(address); String resolvedSubject = placeholderResolver.resolve(subject); for (WiserMessage message : smtpServer.getMessages()) { if (message.getEnvelopeReceiver().equals(resolvedAddress)) { try { if (message.getMimeMessage().getSubject().contains(resolvedSubject)) { receivedExpectedMessage = true; } } catch (MessagingException e) { } } } assertTrue("Did not receive email for " + resolvedAddress + " with subject containing " + resolvedSubject, receivedExpectedMessage); } EmailSteps(PropertyStore propertyStore, PlaceholderResolver placeholderResolver); }
EmailSteps { @Then("^" + Phrases.SUBJECT + " should receive an email containing subject (.+) for (.+)$") public void userShouldReceiveEmailWithSubject(String subject, String address) { boolean receivedExpectedMessage = false; String resolvedAddress = placeholderResolver.resolve(address); String resolvedSubject = placeholderResolver.resolve(subject); for (WiserMessage message : smtpServer.getMessages()) { if (message.getEnvelopeReceiver().equals(resolvedAddress)) { try { if (message.getMimeMessage().getSubject().contains(resolvedSubject)) { receivedExpectedMessage = true; } } catch (MessagingException e) { } } } assertTrue("Did not receive email for " + resolvedAddress + " with subject containing " + resolvedSubject, receivedExpectedMessage); } EmailSteps(PropertyStore propertyStore, PlaceholderResolver placeholderResolver); @Before("@emailing") void startUpServer(); @Then("^" + Phrases.SUBJECT + " should receive an email containing subject (.+) for (.+)$") void userShouldReceiveEmailWithSubject(String subject, String address); @Then("^" + Phrases.SUBJECT + " should receive an email for (.+)$") void userShouldReceiveEmail(String address); @And("^the email containing subject (.+) for (.+) is stored as " + Phrases.PROPERTY_KEY + "$") void storeReceivedEmailWithSubject(String subject, String address, String propertyKey); @And("^the email for (.+) is stored as " + Phrases.PROPERTY_KEY + "$") void storeReceivedEmail(String address, String propertyKey); @After("@emailing") void stopServer(); }
EmailSteps { @Then("^" + Phrases.SUBJECT + " should receive an email containing subject (.+) for (.+)$") public void userShouldReceiveEmailWithSubject(String subject, String address) { boolean receivedExpectedMessage = false; String resolvedAddress = placeholderResolver.resolve(address); String resolvedSubject = placeholderResolver.resolve(subject); for (WiserMessage message : smtpServer.getMessages()) { if (message.getEnvelopeReceiver().equals(resolvedAddress)) { try { if (message.getMimeMessage().getSubject().contains(resolvedSubject)) { receivedExpectedMessage = true; } } catch (MessagingException e) { } } } assertTrue("Did not receive email for " + resolvedAddress + " with subject containing " + resolvedSubject, receivedExpectedMessage); } EmailSteps(PropertyStore propertyStore, PlaceholderResolver placeholderResolver); @Before("@emailing") void startUpServer(); @Then("^" + Phrases.SUBJECT + " should receive an email containing subject (.+) for (.+)$") void userShouldReceiveEmailWithSubject(String subject, String address); @Then("^" + Phrases.SUBJECT + " should receive an email for (.+)$") void userShouldReceiveEmail(String address); @And("^the email containing subject (.+) for (.+) is stored as " + Phrases.PROPERTY_KEY + "$") void storeReceivedEmailWithSubject(String subject, String address, String propertyKey); @And("^the email for (.+) is stored as " + Phrases.PROPERTY_KEY + "$") void storeReceivedEmail(String address, String propertyKey); @After("@emailing") void stopServer(); final static String SMTP_PORT; }