--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+/**
+ * Base Requester Test.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+public abstract class AbstractRequesterTest extends Assert {
+
+ protected static final int CORRECT_ID = 1;
+ protected static final int INCORRECT_ID = 0;
+
+ protected static final String REQUEST_URL = "http://api.snooker.org/";
+
+ private static final String REQUEST_URL_METHOD_NAME = "getRequestUrl";
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ protected abstract Requester getRequester();
+
+ protected abstract RequestParams getCorrectRequestParams();
+
+ protected abstract RequestParams getIncorrectRequestParams();
+
+ protected abstract String getCorrectRequestUrl();
+
+ @Test
+ public void testRequestTypes() throws Exception {
+ for (RequestType requestType : RequestType.values()) {
+ assertNotNull(
+ requestType.requester()
+ );
+ }
+ }
+
+ @Test
+ public void testCorrectRequestById() throws Exception {
+ String requestUrl = invokeRequestUrl(CORRECT_ID);
+ assertEquals(
+ getCorrectRequestUrl(), requestUrl
+ );
+ }
+
+ @Test
+ public void testCorrectRequestByParams() throws Exception {
+ String requestUrl = invokeRequestUrl(
+ getCorrectRequestParams()
+ );
+ assertEquals(
+ getCorrectRequestUrl(), requestUrl
+ );
+ }
+
+ @Test
+ public void testIncorrectRequestById() throws Exception {
+ thrown.expect(InvocationTargetException.class);
+ invokeRequestUrl(INCORRECT_ID);
+ thrown = ExpectedException.none();
+ }
+
+ @Test
+ public void testIncorrectRequestByParams() throws Exception {
+ thrown.expect(InvocationTargetException.class);
+ invokeRequestUrl(
+ getIncorrectRequestParams()
+ );
+ thrown = ExpectedException.none();
+ }
+
+ private String invokeRequestUrl(int id) throws Exception {
+ Requester requester = getRequester();
+ Method requestMethod = requester.getClass().getDeclaredMethod(
+ REQUEST_URL_METHOD_NAME, int.class
+ );
+ assertEquals(
+ String.class, requestMethod.getReturnType()
+ );
+ requestMethod.setAccessible(true);
+ return (String) requestMethod.invoke(requester, id);
+ }
+
+ private String invokeRequestUrl(RequestParams params) throws Exception {
+ Requester requester = getRequester();
+ Method requestMethod = requester.getClass().getDeclaredMethod(
+ REQUEST_URL_METHOD_NAME, RequestParams.class
+ );
+ assertEquals(
+ String.class, requestMethod.getReturnType()
+ );
+ requestMethod.setAccessible(true);
+ return (String) requestMethod.invoke(requester, params);
+ }
+
+ private boolean isHostAvailable() {
+ try {
+ URL url = new URL(REQUEST_URL);
+ HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection();
+ httpConnection.setRequestMethod("HEAD");
+ return httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK;
+ } catch (Exception ignored) {
+ }
+ return false;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link EventMatchesRequester}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class EventMatchesRequesterTest extends AbstractRequesterTest {
+
+ @Test
+ public void testGetInstance() throws Exception {
+ assertNotNull(
+ EventMatchesRequester.getInstance()
+ );
+ }
+
+ @Override
+ protected Requester getRequester() {
+ return EventMatchesRequester.getInstance();
+ }
+
+ @Override
+ protected RequestParams getCorrectRequestParams() {
+ return new RequestParams(RequestType.EVENT_MATCHES, CORRECT_ID, null);
+ }
+
+ @Override
+ protected RequestParams getIncorrectRequestParams() {
+ return new RequestParams(RequestType.EVENT_MATCHES, INCORRECT_ID, null);
+ }
+
+ @Override
+ protected String getCorrectRequestUrl() {
+ return String.format("%s?t=6&e=%d",REQUEST_URL, CORRECT_ID);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link EventPlayersRequester}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class EventPlayersRequesterTest extends AbstractRequesterTest {
+
+ @Test
+ public void testGetInstance() throws Exception {
+ assertNotNull(
+ EventPlayersRequester.getInstance()
+ );
+ }
+
+ @Override
+ protected Requester getRequester() {
+ return EventPlayersRequester.getInstance();
+ }
+
+ @Override
+ protected RequestParams getCorrectRequestParams() {
+ return new RequestParams(RequestType.EVENT_PLAYERS, CORRECT_ID, null);
+ }
+
+ @Override
+ protected RequestParams getIncorrectRequestParams() {
+ return new RequestParams(RequestType.EVENT_PLAYERS, INCORRECT_ID, null);
+ }
+
+ @Override
+ protected String getCorrectRequestUrl() {
+ return String.format("%s?t=9&e=%d", REQUEST_URL, CORRECT_ID);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link EventRequester}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class EventRequesterTest extends AbstractRequesterTest {
+
+ @Test
+ public void testGetInstance() throws Exception {
+ assertNotNull(
+ EventRequester.getInstance()
+ );
+ }
+
+ @Override
+ protected Requester getRequester() {
+ return EventRequester.getInstance();
+ }
+
+ @Override
+ protected RequestParams getCorrectRequestParams() {
+ return new RequestParams(RequestType.EVENT, CORRECT_ID, null);
+ }
+
+ @Override
+ protected RequestParams getIncorrectRequestParams() {
+ return new RequestParams(RequestType.EVENT, INCORRECT_ID, null);
+ }
+
+ @Override
+ protected String getCorrectRequestUrl() {
+ return String.format("%s?e=%d", REQUEST_URL, CORRECT_ID);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link EventRoundsRequester}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class EventRoundsRequesterTest extends AbstractRequesterTest {
+
+ @Test
+ public void testGetInstance() throws Exception {
+ assertNotNull(
+ EventRoundsRequester.getInstance()
+ );
+ }
+
+ @Override
+ protected Requester getRequester() {
+ return EventRoundsRequester.getInstance();
+ }
+
+ @Override
+ protected RequestParams getCorrectRequestParams() {
+ return new RequestParams(RequestType.EVENT_ROUNDS, CORRECT_ID, null);
+ }
+
+ @Override
+ protected RequestParams getIncorrectRequestParams() {
+ return new RequestParams(RequestType.EVENT_ROUNDS, INCORRECT_ID, null);
+ }
+
+ @Override
+ protected String getCorrectRequestUrl() {
+ return String.format("%s?t=12&e=%d", REQUEST_URL, CORRECT_ID);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link EventSeedingRequester}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class EventSeedingRequesterTest extends AbstractRequesterTest {
+
+ @Test
+ public void testGetInstance() throws Exception {
+ assertNotNull(
+ EventSeedingRequester.getInstance()
+ );
+ }
+
+ @Override
+ protected Requester getRequester() {
+ return EventSeedingRequester.getInstance();
+ }
+
+ @Override
+ protected RequestParams getCorrectRequestParams() {
+ return new RequestParams(RequestType.EVENT_SEEDING, CORRECT_ID, null);
+ }
+
+ @Override
+ protected RequestParams getIncorrectRequestParams() {
+ return new RequestParams(RequestType.EVENT_SEEDING, INCORRECT_ID, null);
+ }
+
+ @Override
+ protected String getCorrectRequestUrl() {
+ return String.format("%s?t=13&e=%d", REQUEST_URL, CORRECT_ID);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link MatchRequester}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class MatchRequesterTest extends AbstractRequesterTest {
+
+ @Test
+ public void testGetInstance() throws Exception {
+ assertNotNull(
+ MatchRequester.getInstance()
+ );
+ }
+
+ @Test
+ @Override
+ public void testCorrectRequestById() throws Exception {
+ // do not supported
+ }
+
+ @Override
+ protected Requester getRequester() {
+ return MatchRequester.getInstance();
+ }
+
+ @Override
+ protected RequestParams getCorrectRequestParams() {
+ return new RequestParams(CORRECT_ID, CORRECT_ID, CORRECT_ID);
+ }
+
+ @Override
+ protected RequestParams getIncorrectRequestParams() {
+ return new RequestParams(INCORRECT_ID, INCORRECT_ID, INCORRECT_ID);
+ }
+
+ @Override
+ protected String getCorrectRequestUrl() {
+ return String.format("%s?e=%d&r=%d&n=%d", REQUEST_URL, CORRECT_ID, CORRECT_ID, CORRECT_ID);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link OngoingMatchesRequester}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class OngoingMatchesRequesterTest extends AbstractRequesterTest {
+
+ @Test
+ public void testGetInstance() throws Exception {
+ assertNotNull(
+ OngoingMatchesRequester.getInstance()
+ );
+ }
+
+ @Test
+ @Override
+ public void testIncorrectRequestById() throws Exception {
+ // do not supported
+ }
+
+ @Test
+ @Override
+ public void testIncorrectRequestByParams() throws Exception {
+ // do not supported
+ }
+
+ @Override
+ protected Requester getRequester() {
+ return OngoingMatchesRequester.getInstance();
+ }
+
+ @Override
+ protected RequestParams getCorrectRequestParams() {
+ return null;
+ }
+
+ @Override
+ protected RequestParams getIncorrectRequestParams() {
+ return null;
+ }
+
+ @Override
+ protected String getCorrectRequestUrl() {
+ return String.format("%s?t=7", REQUEST_URL);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import org.hedgecode.snooker.api.Season;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link PlayerMatchesRequester}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class PlayerMatchesRequesterTest extends AbstractRequesterTest {
+
+ @Test
+ public void testGetInstance() throws Exception {
+ assertNotNull(
+ PlayerMatchesRequester.getInstance()
+ );
+ }
+
+ @Override
+ protected Requester getRequester() {
+ return PlayerMatchesRequester.getInstance();
+ }
+
+ @Override
+ protected RequestParams getCorrectRequestParams() {
+ return new RequestParams(RequestType.PLAYER_MATCHES, CORRECT_ID, Season.CURRENT_SEASON);
+ }
+
+ @Override
+ protected RequestParams getIncorrectRequestParams() {
+ return new RequestParams(RequestType.PLAYER_MATCHES, INCORRECT_ID, Season.CURRENT_SEASON);
+ }
+
+ @Override
+ protected String getCorrectRequestUrl() {
+ return String.format("%s?t=8&p=%d&s=%d", REQUEST_URL, CORRECT_ID, Season.CURRENT_YEAR);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link PlayerRequester}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class PlayerRequesterTest extends AbstractRequesterTest {
+
+ @Test
+ public void testGetInstance() throws Exception {
+ assertNotNull(
+ PlayerRequester.getInstance()
+ );
+ }
+
+ @Override
+ protected Requester getRequester() {
+ return PlayerRequester.getInstance();
+ }
+
+ @Override
+ protected RequestParams getCorrectRequestParams() {
+ return new RequestParams(RequestType.PLAYER, CORRECT_ID, null);
+ }
+
+ @Override
+ protected RequestParams getIncorrectRequestParams() {
+ return new RequestParams(RequestType.PLAYER, INCORRECT_ID, null);
+ }
+
+ @Override
+ protected String getCorrectRequestUrl() {
+ return String.format("%s?p=%d", REQUEST_URL, CORRECT_ID);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import org.hedgecode.snooker.api.RankingType;
+import org.hedgecode.snooker.api.Season;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link RankingRequester}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class RankingRequesterTest extends AbstractRequesterTest {
+
+ @Test
+ public void testGetInstance() throws Exception {
+ assertNotNull(
+ RankingRequester.getInstance()
+ );
+ }
+
+ @Test
+ @Override
+ public void testCorrectRequestById() throws Exception {
+ // do not supported
+ }
+
+ @Override
+ protected Requester getRequester() {
+ return RankingRequester.getInstance();
+ }
+
+ @Override
+ protected RequestParams getCorrectRequestParams() {
+ return new RequestParams(Season.CURRENT_SEASON, RankingType.MoneyRankings);
+ }
+
+ @Override
+ protected RequestParams getIncorrectRequestParams() {
+ return new RequestParams(RequestType.RANKING, INCORRECT_ID, null);
+ }
+
+ @Override
+ protected String getCorrectRequestUrl() {
+ return String.format("%s?rt=%s&s=%d", REQUEST_URL, RankingType.MoneyRankings, Season.CURRENT_YEAR);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import org.hedgecode.snooker.api.Season;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link SeasonEventsRequester}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class SeasonEventsRequesterTest extends AbstractRequesterTest {
+
+ @Test
+ public void testGetInstance() throws Exception {
+ assertNotNull(
+ SeasonEventsRequester.getInstance()
+ );
+ }
+
+ @Test
+ @Override
+ public void testIncorrectRequestById() throws Exception {
+ // do not supported
+ }
+
+ @Override
+ protected Requester getRequester() {
+ return SeasonEventsRequester.getInstance();
+ }
+
+ @Override
+ protected RequestParams getCorrectRequestParams() {
+ return new RequestParams(RequestType.SEASON_EVENTS, CORRECT_ID, Season.CURRENT_SEASON);
+ }
+
+ @Override
+ protected RequestParams getIncorrectRequestParams() {
+ return new RequestParams(RequestType.SEASON_EVENTS, INCORRECT_ID, null);
+ }
+
+ @Override
+ protected String getCorrectRequestUrl() {
+ return String.format("%s?t=5&s=%d", REQUEST_URL, Season.CURRENT_YEAR);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2017-2020. 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.request;
+
+import org.hedgecode.snooker.api.PlayerCategory;
+import org.hedgecode.snooker.api.Season;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/**
+ * Tests for {@link SeasonPlayersRequester}.
+ *
+ * @author Dmitry Samoshin aka gotty
+ */
+@RunWith(JUnit4.class)
+public class SeasonPlayersRequesterTest extends AbstractRequesterTest {
+
+ @Test
+ public void testGetInstance() throws Exception {
+ assertNotNull(
+ SeasonPlayersRequester.getInstance()
+ );
+ }
+
+ @Test
+ @Override
+ public void testIncorrectRequestById() throws Exception {
+ // do not supported
+ }
+
+ @Override
+ protected Requester getRequester() {
+ return SeasonPlayersRequester.getInstance();
+ }
+
+ @Override
+ protected RequestParams getCorrectRequestParams() {
+ return new RequestParams(Season.CURRENT_SEASON, PlayerCategory.PRO);
+ }
+
+ @Override
+ protected RequestParams getIncorrectRequestParams() {
+ return new RequestParams(RequestType.SEASON_PLAYERS, INCORRECT_ID, null);
+ }
+
+ @Override
+ protected String getCorrectRequestUrl() {
+ return String.format(
+ "%s?t=10&st=%s&s=%d", REQUEST_URL, PlayerCategory.PRO.letter(), Season.CURRENT_YEAR
+ );
+ }
+
+}