Converted Message to Kotlin.

This commit is contained in:
Erik C. Thauvin 2020-04-01 17:38:22 -07:00
parent bde70343b7
commit 4048636696
17 changed files with 196 additions and 284 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").getMessage())
assertThat(CurrencyConverter.convertCurrency("100 USD to EUR").getText())
.as("100 USD to EUR").matches("100\\.00 USD = \\d{2,3}\\.\\d{2} EUR");
assertThat(CurrencyConverter.convertCurrency("100 USD to USD").getMessage())
assertThat(CurrencyConverter.convertCurrency("100 USD to USD").getText())
.as("100 USD to USD").contains("You're kidding, right?");
assertThat(CurrencyConverter.convertCurrency("100 USD").getMessage())
assertThat(CurrencyConverter.convertCurrency("100 USD").getText())
.as("100 USD").contains("Invalid query.");
assertThat(CurrencyConverter.currencyRates().size())
.as("currencyRates().size() == 33").isEqualTo(33);

View file

@ -63,20 +63,20 @@ 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).getMessage()).as("found mobitopia").contains("mobibot");
assertThat(messages.get(0).getText()).as("found mobitopia").contains("mobibot");
messages = GoogleSearch.searchGoogle("aapl", apiKey, cseKey);
assertThat(messages).as("aapl results not empty").isNotEmpty();
assertThat(messages.get(0).getMessage()).as("found apple").containsIgnoringCase("apple");
assertThat(messages.get(0).getText()).as("found apple").containsIgnoringCase("apple");
assertThatThrownBy(() -> GoogleSearch.searchGoogle("test", "", "apiKey")).as("no API key").isInstanceOf(
ModuleException.class).hasNoCause();
ModuleException.class).hasNoCause();
assertThatThrownBy(() -> GoogleSearch.searchGoogle("test", "apiKey", "")).as("no CSE API key").isInstanceOf(
ModuleException.class).hasNoCause();
ModuleException.class).hasNoCause();
assertThatThrownBy(() -> GoogleSearch.searchGoogle("", "apikey", "apiKey")).as("no query").isInstanceOf(
ModuleException.class).hasNoCause();
ModuleException.class).hasNoCause();
} catch (ModuleException e) {
// Avoid displaying api keys in CI logs
if ("true".equals(System.getenv("CI"))) {

View file

@ -51,7 +51,7 @@ public class JokeTest {
@Test
public void testRamdomJoke() throws ModuleException {
assertThat(Joke.randomJoke().getMessage().length() > 0).as("randomJoke() > 0").isTrue();
assertThat(Joke.randomJoke().getMessage()).as("randomJoke()").containsIgnoringCase("chuck");
assertThat(Joke.randomJoke().getText().length() > 0).as("randomJoke() > 0").isTrue();
assertThat(Joke.randomJoke().getText()).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).getMessage()).as("same stock symbol").contains("AAPL").contains("Apple Inc.");
assertThat(messages.get(0).getText()).as("same stock symbol").contains("AAPL").contains("Apple Inc.");
try {
StockQuote.getQuote("012", apiKey);

View file

@ -74,6 +74,6 @@ public class TwitterTest {
LocalProperties.getProperty(Twitter.TOKEN_SECRET_PROP),
LocalProperties.getProperty(Constants.TWITTER_HANDLE_PROP),
msg,
true).getMessage()).as("twitterPost(" + msg + ')').isEqualTo(msg);
true).getText()).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", LocalProperties.getProperty(Weather2.OWM_API_KEY_PROP));
assertThat(messages.get(0).getMessage()).as("is Everett").contains("Everett").contains("US");
assertThat(messages.get(messages.size() - 1).getMessage()).as("is City Search").endsWith("98204%2CUS");
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");
messages = Weather2.getWeather("London, UK", LocalProperties.getProperty(Weather2.OWM_API_KEY_PROP));
assertThat(messages.get(0).getMessage()).as("is UK").contains("London").contains("UK");
assertThat(messages.get(messages.size() - 1).getMessage()).as("is City Code").endsWith("4517009");
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");
assertThatThrownBy(
() -> Weather2.getWeather("Montpellier, FR", LocalProperties.getProperty(Weather2.OWM_API_KEY_PROP))).as(

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").getMessage()).as("PST").endsWith(Utils.bold("Los Angeles"));
assertThat(WorldTime.worldTime("PST").getText()).as("PST").endsWith(Utils.bold("Los Angeles"));
assertThat(WorldTime.worldTime("BLAH").isError()).as("BLAH").isTrue();
assertThat(WorldTime.worldTime("BEATS").getMessage()).as("BEATS").contains("@");
assertThat(WorldTime.worldTime("BEATS").getText()).as("BEATS").contains("@");
}
@Test