From 955730bdb935c25945c3cdc9a2eff2f720e8aac0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 9 Jul 2019 10:22:32 +0200 Subject: [PATCH] =?utf8?q?=E2=9C=A8=20Add=20toString()=20implementation=20?= =?utf8?q?for=20Client?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/main/java/net/pterodactylus/sone/data/Client.java | 5 +++++ src/test/kotlin/net/pterodactylus/sone/data/ClientTest.kt | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/test/kotlin/net/pterodactylus/sone/data/ClientTest.kt diff --git a/src/main/java/net/pterodactylus/sone/data/Client.java b/src/main/java/net/pterodactylus/sone/data/Client.java index f23decf..7dd086d 100644 --- a/src/main/java/net/pterodactylus/sone/data/Client.java +++ b/src/main/java/net/pterodactylus/sone/data/Client.java @@ -81,4 +81,9 @@ public class Client { return Objects.hashCode(name, version); } + @Override + public String toString() { + return name + " " + version; + } + } diff --git a/src/test/kotlin/net/pterodactylus/sone/data/ClientTest.kt b/src/test/kotlin/net/pterodactylus/sone/data/ClientTest.kt new file mode 100644 index 0000000..bad8ff8 --- /dev/null +++ b/src/test/kotlin/net/pterodactylus/sone/data/ClientTest.kt @@ -0,0 +1,15 @@ +package net.pterodactylus.sone.data + +import org.hamcrest.MatcherAssert.* +import org.hamcrest.Matchers.* +import kotlin.test.* + +class ClientTest { + + @Test + fun `toString() formats client name and version`() { + val client = Client("Test Client", "v123") + assertThat(client.toString(), equalTo("Test Client v123")) + } + +} -- 2.7.4