From 21cbecff8e29ea1a67eec0357e68ef541a5e8afa Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Wed, 28 Apr 2021 08:23:14 -0700 Subject: [PATCH] Cleanup tests. --- .../net/thauvin/erik/mobibot/UtilsTest.kt | 66 +++++++++---------- .../mobibot/commands/tell/TellMessageTest.kt | 22 +++---- .../erik/mobibot/entries/EntryLinkTest.kt | 22 +++---- .../thauvin/erik/mobibot/modules/CalcTest.kt | 14 ++-- .../mobibot/modules/CurrencyConverterTest.kt | 16 ++--- .../thauvin/erik/mobibot/modules/DiceTest.kt | 12 +--- .../erik/mobibot/modules/GoogleSearchTest.kt | 17 ++--- .../thauvin/erik/mobibot/modules/JokeTest.kt | 6 +- .../erik/mobibot/modules/LookupTest.kt | 6 +- .../thauvin/erik/mobibot/modules/PingTest.kt | 6 +- .../mobibot/modules/RockPaperScissorsTest.kt | 29 +++----- .../erik/mobibot/modules/StockQuoteTest.kt | 18 +++-- .../erik/mobibot/modules/TwitterTest.kt | 4 +- .../erik/mobibot/modules/Weather2Test.kt | 17 ++--- .../erik/mobibot/modules/WordTimeTest.kt | 8 +-- version.properties | 6 +- 16 files changed, 120 insertions(+), 149 deletions(-) diff --git a/src/test/java/net/thauvin/erik/mobibot/UtilsTest.kt b/src/test/java/net/thauvin/erik/mobibot/UtilsTest.kt index 145ae7a..8a33943 100644 --- a/src/test/java/net/thauvin/erik/mobibot/UtilsTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/UtilsTest.kt @@ -48,7 +48,7 @@ import net.thauvin.erik.mobibot.Utils.uptime import net.thauvin.erik.mobibot.Utils.urlReader import net.thauvin.erik.mobibot.Utils.utcDateTime import org.apache.commons.lang3.StringUtils -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.jibble.pircbot.Colors import org.testng.annotations.BeforeClass import org.testng.annotations.Test @@ -74,108 +74,106 @@ class UtilsTest { @Test fun testBold() { - Assertions.assertThat(bold(1)).`as`("bold(1)").isEqualTo(Colors.BOLD + "1" + Colors.BOLD) - Assertions.assertThat(bold(ascii)).`as`("bold(ascii)").isEqualTo(Colors.BOLD + ascii + Colors.BOLD) + assertThat(bold(1)).`as`("bold(1)").isEqualTo(Colors.BOLD + "1" + Colors.BOLD) + assertThat(bold(ascii)).`as`("bold(ascii)").isEqualTo(Colors.BOLD + ascii + Colors.BOLD) } @Test fun testCapitalize() { - Assertions.assertThat(capitalize("test")).`as`("capitalize(test)").isEqualTo("Test") - Assertions.assertThat(capitalize("Test")).`as`("capitalize(Test)").isEqualTo("Test") - Assertions.assertThat(capitalize(null)).`as`("captitalize(null)").isNull() - Assertions.assertThat(capitalize("")).`as`("capitalize()").isEqualTo("") + assertThat(capitalize("test")).`as`("capitalize(test)").isEqualTo("Test") + assertThat(capitalize("Test")).`as`("capitalize(Test)").isEqualTo("Test") + assertThat(capitalize(null)).`as`("captitalize(null)").isNull() + assertThat(capitalize("")).`as`("capitalize()").isEqualTo("") } @Test fun testColorize() { - Assertions.assertThat(colorize(ascii, Colors.REVERSE)).`as`("colorize(reverse)").isEqualTo( + assertThat(colorize(ascii, Colors.REVERSE)).`as`("colorize(reverse)").isEqualTo( Colors.REVERSE + ascii + Colors.REVERSE ) - Assertions.assertThat(colorize(ascii, Colors.RED)).`as`("colorize(red)") - .isEqualTo(Colors.RED + ascii + Colors.NORMAL) - Assertions.assertThat(colorize(null, Colors.RED)).`as`("colorize(null)").isEqualTo(Colors.NORMAL) + assertThat(colorize(ascii, Colors.RED)).`as`("colorize(red)").isEqualTo(Colors.RED + ascii + Colors.NORMAL) + assertThat(colorize(null, Colors.RED)).`as`("colorize(null)").isEqualTo(Colors.NORMAL) } @Test fun testCyan() { - Assertions.assertThat(cyan(ascii)).isEqualTo(Colors.CYAN + ascii + Colors.NORMAL) + assertThat(cyan(ascii)).isEqualTo(Colors.CYAN + ascii + Colors.NORMAL) } @Test fun testEnsureDir() { - Assertions.assertThat(ensureDir("dir", false)).`as`("ensureDir(dir, false)") - .isEqualTo("dir" + File.separatorChar) - Assertions.assertThat(ensureDir("https://erik.thauvin.net", true)).`as`("ensureDir(erik.thauvin.net, true)") + assertThat(ensureDir("dir", false)).`as`("ensureDir(dir, false)").isEqualTo("dir" + File.separatorChar) + assertThat(ensureDir("https://erik.thauvin.net", true)).`as`("ensureDir(erik.thauvin.net, true)") .isEqualTo("https://erik.thauvin.net/") } @Test fun testGetIntProperty() { - Assertions.assertThat(getIntProperty("10", 1)).`as`("getIntProperty(10, 1)").isEqualTo(10) - Assertions.assertThat(getIntProperty("a", 1)).`as`("getIntProperty(a, 1)").isEqualTo(1) + assertThat(getIntProperty("10", 1)).`as`("getIntProperty(10, 1)").isEqualTo(10) + assertThat(getIntProperty("a", 1)).`as`("getIntProperty(a, 1)").isEqualTo(1) } @Test fun testGreen() { - Assertions.assertThat(green(ascii)).isEqualTo(Colors.DARK_GREEN + ascii + Colors.NORMAL) + assertThat(green(ascii)).isEqualTo(Colors.DARK_GREEN + ascii + Colors.NORMAL) } @Test fun testIsoLocalDate() { - Assertions.assertThat(isoLocalDate(cal.time)).`as`("isoLocalDate(date)").isEqualTo("1952-02-17") - Assertions.assertThat(isoLocalDate(localDateTime)).`as`("isoLocalDate(localDate)").isEqualTo("1952-02-17") + assertThat(isoLocalDate(cal.time)).`as`("isoLocalDate(date)").isEqualTo("1952-02-17") + assertThat(isoLocalDate(localDateTime)).`as`("isoLocalDate(localDate)").isEqualTo("1952-02-17") } @Test fun testObfuscate() { - Assertions.assertThat(obfuscate(ascii).length).`as`("obfuscate is right length").isEqualTo(ascii.length) - Assertions.assertThat(obfuscate(ascii)).`as`("obfuscate()").isEqualTo(StringUtils.repeat("x", ascii.length)) - Assertions.assertThat(obfuscate(" ")).`as`("obfuscate(blank)").isEqualTo(" ") + assertThat(obfuscate(ascii).length).`as`("obfuscate is right length").isEqualTo(ascii.length) + assertThat(obfuscate(ascii)).`as`("obfuscate()").isEqualTo(StringUtils.repeat("x", ascii.length)) + assertThat(obfuscate(" ")).`as`("obfuscate(blank)").isEqualTo(" ") } @Test fun testPlural() { val week = "week" val weeks = "weeks" - Assertions.assertThat(plural(-1, week, weeks)).`as`("plural(-1)").isEqualTo(week) - Assertions.assertThat(plural(0, week, weeks)).`as`("plural(0)").isEqualTo(week) - Assertions.assertThat(plural(1, week, weeks)).`as`("plural(1)").isEqualTo(week) - Assertions.assertThat(plural(2, week, weeks)).`as`("plural(2)").isEqualTo(weeks) + assertThat(plural(-1, week, weeks)).`as`("plural(-1)").isEqualTo(week) + assertThat(plural(0, week, weeks)).`as`("plural(0)").isEqualTo(week) + assertThat(plural(1, week, weeks)).`as`("plural(1)").isEqualTo(week) + assertThat(plural(2, week, weeks)).`as`("plural(2)").isEqualTo(weeks) } @Test fun testReverseColor() { - Assertions.assertThat(reverseColor(ascii)).isEqualTo(Colors.REVERSE + ascii + Colors.REVERSE) + assertThat(reverseColor(ascii)).isEqualTo(Colors.REVERSE + ascii + Colors.REVERSE) } @Test fun testToday() { - Assertions.assertThat(today()).isEqualTo(isoLocalDate(LocalDateTime.now())) + assertThat(today()).isEqualTo(isoLocalDate(LocalDateTime.now())) } @Test fun testUnescapeXml() { - Assertions.assertThat(unescapeXml("<a name="test & ''">")).isEqualTo( + assertThat(unescapeXml("<a name="test & ''">")).isEqualTo( "" ) } @Test fun testUptime() { - Assertions.assertThat("17 years 2 months 2 weeks 1 day 6 hours 45 minutes").isEqualTo(uptime(547800300076L)) + assertThat("17 years 2 months 2 weeks 1 day 6 hours 45 minutes").isEqualTo(uptime(547800300076L)) } @Test @Throws(IOException::class) fun testUrlReader() { - Assertions.assertThat(urlReader(URL("https://postman-echo.com/status/200"))).`as`("urlReader()").isEqualTo( + assertThat(urlReader(URL("https://postman-echo.com/status/200"))).`as`("urlReader()").isEqualTo( "{\"status\":200}" ) } @Test fun testUtcDateTime() { - Assertions.assertThat(utcDateTime(cal.time)).`as`("utcDateTime(date)").isEqualTo("1952-02-17 12:30") - Assertions.assertThat(utcDateTime(localDateTime)).`as`("utcDateTime(localDate)").isEqualTo("1952-02-17 12:30") + assertThat(utcDateTime(cal.time)).`as`("utcDateTime(date)").isEqualTo("1952-02-17 12:30") + assertThat(utcDateTime(localDateTime)).`as`("utcDateTime(localDate)").isEqualTo("1952-02-17 12:30") } } diff --git a/src/test/java/net/thauvin/erik/mobibot/commands/tell/TellMessageTest.kt b/src/test/java/net/thauvin/erik/mobibot/commands/tell/TellMessageTest.kt index 80dd85b..f0f0054 100644 --- a/src/test/java/net/thauvin/erik/mobibot/commands/tell/TellMessageTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/commands/tell/TellMessageTest.kt @@ -31,7 +31,7 @@ */ package net.thauvin.erik.mobibot.commands.tell -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.testng.annotations.Test import java.time.Duration import java.time.LocalDateTime @@ -51,17 +51,17 @@ class TellMessageTest { val recipient = "recipient" val sender = "sender" val tellMessage = TellMessage(sender, recipient, message) - Assertions.assertThat(tellMessage.sender).`as`(sender).isEqualTo(sender) - Assertions.assertThat(tellMessage.recipient).`as`(recipient).isEqualTo(recipient) - Assertions.assertThat(tellMessage.message).`as`(message).isEqualTo(message) - Assertions.assertThat(isValidDate(tellMessage.queued)).`as`("queued is valid date/time").isTrue - Assertions.assertThat(tellMessage.isMatch(sender)).`as`("match sender").isTrue - Assertions.assertThat(tellMessage.isMatch(recipient)).`as`("match recipient").isTrue - Assertions.assertThat(tellMessage.isMatch("foo")).`as`("foo is no match").isFalse + assertThat(tellMessage.sender).`as`(sender).isEqualTo(sender) + assertThat(tellMessage.recipient).`as`(recipient).isEqualTo(recipient) + assertThat(tellMessage.message).`as`(message).isEqualTo(message) + assertThat(isValidDate(tellMessage.queued)).`as`("queued is valid date/time").isTrue + assertThat(tellMessage.isMatch(sender)).`as`("match sender").isTrue + assertThat(tellMessage.isMatch(recipient)).`as`("match recipient").isTrue + assertThat(tellMessage.isMatch("foo")).`as`("foo is no match").isFalse tellMessage.isReceived = true - Assertions.assertThat(tellMessage.isReceived).`as`("is received").isTrue - Assertions.assertThat(isValidDate(tellMessage.receptionDate)).`as`("received is valid date/time").isTrue + assertThat(tellMessage.isReceived).`as`("is received").isTrue + assertThat(isValidDate(tellMessage.receptionDate)).`as`("received is valid date/time").isTrue tellMessage.isNotified = true - Assertions.assertThat(tellMessage.isNotified).`as`("is notified").isTrue + assertThat(tellMessage.isNotified).`as`("is notified").isTrue } } diff --git a/src/test/java/net/thauvin/erik/mobibot/entries/EntryLinkTest.kt b/src/test/java/net/thauvin/erik/mobibot/entries/EntryLinkTest.kt index a7d3264..dcb9378 100644 --- a/src/test/java/net/thauvin/erik/mobibot/entries/EntryLinkTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/entries/EntryLinkTest.kt @@ -32,7 +32,7 @@ package net.thauvin.erik.mobibot.entries import com.rometools.rome.feed.synd.SyndCategory -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.testng.annotations.Test import java.security.SecureRandom @@ -56,37 +56,37 @@ class EntryLinkTest { entryLink.addComment("c$i", "u$i") i++ } - Assertions.assertThat(entryLink.comments.size).`as`("getComments().size() == 5").isEqualTo(i) + assertThat(entryLink.comments.size).`as`("getComments().size() == 5").isEqualTo(i) i = 0 for (comment in entryLink.comments) { - Assertions.assertThat(comment.comment).`as`("getComment($i)").isEqualTo("c$i") - Assertions.assertThat(comment.nick).`as`("getNick($i)").isEqualTo("u$i") + assertThat(comment.comment).`as`("getComment($i)").isEqualTo("c$i") + assertThat(comment.nick).`as`("getNick($i)").isEqualTo("u$i") i++ } val r = SecureRandom() while (entryLink.comments.size > 0) { entryLink.deleteComment(r.nextInt(entryLink.comments.size)) } - Assertions.assertThat(entryLink.comments.isNotEmpty()).`as`("hasComments()").isFalse + assertThat(entryLink.comments.isNotEmpty()).`as`("hasComments()").isFalse entryLink.addComment("nothing", "nobody") entryLink.setComment(0, "something", "somebody") - Assertions.assertThat(entryLink.getComment(0).nick).`as`("getNick(somebody)").isEqualTo("somebody") - Assertions.assertThat(entryLink.getComment(0).comment).`as`("getComment(something)").isEqualTo("something") + assertThat(entryLink.getComment(0).nick).`as`("getNick(somebody)").isEqualTo("somebody") + assertThat(entryLink.getComment(0).comment).`as`("getComment(something)").isEqualTo("something") } @Test fun testTags() { val tags: List = entryLink.tags for ((i, tag) in tags.withIndex()) { - Assertions.assertThat(tag.name).`as`("tag.getName($i)").isEqualTo("tag" + (i + 1)) + assertThat(tag.name).`as`("tag.getName($i)").isEqualTo("tag" + (i + 1)) } - Assertions.assertThat(entryLink.tags.size).`as`("getTags().size() is 5").isEqualTo(5) - Assertions.assertThat(entryLink.tags.isNotEmpty()).`as`("hasTags() is true").isTrue + assertThat(entryLink.tags.size).`as`("getTags().size() is 5").isEqualTo(5) + assertThat(entryLink.tags.isNotEmpty()).`as`("hasTags() is true").isTrue entryLink.setTags("-tag5") entryLink.setTags("+mobitopia") entryLink.setTags("tag4") entryLink.setTags("-mobitopia") - Assertions.assertThat(entryLink.pinboardTags).`as`("getPinboardTags()") + assertThat(entryLink.pinboardTags).`as`("getPinboardTags()") .isEqualTo(entryLink.nick + ",tag1,tag2,tag3,tag4,mobitopia") } } diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/CalcTest.kt b/src/test/java/net/thauvin/erik/mobibot/modules/CalcTest.kt index 643dbd6..45f3848 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/CalcTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/CalcTest.kt @@ -33,7 +33,7 @@ package net.thauvin.erik.mobibot.modules import net.thauvin.erik.mobibot.Utils import net.thauvin.erik.mobibot.modules.Calc.Companion.calc -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.testng.annotations.Test /** @@ -42,13 +42,9 @@ import org.testng.annotations.Test class CalcTest { @Test fun testCalc() { - Assertions.assertThat(calc("1 + 1")).`as`("calc(1+1)") - .isEqualTo("1+1 = %s", Utils.bold(2)) - Assertions.assertThat(calc("1 -3")).`as`("calc(1 -3)") - .isEqualTo("1-3 = %s", Utils.bold(-2)) - Assertions.assertThat(calc("pi+π+e+φ")).`as`("calc(pi+π+e+φ)") - .isEqualTo("pi+π+e+φ = %s", Utils.bold("10.62")) - Assertions.assertThat(calc("one + one")).`as`("calc(one + one)") - .startsWith("No idea.") + assertThat(calc("1 + 1")).`as`("calc(1+1)").isEqualTo("1+1 = %s", Utils.bold(2)) + assertThat(calc("1 -3")).`as`("calc(1 -3)").isEqualTo("1-3 = %s", Utils.bold(-2)) + assertThat(calc("pi+π+e+φ")).`as`("calc(pi+π+e+φ)").isEqualTo("pi+π+e+φ = %s", Utils.bold("10.62")) + assertThat(calc("one + one")).`as`("calc(one + one)").startsWith("No idea.") } } diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/CurrencyConverterTest.kt b/src/test/java/net/thauvin/erik/mobibot/modules/CurrencyConverterTest.kt index edcbb65..0fbfedd 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/CurrencyConverterTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/CurrencyConverterTest.kt @@ -34,7 +34,7 @@ package net.thauvin.erik.mobibot.modules import net.thauvin.erik.mobibot.modules.CurrencyConverter.Companion.convertCurrency import net.thauvin.erik.mobibot.modules.CurrencyConverter.Companion.currencyRates import net.thauvin.erik.mobibot.modules.CurrencyConverter.Companion.loadRates -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.testng.annotations.BeforeClass import org.testng.annotations.Test @@ -50,15 +50,11 @@ class CurrencyConverterTest { @Test fun testConvertCurrency() { - Assertions.assertThat(convertCurrency("100 USD to EUR").msg) + assertThat(convertCurrency("100 USD to EUR").msg) .`as`("100 USD to EUR").matches("100\\.00 USD = \\d{2,3}\\.\\d{2} EUR") - Assertions.assertThat(convertCurrency("100 USD to USD").msg) - .`as`("100 USD to USD").contains("You're kidding, right?") - Assertions.assertThat(convertCurrency("100 USD").msg) - .`as`("100 USD").contains("Invalid query.") - Assertions.assertThat(currencyRates().size) - .`as`("currencyRates().size() == 33").isEqualTo(33) - Assertions.assertThat(currencyRates()) - .`as`("currencyRates().get(EUR)").contains(" EUR: 1") + assertThat(convertCurrency("100 USD to USD").msg).`as`("100 USD to USD").contains("You're kidding, right?") + assertThat(convertCurrency("100 USD").msg).`as`("100 USD").contains("Invalid query.") + assertThat(currencyRates().size).`as`("currencyRates().size() == 33").isEqualTo(33) + assertThat(currencyRates()).`as`("currencyRates().get(EUR)").contains(" EUR: 1") } } diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/DiceTest.kt b/src/test/java/net/thauvin/erik/mobibot/modules/DiceTest.kt index 5a194a6..cea3e35 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/DiceTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/DiceTest.kt @@ -39,14 +39,8 @@ import org.testng.annotations.Test class DiceTest { @Test fun testWinLoseOrTie() { - assertThat( - Dice.winLoseOrTie(6, 6) - ).`as`("6 vs. 6").isEqualTo(Dice.Result.TIE) - assertThat( - Dice.winLoseOrTie(6, 5) - ).`as`("6 vs. 5").isEqualTo(Dice.Result.WIN) - assertThat( - Dice.winLoseOrTie(5, 6) - ).`as`("5 vs. 6").isEqualTo(Dice.Result.LOSE) + assertThat(Dice.winLoseOrTie(6, 6)).`as`("6 vs. 6").isEqualTo(Dice.Result.TIE) + assertThat(Dice.winLoseOrTie(6, 5)).`as`("6 vs. 5").isEqualTo(Dice.Result.WIN) + assertThat(Dice.winLoseOrTie(5, 6)).`as`("5 vs. 6").isEqualTo(Dice.Result.LOSE) } } diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/GoogleSearchTest.kt b/src/test/java/net/thauvin/erik/mobibot/modules/GoogleSearchTest.kt index 4394ceb..c7f0aef 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/GoogleSearchTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/GoogleSearchTest.kt @@ -33,7 +33,8 @@ package net.thauvin.erik.mobibot.modules import net.thauvin.erik.mobibot.LocalProperties import net.thauvin.erik.mobibot.modules.GoogleSearch.Companion.searchGoogle -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatThrownBy import org.testng.annotations.Test /** @@ -47,18 +48,18 @@ class GoogleSearchTest : LocalProperties() { val cseKey = getProperty(GoogleSearch.GOOGLE_CSE_KEY_PROP) try { var messages = searchGoogle("mobibot site:github.com", apiKey, cseKey) - Assertions.assertThat(messages).`as`("mobibot results not empty").isNotEmpty - Assertions.assertThat(messages[0].msg).`as`("found mobitopia").contains("mobibot") + assertThat(messages).`as`("mobibot results not empty").isNotEmpty + assertThat(messages[0].msg).`as`("found mobitopia").contains("mobibot") messages = searchGoogle("aapl", apiKey, cseKey) - Assertions.assertThat(messages).`as`("aapl results not empty").isNotEmpty - Assertions.assertThat(messages[0].msg).`as`("found apple").containsIgnoringCase("apple") - Assertions.assertThatThrownBy { searchGoogle("test", "", "apiKey") } + assertThat(messages).`as`("aapl results not empty").isNotEmpty + assertThat(messages[0].msg).`as`("found apple").containsIgnoringCase("apple") + assertThatThrownBy { searchGoogle("test", "", "apiKey") } .`as`("no API key") .isInstanceOf(ModuleException::class.java).hasNoCause() - Assertions.assertThatThrownBy { searchGoogle("test", "apiKey", "") } + assertThatThrownBy { searchGoogle("test", "apiKey", "") } .`as`("no CSE API key") .isInstanceOf(ModuleException::class.java).hasNoCause() - Assertions.assertThatThrownBy { searchGoogle("", "apikey", "apiKey") } + assertThatThrownBy { searchGoogle("", "apikey", "apiKey") } .`as`("no query").isInstanceOf(ModuleException::class.java).hasNoCause() } catch (e: ModuleException) { // Avoid displaying api keys in CI logs diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/JokeTest.kt b/src/test/java/net/thauvin/erik/mobibot/modules/JokeTest.kt index 5a2f221..36156e2 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/JokeTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/JokeTest.kt @@ -32,7 +32,7 @@ package net.thauvin.erik.mobibot.modules import net.thauvin.erik.mobibot.modules.Joke.Companion.randomJoke -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.testng.annotations.Test /** @@ -42,7 +42,7 @@ class JokeTest { @Test @Throws(ModuleException::class) fun testRamdomJoke() { - Assertions.assertThat(randomJoke().msg.isNotEmpty()).`as`("randomJoke() > 0").isTrue - Assertions.assertThat(randomJoke().msg).`as`("randomJoke()").containsIgnoringCase("chuck") + assertThat(randomJoke().msg.isNotEmpty()).`as`("randomJoke() > 0").isTrue + assertThat(randomJoke().msg).`as`("randomJoke()").containsIgnoringCase("chuck") } } diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/LookupTest.kt b/src/test/java/net/thauvin/erik/mobibot/modules/LookupTest.kt index fdbb51c..b623d83 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/LookupTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/LookupTest.kt @@ -33,7 +33,7 @@ package net.thauvin.erik.mobibot.modules import net.thauvin.erik.mobibot.modules.Lookup.Companion.lookup import net.thauvin.erik.mobibot.modules.Lookup.Companion.whois -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.testng.annotations.Test /** @@ -44,14 +44,14 @@ class LookupTest { @Throws(Exception::class) fun testLookup() { val result = lookup("apple.com") - Assertions.assertThat(result).`as`("lookup(apple.com)").contains("17.253.144.10") + assertThat(result).`as`("lookup(apple.com)").contains("17.253.144.10") } @Test @Throws(Exception::class) fun testWhois() { val result = whois("17.178.96.59", Lookup.WHOIS_HOST) - Assertions.assertThat(result.stream().anyMatch { m: String -> m.contains("Apple Inc.") }) + assertThat(result.stream().anyMatch { m: String -> m.contains("Apple Inc.") }) .`as`("whois(17.178.96.59/Apple Inc.").isTrue } } diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/PingTest.kt b/src/test/java/net/thauvin/erik/mobibot/modules/PingTest.kt index 1b0c460..b849192 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/PingTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/PingTest.kt @@ -32,7 +32,7 @@ package net.thauvin.erik.mobibot.modules import net.thauvin.erik.mobibot.modules.Ping.Companion.randomPing -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.testng.annotations.Test /** @@ -41,13 +41,13 @@ import org.testng.annotations.Test class PingTest { @Test fun testPingsArray() { - Assertions.assertThat(Ping.PINGS).`as`("Pings array is not empty.").isNotEmpty + assertThat(Ping.PINGS).`as`("Pings array is not empty.").isNotEmpty } @Test fun testRandomPing() { for (i in 0..9) { - Assertions.assertThat(randomPing()).`as`("Random ping $i").isIn(Ping.PINGS) + assertThat(randomPing()).`as`("Random ping $i").isIn(Ping.PINGS) } } } diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/RockPaperScissorsTest.kt b/src/test/java/net/thauvin/erik/mobibot/modules/RockPaperScissorsTest.kt index bad8ca4..34cf7bb 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/RockPaperScissorsTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/RockPaperScissorsTest.kt @@ -38,26 +38,13 @@ import org.testng.annotations.Test class RockPaperScissorsTest { @Test fun testWinLoseOrDraw() { - assertThat( - RockPaperScissors.winLoseOrDraw("scissors", "paper") - ).`as`("scissors vs. paper").isEqualTo("win") - assertThat( - RockPaperScissors.winLoseOrDraw("paper", "rock") - ).`as`("paper vs. rock").isEqualTo("win") - assertThat( - RockPaperScissors.winLoseOrDraw("rock", "scissors") - ).`as`("rock vs. scissors").isEqualTo("win") - assertThat( - RockPaperScissors.winLoseOrDraw("paper", "scissors") - ).`as`("paper vs. scissors").isEqualTo("lose") - assertThat( - RockPaperScissors.winLoseOrDraw("rock", "paper") - ).`as`("rock vs. paper").isEqualTo("lose") - assertThat( - RockPaperScissors.winLoseOrDraw("scissors", "rock") - ).`as`("scissors vs. rock").isEqualTo("lose") - assertThat( - RockPaperScissors.winLoseOrDraw("scissors", "scissors") - ).`as`("scissors vs. scissors").isEqualTo("draw") + assertThat(RockPaperScissors.winLoseOrDraw("scissors", "paper")).`as`("scissors vs. paper").isEqualTo("win") + assertThat(RockPaperScissors.winLoseOrDraw("paper", "rock")).`as`("paper vs. rock").isEqualTo("win") + assertThat(RockPaperScissors.winLoseOrDraw("rock", "scissors")).`as`("rock vs. scissors").isEqualTo("win") + assertThat(RockPaperScissors.winLoseOrDraw("paper", "scissors")).`as`("paper vs. scissors").isEqualTo("lose") + assertThat(RockPaperScissors.winLoseOrDraw("rock", "paper")).`as`("rock vs. paper").isEqualTo("lose") + assertThat(RockPaperScissors.winLoseOrDraw("scissors", "rock")).`as`("scissors vs. rock").isEqualTo("lose") + assertThat(RockPaperScissors.winLoseOrDraw("scissors", "scissors")) + .`as`("scissors vs. scissors").isEqualTo("draw") } } diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/StockQuoteTest.kt b/src/test/java/net/thauvin/erik/mobibot/modules/StockQuoteTest.kt index 36c1680..5053d22 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/StockQuoteTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/StockQuoteTest.kt @@ -33,7 +33,8 @@ package net.thauvin.erik.mobibot.modules import net.thauvin.erik.mobibot.LocalProperties import net.thauvin.erik.mobibot.modules.StockQuote.Companion.getQuote -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatThrownBy import org.testng.annotations.Test /** @@ -46,20 +47,17 @@ class StockQuoteTest : LocalProperties() { val apiKey = getProperty(StockQuote.ALPHAVANTAGE_API_KEY_PROP) try { val messages = getQuote("apple inc", apiKey) - Assertions.assertThat(messages).`as`("response not empty").isNotEmpty - Assertions.assertThat(messages[0].msg).`as`("same stock symbol") - .startsWith("Symbol: AAPL") - Assertions.assertThat(messages[1].msg).`as`("price label") - .startsWith(" Price: ") + assertThat(messages).`as`("response not empty").isNotEmpty + assertThat(messages[0].msg).`as`("same stock symbol").startsWith("Symbol: AAPL") + assertThat(messages[1].msg).`as`("price label").startsWith(" Price: ") try { getQuote("blahfoo", apiKey) } catch (e: ModuleException) { - Assertions.assertThat(e.message).`as`("invalid symbol") - .containsIgnoringCase(StockQuote.INVALID_SYMBOL) + assertThat(e.message).`as`("invalid symbol").containsIgnoringCase(StockQuote.INVALID_SYMBOL) } - Assertions.assertThatThrownBy { getQuote("test", "") }.`as`("no API key") + assertThatThrownBy { getQuote("test", "") }.`as`("no API key") .isInstanceOf(ModuleException::class.java).hasNoCause() - Assertions.assertThatThrownBy { getQuote("", "apikey") }.`as`("no symbol") + assertThatThrownBy { getQuote("", "apikey") }.`as`("no symbol") .isInstanceOf(ModuleException::class.java).hasNoCause() } catch (e: ModuleException) { // Avoid displaying api keys in CI logs diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/TwitterTest.kt b/src/test/java/net/thauvin/erik/mobibot/modules/TwitterTest.kt index da9b26a..4c309c6 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/TwitterTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/TwitterTest.kt @@ -33,7 +33,7 @@ package net.thauvin.erik.mobibot.modules import net.thauvin.erik.mobibot.LocalProperties import net.thauvin.erik.mobibot.modules.Twitter.Companion.twitterPost -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.testng.annotations.Test import java.net.InetAddress import java.net.UnknownHostException @@ -56,7 +56,7 @@ class TwitterTest : LocalProperties() { @Throws(ModuleException::class) fun testPostTwitter() { val msg = "Testing Twitter API from $ci" - Assertions.assertThat( + assertThat( twitterPost( getProperty(Twitter.CONSUMER_KEY_PROP), getProperty(Twitter.CONSUMER_SECRET_PROP), diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/Weather2Test.kt b/src/test/java/net/thauvin/erik/mobibot/modules/Weather2Test.kt index 4364585..0d9570c 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/Weather2Test.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/Weather2Test.kt @@ -34,7 +34,8 @@ package net.thauvin.erik.mobibot.modules import net.aksingh.owmjapis.api.APIException import net.thauvin.erik.mobibot.LocalProperties import net.thauvin.erik.mobibot.modules.Weather2.Companion.getWeather -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat +import org.assertj.core.api.Assertions.assertThatThrownBy import org.testng.annotations.Test /** @@ -45,16 +46,16 @@ class Weather2Test : LocalProperties() { @Throws(ModuleException::class) fun testWeather() { var messages = getWeather("98204", getProperty(Weather2.OWM_API_KEY_PROP)) - Assertions.assertThat(messages[0].msg).`as`("is Everett").contains("Everett").contains("US") - Assertions.assertThat(messages[messages.size - 1].msg).`as`("is City Search").endsWith("98204%2CUS") + assertThat(messages[0].msg).`as`("is Everett").contains("Everett").contains("US") + assertThat(messages[messages.size - 1].msg).`as`("is City Search").endsWith("98204%2CUS") messages = getWeather("London, UK", getProperty(Weather2.OWM_API_KEY_PROP)) - Assertions.assertThat(messages[0].msg).`as`("is UK").contains("London").contains("UK") - Assertions.assertThat(messages[messages.size - 1].msg).`as`("is City Code").endsWith("4517009") - Assertions.assertThatThrownBy { getWeather("Montpellier, FR", getProperty(Weather2.OWM_API_KEY_PROP)) } + assertThat(messages[0].msg).`as`("is UK").contains("London").contains("UK") + assertThat(messages[messages.size - 1].msg).`as`("is City Code").endsWith("4517009") + assertThatThrownBy { getWeather("Montpellier, FR", getProperty(Weather2.OWM_API_KEY_PROP)) } .`as`("Montpellier not found").hasCauseInstanceOf(APIException::class.java) - Assertions.assertThatThrownBy { getWeather("test", "") } + assertThatThrownBy { getWeather("test", "") } .`as`("no API key").isInstanceOf(ModuleException::class.java).hasNoCause() messages = getWeather("", "apikey") - Assertions.assertThat(messages[0].isError).`as`("no query").isTrue + assertThat(messages[0].isError).`as`("no query").isTrue } } diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/WordTimeTest.kt b/src/test/java/net/thauvin/erik/mobibot/modules/WordTimeTest.kt index b6a40aa..dd696c9 100644 --- a/src/test/java/net/thauvin/erik/mobibot/modules/WordTimeTest.kt +++ b/src/test/java/net/thauvin/erik/mobibot/modules/WordTimeTest.kt @@ -33,7 +33,7 @@ package net.thauvin.erik.mobibot.modules import net.thauvin.erik.mobibot.Utils import net.thauvin.erik.mobibot.modules.WorldTime.Companion.worldTime -import org.assertj.core.api.Assertions +import org.assertj.core.api.Assertions.assertThat import org.testng.annotations.Test /** @@ -42,8 +42,8 @@ import org.testng.annotations.Test class WordTimeTest { @Test fun testWorldTime() { - Assertions.assertThat(worldTime("PST").msg).`as`("PST").endsWith(Utils.bold("Los Angeles")) - Assertions.assertThat(worldTime("BLAH").isError).`as`("BLAH").isTrue - Assertions.assertThat(worldTime("BEATS").msg).`as`("BEATS").contains("@") + assertThat(worldTime("PST").msg).`as`("PST").endsWith(Utils.bold("Los Angeles")) + assertThat(worldTime("BLAH").isError).`as`("BLAH").isTrue + assertThat(worldTime("BEATS").msg).`as`("BEATS").contains("@") } } diff --git a/version.properties b/version.properties index 8e5338f..bf0ed79 100644 --- a/version.properties +++ b/version.properties @@ -1,9 +1,9 @@ #Generated by the Semver Plugin for Gradle -#Tue Apr 27 17:59:17 PDT 2021 -version.buildmeta=487 +#Wed Apr 28 08:21:37 PDT 2021 +version.buildmeta=494 version.major=0 version.minor=8 version.patch=0 version.prerelease=beta version.project=mobibot -version.semver=0.8.0-beta+487 +version.semver=0.8.0-beta+494