-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #21 Add sender parameter to Configuration
- Loading branch information
Showing
6 changed files
with
205 additions
and
19 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
64 changes: 57 additions & 7 deletions
64
src/test/java/net/sargue/mailgun/test/ConfigurationTests.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,89 @@ | ||
package net.sargue.mailgun.test; | ||
|
||
import com.google.common.collect.Lists; | ||
import net.sargue.mailgun.Configuration; | ||
import org.junit.Test; | ||
|
||
import java.util.Collections; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNull; | ||
|
||
public class ConfigurationTests { | ||
|
||
public static final String FROM = "Doc Brown <doc@delorean.com>"; | ||
|
||
@Test | ||
public void testConfigurationFrom() { | ||
String from = "Doc Brown <doc@delorean.com>"; | ||
Configuration configuration = new Configuration().from(from); | ||
assertEquals(from, configuration.from()); | ||
Configuration configuration = new Configuration().from(FROM); | ||
assertEquals(FROM, configuration.from()); | ||
} | ||
|
||
@Test | ||
public void testConfigurationSplitFrom() { | ||
Configuration configuration = | ||
new Configuration().from("Doc Brown", "doc@delorean.com"); | ||
assertEquals("Doc Brown <doc@delorean.com>", configuration.from()); | ||
assertEquals(FROM, configuration.from()); | ||
} | ||
|
||
@Test | ||
public void testConfigurationConstructor() { | ||
String domain = "example.com"; | ||
String key = "1234"; | ||
String from = "Doc Brown <doc@delorean.com>"; | ||
Configuration configuration = new Configuration(domain, key, from); | ||
Configuration configuration = new Configuration(domain, key, FROM); | ||
assertEquals(domain, configuration.domain()); | ||
assertEquals(key, configuration.apiKey()); | ||
assertEquals(from, configuration.from()); | ||
assertEquals(FROM, configuration.from()); | ||
} | ||
|
||
@Test | ||
public void testConfigurationURL() { | ||
Configuration configuration = new Configuration().apiUrl("anotherURL"); | ||
assertEquals("anotherURL", configuration.apiUrl()); | ||
} | ||
|
||
@Test | ||
public void testFromDefault() { | ||
Configuration configuration = new Configuration() | ||
.from(FROM); | ||
assertEquals(configuration.defaultParameters().get("from"), | ||
Collections.singletonList(FROM)); | ||
} | ||
|
||
@Test | ||
public void testFromSingleValue() { | ||
Configuration configuration = new Configuration() | ||
.from("from1") | ||
.from(FROM); | ||
assertEquals(configuration.defaultParameters().get("from"), | ||
Collections.singletonList(FROM)); | ||
} | ||
|
||
@Test | ||
public void testCustomDefault() { | ||
Configuration configuration = new Configuration() | ||
.addDefaultParameter("foo", "bar"); | ||
assertEquals(configuration.defaultParameters().get("foo"), | ||
Collections.singletonList("bar")); | ||
} | ||
|
||
@Test | ||
public void testCustomDefaultMultiValue() { | ||
Configuration configuration = new Configuration() | ||
.addDefaultParameter("foo", "bar") | ||
.addDefaultParameter("foo", "bar2"); | ||
assertEquals(configuration.defaultParameters().get("foo"), | ||
Lists.newArrayList("bar", "bar2")); | ||
} | ||
|
||
@Test | ||
public void testResetDefault() { | ||
Configuration configuration = new Configuration() | ||
.addDefaultParameter("foo", "bar") | ||
.addDefaultParameter("foo", "bar2") | ||
.clearDefaultParameter("foo"); | ||
assertFalse(configuration.defaultParameters().containsKey("foo")); | ||
assertNull(configuration.defaultParameters().get("foo")); | ||
} | ||
} |
This file contains 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