From a0efef60788f9bf4900d860a39f7e96ac648f18a Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Tue, 10 Sep 2024 02:33:38 +0530 Subject: [PATCH] GRAD2-2822: School Report Regeneration Process - Backend Changes --- .../api/batchgraduation/util/RestUtilsTest.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java index d3ed2f17..9478c727 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/batchgraduation/util/RestUtilsTest.java @@ -901,16 +901,25 @@ public void testcreateAndStoreSchoolReports_0() { assertNotNull(result); } @Test - public void testcreateAndStoreSchoolReports_WithParams() { + public void whenCreateAndStoreSchoolReports_WithParams_ThenReturnResult() { final String type = "TVRRUN"; - mockTokenResponseObject(); + + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.uri(String.format(constants.getCreateAndStoreSchoolReports(),type))).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); + when(this.requestBodyMock.contentType(any())).thenReturn(this.requestBodyMock); + when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(Integer.class)).thenReturn(Mono.just(0)); + when(LOGGER.isDebugEnabled()).thenReturn(true); + var result = this.restUtils.createAndStoreSchoolReports(Arrays.asList("12345"), type, new DistributionSummaryDTO()); assertNotNull(type); assertNotNull(result); } @Test(expected = Exception.class) - public void testcreateAndStoreSchoolReports_WithParams_ThenThrowException() { + public void whenCreateAndStoreSchoolReports_WithParams_ThenThrowException() { final String type = "TVRRUN"; when(this.webClient.post()).thenThrow(Exception.class);