Skip to content

Commit c030a60

Browse files
committed
Fix While loop logic for manteca status
1 parent a1ed0d0 commit c030a60

File tree

1 file changed

+42
-30
lines changed

1 file changed

+42
-30
lines changed

src/test/java/org/openapitools/client/api/RecordingsApiTest.java

Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,14 @@ public void testCallRecordingAndTranscription() throws Exception {
174174
assertThat(updateCallResponse.getStatusCode(), is(200));
175175

176176
// Make sure its been recorded by fetching the status from Manteca
177-
Boolean testRecordingStatus = false;
178-
for (int i = 0; i < MAX_RETRIES; i++) {
179-
while (testRecordingStatus != true) {
180-
TimeUnit.SECONDS.sleep(TEST_SLEEP);
181-
testRecordingStatus = getTestStatus(testId).callRecorded;
182-
}
177+
int x = 0;
178+
Boolean recordingStatus = false;
179+
while (recordingStatus != true && x < MAX_RETRIES) {
180+
TimeUnit.SECONDS.sleep(TEST_SLEEP);
181+
recordingStatus = getTestStatus(testId).callRecorded;
182+
x++;
183183
}
184-
assertThat(testRecordingStatus, is(true));
184+
assertThat(recordingStatus, is(true));
185185

186186
// Validate the recording metadata endpoint
187187
ApiResponse<List<CallRecordingMetadata>> listRecordingMetadataResponse = recordingsApi
@@ -198,14 +198,14 @@ public void testCallRecordingAndTranscription() throws Exception {
198198
assertThat(requestTranscriptionResponse.getStatusCode(), is(204));
199199

200200
// Make sure its been transcribed by fetching status from manteca
201-
Boolean testTranscriptionStatus = false;
202-
for (int i = 0; i < MAX_RETRIES; i++) {
203-
while (testTranscriptionStatus != true) {
204-
TimeUnit.SECONDS.sleep(TEST_SLEEP);
205-
testTranscriptionStatus = getTestStatus(testId).callTranscribed;
206-
}
201+
int i = 0;
202+
Boolean transcriptionStatus = false;
203+
while (transcriptionStatus != true && i < MAX_RETRIES) {
204+
TimeUnit.SECONDS.sleep(TEST_SLEEP);
205+
transcriptionStatus = getTestStatus(testId).callTranscribed;
206+
i++;
207207
}
208-
assertThat(testTranscriptionStatus, is(true));
208+
assertThat(transcriptionStatus, is(true));
209209

210210
// Validate the transcription metadata endpoint
211211
ApiResponse<TranscriptionList> listTranscriptionsResponse = recordingsApi
@@ -234,7 +234,8 @@ public void testGetAccountRecordings() throws ApiException {
234234
Basic.setPassword(BW_PASSWORD);
235235

236236
ApiResponse<List<CallRecordingMetadata>> response = recordingsApi
237-
.listAccountCallRecordingsWithHttpInfo(BW_ACCOUNT_ID, null, null, null, null);
237+
.listAccountCallRecordingsWithHttpInfo(BW_ACCOUNT_ID, null, null, null,
238+
null);
238239

239240
assertThat(response.getStatusCode(), is(200));
240241
}
@@ -245,7 +246,8 @@ public void testGetAccountRecordingsUnauthorized() {
245246
Basic.setPassword("bad_password");
246247

247248
ApiException exception = Assertions.assertThrows(ApiException.class,
248-
() -> recordingsApi.listAccountCallRecordingsWithHttpInfo(BW_ACCOUNT_ID, null, null, null, null));
249+
() -> recordingsApi.listAccountCallRecordingsWithHttpInfo(BW_ACCOUNT_ID,
250+
null, null, null, null));
249251

250252
assertThat(exception.getCode(), is(401));
251253
}
@@ -256,20 +258,22 @@ public void testGetAccountRecordingsForbidden() {
256258
Basic.setPassword(FORBIDDEN_PASSWORD);
257259

258260
ApiException exception = Assertions.assertThrows(ApiException.class,
259-
() -> recordingsApi.listAccountCallRecordingsWithHttpInfo(BW_ACCOUNT_ID, null, null, null, null));
261+
() -> recordingsApi.listAccountCallRecordingsWithHttpInfo(BW_ACCOUNT_ID,
262+
null, null, null, null));
260263

261264
assertThat(exception.getCode(), is(403));
262265
}
263266

264267
@Test
265268
public void testRecordingNotFound() {
266-
Basic.setUsername(BW_USERNAME);
267-
Basic.setPassword(BW_PASSWORD);
269+
Basic.setUsername(BW_USERNAME);
270+
Basic.setPassword(BW_PASSWORD);
268271

269-
ApiException exception = Assertions.assertThrows(ApiException.class,
270-
() -> recordingsApi.getCallRecording(BW_ACCOUNT_ID, "not a call", "not a recording"));
272+
ApiException exception = Assertions.assertThrows(ApiException.class,
273+
() -> recordingsApi.getCallRecording(BW_ACCOUNT_ID, "not a call", "not a
274+
recording"));
271275

272-
assertThat(exception.getCode(), is(404));
276+
assertThat(exception.getCode(), is(404));
273277
}
274278

275279
@Test
@@ -322,7 +326,8 @@ public void testUnauthorizedDownloadRecording() {
322326
Basic.setPassword("bad_password");
323327

324328
ApiException exception = Assertions.assertThrows(ApiException.class,
325-
() -> recordingsApi.downloadCallRecording(BW_ACCOUNT_ID, callId, recordingId));
329+
() -> recordingsApi.downloadCallRecording(BW_ACCOUNT_ID, callId,
330+
recordingId));
326331

327332
assertThat(exception.getCode(), is(401));
328333
}
@@ -333,7 +338,8 @@ public void testForbiddenDownloadRecording() {
333338
Basic.setPassword(FORBIDDEN_PASSWORD);
334339

335340
ApiException exception = Assertions.assertThrows(ApiException.class,
336-
() -> recordingsApi.downloadCallRecording(BW_ACCOUNT_ID, callId, recordingId));
341+
() -> recordingsApi.downloadCallRecording(BW_ACCOUNT_ID, callId,
342+
recordingId));
337343

338344
assertThat(exception.getCode(), is(403));
339345
}
@@ -366,7 +372,8 @@ public void testUnauthorizedGetTranscription() {
366372
Basic.setPassword("bad_password");
367373

368374
ApiException exception = Assertions.assertThrows(ApiException.class,
369-
() -> recordingsApi.deleteCallTranscription(BW_ACCOUNT_ID, callId, recordingId));
375+
() -> recordingsApi.deleteCallTranscription(BW_ACCOUNT_ID, callId,
376+
recordingId));
370377

371378
assertThat(exception.getCode(), is(401));
372379
}
@@ -377,7 +384,8 @@ public void testForbiddenGetTranscription() {
377384
Basic.setPassword(FORBIDDEN_PASSWORD);
378385

379386
ApiException exception = Assertions.assertThrows(ApiException.class,
380-
() -> recordingsApi.deleteCallTranscription(BW_ACCOUNT_ID, callId, recordingId));
387+
() -> recordingsApi.deleteCallTranscription(BW_ACCOUNT_ID, callId,
388+
recordingId));
381389

382390
assertThat(exception.getCode(), is(403));
383391
}
@@ -388,7 +396,8 @@ public void testUnauthorizedCreateTranscriptionRequest() {
388396
Basic.setPassword("bad_password");
389397

390398
ApiException exception = Assertions.assertThrows(ApiException.class,
391-
() -> recordingsApi.transcribeCallRecording(BW_ACCOUNT_ID, callId, recordingId, transcribeRecording));
399+
() -> recordingsApi.transcribeCallRecording(BW_ACCOUNT_ID, callId,
400+
recordingId, transcribeRecording));
392401

393402
assertThat(exception.getCode(), is(401));
394403
}
@@ -399,7 +408,8 @@ public void testForbiddenCreateTranscriptionRequest() {
399408
Basic.setPassword(FORBIDDEN_PASSWORD);
400409

401410
ApiException exception = Assertions.assertThrows(ApiException.class,
402-
() -> recordingsApi.transcribeCallRecording(BW_ACCOUNT_ID, callId, recordingId, transcribeRecording));
411+
() -> recordingsApi.transcribeCallRecording(BW_ACCOUNT_ID, callId,
412+
recordingId, transcribeRecording));
403413

404414
System.out.println(exception.getCode());
405415
assertThat(exception.getCode(), is(403));
@@ -411,7 +421,8 @@ public void testUnauthorizedDeleteTranscription() throws ApiException {
411421
Basic.setPassword("bad_password");
412422

413423
ApiException exception = Assertions.assertThrows(ApiException.class,
414-
() -> recordingsApi.deleteCallTranscription(BW_ACCOUNT_ID, callId, recordingId));
424+
() -> recordingsApi.deleteCallTranscription(BW_ACCOUNT_ID, callId,
425+
recordingId));
415426

416427
assertThat(exception.getCode(), is(401));
417428
}
@@ -422,7 +433,8 @@ public void testForbiddenDeleteTranscription() {
422433
Basic.setPassword(FORBIDDEN_PASSWORD);
423434

424435
ApiException exception = Assertions.assertThrows(ApiException.class,
425-
() -> recordingsApi.deleteCallTranscription(BW_ACCOUNT_ID, callId, recordingId));
436+
() -> recordingsApi.deleteCallTranscription(BW_ACCOUNT_ID, callId,
437+
recordingId));
426438

427439
assertThat(exception.getCode(), is(403));
428440
}

0 commit comments

Comments
 (0)