[LIB-2] Add snooker-score-api source files
[snooker-score-api.git] / src / test / java / org / hedgecode / snooker / json / JsonMatchTest.java
1 /*
2  * Copyright (c) 2017. Developed by Hedgecode.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.hedgecode.snooker.json;
18
19 import org.junit.Test;
20 import org.junit.runner.RunWith;
21 import org.junit.runners.JUnit4;
22
23 /**
24  * Tests for {@link JsonMatch}.
25  *
26  * @author Dmitry Samoshin aka gotty
27  */
28 @RunWith(JUnit4.class)
29 public class JsonMatchTest extends AbstractJsonTest {
30
31     @Test
32     public void testMatch() throws Exception {
33         JsonMatch[] jsonMatches = GSON.fromJson(
34                 JsonStringToken.token(
35                         jsonFromFile()
36                 ),
37                 JsonMatch[].class
38         );
39         //serialize(jsonMatches[0]);
40         JsonMatch expectedMatch = (JsonMatch) deserialize();
41         assertNull(
42                 expectedMatch,
43                 jsonMatches
44         );
45         JsonMatch actualMatch = jsonMatches[0];
46         assertEquals(
47                 expectedMatch,
48                 actualMatch
49         );
50     }
51
52     public static void assertEquals(JsonMatch expected, JsonMatch actual) {
53         assertEquals(expected.matchId(), actual.matchId());
54         assertEquals(expected.eventId(), actual.eventId());
55         assertEquals(expected.round(), actual.round());
56         assertEquals(expected.number(), actual.number());
57         assertEquals(expected.player1Id(), actual.player1Id());
58         assertEquals(expected.score1(), actual.score1());
59         assertEquals(expected.walkover1(), actual.walkover1());
60         assertEquals(expected.player2Id(), actual.player2Id());
61         assertEquals(expected.score2(), actual.score2());
62         assertEquals(expected.walkover2(), actual.walkover2());
63         assertEquals(expected.winnerId(), actual.winnerId());
64         assertEquals(expected.unfinished(), actual.unfinished());
65         assertEquals(expected.onBreak(), actual.onBreak());
66         assertEquals(expected.worldSnookerId(), actual.worldSnookerId());
67         assertEquals(expected.liveUrl(), actual.liveUrl());
68         assertEquals(expected.detailsUrl(), actual.detailsUrl());
69         assertEquals(expected.pointsDropped(), actual.pointsDropped());
70         assertEquals(expected.showCommonNote(), actual.showCommonNote());
71         assertEquals(expected.estimated(), actual.estimated());
72         assertEquals(expected.type(), actual.type());
73         assertEquals(expected.tableNo(), actual.tableNo());
74         assertEquals(expected.videoURL(), actual.videoURL());
75         assertEquals(expected.initDate(), actual.initDate());
76         assertEquals(expected.modDate(), actual.modDate());
77         assertEquals(expected.startDate(), actual.startDate());
78         assertEquals(expected.endDate(), actual.endDate());
79         assertEquals(expected.scheduledDate(), actual.scheduledDate());
80         assertEquals(expected.frameScores(), actual.frameScores());
81         assertEquals(expected.sessions(), actual.sessions());
82         assertEquals(expected.note(), actual.note());
83         assertEquals(expected.extendedNote(), actual.extendedNote());
84     }
85
86 }