✨ Add toString() implementation for Client
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 9 Jul 2019 08:22:32 +0000 (10:22 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 10 Jul 2019 06:24:13 +0000 (08:24 +0200)
src/main/java/net/pterodactylus/sone/data/Client.java
src/test/kotlin/net/pterodactylus/sone/data/ClientTest.kt [new file with mode: 0644]

index f23decf..7dd086d 100644 (file)
@@ -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 (file)
index 0000000..bad8ff8
--- /dev/null
@@ -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"))
+       }
+
+}