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

@ -970,7 +970,7 @@ public class Mobibot extends PircBot {
* @param message The message. * @param message The message.
*/ */
public final void send(final String who, final Message message) { public final void send(final String who, final Message message) {
send(message.isNotice() ? who : getChannel(), message.getMessage(), message.getColor(), message.isPrivate()); send(message.isNotice() ? who : getChannel(), message.getText(), message.getColor(), message.isPrivate());
} }
/** /**

View file

@ -118,7 +118,7 @@ public final class Joke extends ThreadedModule {
@Override @Override
void run(final Mobibot bot, final String sender, final String cmd, final String arg, final boolean isPrivate) { void run(final Mobibot bot, final String sender, final String cmd, final String arg, final boolean isPrivate) {
try { try {
bot.send(Utils.cyan(randomJoke().getMessage())); bot.send(Utils.cyan(randomJoke().getText()));
} catch (ModuleException e) { } catch (ModuleException e) {
bot.getLogger().warn(e.getDebugMessage(), e); bot.getLogger().warn(e.getDebugMessage(), e);
bot.send(sender, e.getMessage(), isPrivate); bot.send(sender, e.getMessage(), isPrivate);

View file

@ -142,7 +142,7 @@ public final class Twitter extends ThreadedModule {
void run(final Mobibot bot, final String sender, final String cmd, final String message, final boolean isPrivate) { void run(final Mobibot bot, final String sender, final String cmd, final String message, final boolean isPrivate) {
try { try {
bot.send(sender, bot.send(sender,
post(sender, message + " (by " + sender + " on " + bot.getChannel() + ')', false).getMessage(), post(sender, message + " (by " + sender + " on " + bot.getChannel() + ')', false).getText(),
isPrivate); isPrivate);
} catch (ModuleException e) { } catch (ModuleException e) {
bot.getLogger().warn(e.getDebugMessage(), e); bot.getLogger().warn(e.getDebugMessage(), e);

View file

@ -229,12 +229,12 @@ public final class WorldTime extends AbstractModule {
} else { } else {
final Message msg = worldTime(args); final Message msg = worldTime(args);
if (isPrivate) { if (isPrivate) {
bot.send(sender, msg.getMessage(), true); bot.send(sender, msg.getText(), true);
} else { } else {
if (msg.isError()) { if (msg.isError()) {
bot.send(sender, msg.getMessage(), false); bot.send(sender, msg.getText(), false);
} else { } else {
bot.send(msg.getMessage()); bot.send(msg.getText());
} }
} }
} }

View file

@ -29,41 +29,38 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot.msg
package net.thauvin.erik.mobibot.msg;
/** /**
* The <code>ErrorMessage</code> class. * The `ErrorMessage` class.
* *
* @author <a href="https://erik.thauvin.net/" target="_blank">Erik C. Thauvin</a> * @author [Erik C. Thauvin](https://erik.thauvin.net/)
* @created 2019-04-07 * @created 2019-04-07
* @since 1.0 * @since 1.0
*/ */
public class ErrorMessage extends Message { class ErrorMessage : Message {
/** /**
* Creates a new error message. * Creates a new error message.
* *
* @param message The error message. * @param text The error message.
*/ */
public ErrorMessage(final String message) { constructor(text: String) : super() {
super(); this.text = text
this.setMessage(message); isError = true
this.setError(true); isNotice = true
this.setNotice(true);
} }
/** /**
* Creates a new error message. * Creates a new error message.
* *
* @param message The message. * @param text The message.
* @param color The message color. * @param color The message color.
*/ */
@SuppressWarnings("unused") @Suppress("unused")
public ErrorMessage(final String message, final String color) { constructor(text: String, color: String) : super() {
super(); this.text = text
this.setMessage(message); isError = true
this.setError(true); isNotice = true
this.setNotice(true); this.color = color
this.setColor(color);
} }
} }

View file

@ -1,193 +0,0 @@
/*
* Message.java
*
* Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of this project nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.thauvin.erik.mobibot.msg;
import org.jibble.pircbot.Colors;
/**
* The <code>Message</code> class.
*
* @author <a href="https://erik.thauvin.net/" target="_blank">Erik C. Thauvin</a>
* @created 2019-04-07
* @since 1.0
*/
public class Message {
private String color = Colors.NORMAL;
private boolean isError;
private boolean isNotice;
private boolean isPrivate;
private String msg = "";
/**
* Creates a new message.
*/
public Message() {
// This constructor is intentionally empty
}
/**
* Creates a new message.
*
* @param message The message.
* @param isNotice The notice flag.
* @param isError The error flag.
* @param isPrivate The Private message
*/
@SuppressWarnings("unused")
public Message(final String message, final boolean isNotice, final boolean isError, final boolean isPrivate) {
msg = message;
this.isNotice = isNotice;
this.isError = isError;
this.isPrivate = isPrivate;
}
/**
* Creates a new message.
*
* @param message The message.
* @param isNotice The notice flag.
* @param isError The error flag.
* @param isPrivate The Private message
* @param color The color.
*/
@SuppressWarnings("unused")
public Message(final String message,
final boolean isNotice,
final boolean isError,
final boolean isPrivate,
final String color) {
msg = message;
this.isNotice = isNotice;
this.isError = isError;
this.isPrivate = isPrivate;
this.color = color;
}
/**
* Returns the message color.
*
* @return The color.
*/
public String getColor() {
return color;
}
/**
* Returns the message.
*
* @return The message.
*/
public String getMessage() {
return msg;
}
/**
* Returns the message error flag.
*
* @return The error flag.
*/
public boolean isError() {
return isError;
}
/**
* Returns the message notice flag.
*
* @return The notice flag.
*/
public boolean isNotice() {
return isNotice;
}
/**
* Returns the message private flag.
*
* @return The private flag.
*/
public boolean isPrivate() {
return isPrivate;
}
/**
* Set the color.
*
* @param color The new color.
*/
public void setColor(final String color) {
this.color = color;
}
/**
* Sets the message error flag.
*
* @param error The error flag.
*/
public void setError(final boolean error) {
isError = error;
}
/**
* Sets the message.
*
* @param message The new message.
*/
public void setMessage(final String message) {
msg = message;
}
/**
* Sets the message notice flag.
*
* @param isNotice The notice flag.
*/
public void setNotice(final boolean isNotice) {
this.isNotice = isNotice;
}
/**
* Sets the message private flag.
*
* @param isPrivate The private flag.
*/
@SuppressWarnings("unused")
public void setPrivate(final boolean isPrivate) {
this.isPrivate = isPrivate;
}
@Override
public String toString() {
return "Message{" + "color='" + color + '\'' + ", isError=" + isError + ", isNotice=" + isNotice
+ ", isPrivate=" + isPrivate + ", msg='" + msg + '\'' + '}';
}
}

View file

@ -0,0 +1,105 @@
/*
* Message.java
*
* Copyright (c) 2004-2020, Erik C. Thauvin (erik@thauvin.net)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of this project nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.thauvin.erik.mobibot.msg
import org.jibble.pircbot.Colors
/**
* The `Message` class.
*
* @author [Erik C. Thauvin](https://erik.thauvin.net/)
* @created 2019-04-07
* @since 1.0
*/
open class Message {
/** Color */
var color = Colors.NORMAL
/** Error */
var isError = false
/** Notice */
var isNotice = false
/** Private */
var isPrivate = false
/** Message text*/
var text = ""
/** Creates a new message. */
constructor() {
// This constructor is intentionally empty
}
/**
* Creates a new message.
*
* @param text The message.
* @param isNotice The notice flag.
* @param isError The error flag.
* @param isPrivate The Private message
*/
constructor(text: String, isNotice: Boolean, isError: Boolean, isPrivate: Boolean) {
this.text = text
this.isNotice = isNotice
this.isError = isError
this.isPrivate = isPrivate
}
/**
* Creates a new message.
*
* @param text The message.
* @param isNotice The notice flag.
* @param isError The error flag.
* @param isPrivate The Private message
* @param color The color.
*/
constructor(
text: String,
isNotice: Boolean,
isError: Boolean,
isPrivate: Boolean,
color: String
) {
this.text = text
this.isNotice = isNotice
this.isError = isError
this.isPrivate = isPrivate
this.color = color
}
override fun toString(): String {
return "Message(color='$color', isError=$isError, isNotice=$isNotice, isPrivate=$isPrivate, message='$text')"
}
}

View file

@ -29,38 +29,35 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot.msg
package net.thauvin.erik.mobibot.msg;
/** /**
* The <code>NoticeMessage</code> class. * The `NoticeMessage` class.
* *
* @author <a href="https://erik.thauvin.net/" target="_blank">Erik C. Thauvin</a> * @author [Erik C. Thauvin](https://erik.thauvin.net/)
* @created 2019-04-07 * @created 2019-04-07
* @since 1.0 * @since 1.0
*/ */
public class NoticeMessage extends Message { class NoticeMessage : Message {
/** /**
* Creates a new notice. * Creates a new notice.
* *
* @param message The notice's message. * @param text The notice's message.
*/ */
public NoticeMessage(final String message) { constructor(text: String) : super() {
super(); this.text = text
this.setMessage(message); isNotice = true
this.setNotice(true);
} }
/** /**
* Create a new notice. * Create a new notice.
* *
* @param message The notice's message. * @param text The notice's message.
* @param color The color. * @param color The color.
*/ */
public NoticeMessage(final String message, final String color) { constructor(text: String, color: String) : super() {
super(); this.text = text
this.setMessage(message); isNotice = true
this.setNotice(true); this.color = color
this.setColor(color);
} }
} }

View file

@ -29,32 +29,36 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot.msg
package net.thauvin.erik.mobibot.msg;
/** /**
* The <code>PrivateMessage</code> class. * The `PrivateMessage` class.
* *
* @author <a href="https://erik.thauvin.net/" target="_blank">Erik C. Thauvin</a> * @author [Erik C. Thauvin](https://erik.thauvin.net/)
* @created 2019-04-09 * @created 2019-04-09
* @since 1.0 * @since 1.0
*/ */
@SuppressWarnings("unused") @Suppress("unused")
public class PrivateMessage extends Message { class PrivateMessage : Message {
public PrivateMessage(final String message) { /**
super(); * Creates a new private message.
this.setMessage(message); *
* @param text The message.
*/
constructor(text: String) : super() {
this.text = text
isPrivate = true
} }
/** /**
* Creates a new private message. * Creates a new private message.
* *
* @param message The message. * @param text The message.
* @param color The message color. * @param color The message color.
*/ */
public PrivateMessage(final String message, final String color) { constructor(text: String, color: String) : super() {
super(); this.text = text
this.setMessage(message); this.color = color
this.setColor(color); isPrivate = true
} }
} }

View file

@ -29,32 +29,34 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
package net.thauvin.erik.mobibot.msg
package net.thauvin.erik.mobibot.msg;
/** /**
* The <code>PublicMessage</code> class. * The `PublicMessage` class.
* *
* @author <a href="https://erik.thauvin.net/" target="_blank">Erik C. Thauvin</a> * @author [Erik C. Thauvin](https://erik.thauvin.net/)
* @created 2019-04-07 * @created 2019-04-07
* @since 1.0 * @since 1.0
*/ */
public class PublicMessage extends Message { class PublicMessage : Message {
public PublicMessage(final String message) { /**
super(); * Creates a new public message.
this.setMessage(message); *
* @param text The message.
*/
constructor(text: String) : super() {
this.text = text
} }
/** /**
* Creates a new public message. * Creates a new public message.
* *
* @param message The message. * @param text The message.
* @param color The message color. * @param color The message color.
*/ */
@SuppressWarnings("unused") @Suppress("unused")
public PublicMessage(final String message, final String color) { constructor(text: String, color: String) : super() {
super(); this.text = text
this.setMessage(message); this.color = color
this.setColor(color);
} }
} }

View file

@ -54,11 +54,11 @@ public class CurrencyConverterTest {
@Test @Test
@SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS") @SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
public void testConvertCurrency() { 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"); .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?"); .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."); .as("100 USD").contains("Invalid query.");
assertThat(CurrencyConverter.currencyRates().size()) assertThat(CurrencyConverter.currencyRates().size())
.as("currencyRates().size() == 33").isEqualTo(33); .as("currencyRates().size() == 33").isEqualTo(33);

View file

@ -63,20 +63,20 @@ public class GoogleSearchTest extends LocalProperties {
try { try {
List<Message> messages = GoogleSearch.searchGoogle("mobibot site:github.com", apiKey, cseKey); List<Message> messages = GoogleSearch.searchGoogle("mobibot site:github.com", apiKey, cseKey);
assertThat(messages).as("mobibot results not empty").isNotEmpty(); 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); messages = GoogleSearch.searchGoogle("aapl", apiKey, cseKey);
assertThat(messages).as("aapl results not empty").isNotEmpty(); 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( 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( 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( assertThatThrownBy(() -> GoogleSearch.searchGoogle("", "apikey", "apiKey")).as("no query").isInstanceOf(
ModuleException.class).hasNoCause(); ModuleException.class).hasNoCause();
} catch (ModuleException e) { } catch (ModuleException e) {
// Avoid displaying api keys in CI logs // Avoid displaying api keys in CI logs
if ("true".equals(System.getenv("CI"))) { if ("true".equals(System.getenv("CI"))) {

View file

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

View file

@ -58,7 +58,7 @@ public class StockQuoteTest extends LocalProperties {
try { try {
final List<Message> messages = StockQuote.getQuote("apple inc", apiKey); final List<Message> messages = StockQuote.getQuote("apple inc", apiKey);
assertThat(messages).as("response not empty").isNotEmpty(); 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 { try {
StockQuote.getQuote("012", apiKey); StockQuote.getQuote("012", apiKey);

View file

@ -74,6 +74,6 @@ public class TwitterTest {
LocalProperties.getProperty(Twitter.TOKEN_SECRET_PROP), LocalProperties.getProperty(Twitter.TOKEN_SECRET_PROP),
LocalProperties.getProperty(Constants.TWITTER_HANDLE_PROP), LocalProperties.getProperty(Constants.TWITTER_HANDLE_PROP),
msg, 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 @Test
public void testWeather() throws ModuleException { public void testWeather() throws ModuleException {
List<Message> messages = Weather2.getWeather("98204", LocalProperties.getProperty(Weather2.OWM_API_KEY_PROP)); 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(0).getText()).as("is Everett").contains("Everett").contains("US");
assertThat(messages.get(messages.size() - 1).getMessage()).as("is City Search").endsWith("98204%2CUS"); 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)); 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(0).getText()).as("is UK").contains("London").contains("UK");
assertThat(messages.get(messages.size() - 1).getMessage()).as("is City Code").endsWith("4517009"); assertThat(messages.get(messages.size() - 1).getText()).as("is City Code").endsWith("4517009");
assertThatThrownBy( assertThatThrownBy(
() -> Weather2.getWeather("Montpellier, FR", LocalProperties.getProperty(Weather2.OWM_API_KEY_PROP))).as( () -> 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 { public class WordTimeTest {
@Test @Test
public void testWorldTime() { 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("BLAH").isError()).as("BLAH").isTrue();
assertThat(WorldTime.worldTime("BEATS").getMessage()).as("BEATS").contains("@"); assertThat(WorldTime.worldTime("BEATS").getText()).as("BEATS").contains("@");
} }
@Test @Test