This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Inbox { | |
public static final String INBOX = "INBOX"; | |
public static final String POP3 = "pop3"; | |
public Message[] inboxMessages; | |
public Inbox(final MailAdress mailAdress) throws Exception { | |
Folder folder = openInboxFolder(mailAdress); | |
inboxMessages = folder.getMessages(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Expected: a message with subject: "test subject", in inbox | |
got: <Mails in inbox: 1 [subject: bad subject] > | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MailTestMatchersAndUtilities { | |
public static Inbox inboxOf(final MailAdress userMailAdress) throws Exception { | |
return new Inbox(userMailAdress); | |
} | |
public static TypeSafeMatcher<Inbox> hasOneEmailWithSubject(final String expectedSubject) { | |
return new TypeSafeMatcher<Inbox>() { | |
@Override | |
public boolean matchesSafely(Inbox inbox) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EmailNotifierTest { | |
static final String TEST_BODY = "cuerpo de test"; | |
static final String TEST_SUBJECT = "asunto de test"; | |
final MailAdress alfredo = new MailAdress("[email protected]"); | |
final EmailNotifier emailNotifier = new EmailNotifier(); | |
@Test | |
public void shouldSendOneEmailToTheGivenEmailAdress() throws Exception { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Expected: (a collection containing "manzana" or a collection containing "pera") | |
got: <[kiwi, fresa, platano]> | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set<String> cesta = new HashSet(); | |
cesta.add("manzana"); | |
cesta.add("platano"); | |
cesta.add("fresa"); | |
assertThat(cesta, anyOf(hasItem("manzana"), | |
hasItem("pera"))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set<String> cesta = new HashSet(); | |
cesta.add("manzana"); | |
cesta.add("platano"); | |
cesta.add("fresa"); | |
assertTrue(cesta.contains("manzana") || cesta.contains("pera")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
assertThat(mensaje, allOf(containsString(WITH_EXPECTED_USER_NAME), | |
containsString(WITH_EXPECTED_DNI))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Expected: (a string containing "Alfredo Casado" and a string containing "123456798P") | |
got: "El usuario Alfredo Casado tiene el dni: 123556798P" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String mensaje = "El usuario Alfredo Casado tiene el dni: 123456798P"; | |
assertThat(mensaje, allOf(containsString("Alfredo Casado"), | |
containsString("123456798P"))); |