From 22458ba912ec789646f387a7b25d12b5f45c907d Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 12 Oct 2019 10:44:25 +0200 Subject: [PATCH] =?utf8?q?=F0=9F=8E=A8=20Replace=20escaped=20Mockito=20met?= =?utf8?q?hods=20with=20better-named=20versions?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../sone/core/DefaultElementLoaderTest.kt | 7 ++-- .../sone/core/FreenetInterfaceTest.kt | 2 +- .../pterodactylus/sone/core/ImageInserterTest.kt | 2 +- .../pterodactylus/sone/core/SoneInserterTest.kt | 4 +-- .../net/pterodactylus/sone/core/SoneRescuerTest.kt | 2 +- .../sone/template/LinkedElementsFilterTest.kt | 39 +++++++++++----------- .../sone/template/ParserFilterTest.kt | 13 +++----- .../sone/template/ProfileAccessorTest.kt | 16 ++++----- .../sone/template/ShortenFilterTest.kt | 7 ++-- .../net/pterodactylus/sone/test/Mockotlin.kt | 3 +- .../pterodactylus/sone/text/FreenetLinkPartTest.kt | 4 +-- .../net/pterodactylus/sone/text/LinkPartTest.kt | 4 +-- .../net/pterodactylus/sone/text/SonePartTest.kt | 12 +++---- 13 files changed, 53 insertions(+), 62 deletions(-) diff --git a/src/test/kotlin/net/pterodactylus/sone/core/DefaultElementLoaderTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/DefaultElementLoaderTest.kt index 726ceb7..c66e6ff 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/DefaultElementLoaderTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/DefaultElementLoaderTest.kt @@ -4,15 +4,12 @@ import com.google.common.base.Ticker import com.google.common.io.ByteStreams import freenet.keys.FreenetURI import net.pterodactylus.sone.core.FreenetInterface.BackgroundFetchCallback -import net.pterodactylus.sone.test.capture -import net.pterodactylus.sone.test.mock +import net.pterodactylus.sone.test.* import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.equalTo -import org.hamcrest.Matchers.equalTo import org.junit.Test import org.mockito.ArgumentMatchers.any import org.mockito.ArgumentMatchers.eq -import org.mockito.Mockito.`when` import org.mockito.Mockito.times import org.mockito.Mockito.verify import java.io.ByteArrayOutputStream @@ -173,7 +170,7 @@ class DefaultElementLoaderTest { elementLoader.loadElement(IMAGE_ID) verify(freenetInterface).startFetch(eq(freenetURI), callback.capture()) callback.value.failed(freenetURI) - `when`(ticker.read()).thenReturn(TimeUnit.MINUTES.toNanos(31)) + whenever(ticker.read()).thenReturn(TimeUnit.MINUTES.toNanos(31)) val linkedElement = elementLoader.loadElement(IMAGE_ID) assertThat(linkedElement.failed, equalTo(false)) assertThat(linkedElement.loading, equalTo(true)) diff --git a/src/test/kotlin/net/pterodactylus/sone/core/FreenetInterfaceTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/FreenetInterfaceTest.kt index cdf0dfb..6647434 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/FreenetInterfaceTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/FreenetInterfaceTest.kt @@ -88,7 +88,7 @@ class FreenetInterfaceTest { @Before fun setupCallbackCaptorAndUskManager() { - doNothing().`when`(uskManager).subscribe(any(USK::class.java), callbackCaptor.capture(), anyBoolean(), any(RequestClient::class.java)) + doNothing().whenever(uskManager).subscribe(any(USK::class.java), callbackCaptor.capture(), anyBoolean(), any(RequestClient::class.java)) } @Test diff --git a/src/test/kotlin/net/pterodactylus/sone/core/ImageInserterTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/ImageInserterTest.kt index 39a11dc..60bb7e2 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/ImageInserterTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/ImageInserterTest.kt @@ -37,7 +37,7 @@ class ImageInserterTest { @Test fun `exception when inserting image is ignored`() { - doThrow(SoneException::class.java).`when`(freenetInterface).insertImage(eq(temporaryImage), eq(image), any(InsertToken::class.java)) + doThrow(SoneException::class.java).whenever(freenetInterface).insertImage(eq(temporaryImage), eq(image), any(InsertToken::class.java)) imageInserter.insertImage(temporaryImage, image) verify(freenetInterface).insertImage(eq(temporaryImage), eq(image), any(InsertToken::class.java)) } diff --git a/src/test/kotlin/net/pterodactylus/sone/core/SoneInserterTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/SoneInserterTest.kt index 8b061a7..2f90250 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/SoneInserterTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/SoneInserterTest.kt @@ -104,7 +104,7 @@ class SoneInserterTest { doAnswer { soneInserter.stop() null - }.`when`(core).touchConfiguration() + }.whenever(core).touchConfiguration() soneInserter.serviceRun() val soneEvents = ArgumentCaptor.forClass(SoneEvent::class.java) verify(freenetInterface).insertDirectory(eq(insertUri), any>(), eq("index.html")) @@ -251,7 +251,7 @@ class SoneInserterTest { doAnswer { soneInserter.stop() null - }.`when`(core).touchConfiguration() + }.whenever(core).touchConfiguration() soneInserter.serviceRun() val histogram = metricRegistry.histogram("sone.insert.duration") assertThat(histogram.count, equalTo(1L)) diff --git a/src/test/kotlin/net/pterodactylus/sone/core/SoneRescuerTest.kt b/src/test/kotlin/net/pterodactylus/sone/core/SoneRescuerTest.kt index a74b874..af8a402 100644 --- a/src/test/kotlin/net/pterodactylus/sone/core/SoneRescuerTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/core/SoneRescuerTest.kt @@ -94,7 +94,7 @@ class SoneRescuerTest { doAnswer { soneRescuer.stop() fetchedSone - }.`when`(soneDownloader).fetchSone(eq(sone), eq(keyWithMetaStrings), eq(true)) + }.whenever(soneDownloader).fetchSone(eq(sone), eq(keyWithMetaStrings), eq(true)) } private fun setupFreenetUri(): FreenetURI { diff --git a/src/test/kotlin/net/pterodactylus/sone/template/LinkedElementsFilterTest.kt b/src/test/kotlin/net/pterodactylus/sone/template/LinkedElementsFilterTest.kt index 1e83b85..32e8587 100644 --- a/src/test/kotlin/net/pterodactylus/sone/template/LinkedElementsFilterTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/template/LinkedElementsFilterTest.kt @@ -10,7 +10,7 @@ import net.pterodactylus.sone.data.SoneOptions.LoadExternalContent.MANUALLY_TRUS import net.pterodactylus.sone.data.SoneOptions.LoadExternalContent.TRUSTED import net.pterodactylus.sone.freenet.wot.OwnIdentity import net.pterodactylus.sone.freenet.wot.Trust -import net.pterodactylus.sone.test.mock +import net.pterodactylus.sone.test.* import net.pterodactylus.sone.text.FreenetLinkPart import net.pterodactylus.sone.text.LinkPart import net.pterodactylus.sone.text.Part @@ -21,7 +21,6 @@ import org.hamcrest.Matchers.contains import org.hamcrest.Matchers.emptyIterable import org.junit.Before import org.junit.Test -import org.mockito.Mockito.`when` /** * Unit test for [LinkedElementsFilter]. @@ -44,14 +43,14 @@ class LinkedElementsFilterTest { @Before fun setupSone() { - `when`(sone.options).thenReturn(DefaultSoneOptions()) + whenever(sone.options).thenReturn(DefaultSoneOptions()) } @Before fun setupImageLoader() { - `when`(imageLoader.loadElement("KSK@link")).thenReturn(LinkedElement("KSK@link", failed = true)) - `when`(imageLoader.loadElement("KSK@loading.png")).thenReturn(LinkedElement("KSK@loading.png", loading = true)) - `when`(imageLoader.loadElement("KSK@link.png")).thenReturn(LinkedElement("KSK@link.png")) + whenever(imageLoader.loadElement("KSK@link")).thenReturn(LinkedElement("KSK@link", failed = true)) + whenever(imageLoader.loadElement("KSK@loading.png")).thenReturn(LinkedElement("KSK@loading.png", loading = true)) + whenever(imageLoader.loadElement("KSK@link.png")).thenReturn(LinkedElement("KSK@link.png")) } @Test @@ -89,7 +88,7 @@ class LinkedElementsFilterTest { fun `filter finds images if the remote sone is local`() { sone.options.loadLinkedImages = MANUALLY_TRUSTED templateContext.set("currentSone", sone) - `when`(remoteSone.isLocal).thenReturn(true) + whenever(remoteSone.isLocal).thenReturn(true) parameters["sone"] = remoteSone verifyThatImagesArePresent() } @@ -106,7 +105,7 @@ class LinkedElementsFilterTest { fun `filter does not find images if local sone requires manual trust and remote sone has only implicit trust`() { sone.options.loadLinkedImages = MANUALLY_TRUSTED templateContext.set("currentSone", sone) - `when`(remoteSone.identity.getTrust(this.sone.identity as OwnIdentity)).thenReturn(Trust(null, 100, null)) + whenever(remoteSone.identity.getTrust(this.sone.identity as OwnIdentity)).thenReturn(Trust(null, 100, null)) parameters["sone"] = remoteSone verifyThatImagesAreNotPresent() } @@ -115,7 +114,7 @@ class LinkedElementsFilterTest { fun `filter does not find images if local sone requires manual trust and remote sone has explicit trust of zero`() { sone.options.loadLinkedImages = MANUALLY_TRUSTED templateContext.set("currentSone", sone) - `when`(remoteSone.identity.getTrust(this.sone.identity as OwnIdentity)).thenReturn(Trust(0, null, null)) + whenever(remoteSone.identity.getTrust(this.sone.identity as OwnIdentity)).thenReturn(Trust(0, null, null)) parameters["sone"] = remoteSone verifyThatImagesAreNotPresent() } @@ -124,7 +123,7 @@ class LinkedElementsFilterTest { fun `filter finds images if local sone requires manual trust and remote sone has explicit trust of one`() { sone.options.loadLinkedImages = MANUALLY_TRUSTED templateContext.set("currentSone", sone) - `when`(remoteSone.identity.getTrust(this.sone.identity as OwnIdentity)).thenReturn(Trust(1, null, null)) + whenever(remoteSone.identity.getTrust(this.sone.identity as OwnIdentity)).thenReturn(Trust(1, null, null)) parameters["sone"] = remoteSone verifyThatImagesArePresent() } @@ -140,7 +139,7 @@ class LinkedElementsFilterTest { @Test fun `filter finds images if local sone requires following and remote sone is followed`() { sone.options.loadLinkedImages = FOLLOWED - `when`(sone.hasFriend("remote-id")).thenReturn(true) + whenever(sone.hasFriend("remote-id")).thenReturn(true) templateContext["currentSone"] = sone parameters["sone"] = remoteSone verifyThatImagesArePresent() @@ -158,7 +157,7 @@ class LinkedElementsFilterTest { fun `filter finds images if following is required and remote sone is a local sone`() { sone.options.loadLinkedImages = FOLLOWED templateContext["currentSone"] = sone - `when`(remoteSone.isLocal).thenReturn(true) + whenever(remoteSone.isLocal).thenReturn(true) parameters["sone"] = remoteSone verifyThatImagesArePresent() } @@ -175,7 +174,7 @@ class LinkedElementsFilterTest { fun `filter does not find images if any trust is required and remote sone has implicit trust of zero`() { sone.options.loadLinkedImages = TRUSTED templateContext["currentSone"] = sone - `when`(remoteSone.identity.getTrust(sone.identity as OwnIdentity)).thenReturn(Trust(null, 0, null)) + whenever(remoteSone.identity.getTrust(sone.identity as OwnIdentity)).thenReturn(Trust(null, 0, null)) parameters["sone"] = remoteSone verifyThatImagesAreNotPresent() } @@ -184,7 +183,7 @@ class LinkedElementsFilterTest { fun `filter finds images if any trust is required and remote sone has implicit trust of one`() { sone.options.loadLinkedImages = TRUSTED templateContext["currentSone"] = sone - `when`(remoteSone.identity.getTrust(sone.identity as OwnIdentity)).thenReturn(Trust(null, 1, null)) + whenever(remoteSone.identity.getTrust(sone.identity as OwnIdentity)).thenReturn(Trust(null, 1, null)) parameters["sone"] = remoteSone verifyThatImagesArePresent() } @@ -193,7 +192,7 @@ class LinkedElementsFilterTest { fun `filter does not find images if any trust is required and remote sone has explicit trust of zero but implicit trust of one`() { sone.options.loadLinkedImages = TRUSTED templateContext["currentSone"] = sone - `when`(remoteSone.identity.getTrust(sone.identity as OwnIdentity)).thenReturn(Trust(0, 1, null)) + whenever(remoteSone.identity.getTrust(sone.identity as OwnIdentity)).thenReturn(Trust(0, 1, null)) parameters["sone"] = remoteSone verifyThatImagesAreNotPresent() } @@ -202,7 +201,7 @@ class LinkedElementsFilterTest { fun `filter finds images if any trust is required and remote sone has explicit trust of one but no implicit trust`() { sone.options.loadLinkedImages = TRUSTED templateContext["currentSone"] = sone - `when`(remoteSone.identity.getTrust(sone.identity as OwnIdentity)).thenReturn(Trust(1, null, null)) + whenever(remoteSone.identity.getTrust(sone.identity as OwnIdentity)).thenReturn(Trust(1, null, null)) parameters["sone"] = remoteSone verifyThatImagesArePresent() } @@ -211,7 +210,7 @@ class LinkedElementsFilterTest { fun `filter finds images if any trust is required and remote sone is a local sone`() { sone.options.loadLinkedImages = TRUSTED templateContext["currentSone"] = sone - `when`(remoteSone.isLocal).thenReturn(true) + whenever(remoteSone.isLocal).thenReturn(true) parameters["sone"] = remoteSone verifyThatImagesArePresent() } @@ -238,9 +237,9 @@ class LinkedElementsFilterTest { private fun createSone(id: String = "sone-id"): Sone { val sone = mock() - `when`(sone.id).thenReturn(id) - `when`(sone.options).thenReturn(DefaultSoneOptions()) - `when`(sone.identity).thenReturn(mock()) + whenever(sone.id).thenReturn(id) + whenever(sone.options).thenReturn(DefaultSoneOptions()) + whenever(sone.identity).thenReturn(mock()) return sone } diff --git a/src/test/kotlin/net/pterodactylus/sone/template/ParserFilterTest.kt b/src/test/kotlin/net/pterodactylus/sone/template/ParserFilterTest.kt index 0e44568..5864a6a 100644 --- a/src/test/kotlin/net/pterodactylus/sone/template/ParserFilterTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/template/ParserFilterTest.kt @@ -3,20 +3,17 @@ package net.pterodactylus.sone.template import com.google.inject.Guice import net.pterodactylus.sone.core.Core import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.test.getInstance -import net.pterodactylus.sone.test.isProvidedByMock -import net.pterodactylus.sone.test.mock +import net.pterodactylus.sone.test.* import net.pterodactylus.sone.text.SoneTextParser import net.pterodactylus.sone.text.SoneTextParserContext import net.pterodactylus.util.template.TemplateContext import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.`is` +import org.hamcrest.Matchers.equalTo import org.hamcrest.Matchers.emptyIterable import org.hamcrest.Matchers.notNullValue import org.hamcrest.Matchers.sameInstance import org.junit.Test import org.mockito.ArgumentCaptor.forClass -import org.mockito.Mockito.`when` import org.mockito.Mockito.eq import org.mockito.Mockito.verify @@ -38,8 +35,8 @@ class ParserFilterTest { private fun setupSone(identity: String): Sone { val sone = mock() - `when`(sone.id).thenReturn(identity) - `when`(core.getSone(identity)).thenReturn(sone) + whenever(sone.id).thenReturn(identity) + whenever(core.getSone(identity)).thenReturn(sone) return sone } @@ -63,7 +60,7 @@ class ParserFilterTest { filter.format(templateContext, "text", parameters) val context = forClass(SoneTextParserContext::class.java) verify(soneTextParser).parse(eq("text") ?: "", context.capture()) - assertThat(context.value.postingSone, `is`(sone)) + assertThat(context.value.postingSone, equalTo(sone)) } @Test diff --git a/src/test/kotlin/net/pterodactylus/sone/template/ProfileAccessorTest.kt b/src/test/kotlin/net/pterodactylus/sone/template/ProfileAccessorTest.kt index a2c4ad7..4513ce0 100644 --- a/src/test/kotlin/net/pterodactylus/sone/template/ProfileAccessorTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/template/ProfileAccessorTest.kt @@ -17,7 +17,7 @@ import net.pterodactylus.sone.test.mock import net.pterodactylus.sone.test.whenever import net.pterodactylus.util.template.TemplateContext import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.`is` +import org.hamcrest.Matchers.equalTo import org.hamcrest.Matchers.nullValue import org.junit.Before import org.junit.Test @@ -86,7 +86,7 @@ class ProfileAccessorTest { @Test fun `avatar ID is returned if profile belongs to local sone`() { whenever(remoteSone.isLocal).thenReturn(true) - assertThat(accessor.get(templateContext, profile, "avatar"), `is`("avatar-id")) + assertThat(accessor.get(templateContext, profile, "avatar"), equalTo("avatar-id")) } @Test @@ -98,14 +98,14 @@ class ProfileAccessorTest { @Test fun `avatar ID is returned if sone is configure to always show avatars`() { currentSone.options.showCustomAvatars = ALWAYS - assertThat(accessor.get(templateContext, profile, "avatar"), `is`("avatar-id")) + assertThat(accessor.get(templateContext, profile, "avatar"), equalTo("avatar-id")) } @Test fun `avatar ID is returned if sone is configure to show avatars of followed sones and remote sone is followed`() { currentSone.options.showCustomAvatars = FOLLOWED whenever(currentSone.hasFriend("remote-sone")).thenReturn(true) - assertThat(accessor.get(templateContext, profile, "avatar"), `is`("avatar-id")) + assertThat(accessor.get(templateContext, profile, "avatar"), equalTo("avatar-id")) } @Test @@ -142,7 +142,7 @@ class ProfileAccessorTest { fun `avatar ID is returned if sone is configure to show avatars based on manual trust and explicit trust is one`() { currentSone.options.showCustomAvatars = MANUALLY_TRUSTED setTrust(Trust(1, null, null)) - assertThat(accessor.get(templateContext, profile, "avatar"), `is`("avatar-id")) + assertThat(accessor.get(templateContext, profile, "avatar"), equalTo("avatar-id")) } @Test @@ -156,7 +156,7 @@ class ProfileAccessorTest { fun `avatar ID is returned if sone is configure to show avatars based on trust and explicit trust is one`() { currentSone.options.showCustomAvatars = TRUSTED setTrust(Trust(1, null, null)) - assertThat(accessor.get(templateContext, profile, "avatar"), `is`("avatar-id")) + assertThat(accessor.get(templateContext, profile, "avatar"), equalTo("avatar-id")) } @Test @@ -177,12 +177,12 @@ class ProfileAccessorTest { fun `avatar ID is returned if sone is configure to show avatars based on trust and implicit trust is one`() { currentSone.options.showCustomAvatars = TRUSTED setTrust(Trust(0, 1, null)) - assertThat(accessor.get(templateContext, profile, "avatar"), `is`("avatar-id")) + assertThat(accessor.get(templateContext, profile, "avatar"), equalTo("avatar-id")) } @Test fun `accessing other members uses reflection accessor`() { - assertThat(accessor.get(templateContext, profile, "hashCode"), `is`(profile.hashCode())) + assertThat(accessor.get(templateContext, profile, "hashCode"), equalTo(profile.hashCode())) } } diff --git a/src/test/kotlin/net/pterodactylus/sone/template/ShortenFilterTest.kt b/src/test/kotlin/net/pterodactylus/sone/template/ShortenFilterTest.kt index c6990a7..efed7a3 100644 --- a/src/test/kotlin/net/pterodactylus/sone/template/ShortenFilterTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/template/ShortenFilterTest.kt @@ -2,7 +2,7 @@ package net.pterodactylus.sone.template import net.pterodactylus.sone.data.Profile import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.test.mock +import net.pterodactylus.sone.test.* import net.pterodactylus.sone.text.FreenetLinkPart import net.pterodactylus.sone.text.Part import net.pterodactylus.sone.text.PlainTextPart @@ -10,7 +10,6 @@ import net.pterodactylus.sone.text.SonePart import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.contains import org.junit.Test -import org.mockito.Mockito.`when` /** * Unit test for [ShortenFilter]. @@ -76,7 +75,7 @@ class ShortenFilterTest { @Test fun `sone parts are added but their length is ignored`() { val sone = mock() - `when`(sone.profile).thenReturn(Profile(sone)) + whenever(sone.profile).thenReturn(Profile(sone)) assertThat(shortenParts(15, 10, SonePart(sone), PlainTextPart("This is a long text.")), contains( SonePart(sone), PlainTextPart("This is a …") @@ -86,7 +85,7 @@ class ShortenFilterTest { @Test fun `additional sone parts are ignored`() { val sone = mock() - `when`(sone.profile).thenReturn(Profile(sone)) + whenever(sone.profile).thenReturn(Profile(sone)) assertThat(shortenParts(15, 10, PlainTextPart("This is a long text."), SonePart(sone)), contains( PlainTextPart("This is a …") )) diff --git a/src/test/kotlin/net/pterodactylus/sone/test/Mockotlin.kt b/src/test/kotlin/net/pterodactylus/sone/test/Mockotlin.kt index 85b86d5..4d345b3 100644 --- a/src/test/kotlin/net/pterodactylus/sone/test/Mockotlin.kt +++ b/src/test/kotlin/net/pterodactylus/sone/test/Mockotlin.kt @@ -3,7 +3,7 @@ package net.pterodactylus.sone.test import com.google.inject.Module import org.mockito.* import org.mockito.invocation.InvocationOnMock -import org.mockito.stubbing.OngoingStubbing +import org.mockito.stubbing.* inline fun mock(): T = Mockito.mock(T::class.java)!! inline fun mockBuilder(): T = Mockito.mock(T::class.java, Mockito.RETURNS_SELF)!! @@ -20,6 +20,7 @@ inline fun bindMock(): Module = Module { it!!.bind(T::class.java).toInstance(mock()) } inline fun whenever(methodCall: T) = Mockito.`when`(methodCall)!! +inline fun Stubber.whenever(mock: T) = `when`(mock)!! inline fun OngoingStubbing.thenReturnMock(): OngoingStubbing = this.thenReturn(mock()) diff --git a/src/test/kotlin/net/pterodactylus/sone/text/FreenetLinkPartTest.kt b/src/test/kotlin/net/pterodactylus/sone/text/FreenetLinkPartTest.kt index fcf6e67..aeba2c7 100644 --- a/src/test/kotlin/net/pterodactylus/sone/text/FreenetLinkPartTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/text/FreenetLinkPartTest.kt @@ -1,7 +1,7 @@ package net.pterodactylus.sone.text import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.`is` +import org.hamcrest.Matchers.equalTo import org.junit.Test /** @@ -11,7 +11,7 @@ class FreenetLinkPartTest { @Test fun linkIsUsedAsTitleIfNoTextIsGiven() { - assertThat(FreenetLinkPart("link", "text", true).title, `is`("link")) + assertThat(FreenetLinkPart("link", "text", true).title, equalTo("link")) } } diff --git a/src/test/kotlin/net/pterodactylus/sone/text/LinkPartTest.kt b/src/test/kotlin/net/pterodactylus/sone/text/LinkPartTest.kt index 373a848..e38343c 100644 --- a/src/test/kotlin/net/pterodactylus/sone/text/LinkPartTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/text/LinkPartTest.kt @@ -1,7 +1,7 @@ package net.pterodactylus.sone.text import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.`is` +import org.hamcrest.Matchers.equalTo import org.junit.Test /** @@ -11,7 +11,7 @@ class LinkPartTest { @Test fun linkIsUsedAsTitleIfNoTitleIsGiven() { - assertThat(LinkPart("link", "text").title, `is`("link")) + assertThat(LinkPart("link", "text").title, equalTo("link")) } } diff --git a/src/test/kotlin/net/pterodactylus/sone/text/SonePartTest.kt b/src/test/kotlin/net/pterodactylus/sone/text/SonePartTest.kt index 31fca48..ef1b1c0 100644 --- a/src/test/kotlin/net/pterodactylus/sone/text/SonePartTest.kt +++ b/src/test/kotlin/net/pterodactylus/sone/text/SonePartTest.kt @@ -1,12 +1,10 @@ package net.pterodactylus.sone.text -import net.pterodactylus.sone.data.Profile import net.pterodactylus.sone.data.Sone -import net.pterodactylus.sone.test.mock +import net.pterodactylus.sone.test.* import org.hamcrest.MatcherAssert.assertThat -import org.hamcrest.Matchers.`is` +import org.hamcrest.Matchers.equalTo import org.junit.Test -import org.mockito.Mockito.`when` /** * Unit test for [SonePart]. @@ -16,15 +14,15 @@ class SonePartTest { private val sone = mock() init { - `when`(sone.profile).thenReturn(mock()) - `when`(sone.name).thenReturn("sone") + whenever(sone.profile).thenReturn(mock()) + whenever(sone.name).thenReturn("sone") } private val part = SonePart(sone) @Test fun textIsConstructedFromSonesNiceName() { - assertThat(part.text, `is`("sone")) + assertThat(part.text, equalTo("sone")) } } -- 2.7.4