Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Commit

Permalink
fix/Update ExternalTestStateController.java (#232)
Browse files Browse the repository at this point in the history
fixed fake behavior if fake was 0
  • Loading branch information
mschulte-tsi authored May 27, 2021
1 parent d9cd408 commit a6c704c
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ public DeferredResult<ResponseEntity<TestResult>> getTestState(
log.info("The result for registration token based on hashed Guid will be returned.");
stopWatch.stop();
fakeDelayService.updateFakeTestRequestDelay(stopWatch.getTotalTimeMillis());
deferredResult.setResult(ResponseEntity.ok(generateReturnTestResult(testResult.getTestResult(),fake,
deferredResult.setResult(ResponseEntity.ok(generateReturnTestResult(testResult.getTestResult(),
testResult.getSc())));
return deferredResult;
case TELETAN:
log.info("The result for registration token based on teleTAN will be returned.");
stopWatch.stop();
fakeDelayService.updateFakeTestRequestDelay(stopWatch.getTotalTimeMillis());
scheduledExecutor.schedule(() -> deferredResult.setResult(ResponseEntity.ok(
generateReturnTestResult(LabTestResult.POSITIVE.getTestResult(), fake,
generateReturnTestResult(LabTestResult.POSITIVE.getTestResult(),
appSession.get().getCreatedAt().toEpochSecond(ZoneOffset.UTC)))),
fakeDelayService.realDelayTest(), MILLISECONDS);
return deferredResult;
Expand All @@ -138,12 +138,7 @@ public DeferredResult<ResponseEntity<TestResult>> getTestState(
"Returning the test result for the registration token failed");
}

private TestResult generateReturnTestResult(Integer testResult, String fake, Long cs) {
if (fake == null) {
return new TestResult(testResult,cs, RandomStringUtils.randomAlphanumeric(RESPONSE_PADDING_LENGTH));
}
return new TestResult(testResult, LocalDateTime.now().toEpochSecond(ZoneOffset.UTC),
RandomStringUtils.randomAlphanumeric(RESPONSE_PADDING_LENGTH));
private TestResult generateReturnTestResult(Integer testResult, Long sc) {
return new TestResult(testResult,sc, RandomStringUtils.randomAlphanumeric(RESPONSE_PADDING_LENGTH));
}

}

0 comments on commit a6c704c

Please sign in to comment.