aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--example/src/main/java/com/markozajc/akiwrapper/example/AkinatorExample.java43
-rw-r--r--pom.xml29
-rw-r--r--src/main/java/com/markozajc/akiwrapper/AkiwrapperBuilder.java50
-rw-r--r--src/main/java/com/markozajc/akiwrapper/core/Route.java96
-rw-r--r--src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ApiKey.java25
-rw-r--r--src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/GuessImpl.java25
-rw-r--r--src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ImmutableAkiwrapperMetadata.java63
-rw-r--r--src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/QuestionImpl.java27
-rw-r--r--src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ServerImpl.java24
-rw-r--r--src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/StatusImpl.java16
-rw-r--r--src/main/java/com/markozajc/akiwrapper/core/entities/impl/mutable/MutableAkiwrapperMetadata.java72
-rw-r--r--src/main/java/com/markozajc/akiwrapper/core/exceptions/MissingQuestionException.java3
-rw-r--r--src/main/java/com/markozajc/akiwrapper/core/exceptions/ServerNotFoundException.java3
-rw-r--r--src/main/java/com/markozajc/akiwrapper/core/impl/AkiwrapperImpl.java31
-rw-r--r--src/test/java/com/markozajc/akiwrapper/IntegrationTest.java9
-rw-r--r--versions-ruleset.xml16
16 files changed, 106 insertions, 426 deletions
diff --git a/example/src/main/java/com/markozajc/akiwrapper/example/AkinatorExample.java b/example/src/main/java/com/markozajc/akiwrapper/example/AkinatorExample.java
index 5715aa5..be63603 100644
--- a/example/src/main/java/com/markozajc/akiwrapper/example/AkinatorExample.java
+++ b/example/src/main/java/com/markozajc/akiwrapper/example/AkinatorExample.java
@@ -80,9 +80,9 @@ public class AkinatorExample {
80 Akiwrapper aw; 80 Akiwrapper aw;
81 try { 81 try {
82 aw = new AkiwrapperBuilder().setFilterProfanity(filterProfanity) 82 aw = new AkiwrapperBuilder().setFilterProfanity(filterProfanity)
83 .setLanguage(language) 83 .setLanguage(language)
84 .setGuessType(guessType) 84 .setGuessType(guessType)
85 .build(); 85 .build();
86 } catch (ServerNotFoundException e) { 86 } catch (ServerNotFoundException e) {
87 System.err.println("Invalid combination of language and guess type. Try a different guess type."); 87 System.err.println("Invalid combination of language and guess type. Try a different guess type.");
88 return; 88 return;
@@ -107,8 +107,8 @@ public class AkinatorExample {
107 // Displays the question. 107 // Displays the question.
108 108
109 if (question.getStep() == 0) 109 if (question.getStep() == 0)
110 System.out.println( 110 System.out
111 "\nAnswer with Y (yes), N (no), DK (don't know), P (probably) or PN (probably not) or go back in time with B (back)."); 111 .println("\nAnswer with Y (yes), N (no), DK (don't know), P (probably) or PN (probably not) or go back in time with B (back).");
112 // Displays the tip (only for the first time). 112 // Displays the tip (only for the first time).
113 113
114 answerQuestion(sc, aw); 114 answerQuestion(sc, aw);
@@ -141,7 +141,7 @@ public class AkinatorExample {
141 System.exit(0); 141 System.exit(0);
142 } 142 }
143 143
144 declined.add(Long.valueOf(guess.getIdLong())); 144 declined.add(guess.getIdLong());
145 // Registers this guess as rejected. 145 // Registers this guess as rejected.
146 } 146 }
147 147
@@ -177,16 +177,15 @@ public class AkinatorExample {
177 ApiKey.accquireApiKey(); 177 ApiKey.accquireApiKey();
178 178
179 } else if (answer.equals("debug")) { 179 } else if (answer.equals("debug")) {
180 System.out.println("Debug information:\n\tCurrent API server: " 180 System.out.println("Debug information:\n\tCurrent API server: " + aw.getServer().getUrl() +
181 + aw.getServer().getUrl() 181 "\n\tCurrent guess count: " +
182 + "\n\tCurrent guess count: " 182 aw.getGuesses().size());
183 + aw.getGuesses().size());
184 continue; 183 continue;
185 // Displays some debug information. 184 // Displays some debug information.
186 185
187 } else { 186 } else {
188 System.out.println( 187 System.out
189 "Please answer with either [Y]ES, [N]O, [D|ONT |K]NOW, [P]ROBABLY or [P|ROBABLY |N]OT or go back one step with [B]ACK."); 188 .println("Please answer with either [Y]ES, [N]O, [D|ONT |K]NOW, [P]ROBABLY or [P|ROBABLY |N]OT or go back one step with [B]ACK.");
190 continue; 189 continue;
191 } 190 }
192 191
@@ -224,8 +223,8 @@ public class AkinatorExample {
224 EnumSet<Language> languages = EnumSet.allOf(Language.class); 223 EnumSet<Language> languages = EnumSet.allOf(Language.class);
225 // Fetches all available languages. 224 // Fetches all available languages.
226 225
227 String unsupportedLanguageMessage = "Sorry, that language isn't supported. Rather try with:" 226 String unsupportedLanguageMessage = "Sorry, that language isn't supported. Rather try with:" +
228 + languages.stream().map(Enum::toString).collect(Collectors.joining("\n-", "\n-", "")); 227 languages.stream().map(Enum::toString).collect(Collectors.joining("\n-", "\n-", ""));
229 // Does some Java 8 magic to pre-prepare the error message. 228 // Does some Java 8 magic to pre-prepare the error message.
230 229
231 System.out.println("What's your language? (English)"); 230 System.out.println("What's your language? (English)");
@@ -238,9 +237,9 @@ public class AkinatorExample {
238 } 237 }
239 238
240 Language matching = languages.stream() 239 Language matching = languages.stream()
241 .filter(l -> l.toString().toLowerCase().equals(selectedLanguage)) 240 .filter(l -> l.toString().toLowerCase().equals(selectedLanguage))
242 .findAny() 241 .findAny()
243 .orElse(null); 242 .orElse(null);
244 243
245 if (matching == null) { 244 if (matching == null) {
246 System.out.println(unsupportedLanguageMessage); 245 System.out.println(unsupportedLanguageMessage);
@@ -258,8 +257,8 @@ public class AkinatorExample {
258 EnumSet<GuessType> guessTypes = EnumSet.allOf(GuessType.class); 257 EnumSet<GuessType> guessTypes = EnumSet.allOf(GuessType.class);
259 // Fetches all available guess types. 258 // Fetches all available guess types.
260 259
261 String unsupportedGuessTypeMessage = "Sorry, that guess type isn't supported. Rather try with:" 260 String unsupportedGuessTypeMessage = "Sorry, that guess type isn't supported. Rather try with:" +
262 + guessTypes.stream().map(Enum::toString).collect(Collectors.joining("\n-", "\n-", "")); 261 guessTypes.stream().map(Enum::toString).collect(Collectors.joining("\n-", "\n-", ""));
263 // Does some Java 8 magic to pre-prepare the error message. 262 // Does some Java 8 magic to pre-prepare the error message.
264 263
265 System.out.println("What will you be guessing? (character)"); 264 System.out.println("What will you be guessing? (character)");
@@ -272,9 +271,9 @@ public class AkinatorExample {
272 } 271 }
273 272
274 GuessType matching = guessTypes.stream() 273 GuessType matching = guessTypes.stream()
275 .filter(l -> l.toString().toLowerCase().equals(selectedGuessType)) 274 .filter(l -> l.toString().toLowerCase().equals(selectedGuessType))
276 .findAny() 275 .findAny()
277 .orElse(null); 276 .orElse(null);
278 277
279 if (matching == null) { 278 if (matching == null) {
280 System.out.println(unsupportedGuessTypeMessage); 279 System.out.println(unsupportedGuessTypeMessage);
diff --git a/pom.xml b/pom.xml
index 91f82d4..bea9637 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
5 5
6 <groupId>com.github.markozajc</groupId> 6 <groupId>com.github.markozajc</groupId>
7 <artifactId>akiwrapper</artifactId> 7 <artifactId>akiwrapper</artifactId>
8 <version>1.5.1</version> 8 <version>1.5.1.1</version>
9 9
10 <name>Akiwrapper</name> 10 <name>Akiwrapper</name>
11 <description>A Java API wrapper for Akinator</description> 11 <description>A Java API wrapper for Akinator</description>
@@ -43,6 +43,8 @@
43 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 43 <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
44 <junit.version>5.7.1</junit.version> 44 <junit.version>5.7.1</junit.version>
45 <slf4j.version>1.7.30</slf4j.version> 45 <slf4j.version>1.7.30</slf4j.version>
46 <maven.compiler.source>11</maven.compiler.source>
47 <maven.compiler.target>11</maven.compiler.target>
46 </properties> 48 </properties>
47 49
48 <dependencies> 50 <dependencies>
@@ -57,7 +59,7 @@
57 <dependency> 59 <dependency>
58 <groupId>org.json</groupId> 60 <groupId>org.json</groupId>
59 <artifactId>json</artifactId> 61 <artifactId>json</artifactId>
60 <version>20201115</version> 62 <version>20210307</version>
61 </dependency> 63 </dependency>
62 64
63 <!-- Unit tests --> 65 <!-- Unit tests -->
@@ -87,13 +89,6 @@
87 <version>3.11.11</version> 89 <version>3.11.11</version>
88 </dependency> 90 </dependency>
89 91
90 <!-- Cache -->
91 <dependency>
92 <groupId>com.google.guava</groupId>
93 <artifactId>guava</artifactId>
94 <version>30.1-jre</version>
95 </dependency>
96
97 <!-- Logging --> 92 <!-- Logging -->
98 <dependency> 93 <dependency>
99 <groupId>org.slf4j</groupId> 94 <groupId>org.slf4j</groupId>
@@ -111,7 +106,7 @@
111 <dependency> 106 <dependency>
112 <groupId>com.github.spotbugs</groupId> 107 <groupId>com.github.spotbugs</groupId>
113 <artifactId>spotbugs-annotations</artifactId> 108 <artifactId>spotbugs-annotations</artifactId>
114 <version>4.2.1</version> 109 <version>4.2.2</version>
115 </dependency> 110 </dependency>
116 111
117 <dependency> 112 <dependency>
@@ -125,15 +120,6 @@
125 <build> 120 <build>
126 <plugins> 121 <plugins>
127 122
128 <!-- Compiler -->
129 <plugin>
130 <artifactId>maven-compiler-plugin</artifactId>
131 <version>3.8.1</version>
132 <configuration>
133 <release>11</release>
134 </configuration>
135 </plugin>
136
137 <!-- Javadoc --> 123 <!-- Javadoc -->
138 <plugin> 124 <plugin>
139 <artifactId>maven-javadoc-plugin</artifactId> 125 <artifactId>maven-javadoc-plugin</artifactId>
@@ -169,7 +155,10 @@
169 <plugin> 155 <plugin>
170 <groupId>org.codehaus.mojo</groupId> 156 <groupId>org.codehaus.mojo</groupId>
171 <artifactId>versions-maven-plugin</artifactId> 157 <artifactId>versions-maven-plugin</artifactId>
172 <version>2.7</version> 158 <version>2.8.1</version>
159 <configuration>
160 <rulesUri>file://${project.basedir}/versions-ruleset.xml</rulesUri>
161 </configuration>
173 </plugin> 162 </plugin>
174 163
175 </plugins> 164 </plugins>
diff --git a/src/main/java/com/markozajc/akiwrapper/AkiwrapperBuilder.java b/src/main/java/com/markozajc/akiwrapper/AkiwrapperBuilder.java
index 170cc35..ad429a2 100644
--- a/src/main/java/com/markozajc/akiwrapper/AkiwrapperBuilder.java
+++ b/src/main/java/com/markozajc/akiwrapper/AkiwrapperBuilder.java
@@ -31,6 +31,21 @@ public class AkiwrapperBuilder extends MutableAkiwrapperMetadata {
31 AkiwrapperMetadata.DEFAULT_GUESS_TYPE); 31 AkiwrapperMetadata.DEFAULT_GUESS_TYPE);
32 } 32 }
33 33
34 /**
35 * Sets the {@link Server} or (recommended) a {@link ServerList}. It is not
36 * recommended to set the {@link Server} manually (unless for debugging purposes or
37 * as some kind of workaround where Akiwrapper's server finder fails) as Akiwrapper
38 * already does its best to find the most suitable one. <br>
39 * <b>Caution!</b> Setting the server to a non-null value overwrites the
40 * {@link Language} and the {@link GuessType} with the given {@link Server}'s values.
41 *
42 * @param server
43 *
44 * @return current instance, used for chaining
45 *
46 * @see #getServer()
47 * @see Servers#findServers(Language, GuessType)
48 */
34 @Override 49 @Override
35 public AkiwrapperBuilder setServer(Server server) { 50 public AkiwrapperBuilder setServer(Server server) {
36 super.setServer(server); 51 super.setServer(server);
@@ -38,6 +53,15 @@ public class AkiwrapperBuilder extends MutableAkiwrapperMetadata {
38 return this; 53 return this;
39 } 54 }
40 55
56 /**
57 * Sets the "filter profanity" mode.
58 *
59 * @param filterProfanity
60 *
61 * @return current instance, used for chaining
62 *
63 * @see #doesFilterProfanity()
64 */
41 @Override 65 @Override
42 public AkiwrapperBuilder setFilterProfanity(boolean filterProfanity) { 66 public AkiwrapperBuilder setFilterProfanity(boolean filterProfanity) {
43 super.setFilterProfanity(filterProfanity); 67 super.setFilterProfanity(filterProfanity);
@@ -45,13 +69,35 @@ public class AkiwrapperBuilder extends MutableAkiwrapperMetadata {
45 return this; 69 return this;
46 } 70 }
47 71
72 /**
73 * Sets the {@link Language}.<br>
74 * <b>Caution!</b> Setting the {@link Language} will set the {@link Server} to
75 * {@code null} (meaning it will be automatically selected).
76 *
77 * @param language
78 *
79 * @return current instance, used for chaining
80 *
81 * @see #getLanguage()
82 */
48 @Override 83 @Override
49 public AkiwrapperBuilder setLanguage(Language localization) { 84 public AkiwrapperBuilder setLanguage(Language language) {
50 super.setLanguage(localization); 85 super.setLanguage(language);
51 86
52 return this; 87 return this;
53 } 88 }
54 89
90 /**
91 * Sets the {@link GuessType}.<br>
92 * <b>Caution!</b> Setting the {@link Language} will set the {@link Server} to
93 * {@code null} (meaning it will be automatically selected).
94 *
95 * @param guessType
96 *
97 * @return current instance, used for chaining
98 *
99 * @see #getLanguage()
100 */
55 @Override 101 @Override
56 public AkiwrapperBuilder setGuessType(GuessType guessType) { 102 public AkiwrapperBuilder setGuessType(GuessType guessType) {
57 super.setGuessType(guessType); 103 super.setGuessType(guessType);
diff --git a/src/main/java/com/markozajc/akiwrapper/core/Route.java b/src/main/java/com/markozajc/akiwrapper/core/Route.java
index a2db855..04b0007 100644
--- a/src/main/java/com/markozajc/akiwrapper/core/Route.java
+++ b/src/main/java/com/markozajc/akiwrapper/core/Route.java
@@ -10,7 +10,6 @@ import org.json.*;
10import org.slf4j.*; 10import org.slf4j.*;
11 11
12import com.markozajc.akiwrapper.core.entities.Status; 12import com.markozajc.akiwrapper.core.entities.Status;
13import com.markozajc.akiwrapper.core.entities.Status.Level;
14import com.markozajc.akiwrapper.core.entities.impl.immutable.*; 13import com.markozajc.akiwrapper.core.entities.impl.immutable.*;
15import com.markozajc.akiwrapper.core.exceptions.*; 14import com.markozajc.akiwrapper.core.exceptions.*;
16import com.markozajc.akiwrapper.core.impl.AkiwrapperImpl.Token; 15import com.markozajc.akiwrapper.core.impl.AkiwrapperImpl.Token;
@@ -18,17 +17,8 @@ import com.markozajc.akiwrapper.core.impl.AkiwrapperImpl.Token;
18import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 17import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
19import kong.unirest.*; 18import kong.unirest.*;
20 19
21/**
22 * A class defining various API endpoints. It is capable of building such
23 * {@link Route}s into {@link Request}s, which can then easily be executed and read.
24 *
25 * @author Marko Zajc
26 */
27public final class Route { 20public final class Route {
28 21
29 /**
30 * A public {@link UnirestInstance} with all required default headers set.
31 */
32 public static final UnirestInstance UNIREST; 22 public static final UnirestInstance UNIREST;
33 23
34 static { 24 static {
@@ -54,9 +44,6 @@ public final class Route {
54 // probably doesn't even store cookies right. 44 // probably doesn't even store cookies right.
55 } 45 }
56 46
57 /**
58 * The base Akinator URL, used for scraping and some API calls.
59 */
60 public static final String BASE_AKINATOR_URL = "https://en.akinator.com"; 47 public static final String BASE_AKINATOR_URL = "https://en.akinator.com";
61 private static final String SERVER_DOWN_STATUS_MESSAGE = "server down"; 48 private static final String SERVER_DOWN_STATUS_MESSAGE = "server down";
62 private static final Pattern FILTER_ARGUMENT_PATTERN = Pattern.compile("\\{FILTER\\}"); 49 private static final Pattern FILTER_ARGUMENT_PATTERN = Pattern.compile("\\{FILTER\\}");
@@ -130,18 +117,6 @@ public final class Route {
130 this.parametersQuantity = parameters; 117 this.parametersQuantity = parameters;
131 } 118 }
132 119
133 /**
134 * Tests whether a response is a successful or a failed one.
135 *
136 * @param response
137 * the response to test
138 *
139 * @throws ServerUnavailableException
140 * throws if the status is equal to {@link Level#ERROR} and the error
141 * message hints that the server is down
142 * @throws StatusException
143 * thrown if the status is equal to {@link Level#ERROR}
144 */
145 public static void testResponse(@Nonnull JSONObject response) { 120 public static void testResponse(@Nonnull JSONObject response) {
146 Status completion = new StatusImpl(response); 121 Status completion = new StatusImpl(response);
147 if (completion.getLevel() == Status.Level.ERROR) { 122 if (completion.getLevel() == Status.Level.ERROR) {
@@ -152,20 +127,6 @@ public final class Route {
152 } 127 }
153 } 128 }
154 129
155 /**
156 * Constructs a {@link Request} for a route that can later be executed and converted
157 * into a {@link JSONObject}.
158 *
159 * @param baseUrl
160 * @param filterProfanity
161 * @param token
162 * @param parameters
163 *
164 * @return a {@link Request}.
165 *
166 * @throws IllegalArgumentException
167 * if you have passed too little parameters.
168 */
169 @Nonnull 130 @Nonnull
170 public Request getRequest(@Nonnull String baseUrl, boolean filterProfanity, @Nullable Token token, 131 public Request getRequest(@Nonnull String baseUrl, boolean filterProfanity, @Nullable Token token,
171 @Nonnull String... parameters) { 132 @Nonnull String... parameters) {
@@ -207,53 +168,20 @@ public final class Route {
207 return new Request(baseUrl + formattedPath, jQueryCallback); 168 return new Request(baseUrl + formattedPath, jQueryCallback);
208 } 169 }
209 170
210 /**
211 * Constructs a {@link Request} for a route that can later be executed and converted
212 * into a {@link JSONObject}. The resulting {@link Request} does not perform any
213 * session authentication with a {@link Token}.
214 *
215 * @param baseUrl
216 * @param filterProfanity
217 * @param parameters
218 *
219 * @return a {@link Request}.
220 *
221 * @throws IllegalArgumentException
222 * if you have passed too little parameters.
223 */
224 @Nonnull 171 @Nonnull
225 public Request getRequest(@Nonnull String baseUrl, boolean filterProfanity, @Nonnull String... parameters) { 172 public Request getRequest(@Nonnull String baseUrl, boolean filterProfanity, @Nonnull String... parameters) {
226 return this.getRequest(baseUrl, filterProfanity, null, parameters); 173 return this.getRequest(baseUrl, filterProfanity, null, parameters);
227 } 174 }
228 175
229 /**
230 * Returns {@link Route}'s unformatted path.
231 *
232 * @return route's path.
233 */
234 @Nonnull 176 @Nonnull
235 public String getPath() { 177 public String getPath() {
236 return this.path; 178 return this.path;
237 } 179 }
238 180
239 /**
240 * Returns the minimal quantity of parameters that must be passed to
241 * {@link #getRequest(String, boolean, String...)} and
242 * {@link #getRequest(String, boolean, Token, String...)}. If the amount of passed
243 * parameters is lower than this number, an {@link IllegalArgumentException} is
244 * thrown.
245 *
246 * @return minimal quantity of parameters.
247 */
248 public int getParametersQuantity() { 181 public int getParametersQuantity() {
249 return this.parametersQuantity; 182 return this.parametersQuantity;
250 } 183 }
251 184
252 /**
253 * An executable request.
254 *
255 * @author Marko Zajc
256 */
257 public static class Request { 185 public static class Request {
258 186
259 private static final Logger LOG = LoggerFactory.getLogger(Route.Request.class); 187 private static final Logger LOG = LoggerFactory.getLogger(Route.Request.class);
@@ -268,35 +196,11 @@ public final class Route {
268 this.url = url; 196 this.url = url;
269 } 197 }
270 198
271 /**
272 * Requests the server and returns the route's content as a {@link JSONObject}.
273 *
274 * @return route's content
275 *
276 * @throws ServerUnavailableException
277 * if the server has gone down
278 * @throws StatusException
279 * if the server returns an error response.
280 */
281 @Nonnull 199 @Nonnull
282 public JSONObject getJSON() { 200 public JSONObject getJSON() {
283 return getJSON(defaultRunChecks); 201 return getJSON(defaultRunChecks);
284 } 202 }
285 203
286 /**
287 * Requests the server and returns the route's content as a {@link JSONObject}.
288 *
289 * @param runChecks
290 * whether to run checks for error status codes.
291 *
292 * @return route's content
293 *
294 * @throws ServerUnavailableException
295 * if the server has gone down.
296 * @throws StatusException
297 * if the server returns an error response.
298 *
299 */
300 @Nonnull 204 @Nonnull
301 public JSONObject getJSON(boolean runChecks) { 205 public JSONObject getJSON(boolean runChecks) {
302 String response = UNIREST.get(this.url).asString().getBody().replace(this.jQueryCallback, ""); 206 String response = UNIREST.get(this.url).asString().getBody().replace(this.jQueryCallback, "");
diff --git a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ApiKey.java b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ApiKey.java
index fd0b105..f9eab92 100644
--- a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ApiKey.java
+++ b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ApiKey.java
@@ -7,16 +7,7 @@ import java.util.regex.*;
7import javax.annotation.Nonnull; 7import javax.annotation.Nonnull;
8 8
9import com.markozajc.akiwrapper.core.Route; 9import com.markozajc.akiwrapper.core.Route;
10import com.markozajc.akiwrapper.core.exceptions.StatusException;
11 10
12/**
13 * A class defining the session key that has to be passed to the
14 * {@link Route#NEW_SESSION} endpoint. It is scraped from the website as it is
15 * single-use and triggers a KO if reused.
16 *
17 * @author Marko Zajc
18 *
19 */
20public class ApiKey { 11public class ApiKey {
21 12
22 private static final Pattern API_KEY_PATTERN = 13 private static final Pattern API_KEY_PATTERN =
@@ -34,11 +25,6 @@ public class ApiKey {
34 this.frontAddress = frontAddress; 25 this.frontAddress = frontAddress;
35 } 26 }
36 27
37 /**
38 * Compiles this {@link ApiKey} into querystring that can be appended to an endpoint.
39 *
40 * @return compiled querystring.
41 */
42 @SuppressWarnings("null") 28 @SuppressWarnings("null")
43 @Nonnull 29 @Nonnull
44 public String compile() { 30 public String compile() {
@@ -49,17 +35,6 @@ public class ApiKey {
49 } 35 }
50 } 36 }
51 37
52 /**
53 * Finds and scrapes the API key from Akinator's website and constructs an
54 * {@link ApiKey} instance from it. <br>
55 * <b>Caution!</b>Each {@link ApiKey} is single-use! Reusing it will trigger a
56 * {@link StatusException} from the API server.
57 *
58 * @return an {@link ApiKey}.
59 *
60 * @throws IllegalStateException
61 * if the API key can't be scraped
62 */
63 @SuppressWarnings("null") 38 @SuppressWarnings("null")
64 public static ApiKey accquireApiKey() { 39 public static ApiKey accquireApiKey() {
65 Matcher matcher = 40 Matcher matcher =
diff --git a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/GuessImpl.java b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/GuessImpl.java
index 9acbe19..9918f47 100644
--- a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/GuessImpl.java
+++ b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/GuessImpl.java
@@ -4,17 +4,11 @@ import java.net.*;
4 4
5import javax.annotation.*; 5import javax.annotation.*;
6 6
7import org.json.*; 7import org.json.JSONObject;
8 8
9import com.markozajc.akiwrapper.core.Route;
10import com.markozajc.akiwrapper.core.entities.Guess; 9import com.markozajc.akiwrapper.core.entities.Guess;
11import com.markozajc.akiwrapper.core.utils.JSONUtils; 10import com.markozajc.akiwrapper.core.utils.JSONUtils;
12 11
13/**
14 * An implementation of {@link Guess}.
15 *
16 * @author Marko Zajc
17 */
18public class GuessImpl implements Guess { 12public class GuessImpl implements Guess {
19 13
20 @Nonnull 14 @Nonnull
@@ -28,15 +22,6 @@ public class GuessImpl implements Guess {
28 @Nonnegative 22 @Nonnegative
29 private final double probability; 23 private final double probability;
30 24
31 /**
32 * Creates a new {@link GuessImpl} instance from raw parameters.
33 *
34 * @param id
35 * @param name
36 * @param description
37 * @param image
38 * @param probability
39 */
40 public GuessImpl(@Nonnull String id, @Nonnull String name, @Nullable String description, @Nullable URL image, 25 public GuessImpl(@Nonnull String id, @Nonnull String name, @Nullable String description, @Nullable URL image,
41 @Nonnegative double probability) { 26 @Nonnegative double probability) {
42 this.id = id; 27 this.id = id;
@@ -46,14 +31,6 @@ public class GuessImpl implements Guess {
46 this.probability = probability; 31 this.probability = probability;
47 } 32 }
48 33
49 /**
50 * Creates a new {@link GuessImpl} instance.
51 *
52 * @param json
53 * JSON parameters to use (acquired with {@link Route#LIST} &gt;
54 * {@link JSONArray} elements &gt; {@link JSONObject} (an index) &gt;
55 * {@link JSONObject} element)
56 */
57 @SuppressWarnings("null") 34 @SuppressWarnings("null")
58 public GuessImpl(@Nonnull JSONObject json) { 35 public GuessImpl(@Nonnull JSONObject json) {
59 this(json.getString("id"), json.getString("name"), getDescription(json), getImage(json), 36 this(json.getString("id"), json.getString("name"), getDescription(json), getImage(json),
diff --git a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ImmutableAkiwrapperMetadata.java b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ImmutableAkiwrapperMetadata.java
deleted file mode 100644
index d7e813f..0000000
--- a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ImmutableAkiwrapperMetadata.java
+++ /dev/null
@@ -1,63 +0,0 @@
1package com.markozajc.akiwrapper.core.entities.impl.immutable;
2
3import javax.annotation.*;
4
5import com.markozajc.akiwrapper.core.entities.*;
6import com.markozajc.akiwrapper.core.entities.Server.*;
7
8/**
9 * An immutable implementation of {@link AkiwrapperMetadata}.
10 *
11 * @author Marko Zajc
12 */
13public abstract class ImmutableAkiwrapperMetadata extends AkiwrapperMetadata {
14
15 @Nullable
16 protected final Server server;
17 protected final boolean filterProfanity;
18 @Nonnull
19 protected final Language localization;
20 @Nonnull
21 protected final GuessType guessType;
22
23 /**
24 * Creates a new {@link ImmutableAkiwrapperMetadata} instance.
25 *
26 * @param server
27 * API server that the requests will be sent to.
28 * @param filterProfanity
29 * whether to filter out NSFW {@link Question}s and {@link Guess}es.
30 * @param language
31 * {@link Language} of {@link Question}s.
32 * @param guessType
33 * {@link GuessType} of {@link Guess}es.
34 */
35 public ImmutableAkiwrapperMetadata(@Nullable Server server, boolean filterProfanity, @Nonnull Language language,
36 @Nonnull GuessType guessType) {
37 this.server = server;
38 this.filterProfanity = filterProfanity;
39 this.localization = language;
40 this.guessType = guessType;
41 }
42
43 @Override
44 public Server getServer() {
45 return this.server;
46 }
47
48 @Override
49 public boolean doesFilterProfanity() {
50 return this.filterProfanity;
51 }
52
53 @Override
54 public Language getLanguage() {
55 return this.localization;
56 }
57
58 @Override
59 public GuessType getGuessType() {
60 return this.guessType;
61 }
62
63}
diff --git a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/QuestionImpl.java b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/QuestionImpl.java
index 60cc203..f249ab9 100644
--- a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/QuestionImpl.java
+++ b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/QuestionImpl.java
@@ -9,11 +9,6 @@ import com.markozajc.akiwrapper.core.entities.Status.Level;
9import com.markozajc.akiwrapper.core.exceptions.MissingQuestionException; 9import com.markozajc.akiwrapper.core.exceptions.MissingQuestionException;
10import com.markozajc.akiwrapper.core.utils.JSONUtils; 10import com.markozajc.akiwrapper.core.utils.JSONUtils;
11 11
12/**
13 * An implementation of {@link Question}.
14 *
15 * @author Marko Zajc
16 */
17public class QuestionImpl implements Question { 12public class QuestionImpl implements Question {
18 13
19 @Nonnull 14 @Nonnull
@@ -27,19 +22,6 @@ public class QuestionImpl implements Question {
27 @Nonnegative 22 @Nonnegative
28 private final double progression; 23 private final double progression;
29 24
30 /**
31 * Constructs a new {@link QuestionImpl} instance from raw parameters.
32 *
33 * @param id
34 * @param question
35 * @param step
36 * @param gain
37 * @param progression
38 * @param status
39 *
40 * @throws MissingQuestionException
41 * if there are no more questions left.
42 */
43 public QuestionImpl(@Nonnull String id, @Nonnull String question, @Nonnegative int step, @Nonnegative double gain, 25 public QuestionImpl(@Nonnull String id, @Nonnull String question, @Nonnegative int step, @Nonnegative double gain,
44 @Nonnegative double progression, @Nonnull Status status) { 26 @Nonnegative double progression, @Nonnull Status status) {
45 checkMissingQuestion(status); 27 checkMissingQuestion(status);
@@ -51,15 +33,6 @@ public class QuestionImpl implements Question {
51 this.progression = progression; 33 this.progression = progression;
52 } 34 }
53 35
54 /**
55 * Constructs a new {@link QuestionImpl} instance from a {@link JSONObject}.
56 *
57 * @param json
58 * @param status
59 *
60 * @throws MissingQuestionException
61 * if there are no more questions left.
62 */
63 @SuppressWarnings("null") 36 @SuppressWarnings("null")
64 public QuestionImpl(@Nonnull JSONObject json, @Nonnull Status status) { 37 public QuestionImpl(@Nonnull JSONObject json, @Nonnull Status status) {
65 checkMissingQuestion(status); 38 checkMissingQuestion(status);
diff --git a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ServerImpl.java b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ServerImpl.java
index 35a449b..874cabc 100644
--- a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ServerImpl.java
+++ b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/ServerImpl.java
@@ -8,11 +8,6 @@ import javax.annotation.Nonnull;
8import com.jcabi.xml.XML; 8import com.jcabi.xml.XML;
9import com.markozajc.akiwrapper.core.entities.Server; 9import com.markozajc.akiwrapper.core.entities.Server;
10 10
11/**
12 * An implementation of {@link Server}.
13 *
14 * @author Marko Zajc
15 */
16public class ServerImpl implements Server { 11public class ServerImpl implements Server {
17 12
18 private static final String LANGUAGE_ID_XPATH = "LANGUAGE/LANG_ID/text()"; // NOSONAR not a URL 13 private static final String LANGUAGE_ID_XPATH = "LANGUAGE/LANG_ID/text()"; // NOSONAR not a URL
@@ -25,31 +20,12 @@ public class ServerImpl implements Server {
25 @Nonnull 20 @Nonnull
26 private final GuessType guessType; 21 private final GuessType guessType;
27 22
28 /**
29 * Constructs a new instance of {@link ServerImpl}.
30 *
31 * @param url
32 * server's URL (for example {@code https://srv3.akinator.com:9331/ws}).
33 * @param localization
34 * server's language.
35 * @param guessType
36 * server's guess type.
37 */
38 public ServerImpl(@Nonnull String url, @Nonnull Language localization, @Nonnull GuessType guessType) { 23 public ServerImpl(@Nonnull String url, @Nonnull Language localization, @Nonnull GuessType guessType) {
39 this.url = url; 24 this.url = url;
40 this.localization = localization; 25 this.localization = localization;
41 this.guessType = guessType; 26 this.guessType = guessType;
42 } 27 }
43 28
44 /**
45 * Constructs a {@link ServerImpl} from an {@code <INSTANCE>} XML node provided by
46 * the server-listing API endpoint.
47 *
48 * @param instance
49 * XML node.
50 *
51 * @return a {@link ServerImpl}.
52 */
53 @SuppressWarnings("null") 29 @SuppressWarnings("null")
54 @Nonnull 30 @Nonnull
55 public static List<ServerImpl> fromXml(@Nonnull XML instance) { 31 public static List<ServerImpl> fromXml(@Nonnull XML instance) {
diff --git a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/StatusImpl.java b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/StatusImpl.java
index 731def1..6a63292 100644
--- a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/StatusImpl.java
+++ b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/immutable/StatusImpl.java
@@ -4,14 +4,8 @@ import javax.annotation.*;
4 4
5import org.json.JSONObject; 5import org.json.JSONObject;
6 6
7import com.google.gson.JsonObject;
8import com.markozajc.akiwrapper.core.entities.Status; 7import com.markozajc.akiwrapper.core.entities.Status;
9 8
10/**
11 * An implementation of {@link Status}.
12 *
13 * @author Marko Zajc
14 */
15public class StatusImpl implements Status { 9public class StatusImpl implements Status {
16 10
17 private static final long serialVersionUID = 1; 11 private static final long serialVersionUID = 1;
@@ -24,21 +18,11 @@ public class StatusImpl implements Status {
24 @Nonnull 18 @Nonnull
25 private final Level level; 19 private final Level level;
26 20
27 /**
28 * Constructs a new {@link StatusImpl} instance from raw parameters.
29 *
30 * @param completion
31 */
32 public StatusImpl(@Nonnull String completion) { 21 public StatusImpl(@Nonnull String completion) {
33 this.level = determineLevel(completion); 22 this.level = determineLevel(completion);
34 this.reason = determineReason(completion); 23 this.reason = determineReason(completion);
35 } 24 }
36 25
37 /**
38 * Constructs a new {@link StatusImpl} instance from a {@link JsonObject}.
39 *
40 * @param json
41 */
42 @SuppressWarnings("null") 26 @SuppressWarnings("null")
43 public StatusImpl(@Nonnull JSONObject json) { 27 public StatusImpl(@Nonnull JSONObject json) {
44 this(json.getString("completion")); 28 this(json.getString("completion"));
diff --git a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/mutable/MutableAkiwrapperMetadata.java b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/mutable/MutableAkiwrapperMetadata.java
index e286616..27d5b06 100644
--- a/src/main/java/com/markozajc/akiwrapper/core/entities/impl/mutable/MutableAkiwrapperMetadata.java
+++ b/src/main/java/com/markozajc/akiwrapper/core/entities/impl/mutable/MutableAkiwrapperMetadata.java
@@ -4,14 +4,7 @@ import javax.annotation.*;
4 4
5import com.markozajc.akiwrapper.core.entities.*; 5import com.markozajc.akiwrapper.core.entities.*;
6import com.markozajc.akiwrapper.core.entities.Server.*; 6import com.markozajc.akiwrapper.core.entities.Server.*;
7import com.markozajc.akiwrapper.core.entities.impl.immutable.ImmutableAkiwrapperMetadata;
8import com.markozajc.akiwrapper.core.utils.Servers;
9 7
10/**
11 * A mutable implementation of {@link AkiwrapperMetadata}.
12 *
13 * @author Marko Zajc
14 */
15public abstract class MutableAkiwrapperMetadata extends AkiwrapperMetadata { 8public abstract class MutableAkiwrapperMetadata extends AkiwrapperMetadata {
16 9
17 @Nullable 10 @Nullable
@@ -22,20 +15,8 @@ public abstract class MutableAkiwrapperMetadata extends AkiwrapperMetadata {
22 @Nonnull 15 @Nonnull
23 protected GuessType guessType; 16 protected GuessType guessType;
24 17
25 /** 18 protected MutableAkiwrapperMetadata(@Nullable Server server, boolean filterProfanity, @Nonnull Language language,
26 * Creates a new {@link ImmutableAkiwrapperMetadata} instance. 19 @Nonnull GuessType guessType) {
27 *
28 * @param server
29 * API server that the requests will be sent to.
30 * @param filterProfanity
31 * whether to filter out NSFW {@link Question}s and {@link Guess}es.
32 * @param language
33 * {@link Language} of {@link Question}s.
34 * @param guessType
35 * {@link GuessType} of {@link Guess}es.
36 */
37 public MutableAkiwrapperMetadata(@Nullable Server server, boolean filterProfanity, @Nonnull Language language,
38 @Nonnull GuessType guessType) {
39 this.server = server; 20 this.server = server;
40 this.filterProfanity = filterProfanity; 21 this.filterProfanity = filterProfanity;
41 this.language = language; 22 this.language = language;
@@ -47,21 +28,6 @@ public abstract class MutableAkiwrapperMetadata extends AkiwrapperMetadata {
47 return this.server; 28 return this.server;
48 } 29 }
49 30
50 /**
51 * Sets the {@link Server} or (recommended) a {@link ServerList}. It is not
52 * recommended to set the {@link Server} manually (unless for debugging purposes or
53 * as some kind of workaround where Akiwrapper's server finder fails) as Akiwrapper
54 * already does its best to find the most suitable one. <br>
55 * <b>Caution!</b> Setting the server to a non-null value overwrites the
56 * {@link Language} and the {@link GuessType} with the given {@link Server}'s values.
57 *
58 * @param server
59 *
60 * @return current instance, used for chaining
61 *
62 * @see #getServer()
63 * @see Servers#findServers(Language, GuessType)
64 */
65 @Nonnull 31 @Nonnull
66 public MutableAkiwrapperMetadata setServer(@Nullable Server server) { 32 public MutableAkiwrapperMetadata setServer(@Nullable Server server) {
67 this.server = server; 33 this.server = server;
@@ -69,7 +35,6 @@ public abstract class MutableAkiwrapperMetadata extends AkiwrapperMetadata {
69 this.language = server.getLanguage(); 35 this.language = server.getLanguage();
70 this.guessType = server.getGuessType(); 36 this.guessType = server.getGuessType();
71 } 37 }
72
73 return this; 38 return this;
74 } 39 }
75 40
@@ -78,19 +43,9 @@ public abstract class MutableAkiwrapperMetadata extends AkiwrapperMetadata {
78 return this.filterProfanity; 43 return this.filterProfanity;
79 } 44 }
80 45
81 /**
82 * Sets the "filter profanity" mode.
83 *
84 * @param filterProfanity
85 *
86 * @return current instance, used for chaining
87 *
88 * @see #doesFilterProfanity()
89 */
90 @Nonnull 46 @Nonnull
91 public MutableAkiwrapperMetadata setFilterProfanity(boolean filterProfanity) { 47 public MutableAkiwrapperMetadata setFilterProfanity(boolean filterProfanity) {
92 this.filterProfanity = filterProfanity; 48 this.filterProfanity = filterProfanity;
93
94 return this; 49 return this;
95 } 50 }
96 51
@@ -99,22 +54,10 @@ public abstract class MutableAkiwrapperMetadata extends AkiwrapperMetadata {
99 return this.language; 54 return this.language;
100 } 55 }
101 56
102 /**
103 * Sets the {@link Language}.<br>
104 * <b>Caution!</b> Setting the {@link Language} will set the {@link Server} to
105 * {@code null} (meaning it will be automatically selected).
106 *
107 * @param language
108 *
109 * @return current instance, used for chaining
110 *
111 * @see #getLanguage()
112 */
113 @Nonnull 57 @Nonnull
114 public MutableAkiwrapperMetadata setLanguage(@Nonnull Language language) { 58 public MutableAkiwrapperMetadata setLanguage(@Nonnull Language language) {
115 this.language = language; 59 this.language = language;
116 this.server = null; 60 this.server = null;
117
118 return this; 61 return this;
119 } 62 }
120 63
@@ -123,17 +66,6 @@ public abstract class MutableAkiwrapperMetadata extends AkiwrapperMetadata {
123 return this.guessType; 66 return this.guessType;
124 } 67 }
125 68
126 /**
127 * Sets the {@link GuessType}.<br>
128 * <b>Caution!</b> Setting the {@link Language} will set the {@link Server} to
129 * {@code null} (meaning it will be automatically selected).
130 *
131 * @param guessType
132 *
133 * @return current instance, used for chaining
134 *
135 * @see #getLanguage()
136 */
137 @Nonnull 69 @Nonnull
138 public MutableAkiwrapperMetadata setGuessType(@Nonnull GuessType guessType) { 70 public MutableAkiwrapperMetadata setGuessType(@Nonnull GuessType guessType) {
139 this.guessType = guessType; 71 this.guessType = guessType;
diff --git a/src/main/java/com/markozajc/akiwrapper/core/exceptions/MissingQuestionException.java b/src/main/java/com/markozajc/akiwrapper/core/exceptions/MissingQuestionException.java
index 1c5725a..a03c1db 100644
--- a/src/main/java/com/markozajc/akiwrapper/core/exceptions/MissingQuestionException.java
+++ b/src/main/java/com/markozajc/akiwrapper/core/exceptions/MissingQuestionException.java
@@ -10,7 +10,6 @@ public class MissingQuestionException extends RuntimeException {
10 /** 10 /**
11 * Constructs a new {@link MissingQuestionException} instance. 11 * Constructs a new {@link MissingQuestionException} instance.
12 */ 12 */
13 public MissingQuestionException() { 13 public MissingQuestionException() {}
14 }
15 14
16} 15}
diff --git a/src/main/java/com/markozajc/akiwrapper/core/exceptions/ServerNotFoundException.java b/src/main/java/com/markozajc/akiwrapper/core/exceptions/ServerNotFoundException.java
index e5dcc41..593be6d 100644
--- a/src/main/java/com/markozajc/akiwrapper/core/exceptions/ServerNotFoundException.java
+++ b/src/main/java/com/markozajc/akiwrapper/core/exceptions/ServerNotFoundException.java
@@ -14,7 +14,6 @@ public class ServerNotFoundException extends Exception {
14 /** 14 /**
15 * Constructs a new {@link ServerNotFoundException}. 15 * Constructs a new {@link ServerNotFoundException}.
16 */ 16 */
17 public ServerNotFoundException() { 17 public ServerNotFoundException() {}
18 }
19 18
20} 19}
diff --git a/src/main/java/com/markozajc/akiwrapper/core/impl/AkiwrapperImpl.java b/src/main/java/com/markozajc/akiwrapper/core/impl/AkiwrapperImpl.java
index b84c3e0..96a810a 100644
--- a/src/main/java/com/markozajc/akiwrapper/core/impl/AkiwrapperImpl.java
+++ b/src/main/java/com/markozajc/akiwrapper/core/impl/AkiwrapperImpl.java
@@ -6,28 +6,18 @@ import javax.annotation.*;
6 6
7import org.json.*; 7import org.json.*;
8 8
9import com.markozajc.akiwrapper.*; 9import com.markozajc.akiwrapper.Akiwrapper;
10import com.markozajc.akiwrapper.core.Route; 10import com.markozajc.akiwrapper.core.Route;
11import com.markozajc.akiwrapper.core.entities.*; 11import com.markozajc.akiwrapper.core.entities.*;
12import com.markozajc.akiwrapper.core.entities.Status.Level; 12import com.markozajc.akiwrapper.core.entities.Status.Level;
13import com.markozajc.akiwrapper.core.entities.impl.immutable.*; 13import com.markozajc.akiwrapper.core.entities.impl.immutable.*;
14import com.markozajc.akiwrapper.core.exceptions.*; 14import com.markozajc.akiwrapper.core.exceptions.*;
15 15
16/**
17 * An implementation of {@link Akiwrapper}.
18 *
19 * @author Marko Zajc
20 */
21public class AkiwrapperImpl implements Akiwrapper { 16public class AkiwrapperImpl implements Akiwrapper {
22 17
23 private static final String NO_MORE_QUESTIONS_STATUS = "elem list is empty"; 18 private static final String NO_MORE_QUESTIONS_STATUS = "elem list is empty";
24 private static final String PARAMETERS_KEY = "parameters"; 19 private static final String PARAMETERS_KEY = "parameters";
25 20
26 /**
27 * A class used to define the session token.
28 *
29 * @author Marko Zajc
30 */
31 public static class Token { 21 public static class Token {
32 22
33 private static final String AUTH_QUERYSTRING = "&session=%s&signature=%s"; 23 private static final String AUTH_QUERYSTRING = "&session=%s&signature=%s";
@@ -35,12 +25,6 @@ public class AkiwrapperImpl implements Akiwrapper {
35 private final long signature; 25 private final long signature;
36 private final int session; 26 private final int session;
37 27
38 /**
39 * Creates a new {@link Token}.
40 *
41 * @param signature
42 * @param session
43 */
44 public Token(long signature, int session) { 28 public Token(long signature, int session) {
45 this.signature = signature; 29 this.signature = signature;
46 this.session = session; 30 this.session = session;
@@ -54,9 +38,6 @@ public class AkiwrapperImpl implements Akiwrapper {
54 return this.session; 38 return this.session;
55 } 39 }
56 40
57 /**
58 * @return the compiled token
59 */
60 public String compile() { 41 public String compile() {
61 return String.format(AUTH_QUERYSTRING, "" + this.getSession(), "" + this.getSignature()); 42 return String.format(AUTH_QUERYSTRING, "" + this.getSession(), "" + this.getSignature());
62 } 43 }
@@ -73,16 +54,6 @@ public class AkiwrapperImpl implements Akiwrapper {
73 @Nullable 54 @Nullable
74 private Question currentQuestion; 55 private Question currentQuestion;
75 56
76 /**
77 * Constructs a new {@link Akiwrapper} instance and creates a new API session. The
78 * first question can be retrieved with {@link #getCurrentQuestion()}.
79 *
80 * @param server
81 * {@link Server} to use. Does not work with a {@link ServerList},
82 * {@link AkiwrapperBuilder} implements that functionality.
83 * @param filterProfanity
84 * whether to tell API to filter profanity.
85 */
86 @SuppressWarnings("null") 57 @SuppressWarnings("null")
87 public AkiwrapperImpl(@Nonnull Server server, boolean filterProfanity) { 58 public AkiwrapperImpl(@Nonnull Server server, boolean filterProfanity) {
88 JSONObject question = Route.NEW_SESSION 59 JSONObject question = Route.NEW_SESSION
diff --git a/src/test/java/com/markozajc/akiwrapper/IntegrationTest.java b/src/test/java/com/markozajc/akiwrapper/IntegrationTest.java
index 39d6c32..fb01edd 100644
--- a/src/test/java/com/markozajc/akiwrapper/IntegrationTest.java
+++ b/src/test/java/com/markozajc/akiwrapper/IntegrationTest.java
@@ -18,13 +18,16 @@ import static org.junit.jupiter.api.Assertions.*;
18 18
19class IntegrationTest { 19class IntegrationTest {
20 20
21 private static final String SERVER_GUESSTYPE_NO_MATCH = "The wanted and actual guess type of the server don't match."; 21 private static final String SERVER_GUESSTYPE_NO_MATCH =
22 "The wanted and actual guess type of the server don't match.";
22 private static final String SERVER_LANGUAGE_NO_MATCH = "The wanted and actual language of the server don't match."; 23 private static final String SERVER_LANGUAGE_NO_MATCH = "The wanted and actual language of the server don't match.";
23 private static final String QUESTION_CURRENT_NO_MATCH = "Current question does not match the one just returned by the API."; 24 private static final String QUESTION_CURRENT_NO_MATCH =
25 "Current question does not match the one just returned by the API.";
24 private static final String QUESTION_WRONG_STEP = "Question was on an unexpected step."; 26 private static final String QUESTION_WRONG_STEP = "Question was on an unexpected step.";
25 private static final String QUESTION_EMPTY = "Question mustn't be empty."; 27 private static final String QUESTION_EMPTY = "Question mustn't be empty.";
26 private static final String QUESTION_NULL = "Question was null"; 28 private static final String QUESTION_NULL = "Question was null";
27 private static final String QUESTION_INITIAL_NO_MATCH = "Initial question does not match the one after an equal amount of answers and undoes."; 29 private static final String QUESTION_INITIAL_NO_MATCH =
30 "Initial question does not match the one after an equal amount of answers and undoes.";
28 31
29 @ParameterizedTest 32 @ParameterizedTest
30 @MethodSource("generateTestAkiwrapper") 33 @MethodSource("generateTestAkiwrapper")
diff --git a/versions-ruleset.xml b/versions-ruleset.xml
new file mode 100644
index 0000000..193c626
--- /dev/null
+++ b/versions-ruleset.xml
@@ -0,0 +1,16 @@
1<ruleset
2 xmlns="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 comparisonMethod="maven"
5 xsi:schemaLocation="http://mojo.codehaus.org/versions-maven-plugin/rule/2.0.0 https://mojo.codehaus.org/versions-maven-plugin/xsd/rule-2.0.0.xsd">
6 <rules>
7 <rule groupId="*">
8 <ignoreVersions>
9 <ignoreVersion type="regex">.*-alpha\d$</ignoreVersion>
10 <ignoreVersion type="regex">.*-beta\d$</ignoreVersion>
11 <ignoreVersion type="regex">.*-M\d$</ignoreVersion>
12 <ignoreVersion type="regex">.*-RC\d$</ignoreVersion>
13 </ignoreVersions>
14 </rule>
15 </rules>
16</ruleset>