use of org.hypertrace.entity.query.service.v1.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchHistoryAPIControllerTest method testReadPenRequestBatchPaginated_GivenSchoolGroupCodeFilter_ShouldReturnStatusOk.
/**
* Test read pen request batch paginated given school group code filter should return status ok.
*
* @throws Exception the exception
*/
@Test
public void testReadPenRequestBatchPaginated_GivenSchoolGroupCodeFilter_ShouldReturnStatusOk() throws Exception {
final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("mock_pen_req_batch.json")).getFile());
final List<PenRequestBatch> entities = new ObjectMapper().readValue(file, new TypeReference<>() {
});
final var models = entities.stream().map(mapper::toModel).collect(Collectors.toList()).stream().map(PenRequestBatchTestUtils::populateAuditColumnsAndHistory).collect(Collectors.toList());
this.penRequestBatchRepository.saveAll(models);
final SearchCriteria criteria = SearchCriteria.builder().key("schoolGroupCode").operation(FilterOperation.EQUAL).value(SchoolGroupCodes.K12.getCode()).valueType(ValueType.STRING).build();
final List<SearchCriteria> criteriaList = new ArrayList<>();
criteriaList.add(criteria);
final List<Search> searches = new LinkedList<>();
searches.add(Search.builder().searchCriteriaList(criteriaList).build());
final ObjectMapper objectMapper = new ObjectMapper();
final String criteriaJSON = objectMapper.writeValueAsString(searches);
final MvcResult result = this.mockMvc.perform(get("/api/v1/pen-request-batch/history/paginated").with(jwt().jwt((jwt) -> jwt.claim("scope", "READ_PEN_REQUEST_BATCH_HISTORY"))).param("searchCriteriaList", criteriaJSON).contentType(APPLICATION_JSON)).andReturn();
this.mockMvc.perform(asyncDispatch(result)).andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.content", hasSize(1)));
}
use of org.hypertrace.entity.query.service.v1.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchHistoryAPIControllerTest method testReadPenRequestBatchPaginated_GivenSchoolGroupCodeANDPenReqBatchStatusCodeFilterORMatchedCountANDFixableCount_ShouldReturnStatusOk.
/**
* Test read pen request batch paginated given school group code and pen req batch status code filter or matched count and fixable count should return status ok.
*
* @throws Exception the exception
*/
@Test
public void testReadPenRequestBatchPaginated_GivenSchoolGroupCodeANDPenReqBatchStatusCodeFilterORMatchedCountANDFixableCount_ShouldReturnStatusOk() throws Exception {
final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("mock_pen_req_batch.json")).getFile());
final List<PenRequestBatch> entities = new ObjectMapper().readValue(file, new TypeReference<>() {
});
final var models = entities.stream().map(mapper::toModel).collect(Collectors.toList()).stream().map(PenRequestBatchTestUtils::populateAuditColumnsAndHistory).collect(Collectors.toList());
this.penRequestBatchRepository.saveAll(models);
final SearchCriteria criteria = SearchCriteria.builder().key("schoolGroupCode").operation(FilterOperation.EQUAL).value(SchoolGroupCodes.K12.getCode()).valueType(ValueType.STRING).build();
final SearchCriteria criteria2 = SearchCriteria.builder().key("penRequestBatchStatusCode").condition(AND).operation(FilterOperation.IN).value("LOADED,ACTIVE").valueType(ValueType.STRING).build();
final List<SearchCriteria> criteriaList = new LinkedList<>();
criteriaList.add(criteria);
criteriaList.add(criteria2);
final SearchCriteria criteria3 = SearchCriteria.builder().key("matchedCount").operation(FilterOperation.GREATER_THAN).value("0").valueType(ValueType.LONG).build();
final SearchCriteria criteria4 = SearchCriteria.builder().key("fixableCount").condition(AND).operation(FilterOperation.GREATER_THAN).value("0").valueType(ValueType.LONG).build();
final List<SearchCriteria> criteriaList1 = new LinkedList<>();
criteriaList1.add(criteria3);
criteriaList1.add(criteria4);
final List<Search> searches = new LinkedList<>();
searches.add(Search.builder().searchCriteriaList(criteriaList).build());
searches.add(Search.builder().condition(OR).searchCriteriaList(criteriaList1).build());
final ObjectMapper objectMapper = new ObjectMapper();
final String criteriaJSON = objectMapper.writeValueAsString(searches);
final MvcResult result = this.mockMvc.perform(get("/api/v1/pen-request-batch/history/paginated").with(jwt().jwt((jwt) -> jwt.claim("scope", "READ_PEN_REQUEST_BATCH_HISTORY"))).param("searchCriteriaList", criteriaJSON).contentType(APPLICATION_JSON)).andReturn();
this.mockMvc.perform(asyncDispatch(result)).andDo(print()).andExpect(status().isOk());
}
use of org.hypertrace.entity.query.service.v1.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchHistoryAPIControllerTest method testReadPenRequestBatchPaginated_GivenSchoolGroupCodeOrPenReqBatchStatusCodeFilterAndMatchedCountOrFixableCount_ShouldReturnStatusOk.
/**
* Test read pen request batch paginated given school group code or pen req batch status code filter and matched count or fixable count should return status ok.
*
* @throws Exception the exception
*/
@Test
public void testReadPenRequestBatchPaginated_GivenSchoolGroupCodeOrPenReqBatchStatusCodeFilterAndMatchedCountOrFixableCount_ShouldReturnStatusOk() throws Exception {
final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("mock_pen_req_batch.json")).getFile());
final List<PenRequestBatch> entities = new ObjectMapper().readValue(file, new TypeReference<>() {
});
final var models = entities.stream().map(mapper::toModel).collect(Collectors.toList()).stream().map(PenRequestBatchTestUtils::populateAuditColumnsAndHistory).collect(Collectors.toList());
this.penRequestBatchRepository.saveAll(models);
final SearchCriteria criteria = SearchCriteria.builder().key("schoolGroupCode").operation(FilterOperation.EQUAL).value(SchoolGroupCodes.K12.getCode()).valueType(ValueType.STRING).build();
final SearchCriteria criteria2 = SearchCriteria.builder().key("penRequestBatchStatusCode").condition(OR).operation(FilterOperation.IN).value("LOADED,ACTIVE").valueType(ValueType.STRING).build();
final List<SearchCriteria> criteriaList = new LinkedList<>();
criteriaList.add(criteria);
criteriaList.add(criteria2);
final SearchCriteria criteria3 = SearchCriteria.builder().key("matchedCount").operation(FilterOperation.GREATER_THAN).value("0").valueType(ValueType.LONG).build();
final SearchCriteria criteria4 = SearchCriteria.builder().key("fixableCount").condition(OR).operation(FilterOperation.GREATER_THAN).value("0").valueType(ValueType.LONG).build();
final List<SearchCriteria> criteriaList1 = new LinkedList<>();
criteriaList1.add(criteria3);
criteriaList1.add(criteria4);
final List<Search> searches = new LinkedList<>();
searches.add(Search.builder().searchCriteriaList(criteriaList).build());
searches.add(Search.builder().condition(AND).searchCriteriaList(criteriaList1).build());
final ObjectMapper objectMapper = new ObjectMapper();
final String criteriaJSON = objectMapper.writeValueAsString(searches);
final MvcResult result = this.mockMvc.perform(get("/api/v1/pen-request-batch/history/paginated").with(jwt().jwt((jwt) -> jwt.claim("scope", "READ_PEN_REQUEST_BATCH_HISTORY"))).param("searchCriteriaList", criteriaJSON).contentType(APPLICATION_JSON)).andReturn();
this.mockMvc.perform(asyncDispatch(result)).andDo(print()).andExpect(status().isOk());
}
use of org.hypertrace.entity.query.service.v1.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchAPIControllerTest method testReadPenRequestBatchStudentPaginated_GivenPenRequestBatchIdsAndAllStudentStatusCodesAndOtherConditions_ShouldReturnStatusOk.
/**
* Test read pen request batch student paginated given pen request batch ids and all student status codes and other conditions should return status ok.
*
* @throws Exception the exception
*/
@Test
public void testReadPenRequestBatchStudentPaginated_GivenPenRequestBatchIdsAndAllStudentStatusCodesAndOtherConditions_ShouldReturnStatusOk() throws Exception {
final String batchIDs = this.createBatchStudentRecords(2);
final SearchCriteria criteria = SearchCriteria.builder().key("penRequestBatchEntity.penRequestBatchID").operation(FilterOperation.IN).value(batchIDs).valueType(ValueType.UUID).build();
final List<SearchCriteria> criteriaList = new LinkedList<>();
criteriaList.add(criteria);
final SearchCriteria criteria2 = SearchCriteria.builder().key("penRequestBatchStudentStatusCode").operation(FilterOperation.NOT_EQUAL).value("FIXABLE").valueType(ValueType.STRING).build();
final SearchCriteria criteria3 = SearchCriteria.builder().key("penRequestBatchEntity.mincode").condition(AND).operation(FilterOperation.STARTS_WITH_IGNORE_CASE).value("1").valueType(ValueType.STRING).build();
final SearchCriteria criteria4 = SearchCriteria.builder().key("legalLastName").condition(AND).operation(FilterOperation.STARTS_WITH_IGNORE_CASE).value("j").valueType(ValueType.STRING).build();
final List<SearchCriteria> criteriaList1 = new LinkedList<>();
criteriaList1.add(criteria2);
criteriaList1.add(criteria3);
criteriaList1.add(criteria4);
final List<Search> searches = new LinkedList<>();
searches.add(Search.builder().searchCriteriaList(criteriaList).build());
searches.add(Search.builder().condition(AND).searchCriteriaList(criteriaList1).build());
final ObjectMapper objectMapper = new ObjectMapper();
final String criteriaJSON = objectMapper.writeValueAsString(searches);
final String sort = this.createSortParam();
final MvcResult result = this.mockMvc.perform(get("/api/v1/pen-request-batch/student/paginated").with(jwt().jwt((jwt) -> jwt.claim("scope", "READ_PEN_REQUEST_BATCH"))).param("searchCriteriaList", criteriaJSON).param("sort", sort).param("pageSize", "3").contentType(APPLICATION_JSON)).andReturn();
this.mockMvc.perform(asyncDispatch(result)).andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.content", hasSize(3)));
}
Aggregations