/* * 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 JsonMatch}. * * @author Dmitry Samoshin aka gotty */ @RunWith(JUnit4.class) public class JsonMatchTest extends AbstractJsonTest { @Test public void testMatch() throws Exception { JsonMatch[] jsonMatches = GSON.fromJson( JsonStringToken.token( jsonFromFile() ), JsonMatch[].class ); //serialize(jsonMatches[0]); JsonMatch expectedMatch = (JsonMatch) deserialize(); assertNull( expectedMatch, jsonMatches ); JsonMatch actualMatch = jsonMatches[0]; assertEquals( expectedMatch, actualMatch ); } public static void assertEquals(JsonMatch expected, JsonMatch actual) { assertEquals(expected.matchId(), actual.matchId()); assertEquals(expected.eventId(), actual.eventId()); assertEquals(expected.round(), actual.round()); assertEquals(expected.number(), actual.number()); assertEquals(expected.player1Id(), actual.player1Id()); assertEquals(expected.score1(), actual.score1()); assertEquals(expected.walkover1(), actual.walkover1()); assertEquals(expected.player2Id(), actual.player2Id()); assertEquals(expected.score2(), actual.score2()); assertEquals(expected.walkover2(), actual.walkover2()); assertEquals(expected.winnerId(), actual.winnerId()); assertEquals(expected.unfinished(), actual.unfinished()); assertEquals(expected.onBreak(), actual.onBreak()); assertEquals(expected.worldSnookerId(), actual.worldSnookerId()); assertEquals(expected.liveUrl(), actual.liveUrl()); assertEquals(expected.detailsUrl(), actual.detailsUrl()); assertEquals(expected.pointsDropped(), actual.pointsDropped()); assertEquals(expected.showCommonNote(), actual.showCommonNote()); assertEquals(expected.estimated(), actual.estimated()); assertEquals(expected.type(), actual.type()); assertEquals(expected.tableNo(), actual.tableNo()); assertEquals(expected.videoURL(), actual.videoURL()); assertEquals(expected.initDate(), actual.initDate()); assertEquals(expected.modDate(), actual.modDate()); assertEquals(expected.startDate(), actual.startDate()); assertEquals(expected.endDate(), actual.endDate()); assertEquals(expected.scheduledDate(), actual.scheduledDate()); assertEquals(expected.frameScores(), actual.frameScores()); assertEquals(expected.sessions(), actual.sessions()); assertEquals(expected.note(), actual.note()); assertEquals(expected.extendedNote(), actual.extendedNote()); } }