Skip to content

Commit 5775d16

Browse files
authored
fix quiz tests (#186)
1 parent 621da20 commit 5775d16

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

constructorio-client/src/test/java/io/constructor/client/ConstructorIOQuizNextQuestionTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ public void QuizQuestionAsJsonShouldReturnErrorWithInvalidIndexKey() throws Exce
153153
public void QuizQuestionShouldReturnResultWithAnswersParameter() throws Exception {
154154
ConstructorIO constructor = new ConstructorIO("", quizKey, true, "quizzes.cnstrc.com");
155155
QuizRequest request = new QuizRequest(quizId);
156+
request.setQuizSessionId(quizSessionId);
156157
request.setAnswers(validAnswers);
157158
QuizQuestionResponse response = constructor.quizNextQuestion(request, null);
158159

@@ -164,6 +165,7 @@ public void QuizQuestionShouldReturnResultWithAnswersParameter() throws Exceptio
164165
public void QuizQuestionAsJsonShouldReturnResultWithAnswersParameter() throws Exception {
165166
ConstructorIO constructor = new ConstructorIO("", quizKey, true, "quizzes.cnstrc.com");
166167
QuizRequest request = new QuizRequest(quizId);
168+
request.setQuizSessionId(quizSessionId);
167169
request.setAnswers(validAnswers);
168170
String response = constructor.quizNextQuestionAsJson(request, null);
169171
JSONObject jsonObject = new JSONObject(response);
@@ -179,6 +181,7 @@ public void QuizQuestionAsJsonShouldReturnResultWithAnswersParameter() throws Ex
179181
public void QuizQuestionShouldReturnResultWithAllAnswerTypes() throws Exception {
180182
ConstructorIO constructor = new ConstructorIO("", quizKey, true, "quizzes.cnstrc.com");
181183
QuizRequest request = new QuizRequest(quizId);
184+
request.setQuizSessionId(quizSessionId);
182185
request.setAnswers(finalAnswers);
183186
QuizQuestionResponse response = constructor.quizNextQuestion(request, null);
184187

@@ -190,6 +193,7 @@ public void QuizQuestionShouldReturnResultWithAllAnswerTypes() throws Exception
190193
public void QuizQuestionAsJsonShouldReturnResultWithAllAnswerTypes() throws Exception {
191194
ConstructorIO constructor = new ConstructorIO("", quizKey, true, "quizzes.cnstrc.com");
192195
QuizRequest request = new QuizRequest(quizId);
196+
request.setQuizSessionId(quizSessionId);
193197
request.setAnswers(finalAnswers);
194198
String response = constructor.quizNextQuestionAsJson(request, null);
195199
JSONObject jsonObject = new JSONObject(response);

constructorio-client/src/test/java/io/constructor/client/ConstructorIOQuizResultsTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public void QuizResultsAsJSONShouldErrorWithoutAnswersParameter() throws Excepti
5757
public void QuizResultsShouldReturnResultWithAnswersParameter() throws Exception {
5858
ConstructorIO constructor = new ConstructorIO("", quizKey, true, "quizzes.cnstrc.com");
5959
QuizRequest request = new QuizRequest(quizId);
60+
request.setQuizSessionId(quizSessionId);
6061
request.setAnswers(validAnswers);
6162
QuizResultsResponse response = constructor.quizResults(request, null);
6263

@@ -71,6 +72,7 @@ public void QuizResultsShouldReturnResultWithAnswersParameter() throws Exception
7172
public void QuizResultsAsJsonShouldReturnResultWithAnswersParameter() throws Exception {
7273
ConstructorIO constructor = new ConstructorIO("", quizKey, true, "quizzes.cnstrc.com");
7374
QuizRequest request = new QuizRequest(quizId);
75+
request.setQuizSessionId(quizSessionId);
7476
request.setAnswers(validAnswers);
7577
String response = constructor.quizResultsAsJson(request, null);
7678
JSONObject jsonObject = new JSONObject(response);
@@ -86,6 +88,7 @@ public void QuizResultsAsJsonShouldReturnResultWithAnswersParameter() throws Exc
8688
public void QuizResultsShouldReturnResultWithVersionIdAndSessionId() throws Exception {
8789
ConstructorIO constructor = new ConstructorIO("", quizKey, true, "quizzes.cnstrc.com");
8890
QuizRequest initialRequest = new QuizRequest(quizId);
91+
initialRequest.setQuizSessionId(quizSessionId);
8992
initialRequest.setAnswers(validAnswers);
9093
QuizResultsResponse initialResponse = constructor.quizResults(initialRequest, null);
9194

@@ -126,6 +129,7 @@ public void QuizResultsShouldReturnAResultWithResultSources() throws Exception {
126129
public void QuizResultsAsJsonShouldReturnResultWithVersionIdAndSessionid() throws Exception {
127130
ConstructorIO constructor = new ConstructorIO("", quizKey, true, "quizzes.cnstrc.com");
128131
QuizRequest initialRequest = new QuizRequest(quizId);
132+
initialRequest.setQuizSessionId(quizSessionId);
129133
initialRequest.setAnswers(validAnswers);
130134
QuizResultsResponse initialResponse = constructor.quizResults(initialRequest, null);
131135

@@ -149,6 +153,7 @@ public void QuizResultsAsJsonShouldReturnResultWithVersionIdAndSessionid() throw
149153
public void QuizResultsShouldReturnResultWithAllAnswerTypes() throws Exception {
150154
ConstructorIO constructor = new ConstructorIO("", quizKey, true, "quizzes.cnstrc.com");
151155
QuizRequest request = new QuizRequest(quizId);
156+
request.setQuizSessionId(quizSessionId);
152157
request.setAnswers(finalAnswers);
153158
QuizResultsResponse response = constructor.quizResults(request, null);
154159

@@ -163,6 +168,7 @@ public void QuizResultsShouldReturnResultWithAllAnswerTypes() throws Exception {
163168
public void QuizResultsAsJsonShouldReturnResultWithAllAnswerTypes() throws Exception {
164169
ConstructorIO constructor = new ConstructorIO("", quizKey, true, "quizzes.cnstrc.com");
165170
QuizRequest request = new QuizRequest(quizId);
171+
request.setQuizSessionId(quizSessionId);
166172
request.setAnswers(finalAnswers);
167173
String response = constructor.quizResultsAsJson(request, null);
168174
JSONObject jsonObject = new JSONObject(response);
@@ -178,6 +184,7 @@ public void QuizResultsAsJsonShouldReturnResultWithAllAnswerTypes() throws Excep
178184
public void QuizResultsShouldReturnErrorWithInvalidQuizId() throws Exception {
179185
ConstructorIO constructor = new ConstructorIO("", quizKey, true, "quizzes.cnstrc.com");
180186
QuizRequest request = new QuizRequest("invalidQuiz");
187+
request.setQuizSessionId(quizSessionId);
181188
request.setAnswers(validAnswers);
182189

183190
thrown.expect(ConstructorException.class);
@@ -191,6 +198,7 @@ public void QuizResultsShouldReturnErrorWithInvalidQuizId() throws Exception {
191198
public void QuizResultsAsJsonShouldReturnErrorWithInvalidQuizId() throws Exception {
192199
ConstructorIO constructor = new ConstructorIO("", quizKey, true, "quizzes.cnstrc.com");
193200
QuizRequest request = new QuizRequest("invalidQuiz");
201+
request.setQuizSessionId(quizSessionId);
194202
request.setAnswers(validAnswers);
195203

196204
thrown.expect(ConstructorException.class);
@@ -204,6 +212,7 @@ public void QuizResultsAsJsonShouldReturnErrorWithInvalidQuizId() throws Excepti
204212
public void QuizResultsShouldReturnErrorWithInvalidIndexKey() throws Exception {
205213
ConstructorIO constructor = new ConstructorIO("", "invalidKey", true, "quizzes.cnstrc.com");
206214
QuizRequest request = new QuizRequest(quizId);
215+
request.setQuizSessionId(quizSessionId);
207216
request.setAnswers(validAnswers);
208217

209218
thrown.expect(ConstructorException.class);
@@ -218,6 +227,7 @@ public void QuizResultsShouldReturnErrorWithInvalidIndexKey() throws Exception {
218227
public void QuizResultsAsJsonShouldReturnErrorWithInvalidIndexKey() throws Exception {
219228
ConstructorIO constructor = new ConstructorIO("", "invalidKey", true, "quizzes.cnstrc.com");
220229
QuizRequest request = new QuizRequest(quizId);
230+
request.setQuizSessionId(quizSessionId);
221231
request.setAnswers(validAnswers);
222232

223233
thrown.expect(ConstructorException.class);

0 commit comments

Comments
 (0)