[LIB-10] Tests for Requesters
authorgotty <gotty@fb0bcced-7025-49ed-a12f-f98bce993226>
Sat, 23 Nov 2019 02:54:47 +0000 (02:54 +0000)
committergotty <gotty@fb0bcced-7025-49ed-a12f-f98bce993226>
Sat, 23 Nov 2019 02:54:47 +0000 (02:54 +0000)
git-svn-id: https://svn.hedgecode.org/lib/snooker-score-api/trunk@193 fb0bcced-7025-49ed-a12f-f98bce993226

13 files changed:
src/test/java/org/hedgecode/snooker/request/AbstractRequesterTest.java [new file with mode: 0644]
src/test/java/org/hedgecode/snooker/request/EventMatchesRequesterTest.java [new file with mode: 0644]
src/test/java/org/hedgecode/snooker/request/EventPlayersRequesterTest.java [new file with mode: 0644]
src/test/java/org/hedgecode/snooker/request/EventRequesterTest.java [new file with mode: 0644]
src/test/java/org/hedgecode/snooker/request/EventRoundsRequesterTest.java [new file with mode: 0644]
src/test/java/org/hedgecode/snooker/request/EventSeedingRequesterTest.java [new file with mode: 0644]
src/test/java/org/hedgecode/snooker/request/MatchRequesterTest.java [new file with mode: 0644]
src/test/java/org/hedgecode/snooker/request/OngoingMatchesRequesterTest.java [new file with mode: 0644]
src/test/java/org/hedgecode/snooker/request/PlayerMatchesRequesterTest.java [new file with mode: 0644]
src/test/java/org/hedgecode/snooker/request/PlayerRequesterTest.java [new file with mode: 0644]
src/test/java/org/hedgecode/snooker/request/RankingRequesterTest.java [new file with mode: 0644]
src/test/java/org/hedgecode/snooker/request/SeasonEventsRequesterTest.java [new file with mode: 0644]
src/test/java/org/hedgecode/snooker/request/SeasonPlayersRequesterTest.java [new file with mode: 0644]

diff --git a/src/test/java/org/hedgecode/snooker/request/AbstractRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/AbstractRequesterTest.java
new file mode 100644 (file)
index 0000000..3867367
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * 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;
+    }
+
+}
diff --git a/src/test/java/org/hedgecode/snooker/request/EventMatchesRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/EventMatchesRequesterTest.java
new file mode 100644 (file)
index 0000000..11f7470
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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);
+    }
+
+}
diff --git a/src/test/java/org/hedgecode/snooker/request/EventPlayersRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/EventPlayersRequesterTest.java
new file mode 100644 (file)
index 0000000..11c725e
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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);
+    }
+
+}
diff --git a/src/test/java/org/hedgecode/snooker/request/EventRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/EventRequesterTest.java
new file mode 100644 (file)
index 0000000..79b8b7b
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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);
+    }
+
+}
diff --git a/src/test/java/org/hedgecode/snooker/request/EventRoundsRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/EventRoundsRequesterTest.java
new file mode 100644 (file)
index 0000000..ba9748e
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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);
+    }
+
+}
diff --git a/src/test/java/org/hedgecode/snooker/request/EventSeedingRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/EventSeedingRequesterTest.java
new file mode 100644 (file)
index 0000000..246a67d
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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);
+    }
+
+}
diff --git a/src/test/java/org/hedgecode/snooker/request/MatchRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/MatchRequesterTest.java
new file mode 100644 (file)
index 0000000..aad07f5
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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);
+    }
+
+}
diff --git a/src/test/java/org/hedgecode/snooker/request/OngoingMatchesRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/OngoingMatchesRequesterTest.java
new file mode 100644 (file)
index 0000000..a5a870d
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * 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);
+    }
+
+}
diff --git a/src/test/java/org/hedgecode/snooker/request/PlayerMatchesRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/PlayerMatchesRequesterTest.java
new file mode 100644 (file)
index 0000000..70d0b7c
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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);
+    }
+
+}
diff --git a/src/test/java/org/hedgecode/snooker/request/PlayerRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/PlayerRequesterTest.java
new file mode 100644 (file)
index 0000000..4091972
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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);
+    }
+
+}
diff --git a/src/test/java/org/hedgecode/snooker/request/RankingRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/RankingRequesterTest.java
new file mode 100644 (file)
index 0000000..088e83c
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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);
+    }
+
+}
diff --git a/src/test/java/org/hedgecode/snooker/request/SeasonEventsRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/SeasonEventsRequesterTest.java
new file mode 100644 (file)
index 0000000..989bd7a
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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);
+    }
+
+}
diff --git a/src/test/java/org/hedgecode/snooker/request/SeasonPlayersRequesterTest.java b/src/test/java/org/hedgecode/snooker/request/SeasonPlayersRequesterTest.java
new file mode 100644 (file)
index 0000000..edf663c
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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
+        );
+    }
+
+}