Cleaned up msg.

This commit is contained in:
Erik C. Thauvin 2020-06-13 03:27:50 -07:00
parent d843c65f6f
commit d6a85ef4af
21 changed files with 68 additions and 154 deletions

View file

@ -54,11 +54,11 @@ public class CurrencyConverterTest {
@Test
@SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
public void testConvertCurrency() {
assertThat(CurrencyConverter.convertCurrency("100 USD to EUR").getText())
assertThat(CurrencyConverter.convertCurrency("100 USD to EUR").getMsg())
.as("100 USD to EUR").matches("100\\.00 USD = \\d{2,3}\\.\\d{2} EUR");
assertThat(CurrencyConverter.convertCurrency("100 USD to USD").getText())
assertThat(CurrencyConverter.convertCurrency("100 USD to USD").getMsg())
.as("100 USD to USD").contains("You're kidding, right?");
assertThat(CurrencyConverter.convertCurrency("100 USD").getText())
assertThat(CurrencyConverter.convertCurrency("100 USD").getMsg())
.as("100 USD").contains("Invalid query.");
assertThat(CurrencyConverter.currencyRates().size())
.as("currencyRates().size() == 33").isEqualTo(33);

View file

@ -63,11 +63,11 @@ public class GoogleSearchTest extends LocalProperties {
try {
List<Message> messages = GoogleSearch.searchGoogle("mobibot site:github.com", apiKey, cseKey);
assertThat(messages).as("mobibot results not empty").isNotEmpty();
assertThat(messages.get(0).getText()).as("found mobitopia").contains("mobibot");
assertThat(messages.get(0).getMsg()).as("found mobitopia").contains("mobibot");
messages = GoogleSearch.searchGoogle("aapl", apiKey, cseKey);
assertThat(messages).as("aapl results not empty").isNotEmpty();
assertThat(messages.get(0).getText()).as("found apple").containsIgnoringCase("apple");
assertThat(messages.get(0).getMsg()).as("found apple").containsIgnoringCase("apple");
assertThatThrownBy(() -> GoogleSearch.searchGoogle("test", "", "apiKey")).as("no API key").isInstanceOf(
ModuleException.class).hasNoCause();

View file

@ -51,7 +51,7 @@ public class JokeTest {
@Test
public void testRamdomJoke() throws ModuleException {
assertThat(Joke.randomJoke().getText().length() > 0).as("randomJoke() > 0").isTrue();
assertThat(Joke.randomJoke().getText()).as("randomJoke()").containsIgnoringCase("chuck");
assertThat(Joke.randomJoke().getMsg().length() > 0).as("randomJoke() > 0").isTrue();
assertThat(Joke.randomJoke().getMsg()).as("randomJoke()").containsIgnoringCase("chuck");
}
}

View file

@ -58,7 +58,7 @@ public class StockQuoteTest extends LocalProperties {
try {
final List<Message> messages = StockQuote.getQuote("apple inc", apiKey);
assertThat(messages).as("response not empty").isNotEmpty();
assertThat(messages.get(0).getText()).as("same stock symbol").contains("AAPL").contains("Apple Inc.");
assertThat(messages.get(0).getMsg()).as("same stock symbol").contains("AAPL").contains("Apple Inc.");
try {
StockQuote.getQuote("blahfoo", apiKey);

View file

@ -73,6 +73,6 @@ public class TwitterTest extends LocalProperties {
getProperty(Twitter.TOKEN_SECRET_PROP),
getProperty(Twitter.HANDLE_PROP),
msg,
true).getText()).as("twitterPost(" + msg + ')').isEqualTo(msg);
true).getMsg()).as("twitterPost(" + msg + ')').isEqualTo(msg);
}
}

View file

@ -54,12 +54,12 @@ public class Weather2Test extends LocalProperties {
@Test
public void testWeather() throws ModuleException {
List<Message> messages = Weather2.getWeather("98204", getProperty(Weather2.OWM_API_KEY_PROP));
assertThat(messages.get(0).getText()).as("is Everett").contains("Everett").contains("US");
assertThat(messages.get(messages.size() - 1).getText()).as("is City Search").endsWith("98204%2CUS");
assertThat(messages.get(0).getMsg()).as("is Everett").contains("Everett").contains("US");
assertThat(messages.get(messages.size() - 1).getMsg()).as("is City Search").endsWith("98204%2CUS");
messages = Weather2.getWeather("London, UK", getProperty(Weather2.OWM_API_KEY_PROP));
assertThat(messages.get(0).getText()).as("is UK").contains("London").contains("UK");
assertThat(messages.get(messages.size() - 1).getText()).as("is City Code").endsWith("4517009");
assertThat(messages.get(0).getMsg()).as("is UK").contains("London").contains("UK");
assertThat(messages.get(messages.size() - 1).getMsg()).as("is City Code").endsWith("4517009");
assertThatThrownBy(() -> Weather2.getWeather("Montpellier, FR", getProperty(Weather2.OWM_API_KEY_PROP)))
.as("Montpellier not found").hasCauseInstanceOf(APIException.class);

View file

@ -47,9 +47,9 @@ import static org.assertj.core.api.Assertions.assertThat;
public class WordTimeTest {
@Test
public void testWorldTime() {
assertThat(WorldTime.worldTime("PST").getText()).as("PST").endsWith(Utils.bold("Los Angeles"));
assertThat(WorldTime.worldTime("PST").getMsg()).as("PST").endsWith(Utils.bold("Los Angeles"));
assertThat(WorldTime.worldTime("BLAH").isError()).as("BLAH").isTrue();
assertThat(WorldTime.worldTime("BEATS").getText()).as("BEATS").contains("@");
assertThat(WorldTime.worldTime("BEATS").getMsg()).as("BEATS").contains("@");
}
@Test