[LIB-2] Add snooker-score-api source files
[snooker-score-api.git] / src / test / java / org / hedgecode / snooker / json / JsonPlayerTest.java
diff --git a/src/test/java/org/hedgecode/snooker/json/JsonPlayerTest.java b/src/test/java/org/hedgecode/snooker/json/JsonPlayerTest.java
new file mode 100644 (file)
index 0000000..9b3ae63
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2017. Developed by Hedgecode.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hedgecode.snooker.json;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link JsonPlayer}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class JsonPlayerTest extends AbstractJsonTest {
+
+    @Test
+    public void testPlayer() throws Exception {
+        JsonPlayer[] jsonPlayers = GSON.fromJson(
+                JsonStringToken.token(
+                        jsonFromFile()
+                ),
+                JsonPlayer[].class
+        );
+        //serialize(jsonPlayers[0]);
+        JsonPlayer expectedPlayer = (JsonPlayer) deserialize();
+        assertNull(
+                expectedPlayer,
+                jsonPlayers
+        );
+        JsonPlayer actualPlayer = jsonPlayers[0];
+        assertEquals(
+                expectedPlayer,
+                actualPlayer
+        );
+    }
+
+    public static void assertEquals(JsonPlayer expected, JsonPlayer actual) {
+        assertEquals(expected.playerId(), actual.playerId());
+        assertEquals(expected.type(), actual.type());
+        assertEquals(expected.firstName(), actual.firstName());
+        assertEquals(expected.middleName(), actual.middleName());
+        assertEquals(expected.lastName(), actual.lastName());
+        assertEquals(expected.teamName(), actual.teamName());
+        assertEquals(expected.teamNumber(), actual.teamNumber());
+        assertEquals(expected.teamSeason(), actual.teamSeason());
+        assertEquals(expected.shortName(), actual.shortName());
+        assertEquals(expected.nationality(), actual.nationality());
+        assertEquals(expected.sex(), actual.sex());
+        assertEquals(expected.bioPage(), actual.bioPage());
+        assertEquals(expected.born(), actual.born());
+        assertEquals(expected.twitter(), actual.twitter());
+        assertEquals(expected.surnameFirst(), actual.surnameFirst());
+        assertEquals(expected.license(), actual.license());
+        assertEquals(expected.club(), actual.club());
+        assertEquals(expected.url(), actual.url());
+        assertEquals(expected.photo(), actual.photo());
+        assertEquals(expected.info(), actual.info());
+    }
+
+}