--- /dev/null
+/*
+ * Copyright (c) 2017-2019. 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 JsonRound}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class JsonRoundTest extends AbstractJsonTest {
+
+ @Test
+ public void testRound() throws Exception {
+ JsonRound[] jsonRounds = GSON.fromJson(
+ JsonStringToken.token(
+ jsonFromFile()
+ ),
+ JsonRound[].class
+ );
+ //serialize(jsonRounds[0]);
+ JsonRound expectedRound = (JsonRound) deserialize();
+ assertNull(
+ expectedRound,
+ jsonRounds
+ );
+ JsonRound actualRound = jsonRounds[0];
+ assertEquals(
+ expectedRound,
+ actualRound
+ );
+ }
+
+ public static void assertEquals(JsonRound expected, JsonRound actual) {
+ assertEquals(expected.round(), actual.round());
+ assertEquals(expected.roundName(), actual.roundName());
+ assertEquals(expected.eventId(), actual.eventId());
+ assertEquals(expected.mainEventId(), actual.mainEventId());
+ assertEquals(expected.distance(), actual.distance());
+ assertEquals(expected.numLeft(), actual.numLeft());
+ assertEquals(expected.numMatches(), actual.numMatches());
+ assertEquals(expected.note(), actual.note());
+ assertEquals(expected.valueType(), actual.valueType());
+ assertEquals(expected.rank(), actual.rank());
+ assertEquals(expected.money(), actual.money());
+ assertEquals(expected.seedGetsHalf(), actual.seedGetsHalf());
+ assertEquals(expected.actualMoney(), actual.actualMoney());
+ assertEquals(expected.currency(), actual.currency());
+ assertEquals(expected.conversionRate(), actual.conversionRate());
+ assertEquals(expected.points(), actual.points());
+ assertEquals(expected.seedPoints(), actual.seedPoints());
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2017-2019. 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.hedgecode.snooker.api.Round;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link JsonRounds}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class JsonRoundsTest extends AbstractJsonTest {
+
+ @Test
+ public void testRounds() throws Exception {
+ JsonRounds actualRounds = new JsonRounds(
+ GSON.fromJson(
+ JsonStringToken.token(
+ jsonFromFile()
+ ),
+ JsonRound[].class
+ )
+ );
+ //serialize(actualRounds);
+ JsonRounds expectedRounds = (JsonRounds) deserialize();
+ assertEquals(
+ expectedRounds,
+ actualRounds
+ );
+ }
+
+ public static void assertEquals(JsonRounds expecteds, JsonRounds actuals) {
+ assertEquals(
+ expecteds.size(),
+ actuals.size()
+ );
+ for (Round expected : expecteds) {
+ JsonRoundTest.assertEquals(
+ (JsonRound) expected,
+ (JsonRound) actuals.byId(expected.getId())
+ );
+ }
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2017-2019. 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 JsonSeeding}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class JsonSeedingTest extends AbstractJsonTest {
+
+ @Test
+ public void testSeeding() throws Exception {
+ JsonSeeding[] jsonSeedings = GSON.fromJson(
+ JsonStringToken.token(
+ jsonFromFile()
+ ),
+ JsonSeeding[].class
+ );
+ //serialize(jsonSeedings[0]);
+ JsonSeeding expectedSeeding = (JsonSeeding) deserialize();
+ assertNull(
+ expectedSeeding,
+ jsonSeedings
+ );
+ JsonSeeding actualSeeding = jsonSeedings[0];
+ assertEquals(
+ expectedSeeding,
+ actualSeeding
+ );
+ }
+
+ public static void assertEquals(JsonSeeding expected, JsonSeeding actual) {
+ assertEquals(expected.eventId(), actual.eventId());
+ assertEquals(expected.playerId(), actual.playerId());
+ assertEquals(expected.seeding(), actual.seeding());
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2017-2019. 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.hedgecode.snooker.api.Seeding;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link JsonSeedings}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class JsonSeedingsTest extends AbstractJsonTest {
+
+ @Test
+ public void testSeedings() throws Exception {
+ JsonSeedings actualSeedings = new JsonSeedings(
+ GSON.fromJson(
+ JsonStringToken.token(
+ jsonFromFile()
+ ),
+ JsonSeeding[].class
+ )
+ );
+ //serialize(actualSeedings);
+ JsonSeedings expectedSeedings = (JsonSeedings) deserialize();
+ assertEquals(
+ expectedSeedings,
+ actualSeedings
+ );
+ }
+
+ public static void assertEquals(JsonSeedings expecteds, JsonSeedings actuals) {
+ assertEquals(
+ expecteds.size(),
+ actuals.size()
+ );
+ for (Seeding expected : expecteds) {
+ JsonSeedingTest.assertEquals(
+ (JsonSeeding) expected,
+ (JsonSeeding) actuals.byId(expected.getId())
+ );
+ }
+ }
+
+}
\ No newline at end of file