|
| 1 | +/** |
| 2 | + * Copyright (c) 2020-2022, Self XDSD Contributors |
| 3 | + * All rights reserved. |
| 4 | + * <p> |
| 5 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | + * of this software and associated documentation files (the "Software"), |
| 7 | + * to read the Software only. Permission is hereby NOT GRANTED to use, copy, |
| 8 | + * modify, merge, publish, distribute, sublicense, and/or sell copies of |
| 9 | + * the Software. |
| 10 | + * <p> |
| 11 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 12 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 13 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 14 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 15 | + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, |
| 16 | + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
| 17 | + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 18 | + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 19 | + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 20 | + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 21 | + * POSSIBILITY OF SUCH DAMAGE. |
| 22 | + */ |
| 23 | +package com.selfxdsd.core; |
| 24 | + |
| 25 | +import com.selfxdsd.api.PlatformInvoice; |
| 26 | +import org.hamcrest.MatcherAssert; |
| 27 | +import org.hamcrest.Matchers; |
| 28 | +import org.junit.Test; |
| 29 | +import org.mockito.Mockito; |
| 30 | + |
| 31 | +import java.time.LocalDateTime; |
| 32 | + |
| 33 | +/** |
| 34 | + * Unit tests for {@link PlatformInvoiceEmailNotification}. |
| 35 | + * @author Mihai Andronache (amihaiemil@gmail.com) |
| 36 | + * @version $Id$ |
| 37 | + * @since 0.0.99 |
| 38 | + */ |
| 39 | +public final class PlatformInvoiceEmailNotificationTestCase { |
| 40 | + |
| 41 | + /** |
| 42 | + * It can return the "to" e-mail address. |
| 43 | + */ |
| 44 | + @Test |
| 45 | + public void returnsToEmailAddress() { |
| 46 | + MatcherAssert.assertThat( |
| 47 | + new PlatformInvoiceEmailNotification( |
| 48 | + Mockito.mock(PlatformInvoice.class) |
| 49 | + ).to(), |
| 50 | + Matchers.equalTo("office@extremelydistributed.com") |
| 51 | + ); |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * It can return the "to" name. |
| 56 | + */ |
| 57 | + @Test |
| 58 | + public void returnsToName() { |
| 59 | + MatcherAssert.assertThat( |
| 60 | + new PlatformInvoiceEmailNotification( |
| 61 | + Mockito.mock(PlatformInvoice.class) |
| 62 | + ).toName(), |
| 63 | + Matchers.equalTo("Self XDSD Admin") |
| 64 | + ); |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * It can return the "from" e-mail address. |
| 69 | + */ |
| 70 | + @Test |
| 71 | + public void returnsFromEmailAddress() { |
| 72 | + MatcherAssert.assertThat( |
| 73 | + new PlatformInvoiceEmailNotification( |
| 74 | + Mockito.mock(PlatformInvoice.class) |
| 75 | + ).from(), |
| 76 | + Matchers.equalTo("support@self-xdsd.com") |
| 77 | + ); |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * It can return the "from" name. |
| 82 | + */ |
| 83 | + @Test |
| 84 | + public void returnsFromName() { |
| 85 | + MatcherAssert.assertThat( |
| 86 | + new PlatformInvoiceEmailNotification( |
| 87 | + Mockito.mock(PlatformInvoice.class) |
| 88 | + ).fromName(), |
| 89 | + Matchers.equalTo("Self XDSD") |
| 90 | + ); |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * It can return the type. |
| 95 | + */ |
| 96 | + @Test |
| 97 | + public void returnsType() { |
| 98 | + MatcherAssert.assertThat( |
| 99 | + new PlatformInvoiceEmailNotification( |
| 100 | + Mockito.mock(PlatformInvoice.class) |
| 101 | + ).type(), |
| 102 | + Matchers.equalTo("PlatformInvoide Mail Notification") |
| 103 | + ); |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * It can return the subject. |
| 108 | + */ |
| 109 | + @Test |
| 110 | + public void returnsSubject() { |
| 111 | + final PlatformInvoice invoice = Mockito.mock(PlatformInvoice.class); |
| 112 | + Mockito.when(invoice.id()).thenReturn(15); |
| 113 | + MatcherAssert.assertThat( |
| 114 | + new PlatformInvoiceEmailNotification(invoice).subject(), |
| 115 | + Matchers.equalTo("New Platform Invoice created (Id: 15)") |
| 116 | + ); |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * It can return the body. |
| 121 | + */ |
| 122 | + @Test |
| 123 | + public void returnsBody() { |
| 124 | + final LocalDateTime createdAt = LocalDateTime.now(); |
| 125 | + final PlatformInvoice invoice = Mockito.mock(PlatformInvoice.class); |
| 126 | + Mockito.when(invoice.id()).thenReturn(15); |
| 127 | + Mockito.when(invoice.createdAt()).thenReturn(createdAt); |
| 128 | + |
| 129 | + MatcherAssert.assertThat( |
| 130 | + new PlatformInvoiceEmailNotification(invoice).body(), |
| 131 | + Matchers.equalTo( |
| 132 | + "New platform invoice (id is 15) registered at " |
| 133 | + + createdAt + "." |
| 134 | + ) |
| 135 | + ); |
| 136 | + } |
| 137 | + |
| 138 | +} |
0 commit comments