Skip to content

Commit

Permalink
Part 7 - Updated API responses
Browse files Browse the repository at this point in the history
  • Loading branch information
githubmamatha committed Jan 6, 2025
1 parent 007e7e1 commit 90f7ab8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,33 @@
@RestController
@RequestMapping(EducGraduationApiConstants.GRAD_BUSINESS_API_ROOT_MAPPING)
@Slf4j
@OpenAPIDefinition(info = @Info(title = "API for School Data.", description = "This Read API is for Reading school data from TRAX.", version = "2"),
@OpenAPIDefinition(info = @Info(title = "API for School and District reports.", description = "This Read API is for Reading school and district data from TRAX.", version = "2"),
security = {@SecurityRequirement(name = "OAUTH2", scopes = {"GET_GRADUATION_DATA"})})
public class SchoolAndDistrictController {
public class SchoolAndDistrictReportsController {

private final GradBusinessService gardBusinessService;


@Autowired
public SchoolAndDistrictController(GradBusinessService gardBusinessService) {
public SchoolAndDistrictReportsController(GradBusinessService gardBusinessService) {
this.gardBusinessService = gardBusinessService;
}

@GetMapping(EducGradBusinessApiConstants.SCHOOL_REPORT_PDF_MINCODE_V2)
@PreAuthorize("hasAuthority('SCOPE_GET_GRADUATION_DATA')")
@Operation(summary = "Get School Report pdf from graduation by mincode and report type", description = "Get School Report pdf from graduation by mincode and report type", tags = { "Graduation Data" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "NOT FOUND"),
@ApiResponse(responseCode = "500", description = "INTERNAL SERVER ERROR.")})
public ResponseEntity<byte[]> schoolReportByMincode(@PathVariable String mincode,@RequestParam(name = "type") String type) {
return gardBusinessService.getSchoolReportPDFByMincode(mincode, type);
}

@GetMapping(EducGradBusinessApiConstants.DISTRICT_REPORT_PDF_DISTCODE_V2)
@PreAuthorize("hasAuthority('SCOPE_GET_GRADUATION_DATA')")
@Operation(summary = "Get District Report pdf from graduation by distcode and report type", description = "Get District Report pdf from graduation by distcode and report type", tags = { "Graduation Data" })
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "NOT FOUND"),
@ApiResponse(responseCode = "500", description = "INTERNAL SERVER ERROR.")})
public ResponseEntity<byte[]> districtReportByDistrictCode(@PathVariable String distcode, @RequestParam(name = "type") String type) {
return gardBusinessService.getDistrictReportPDFByDistcode(distcode, type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ void testgetAmalgamatedSchoolReportPDFByMincode() throws Exception {

ResponseEntity<byte[]> byteData = gradBusinessService.getAmalgamatedSchoolReportPDFByMincode(mincode, type, "accessToken");
assertNotNull(byteData);
//assertNotNull(byteData.getBody());

pdf = new InputStreamResource(new ByteArrayInputStream(new byte[0]));

Expand All @@ -324,7 +323,6 @@ void testgetAmalgamatedSchoolReportPDFByMincode() throws Exception {

byteData = gradBusinessService.getAmalgamatedSchoolReportPDFByMincode(mincode, type, "accessToken");
assertNotNull(byteData);
//assertNull(byteData.getBody());

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.springframework.web.reactive.function.client.WebClient;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Collections;
import java.util.UUID;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
Expand Down Expand Up @@ -80,7 +79,6 @@ void testDistrictReportByDistrictCode_NotFound() {
when(this.restService.get(any(String.class), any())).thenReturn(pdf);

ResponseEntity<byte[]> byteData = gradBusinessService.getDistrictReportPDFByDistcode(distCode, type);
//assertNotNull(byteData);
assertEquals(HttpStatus.NOT_FOUND, byteData.getStatusCode());
assertNull(byteData.getBody());
}
Expand Down

0 comments on commit 90f7ab8

Please sign in to comment.