From 8948a7b474c3cb5b9569b7840835733d5cde6c84 Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Mon, 9 Sep 2024 21:26:50 +0530 Subject: [PATCH] GRAD2-2822: School Report Regeneration Process - Backend Changes --- .../RegenerateSchoolReportsPartitioner.java | 2 +- .../reader/RegenerateSchoolReportsReader.java | 2 +- .../batchgraduation/util/RestUtilsTest.java | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateSchoolReportsPartitioner.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateSchoolReportsPartitioner.java index 7dfab5ff..76d6a444 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateSchoolReportsPartitioner.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateSchoolReportsPartitioner.java @@ -67,7 +67,7 @@ public Map partition(int gridSize) { executionContext.put("readCount", 0); map.put("partition0", executionContext); - log.info("Found {} in total running on 1 partitions", finalSchoolDistricts); + log.info("Found {} in total running on 1 partitions", finalSchoolDistricts.size()); return map; } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateSchoolReportsReader.java b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateSchoolReportsReader.java index 794aa43a..05813c73 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateSchoolReportsReader.java +++ b/api/src/main/java/ca/bc/gov/educ/api/batchgraduation/reader/RegenerateSchoolReportsReader.java @@ -24,7 +24,7 @@ public List read() throws Exception { if(readCount > 0) return null; readCount++; if(log.isDebugEnabled()) { - log.info("Read schools Codes -> {} of {} schools", schools.size(), String.join(",", schools)); + log.info("Read schools Codes -> {} of {} schools", readCount, schools.size()); } return schools; } 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 21e949e5..aa34e76c 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 @@ -896,6 +896,24 @@ public void testcreateAndStoreSchoolReports_0() { assertNotNull(type); assertNotNull(result); } + @Test + public void testcreateAndStoreSchoolReports_WithParams() { + final String type = "TVRRUN"; + + 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)); + + mockTokenResponseObject(); + + var result = this.restUtils.createAndStoreSchoolReports(Arrays.asList("12345"), type, new DistributionSummaryDTO()); + assertNotNull(type); + assertNotNull(result); + } @Test public void testRunGradAlgorithm() {