diff --git a/api/pom.xml b/api/pom.xml
index 1972e4a3..2ca2a2ef 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -232,11 +232,16 @@
jackson-datatype-jsr310
2.15.2
-
+
com.fasterxml.jackson.datatype
jackson-datatype-jsr310
2.15.2
+
+ org.springframework.security
+ spring-security-test
+ test
+
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/CommonController.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/CommonController.java
index 1155ed5c..ec1c8543 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/CommonController.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/controller/CommonController.java
@@ -19,6 +19,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -201,6 +202,18 @@ public ResponseEntity getSpecificHistoryActivityCode(@PathVaria
return response.GET(commonService.getSpecificHistoryActivityCode(activityCode));
}
+ @GetMapping(EducGradStudentApiConstants.GET_ALL_STUDENT_GRADE_CODES)
+ @PreAuthorize(PermissionsConstants.READ_STUDENT_GRADE_CODES)
+ @Transactional(readOnly = true)
+ @Operation(summary = "Find all active Student Grade Codes",
+ description = "Find all active Student Grade Codes", tags = {"Student Grade Code"})
+ @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"),
+ @ApiResponse(responseCode = "204", description = "NO CONTENT.")})
+ public ResponseEntity> getAllStudentGradeCodes() {
+ logger.debug("getAllStudentGradeCodes : ");
+ return response.GET(commonService.getAllStudentGradeCodes());
+ }
+
@GetMapping(EducGradStudentApiConstants.GET_ALL_STUDENT_REPORT_DATA_BY_MINCODE)
@PreAuthorize(PermissionsConstants.READ_GRAD_STUDENT_STATUS)
@Operation(summary = "Find a Student Graduation Data by Mininstry Code",
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/StudentGradeCode.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/StudentGradeCode.java
new file mode 100644
index 00000000..51be66fb
--- /dev/null
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/StudentGradeCode.java
@@ -0,0 +1,21 @@
+package ca.bc.gov.educ.api.gradstudent.model.dto;
+
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDateTime;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Component
+@SuppressWarnings("squid:S1700")
+public class StudentGradeCode extends BaseModel {
+ private String studentGradeCode;
+ private String label;
+ private int displayOrder;
+ private String description;
+ private LocalDateTime effectiveDate;
+ private LocalDateTime expiryDate;
+ private String expected;
+}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/StudentGradeCodeEntity.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/StudentGradeCodeEntity.java
new file mode 100644
index 00000000..b2bf474d
--- /dev/null
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/StudentGradeCodeEntity.java
@@ -0,0 +1,47 @@
+package ca.bc.gov.educ.api.gradstudent.model.entity;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+import jakarta.validation.constraints.NotNull;
+import lombok.*;
+
+import java.time.LocalDateTime;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Entity
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@Table(name = "STUDENT_GRADE_CODE")
+public class StudentGradeCodeEntity extends BaseEntity {
+
+ @Id
+ @Column(name = "STUDENT_GRADE_CODE", unique = true, updatable = false)
+ private String studentGradeCode;
+
+ @NotNull(message = "label cannot be null")
+ @Column(name = "LABEL")
+ private String label;
+
+ @NotNull(message = "displayOrder cannot be null")
+ @Column(name = "DISPLAY_ORDER")
+ private Integer displayOrder;
+
+ @NotNull(message = "description cannot be null")
+ @Column(name = "DESCRIPTION")
+ private String description;
+
+ @NotNull(message = "effectiveDate cannot be null")
+ @Column(name = "EFFECTIVE_DATE")
+ private LocalDateTime effectiveDate;
+
+ @Column(name = "EXPIRY_DATE")
+ private LocalDateTime expiryDate;
+
+ @NotNull(message = "expected cannot be null")
+ @Column(name = "EXPECTED")
+ private String expected;
+}
\ No newline at end of file
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/transformer/StudentGradeCodeTransformer.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/transformer/StudentGradeCodeTransformer.java
new file mode 100644
index 00000000..268bb810
--- /dev/null
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/transformer/StudentGradeCodeTransformer.java
@@ -0,0 +1,22 @@
+package ca.bc.gov.educ.api.gradstudent.model.transformer;
+
+import ca.bc.gov.educ.api.gradstudent.model.dto.StudentGradeCode;
+import ca.bc.gov.educ.api.gradstudent.model.entity.StudentGradeCodeEntity;
+import org.modelmapper.ModelMapper;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class StudentGradeCodeTransformer {
+
+ @Autowired
+ ModelMapper modelMapper;
+
+ public StudentGradeCode transformToDTO (StudentGradeCodeEntity entity) {
+ return modelMapper.map(entity, StudentGradeCode.class);
+ }
+
+ public StudentGradeCodeEntity transformToEntity(StudentGradeCode studentGradeCode) {
+ return modelMapper.map(studentGradeCode, StudentGradeCodeEntity.class);
+ }
+}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/StudentGradeCodeRepository.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/StudentGradeCodeRepository.java
new file mode 100644
index 00000000..744ee161
--- /dev/null
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/StudentGradeCodeRepository.java
@@ -0,0 +1,9 @@
+package ca.bc.gov.educ.api.gradstudent.repository;
+
+import ca.bc.gov.educ.api.gradstudent.model.entity.StudentGradeCodeEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface StudentGradeCodeRepository extends JpaRepository {
+}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/CommonService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/CommonService.java
index 86e6d738..728b12c6 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/CommonService.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/CommonService.java
@@ -1,18 +1,9 @@
package ca.bc.gov.educ.api.gradstudent.service;
import ca.bc.gov.educ.api.gradstudent.model.dto.*;
-import ca.bc.gov.educ.api.gradstudent.model.entity.HistoryActivityCodeEntity;
-import ca.bc.gov.educ.api.gradstudent.model.entity.StudentCareerProgramEntity;
-import ca.bc.gov.educ.api.gradstudent.model.entity.StudentRecordNoteEntity;
-import ca.bc.gov.educ.api.gradstudent.model.entity.StudentStatusEntity;
-import ca.bc.gov.educ.api.gradstudent.model.transformer.GradStudentCareerProgramTransformer;
-import ca.bc.gov.educ.api.gradstudent.model.transformer.HistoryActivityTransformer;
-import ca.bc.gov.educ.api.gradstudent.model.transformer.StudentNoteTransformer;
-import ca.bc.gov.educ.api.gradstudent.model.transformer.StudentStatusTransformer;
-import ca.bc.gov.educ.api.gradstudent.repository.HistoryActivityRepository;
-import ca.bc.gov.educ.api.gradstudent.repository.StudentCareerProgramRepository;
-import ca.bc.gov.educ.api.gradstudent.repository.StudentNoteRepository;
-import ca.bc.gov.educ.api.gradstudent.repository.StudentStatusRepository;
+import ca.bc.gov.educ.api.gradstudent.model.entity.*;
+import ca.bc.gov.educ.api.gradstudent.model.transformer.*;
+import ca.bc.gov.educ.api.gradstudent.repository.*;
import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants;
import ca.bc.gov.educ.api.gradstudent.util.GradValidation;
import ca.bc.gov.educ.api.gradstudent.util.ThreadLocalStateUtil;
@@ -51,6 +42,8 @@ public class CommonService {
final GradValidation validation;
final HistoryActivityRepository historyActivityRepository;
final HistoryActivityTransformer historyActivityTransformer;
+ final StudentGradeCodeRepository studentGradeCodeRepository;
+ final StudentGradeCodeTransformer studentGradeCodeTransformer;
@Autowired
public CommonService(EducGradStudentApiConstants constants,
@@ -65,7 +58,9 @@ public CommonService(EducGradStudentApiConstants constants,
HistoryActivityRepository historyActivityRepository,
HistoryActivityTransformer historyActivityTransformer,
WebClient webClient,
- GradValidation validation) {
+ GradValidation validation,
+ StudentGradeCodeRepository studentGradeCodeRepository,
+ StudentGradeCodeTransformer studentGradeCodeTransformer) {
this.constants = constants;
this.gradStudentCareerProgramRepository = gradStudentCareerProgramRepository;
this.gradStudentCareerProgramTransformer = gradStudentCareerProgramTransformer;
@@ -79,6 +74,8 @@ public CommonService(EducGradStudentApiConstants constants,
this.historyActivityTransformer = historyActivityTransformer;
this.webClient = webClient;
this.validation = validation;
+ this.studentGradeCodeRepository = studentGradeCodeRepository;
+ this.studentGradeCodeTransformer = studentGradeCodeTransformer;
}
@Transactional
@@ -235,4 +232,8 @@ public HistoryActivity getSpecificHistoryActivityCode(String activityCode) {
public List getDeceasedStudentIDs(List studentIDs) {
return gradStudentService.getStudentIDsByStatusCode(studentIDs, "DEC");
}
+
+ public List getAllStudentGradeCodes() {
+ return studentGradeCodeRepository.findAll().stream().map(studentGradeCodeTransformer::transformToDTO).toList();
+ }
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java
index dad2e2f3..1d3689b8 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java
@@ -43,6 +43,7 @@ public class EducGradStudentApiConstants {
public static final String GRADUATION_RECORD_HISTORY_BY_BATCH_ID_DISTRIBUTION_RUN = "/distribution/batchid/{batchID}";
public static final String UPDATE_GRAD_STUDENT_FLAG_BY_BATCH_JOB_TYPE_AND_MULTIPLE_STUDENTIDS = "/multistudentids/batchflag/jobtype/{batchJobType}";
public static final String GRAD_STUDENT_NON_GRAD_REASON_BY_PEN = "/pen/{pen}/nongrad-reason";
+ public static final String GET_ALL_STUDENT_GRADE_CODES = "/student-grade-codes";
public static final String GRAD_STUDENT_OPTIONAL_PROGRAM_BY_PEN = "/optionalprogram/studentid/{studentID}";
public static final String GRAD_STUDENT_OPTIONAL_PROGRAM_BY_PEN_PROGRAM_OPTIONAL_PROGRAM = "/optionalprogram/{studentID}/{optionalProgramID}";
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/PermissionsConstants.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/PermissionsConstants.java
index 1a7a70c9..b6a5e83f 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/PermissionsConstants.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/PermissionsConstants.java
@@ -32,4 +32,5 @@ private PermissionsConstants() {}
public static final String UPDATE_STUDENT_STATUS = PREFIX + "SCOPE_UPDATE_GRAD_STUDENT_STATUS_CODE_DATA"+ SUFFIX;
public static final String STUDENT_ALGORITHM_DATA = PREFIX + "SCOPE_READ_GRAD_GRADUATION_STATUS" + SUFFIX + " and "
+ PREFIX + "SCOPE_READ_GRAD_STUDENT_DATA" + SUFFIX;
+ public static final String READ_STUDENT_GRADE_CODES = PREFIX + "SCOPE_READ_STUDENT_GRADE_CODES" + SUFFIX;
}
diff --git a/api/src/main/resources/db/migration/1.0/V1.0.69__DDL-CREATE_TABLE-STUDENT_GRADE_CODE.sql b/api/src/main/resources/db/migration/1.0/V1.0.69__DDL-CREATE_TABLE-STUDENT_GRADE_CODE.sql
new file mode 100644
index 00000000..fd41521d
--- /dev/null
+++ b/api/src/main/resources/db/migration/1.0/V1.0.69__DDL-CREATE_TABLE-STUDENT_GRADE_CODE.sql
@@ -0,0 +1,19 @@
+-- API_GRAD_STUDENT.STUDENT_GRADE_CODE definition
+
+CREATE TABLE "STUDENT_GRADE_CODE"
+( "STUDENT_GRADE_CODE" VARCHAR2(2) NOT NULL,
+ "LABEL" VARCHAR2(30) NOT NULL,
+ "DESCRIPTION" VARCHAR2(125) NOT NULL,
+ "DISPLAY_ORDER" NUMBER NOT NULL,
+ "EFFECTIVE_DATE" DATE NOT NULL,
+ "EXPIRY_DATE" DATE,
+ "EXPECTED" VARCHAR2(1) NOT NULL,
+ "CREATE_DATE" DATE DEFAULT SYSTIMESTAMP NOT NULL,
+ "CREATE_USER" VARCHAR2(32) DEFAULT USER NOT NULL,
+ "UPDATE_DATE" DATE DEFAULT SYSTIMESTAMP NOT NULL,
+ "UPDATE_USER" VARCHAR2(32) DEFAULT USER NOT NULL,
+ CONSTRAINT "STUDENT_GRADE_CODE_PK" PRIMARY KEY ("STUDENT_GRADE_CODE")
+ USING INDEX TABLESPACE "API_GRAD_IDX"
+) SEGMENT CREATION IMMEDIATE
+ NOCOMPRESS LOGGING
+ TABLESPACE "API_GRAD_DATA" NO INMEMORY ;
diff --git a/api/src/main/resources/db/migration/1.0/V1.0.70__DML-INSERT_DATA-STUDENT_GRADE_CODES.sql b/api/src/main/resources/db/migration/1.0/V1.0.70__DML-INSERT_DATA-STUDENT_GRADE_CODES.sql
new file mode 100644
index 00000000..c3db6a06
--- /dev/null
+++ b/api/src/main/resources/db/migration/1.0/V1.0.70__DML-INSERT_DATA-STUDENT_GRADE_CODES.sql
@@ -0,0 +1,65 @@
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('01','Grade 1','First grade',110,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('02','Grade 2','Second grade',120,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('03','Grade 3','Third grade',130,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('04','Grade 4','Fourth grade',140,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('05','Grade 5','Fifth grade',150,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('06','Grade 6','Sixth grade',160,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('07','Grade 7','Seventh grade',170,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('08','Grade 8','Eighth grade',10,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('09','Grade 9','Ninth grade',20,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('10','Grade 10','Tenth grade',30,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('11','Grade 11','Eleventh grade',40,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('12','Grade 12','Twelfth grade',50,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('AD','Adult Grad','Student on the Adult Graduation Program who is expected to graduate this year (subgrade)',60,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('AN','Adult Non Grad','Student on the Adult Graduation Program who is not expected to graduate this year (subgrade)',70,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('GA','Graduated Adult','An adult student who has graduated in BC or another jurisdiction (subgrade)',90,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('GR','Graduated','Used by MyEdBC schools only when a student withdraws or the school believes they have finished their program',100,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('KF','Kindergarten Full-time','After 2012, the only valid grade code for kindergarten (subgrade)',180,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('SU','Secondary Upgraded','Secondary upgraded (subgrade)',190,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('EU','Elementary Upgraded','Elementary ungraded (subgrade)',200,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'N');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('HS','Home School','Students whose parents provide their educational program and who are registered with the school (subgrade)',80,TIMESTAMP'2024-10-01 00:00:00.0',NULL, 'Y');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('KH','Kindergarten Half','Kindergarten half-time, applicable only until 2012 (subgrade)',210,TIMESTAMP'2024-10-01 00:00:00.0',TIMESTAMP'2012-06-30 00:00:00.0', 'N');
+
+INSERT INTO STUDENT_GRADE_CODE (STUDENT_GRADE_CODE,LABEL,DESCRIPTION,DISPLAY_ORDER,EFFECTIVE_DATE,EXPIRY_DATE, EXPECTED)
+VALUES ('OT','Other','A historic grade code applied by TRAX when an unexpected grade code was submitted for a student',220,TIMESTAMP'2024-10-01 00:00:00.0',TIMESTAMP'2024-10-01 00:00:00.0', 'Y');
\ No newline at end of file
diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/BaseIntegrationTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/BaseIntegrationTest.java
new file mode 100644
index 00000000..b456a56a
--- /dev/null
+++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/BaseIntegrationTest.java
@@ -0,0 +1,47 @@
+package ca.bc.gov.educ.api.gradstudent.controller;
+
+import ca.bc.gov.educ.api.gradstudent.EducGradStudentApiApplication;
+import ca.bc.gov.educ.api.gradstudent.model.entity.StudentGradeCodeEntity;
+import ca.bc.gov.educ.api.gradstudent.repository.StudentGradeCodeRepository;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+
+@SpringBootTest(classes = {EducGradStudentApiApplication.class})
+@ActiveProfiles("test")
+@AutoConfigureMockMvc
+public abstract class BaseIntegrationTest {
+
+ @Autowired
+ StudentGradeCodeRepository studentGradeCodeRepository;
+
+ @BeforeEach
+ public void before() {
+ studentGradeCodeRepository.saveAll(studentGradeCodeData());
+ }
+
+ @AfterEach
+ public void resetState() {
+ studentGradeCodeRepository.deleteAll();
+ }
+
+ public List studentGradeCodeData() {
+ List entities = new ArrayList<>();
+ entities.add(StudentGradeCodeEntity.builder().studentGradeCode("07").description("Grade 7").label("Grade 7").effectiveDate(LocalDateTime.now()).expected("N").displayOrder(1).build());
+
+ entities.add(StudentGradeCodeEntity.builder().studentGradeCode("08").description("Grade 8").label("Grade 8").effectiveDate(LocalDateTime.now()).expected("Y").displayOrder(2).build());
+
+ entities.add(StudentGradeCodeEntity.builder().studentGradeCode("09").description("Grade 9").label("Grade 9").effectiveDate(LocalDateTime.now()).expected("Y").displayOrder(3).build());
+
+ entities.add(StudentGradeCodeEntity.builder().studentGradeCode("10").description("Grade 10").label("Grade 10").effectiveDate(LocalDateTime.now()).expected("Y").displayOrder(4).build());
+
+ return entities;
+ }
+}
diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/CommonControllerIntegrationTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/CommonControllerIntegrationTest.java
new file mode 100644
index 00000000..a1b22178
--- /dev/null
+++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/controller/CommonControllerIntegrationTest.java
@@ -0,0 +1,43 @@
+package ca.bc.gov.educ.api.gradstudent.controller;
+
+import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockitoAnnotations;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors;
+import org.springframework.test.web.servlet.MockMvc;
+
+import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.oidcLogin;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+
+class CommonControllerIntegrationTest extends BaseIntegrationTest {
+
+ @Autowired
+ private MockMvc mockMvc;
+
+ @BeforeEach
+ public void setUp() {
+ MockitoAnnotations.openMocks(this);
+ }
+
+ @Test
+ void testGetAllStudentGradeCodes_ShouldReturnCodes() throws Exception {
+ final GrantedAuthority grantedAuthority = () -> "SCOPE_READ_STUDENT_GRADE_CODES";
+ final SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor mockAuthority = oidcLogin().authorities(grantedAuthority);
+
+ this.mockMvc.perform(get(EducGradStudentApiConstants.GRAD_STUDENT_API_ROOT_MAPPING + EducGradStudentApiConstants.GET_ALL_STUDENT_GRADE_CODES).with(mockAuthority)).andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.length()").value(4)).andExpect(jsonPath("$[0].studentGradeCode").value("07"));
+ }
+
+ @Test
+ void testGetAllStudentGradeCodes_GivenInvalidScope_ShouldReturn403() throws Exception {
+ final GrantedAuthority grantedAuthority = () -> "SCOPE_INVALID_SCOPE";
+ final SecurityMockMvcRequestPostProcessors.OidcLoginRequestPostProcessor mockAuthority = oidcLogin().authorities(grantedAuthority);
+
+ this.mockMvc.perform(get(EducGradStudentApiConstants.GRAD_STUDENT_API_ROOT_MAPPING + EducGradStudentApiConstants.GET_ALL_STUDENT_GRADE_CODES).with(mockAuthority)).andDo(print()).andExpect(status().isForbidden());
+ }
+}
diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/support/MockConfiguration.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/support/MockConfiguration.java
new file mode 100644
index 00000000..192f56a8
--- /dev/null
+++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/support/MockConfiguration.java
@@ -0,0 +1,30 @@
+package ca.bc.gov.educ.api.gradstudent.support;
+
+import org.mockito.Mockito;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+import org.springframework.context.annotation.Profile;
+import org.springframework.web.client.RestTemplate;
+import org.springframework.web.reactive.function.client.WebClient;
+
+/**
+ * The type Mock configuration.
+ */
+@Profile("test")
+@Configuration
+public class MockConfiguration {
+
+ @Bean
+ @Primary
+ public RestTemplate restTemplate() {
+ return Mockito.mock(RestTemplate.class);
+ }
+
+ @Bean
+ @Primary
+ public WebClient webClient() {
+ return Mockito.mock(WebClient.class);
+ }
+
+}
diff --git a/api/src/test/resources/application.yaml b/api/src/test/resources/application.yaml
index 1880b68a..bb142780 100644
--- a/api/src/test/resources/application.yaml
+++ b/api/src/test/resources/application.yaml
@@ -31,8 +31,8 @@ spring:
oauth2:
resourceserver:
jwt:
- issuer-uri: https://soam-dev.apps.silver.devops.gov.bc.ca/auth/realms/master
- jwk-set-uri: https://soam-dev.apps.silver.devops.gov.bc.ca/auth/realms/master/protocol/openid-connect/certs
+ issuer-uri: http://test
+ jwk-set-uri: http://test
#Logging properties
logging:
@@ -105,46 +105,46 @@ cron:
endpoint:
grad-trax-api:
all-commonschools:
- url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/common
+ url: http://test
school-by-min-code:
- url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/%s
+ url: http://test
district-by-district-code:
- url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/district/%s
+ url: http://test
commonschool-by-mincode:
- url: https://educ-grad-trax-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/trax/school/common/%s
+ url: http://test
grad-program-api:
optional_program_name_by_optional_program_id:
- url: https://educ-grad-program-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/program/optionalprograms/id/%s
+ url: http://test
optional_program_id_by_program_code_optional_program_code:
- url: https://educ-grad-program-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/programmanagement/optionalprograms/%s/%s
+ url: http://test
program_name_by_program_code:
- url: https://educ-grad-program-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/program/programs/%s
- career_program-by-career-code:
- url: https://educ-grad-program-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/program/careerprogram/%s
+ url: http://test
+ career_program-by-career-code:
+ url: http://test
grad-student-graduation-api:
ungrad-reason:
ungrad-reason-by-reason-code:
- url: https://educ-grad-student-graduation-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/studentgraduation/ungrad/ungradreason/%s
+ url: http://test
save-student-ungrad-reason:
- url: https://educ-grad-student-graduation-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/studentgraduation/ungrad/studentungradreason/studentid/%s
+ url: http://test
pen-student-api:
by-studentid:
- url: https://student-api-75e61b-tools.apps.silver.devops.gov.bc.ca/api/v1/student/%s
+ url: http://test
search:
- url: https://student-api-75e61b-tools.apps.silver.devops.gov.bc.ca/api/v1/student/paginated
+ url: http://test
by-pen:
- url: https://student-api-75e61b-tools.apps.silver.devops.gov.bc.ca/api/v1/student?pen=%s
+ url: http://test
student:
- url: https://student-api-75e61b-tools.apps.silver.devops.gov.bc.ca/api/v1/student
+ url: http://test
grad-graduation-report-api:
delete-student-achievement:
- url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/studentachievement/%s
+ url: http://test
student-certificates:
- url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/studentcertificates?studentID=%s
+ url: http://test
archive-student-achievement:
- url: https://educ-grad-graduation-report-api-77c02f-dev.apps.silver.devops.gov.bc.ca/api/v1/graduationreports/studentachievement/%s
+ url: http://test
educ-school-api:
- url: https://school-api-75e61b-dev.apps.silver.devops.gov.bc.ca/api/v1/schools
+ url: http://test
#Splunk LogHelper