From faf40d3048047028d83c536ae41864a5a2bac218 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Tue, 11 May 2021 00:51:35 -0700 Subject: [PATCH] Cleaned up tests. --- .../net/thauvin/erik/mobibot/UtilsTest.kt | 53 ++++++++++--------- .../mobibot/commands/tell/TellMessageTest.kt | 20 +++---- .../erik/mobibot/entries/EntryLinkTest.kt | 20 +++---- .../thauvin/erik/mobibot/modules/CalcTest.kt | 11 ++-- .../erik/mobibot/modules/CryptoPricesTest.kt | 33 ++++++------ .../mobibot/modules/CurrencyConverterTest.kt | 11 ++-- .../thauvin/erik/mobibot/modules/DiceTest.kt | 6 +-- .../erik/mobibot/modules/GoogleSearchTest.kt | 14 ++--- .../thauvin/erik/mobibot/modules/JokeTest.kt | 4 +- .../erik/mobibot/modules/LookupTest.kt | 4 +- .../mobibot/modules/ModuleExceptionTest.kt | 2 +- .../thauvin/erik/mobibot/modules/PingTest.kt | 4 +- .../mobibot/modules/RockPaperScissorsTest.kt | 18 ++++--- .../erik/mobibot/modules/StockQuoteTest.kt | 12 ++--- .../erik/mobibot/modules/TwitterTest.kt | 2 +- .../erik/mobibot/modules/Weather2Test.kt | 14 ++--- .../erik/mobibot/modules/WordTimeTest.kt | 6 +-- version.properties | 6 +-- 18 files changed, 123 insertions(+), 117 deletions(-) diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/UtilsTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/UtilsTest.kt index 8a33943..a57d591 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/UtilsTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/UtilsTest.kt @@ -74,25 +74,26 @@ class UtilsTest { @Test fun testBold() { - assertThat(bold(1)).`as`("bold(1)").isEqualTo(Colors.BOLD + "1" + Colors.BOLD) - assertThat(bold(ascii)).`as`("bold(ascii)").isEqualTo(Colors.BOLD + ascii + Colors.BOLD) + assertThat(bold(1)).describedAs("bold(1)").isEqualTo(Colors.BOLD + "1" + Colors.BOLD) + assertThat(bold(ascii)).describedAs("bold(ascii)").isEqualTo(Colors.BOLD + ascii + Colors.BOLD) } @Test fun testCapitalize() { - 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("") + assertThat(capitalize("test")).describedAs("capitalize(test)").isEqualTo("Test") + assertThat(capitalize("Test")).describedAs("capitalize(Test)").isEqualTo("Test") + assertThat(capitalize(null)).describedAs("captitalize(null)").isNull() + assertThat(capitalize("")).describedAs("capitalize()").isEqualTo("") } @Test fun testColorize() { - assertThat(colorize(ascii, Colors.REVERSE)).`as`("colorize(reverse)").isEqualTo( + assertThat(colorize(ascii, Colors.REVERSE)).describedAs("colorize(reverse)").isEqualTo( Colors.REVERSE + ascii + Colors.REVERSE ) - 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) + assertThat(colorize(ascii, Colors.RED)).describedAs("colorize(red)") + .isEqualTo(Colors.RED + ascii + Colors.NORMAL) + assertThat(colorize(null, Colors.RED)).describedAs("colorize(null)").isEqualTo(Colors.NORMAL) } @Test @@ -102,15 +103,15 @@ class UtilsTest { @Test fun testEnsureDir() { - 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)") + assertThat(ensureDir("dir", false)).describedAs("ensureDir(dir, false)").isEqualTo("dir" + File.separatorChar) + assertThat(ensureDir("https://erik.thauvin.net", true)).describedAs("ensureDir(erik.thauvin.net, true)") .isEqualTo("https://erik.thauvin.net/") } @Test fun testGetIntProperty() { - assertThat(getIntProperty("10", 1)).`as`("getIntProperty(10, 1)").isEqualTo(10) - assertThat(getIntProperty("a", 1)).`as`("getIntProperty(a, 1)").isEqualTo(1) + assertThat(getIntProperty("10", 1)).describedAs("getIntProperty(10, 1)").isEqualTo(10) + assertThat(getIntProperty("a", 1)).describedAs("getIntProperty(a, 1)").isEqualTo(1) } @Test @@ -120,25 +121,25 @@ class UtilsTest { @Test fun testIsoLocalDate() { - assertThat(isoLocalDate(cal.time)).`as`("isoLocalDate(date)").isEqualTo("1952-02-17") - assertThat(isoLocalDate(localDateTime)).`as`("isoLocalDate(localDate)").isEqualTo("1952-02-17") + assertThat(isoLocalDate(cal.time)).describedAs("isoLocalDate(date)").isEqualTo("1952-02-17") + assertThat(isoLocalDate(localDateTime)).describedAs("isoLocalDate(localDate)").isEqualTo("1952-02-17") } @Test fun testObfuscate() { - 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(" ") + assertThat(obfuscate(ascii).length).describedAs("obfuscate is right length").isEqualTo(ascii.length) + assertThat(obfuscate(ascii)).describedAs("obfuscate()").isEqualTo(StringUtils.repeat("x", ascii.length)) + assertThat(obfuscate(" ")).describedAs("obfuscate(blank)").isEqualTo(" ") } @Test fun testPlural() { val week = "week" val weeks = "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) + assertThat(plural(-1, week, weeks)).describedAs("plural(-1)").isEqualTo(week) + assertThat(plural(0, week, weeks)).describedAs("plural(0)").isEqualTo(week) + assertThat(plural(1, week, weeks)).describedAs("plural(1)").isEqualTo(week) + assertThat(plural(2, week, weeks)).describedAs("plural(2)").isEqualTo(weeks) } @Test @@ -166,14 +167,14 @@ class UtilsTest { @Test @Throws(IOException::class) fun testUrlReader() { - assertThat(urlReader(URL("https://postman-echo.com/status/200"))).`as`("urlReader()").isEqualTo( - "{\"status\":200}" + assertThat(urlReader(URL("https://postman-echo.com/status/200"))).describedAs("urlReader()") + .isEqualTo("{\"status\":200}" ) } @Test fun testUtcDateTime() { - 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") + assertThat(utcDateTime(cal.time)).describedAs("utcDateTime(date)").isEqualTo("1952-02-17 12:30") + assertThat(utcDateTime(localDateTime)).describedAs("utcDateTime(localDate)").isEqualTo("1952-02-17 12:30") } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/commands/tell/TellMessageTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/commands/tell/TellMessageTest.kt index f0f0054..4fdd2db 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/commands/tell/TellMessageTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/commands/tell/TellMessageTest.kt @@ -51,17 +51,17 @@ class TellMessageTest { val recipient = "recipient" val sender = "sender" val tellMessage = TellMessage(sender, recipient, message) - 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 + assertThat(tellMessage.sender).describedAs(sender).isEqualTo(sender) + assertThat(tellMessage.recipient).describedAs(recipient).isEqualTo(recipient) + assertThat(tellMessage.message).describedAs(message).isEqualTo(message) + assertThat(isValidDate(tellMessage.queued)).describedAs("queued is valid date/time").isTrue + assertThat(tellMessage.isMatch(sender)).describedAs("match sender").isTrue + assertThat(tellMessage.isMatch(recipient)).describedAs("match recipient").isTrue + assertThat(tellMessage.isMatch("foo")).describedAs("foo is no match").isFalse tellMessage.isReceived = true - assertThat(tellMessage.isReceived).`as`("is received").isTrue - assertThat(isValidDate(tellMessage.receptionDate)).`as`("received is valid date/time").isTrue + assertThat(tellMessage.isReceived).describedAs("is received").isTrue + assertThat(isValidDate(tellMessage.receptionDate)).describedAs("received is valid date/time").isTrue tellMessage.isNotified = true - assertThat(tellMessage.isNotified).`as`("is notified").isTrue + assertThat(tellMessage.isNotified).describedAs("is notified").isTrue } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/entries/EntryLinkTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/entries/EntryLinkTest.kt index dcb9378..b6a83dc 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/entries/EntryLinkTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/entries/EntryLinkTest.kt @@ -56,37 +56,37 @@ class EntryLinkTest { entryLink.addComment("c$i", "u$i") i++ } - assertThat(entryLink.comments.size).`as`("getComments().size() == 5").isEqualTo(i) + assertThat(entryLink.comments.size).describedAs("getComments().size() == 5").isEqualTo(i) i = 0 for (comment in entryLink.comments) { - assertThat(comment.comment).`as`("getComment($i)").isEqualTo("c$i") - assertThat(comment.nick).`as`("getNick($i)").isEqualTo("u$i") + assertThat(comment.comment).describedAs("getComment($i)").isEqualTo("c$i") + assertThat(comment.nick).describedAs("getNick($i)").isEqualTo("u$i") i++ } val r = SecureRandom() while (entryLink.comments.size > 0) { entryLink.deleteComment(r.nextInt(entryLink.comments.size)) } - assertThat(entryLink.comments.isNotEmpty()).`as`("hasComments()").isFalse + assertThat(entryLink.comments.isNotEmpty()).describedAs("hasComments()").isFalse entryLink.addComment("nothing", "nobody") entryLink.setComment(0, "something", "somebody") - assertThat(entryLink.getComment(0).nick).`as`("getNick(somebody)").isEqualTo("somebody") - assertThat(entryLink.getComment(0).comment).`as`("getComment(something)").isEqualTo("something") + assertThat(entryLink.getComment(0).nick).describedAs("getNick(somebody)").isEqualTo("somebody") + assertThat(entryLink.getComment(0).comment).describedAs("getComment(something)").isEqualTo("something") } @Test fun testTags() { val tags: List = entryLink.tags for ((i, tag) in tags.withIndex()) { - assertThat(tag.name).`as`("tag.getName($i)").isEqualTo("tag" + (i + 1)) + assertThat(tag.name).describedAs("tag.getName($i)").isEqualTo("tag" + (i + 1)) } - assertThat(entryLink.tags.size).`as`("getTags().size() is 5").isEqualTo(5) - assertThat(entryLink.tags.isNotEmpty()).`as`("hasTags() is true").isTrue + assertThat(entryLink.tags.size).describedAs("getTags().size() is 5").isEqualTo(5) + assertThat(entryLink.tags.isNotEmpty()).describedAs("hasTags() is true").isTrue entryLink.setTags("-tag5") entryLink.setTags("+mobitopia") entryLink.setTags("tag4") entryLink.setTags("-mobitopia") - assertThat(entryLink.pinboardTags).`as`("getPinboardTags()") + assertThat(entryLink.pinboardTags).describedAs("getPinboardTags()") .isEqualTo(entryLink.nick + ",tag1,tag2,tag3,tag4,mobitopia") } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/CalcTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/CalcTest.kt index a397f5a..4064672 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/CalcTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/CalcTest.kt @@ -44,10 +44,11 @@ import org.testng.annotations.Test class CalcTest { @Test fun testCalculate() { - assertThat(calculate("1 + 1")).`as`("calculate(1+1)").isEqualTo("1+1 = %s", Utils.bold(2)) - assertThat(calculate("1 -3")).`as`("calculate(1 -3)").isEqualTo("1-3 = %s", Utils.bold(-2)) - assertThat(calculate("pi+π+e+φ")).`as`("calculate(pi+π+e+φ)").isEqualTo("pi+π+e+φ = %s", Utils.bold("10.62")) - assertThatThrownBy { calculate("one + one") }.`as`("calculate(one+one)") - .isInstanceOf(UnknownFunctionOrVariableException::class.java) + assertThat(calculate("1 + 1")).describedAs("calculate(1+1)").isEqualTo("1+1 = %s", Utils.bold(2)) + assertThat(calculate("1 -3")).describedAs("calculate(1 -3)").isEqualTo("1-3 = %s", Utils.bold(-2)) + assertThat(calculate("pi+π+e+φ")).describedAs("calculate(pi+π+e+φ)") + .isEqualTo("pi+π+e+φ = %s", Utils.bold("10.62")) + assertThatThrownBy { calculate("one + one") }.describedAs("calculate(one+one)") + .isInstanceOf(UnknownFunctionOrVariableException::class.java) } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/CryptoPricesTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/CryptoPricesTest.kt index bd07f1c..baed49c 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/CryptoPricesTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/CryptoPricesTest.kt @@ -31,9 +31,8 @@ */ package net.thauvin.erik.mobibot.modules -import net.thauvin.erik.crypto.CryptoPrice.Companion.marketPrice import net.thauvin.erik.crypto.CryptoException -import net.thauvin.erik.mobibot.LocalProperties +import net.thauvin.erik.crypto.CryptoPrice.Companion.marketPrice import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.testng.annotations.Test @@ -46,28 +45,28 @@ class CryptoPricesTest { @Throws(ModuleException::class) fun testMarketPrice() { var price = marketPrice("BTC", "USD") - assertThat(price.base).`as`("is BTC").isEqualTo("BTC") - assertThat(price.currency).`as`("is USD").isEqualTo("USD") - assertThat(price.amount).`as`("BTC > 0").isGreaterThan(0.00) + assertThat(price.base).describedAs("is BTC").isEqualTo("BTC") + assertThat(price.currency).describedAs("is USD").isEqualTo("USD") + assertThat(price.amount).describedAs("BTC > 0").isGreaterThan(0.00) price = marketPrice("ETH", "EUR") - assertThat(price.base).`as`("is ETH").isEqualTo("ETH") - assertThat(price.currency).`as`("is EUR").isEqualTo("EUR") - assertThat(price.amount).`as`("ETH > 0").isGreaterThan(0.00) + assertThat(price.base).describedAs("is ETH").isEqualTo("ETH") + assertThat(price.currency).describedAs("is EUR").isEqualTo("EUR") + assertThat(price.amount).describedAs("ETH > 0").isGreaterThan(0.00) price = marketPrice("ETH2", "GBP") - assertThat(price.base).`as`("is ETH2").isEqualTo("ETH2") - assertThat(price.currency).`as`("is GBP").isEqualTo("GBP") - assertThat(price.amount).`as`("ETH2 > 0").isGreaterThan(0.00) + assertThat(price.base).describedAs("is ETH2").isEqualTo("ETH2") + assertThat(price.currency).describedAs("is GBP").isEqualTo("GBP") + assertThat(price.amount).describedAs("ETH2 > 0").isGreaterThan(0.00) assertThatThrownBy { marketPrice("FOO", "USD") } - .`as`("FOO") - .isInstanceOf(CryptoException::class.java) - .hasMessageContaining("Invalid base currency") + .describedAs("FOO") + .isInstanceOf(CryptoException::class.java) + .hasMessageContaining("Invalid base currency") assertThatThrownBy { marketPrice("FOO", "BAR") } - .`as`("FOO-BAR") - .isInstanceOf(CryptoException::class.java) - .hasMessageContaining("Invalid currency (BAR)") + .describedAs("FOO-BAR") + .isInstanceOf(CryptoException::class.java) + .hasMessageContaining("Invalid currency (BAR)") } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/CurrencyConverterTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/CurrencyConverterTest.kt index 0fbfedd..5d509d3 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/CurrencyConverterTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/CurrencyConverterTest.kt @@ -51,10 +51,11 @@ class CurrencyConverterTest { @Test fun testConvertCurrency() { assertThat(convertCurrency("100 USD to EUR").msg) - .`as`("100 USD to EUR").matches("100\\.00 USD = \\d{2,3}\\.\\d{2} EUR") - 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") + .describedAs("100 USD to EUR").matches("100\\.00 USD = \\d{2,3}\\.\\d{2} EUR") + assertThat(convertCurrency("100 USD to USD").msg).describedAs("100 USD to USD") + .contains("You're kidding, right?") + assertThat(convertCurrency("100 USD").msg).describedAs("100 USD").contains("Invalid query.") + assertThat(currencyRates().size).describedAs("currencyRates().size() == 33").isEqualTo(33) + assertThat(currencyRates()).describedAs("currencyRates().get(EUR)").contains(" EUR: 1") } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/DiceTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/DiceTest.kt index cea3e35..681dc5b 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/DiceTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/DiceTest.kt @@ -39,8 +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)).describedAs("6 vs. 6").isEqualTo(Dice.Result.TIE) + assertThat(Dice.winLoseOrTie(6, 5)).describedAs("6 vs. 5").isEqualTo(Dice.Result.WIN) + assertThat(Dice.winLoseOrTie(5, 6)).describedAs("5 vs. 6").isEqualTo(Dice.Result.LOSE) } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/GoogleSearchTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/GoogleSearchTest.kt index 4d8abd5..fd34802 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/GoogleSearchTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/GoogleSearchTest.kt @@ -48,19 +48,19 @@ class GoogleSearchTest : LocalProperties() { val cseKey = getProperty(GoogleSearch.GOOGLE_CSE_KEY_PROP) try { var messages = searchGoogle("mobitopia", apiKey, cseKey) - assertThat(messages).`as`("mobitopia results not empty").isNotEmpty - assertThat(messages[0].msg).`as`("found freenode").contains("freenode") + assertThat(messages).describedAs("mobitopia results not empty").isNotEmpty + assertThat(messages[0].msg).describedAs("found freenode").contains("freenode") messages = searchGoogle("aapl", apiKey, cseKey) - assertThat(messages).`as`("aapl results not empty").isNotEmpty - assertThat(messages[0].msg).`as`("found apple").containsIgnoringCase("apple") + assertThat(messages).describedAs("aapl results not empty").isNotEmpty + assertThat(messages[0].msg).describedAs("found apple").containsIgnoringCase("apple") assertThatThrownBy { searchGoogle("test", "", "apiKey") } - .`as`("no API key") + .describedAs("no API key") .isInstanceOf(ModuleException::class.java).hasNoCause() assertThatThrownBy { searchGoogle("test", "apiKey", "") } - .`as`("no CSE API key") + .describedAs("no CSE API key") .isInstanceOf(ModuleException::class.java).hasNoCause() assertThatThrownBy { searchGoogle("", "apikey", "apiKey") } - .`as`("no query").isInstanceOf(ModuleException::class.java).hasNoCause() + .describedAs("no query").isInstanceOf(ModuleException::class.java).hasNoCause() } catch (e: ModuleException) { // Avoid displaying api keys in CI logs if ("true" == System.getenv("CI") && apiKey.isNotBlank() && cseKey.isNotBlank()) { diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/JokeTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/JokeTest.kt index 36156e2..073d089 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/JokeTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/JokeTest.kt @@ -42,7 +42,7 @@ class JokeTest { @Test @Throws(ModuleException::class) fun testRamdomJoke() { - assertThat(randomJoke().msg.isNotEmpty()).`as`("randomJoke() > 0").isTrue - assertThat(randomJoke().msg).`as`("randomJoke()").containsIgnoringCase("chuck") + assertThat(randomJoke().msg.isNotEmpty()).describedAs("randomJoke() > 0").isTrue + assertThat(randomJoke().msg).describedAs("randomJoke()").containsIgnoringCase("chuck") } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/LookupTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/LookupTest.kt index 3b94181..9fbf64c 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/LookupTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/LookupTest.kt @@ -44,7 +44,7 @@ class LookupTest { @Throws(Exception::class) fun testLookup() { val result = nslookup("apple.com") - assertThat(result).`as`("lookup(apple.com)").contains("17.253.144.10") + assertThat(result).describedAs("lookup(apple.com)").contains("17.253.144.10") } @Test @@ -52,6 +52,6 @@ class LookupTest { fun testWhois() { val result = whois("17.178.96.59", Lookup.WHOIS_HOST) assertThat(result.stream().anyMatch { m: String -> m.contains("Apple Inc.") }) - .`as`("whois(17.178.96.59/Apple Inc.").isTrue + .describedAs("whois(17.178.96.59/Apple Inc.").isTrue } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/ModuleExceptionTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/ModuleExceptionTest.kt index e49da97..c2d61e3 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/ModuleExceptionTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/ModuleExceptionTest.kt @@ -50,7 +50,7 @@ class ModuleExceptionTest { fun createData(@Suppress("UNUSED_PARAMETER") m: Method?): Array> { return arrayOf( arrayOf(ModuleException(debugMessage, message, IOException("URL http://foobar.com"))), - arrayOf(ModuleException(debugMessage,message,IOException("URL http://foobar.com?"))), + arrayOf(ModuleException(debugMessage, message, IOException("URL http://foobar.com?"))), arrayOf(ModuleException(debugMessage, message)) ) } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/PingTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/PingTest.kt index b849192..1eba3b7 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/PingTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/PingTest.kt @@ -41,13 +41,13 @@ import org.testng.annotations.Test class PingTest { @Test fun testPingsArray() { - assertThat(Ping.PINGS).`as`("Pings array is not empty.").isNotEmpty + assertThat(Ping.PINGS).describedAs("Pings array is not empty.").isNotEmpty } @Test fun testRandomPing() { for (i in 0..9) { - assertThat(randomPing()).`as`("Random ping $i").isIn(Ping.PINGS) + assertThat(randomPing()).describedAs("Random ping $i").isIn(Ping.PINGS) } } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/RockPaperScissorsTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/RockPaperScissorsTest.kt index 34cf7bb..3f5352f 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/RockPaperScissorsTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/RockPaperScissorsTest.kt @@ -38,13 +38,17 @@ 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", "paper")).describedAs("scissors vs. paper") + .isEqualTo("win") + assertThat(RockPaperScissors.winLoseOrDraw("paper", "rock")).describedAs("paper vs. rock").isEqualTo("win") + assertThat(RockPaperScissors.winLoseOrDraw("rock", "scissors")).describedAs("rock vs. scissors") + .isEqualTo("win") + assertThat(RockPaperScissors.winLoseOrDraw("paper", "scissors")).describedAs("paper vs. scissors") + .isEqualTo("lose") + assertThat(RockPaperScissors.winLoseOrDraw("rock", "paper")).describedAs("rock vs. paper").isEqualTo("lose") + assertThat(RockPaperScissors.winLoseOrDraw("scissors", "rock")).describedAs("scissors vs. rock") + .isEqualTo("lose") assertThat(RockPaperScissors.winLoseOrDraw("scissors", "scissors")) - .`as`("scissors vs. scissors").isEqualTo("draw") + .describedAs("scissors vs. scissors").isEqualTo("draw") } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/StockQuoteTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/StockQuoteTest.kt index c12b33e..60875cf 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/StockQuoteTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/StockQuoteTest.kt @@ -47,17 +47,17 @@ class StockQuoteTest : LocalProperties() { val apiKey = getProperty(StockQuote.ALPHAVANTAGE_API_KEY_PROP) try { val messages = getQuote("apple inc", apiKey) - 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: ") + assertThat(messages).describedAs("response not empty").isNotEmpty + assertThat(messages[0].msg).describedAs("same stock symbol").startsWith("Symbol: AAPL") + assertThat(messages[1].msg).describedAs("price label").startsWith(" Price: ") try { getQuote("blahfoo", apiKey) } catch (e: ModuleException) { - assertThat(e.message).`as`("invalid symbol").containsIgnoringCase(StockQuote.INVALID_SYMBOL) + assertThat(e.message).describedAs("invalid symbol").containsIgnoringCase(StockQuote.INVALID_SYMBOL) } - assertThatThrownBy { getQuote("test", "") }.`as`("no API key") + assertThatThrownBy { getQuote("test", "") }.describedAs("no API key") .isInstanceOf(ModuleException::class.java).hasNoCause() - assertThatThrownBy { getQuote("", "apikey") }.`as`("no symbol") + assertThatThrownBy { getQuote("", "apikey") }.describedAs("no symbol") .isInstanceOf(ModuleException::class.java).hasNoCause() } catch (e: ModuleException) { // Avoid displaying api keys in CI logs diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/TwitterTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/TwitterTest.kt index 10a9d79..ce5c36d 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/TwitterTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/TwitterTest.kt @@ -66,6 +66,6 @@ class TwitterTest : LocalProperties() { msg, true ).msg - ).`as`("twitterPost($msg)").isEqualTo(msg) + ).describedAs("twitterPost($msg)").isEqualTo(msg) } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/Weather2Test.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/Weather2Test.kt index 0d9570c..23d9b16 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/Weather2Test.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/Weather2Test.kt @@ -46,16 +46,16 @@ class Weather2Test : LocalProperties() { @Throws(ModuleException::class) fun testWeather() { var messages = getWeather("98204", getProperty(Weather2.OWM_API_KEY_PROP)) - assertThat(messages[0].msg).`as`("is Everett").contains("Everett").contains("US") - assertThat(messages[messages.size - 1].msg).`as`("is City Search").endsWith("98204%2CUS") + assertThat(messages[0].msg).describedAs("is Everett").contains("Everett").contains("US") + assertThat(messages[messages.size - 1].msg).describedAs("is City Search").endsWith("98204%2CUS") messages = getWeather("London, UK", 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") + assertThat(messages[0].msg).describedAs("is UK").contains("London").contains("UK") + assertThat(messages[messages.size - 1].msg).describedAs("is City Code").endsWith("4517009") assertThatThrownBy { getWeather("Montpellier, FR", getProperty(Weather2.OWM_API_KEY_PROP)) } - .`as`("Montpellier not found").hasCauseInstanceOf(APIException::class.java) + .describedAs("Montpellier not found").hasCauseInstanceOf(APIException::class.java) assertThatThrownBy { getWeather("test", "") } - .`as`("no API key").isInstanceOf(ModuleException::class.java).hasNoCause() + .describedAs("no API key").isInstanceOf(ModuleException::class.java).hasNoCause() messages = getWeather("", "apikey") - assertThat(messages[0].isError).`as`("no query").isTrue + assertThat(messages[0].isError).describedAs("no query").isTrue } } diff --git a/src/test/kotlin/net/thauvin/erik/mobibot/modules/WordTimeTest.kt b/src/test/kotlin/net/thauvin/erik/mobibot/modules/WordTimeTest.kt index 4243383..d0c3e00 100644 --- a/src/test/kotlin/net/thauvin/erik/mobibot/modules/WordTimeTest.kt +++ b/src/test/kotlin/net/thauvin/erik/mobibot/modules/WordTimeTest.kt @@ -42,8 +42,8 @@ import org.testng.annotations.Test class WordTimeTest { @Test fun testTime() { - assertThat(time("PST").msg).`as`("PST").endsWith(Utils.bold("Los Angeles")) - assertThat(time("BLAH").isError).`as`("BLAH").isTrue - assertThat(time("BEATS").msg).`as`("BEATS").contains("@") + assertThat(time("PST").msg).describedAs("PST").endsWith(Utils.bold("Los Angeles")) + assertThat(time("BLAH").isError).describedAs("BLAH").isTrue + assertThat(time("BEATS").msg).describedAs("BEATS").contains("@") } } diff --git a/version.properties b/version.properties index e7931a0..0d16bd8 100644 --- a/version.properties +++ b/version.properties @@ -1,9 +1,9 @@ #Generated by the Semver Plugin for Gradle -#Tue May 11 00:11:43 PDT 2021 -version.buildmeta=720 +#Tue May 11 00:47:17 PDT 2021 +version.buildmeta=722 version.major=0 version.minor=8 version.patch=0 version.prerelease=beta version.project=mobibot -version.semver=0.8.0-beta+720 +version.semver=0.8.0-beta+722