use of org.hypertrace.entity.query.service.v1.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchAPIControllerTest method testReadPenRequestBatchPaginated_GivenSchoolNameAndInvalidStudentName_ShouldReturnStatusOk.
/**
* Test read pen request batch paginated given school name and invalid student name should return empty list.
*
* @throws Exception the exception
*/
@Test
public void testReadPenRequestBatchPaginated_GivenSchoolNameAndInvalidStudentName_ShouldReturnStatusOk() throws Exception {
final String batchIDs = this.createBatchStudentRecords(2);
final SearchCriteria criteria = SearchCriteria.builder().key("schoolName").operation(FilterOperation.STARTS_WITH).value("Brae").valueType(ValueType.STRING).build();
final SearchCriteria criteria2 = SearchCriteria.builder().key("penRequestBatchStudentEntities.legalLastName").condition(AND).operation(FilterOperation.STARTS_WITH).value("AB").valueType(ValueType.STRING).build();
final List<SearchCriteria> criteriaList = new ArrayList<>();
criteriaList.add(criteria);
criteriaList.add(criteria2);
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/paginated").with(jwt().jwt((jwt) -> jwt.claim("scope", "READ_PEN_REQUEST_BATCH"))).param("searchCriteriaList", criteriaJSON).contentType(APPLICATION_JSON)).andReturn();
this.mockMvc.perform(asyncDispatch(result)).andDo(print()).andExpect(status().isOk()).andExpect(jsonPath("$.content", hasSize(0)));
}
use of org.hypertrace.entity.query.service.v1.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchHistoryAPIControllerTest method testReadPenRequestBatchPaginated_GivenSchoolGroupCodeAndPenReqBatchStatusCodeFilterAndMatchedCountOrFixableCount_ShouldReturnStatusOk.
/**
* Test read pen request batch paginated given school group code and pen req batch status code filter and matched count or fixable count should return status ok.
*
* @throws Exception the exception
*/
@Test
public void testReadPenRequestBatchPaginated_GivenSchoolGroupCodeAndPenReqBatchStatusCodeFilterAndMatchedCountOrFixableCount_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(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()).andExpect(jsonPath("$.content", hasSize(0)));
}
use of org.hypertrace.entity.query.service.v1.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchHistoryAPIControllerTest method testReadPenRequestBatchPaginated_GivenFixableCountFilterWithoutData_ShouldReturnStatusOk.
/**
* Test read pen request batch paginated given fixable count filter without data should return status ok.
*
* @throws Exception the exception
*/
@Test
public void testReadPenRequestBatchPaginated_GivenFixableCountFilterWithoutData_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("fixableCount").operation(FilterOperation.GREATER_THAN).value("10").valueType(ValueType.LONG).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(0)));
}
use of org.hypertrace.entity.query.service.v1.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchHistoryAPIControllerTest method testReadPenRequestBatchPaginated_GivenStatusFilter_ShouldReturnStatusOk.
/**
* Test read pen request batch paginated given school group code filter should return status ok.
*
* @throws Exception the exception
*/
@Test
public void testReadPenRequestBatchPaginated_GivenStatusFilter_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("penRequestBatchStatusCode").operation(FilterOperation.EQUAL).value(PenRequestBatchStatusCodes.LOADED.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(2)));
}
use of org.hypertrace.entity.query.service.v1.ValueType in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchHistoryAPIControllerTest method testReadPenRequestBatchPaginated_GivenMultipleGroupCondition_ShouldReturnStatusOk.
/**
* Test read pen request batch paginated given multiple group condition should return status ok.
*
* @throws Exception the exception
*/
@Test
public void testReadPenRequestBatchPaginated_GivenMultipleGroupCondition_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 SearchCriteria criteria3 = SearchCriteria.builder().key("sisProductName").condition(OR).operation(FilterOperation.CONTAINS_IGNORE_CASE).value("MYED").valueType(ValueType.STRING).build();
final List<SearchCriteria> criteriaList = new LinkedList<>();
criteriaList.add(criteria);
criteriaList.add(criteria2);
criteriaList.add(criteria3);
final SearchCriteria criteria4 = SearchCriteria.builder().key("matchedCount").operation(FilterOperation.GREATER_THAN).value("0").valueType(ValueType.LONG).build();
final SearchCriteria criteria5 = SearchCriteria.builder().key("fixableCount").condition(OR).operation(FilterOperation.GREATER_THAN).value("0").valueType(ValueType.LONG).build();
final SearchCriteria criteria6 = SearchCriteria.builder().key("sourceStudentCount").condition(OR).operation(FilterOperation.GREATER_THAN).value("0").valueType(ValueType.LONG).build();
final List<SearchCriteria> criteriaList1 = new LinkedList<>();
criteriaList1.add(criteria4);
criteriaList1.add(criteria5);
criteriaList1.add(criteria6);
final SearchCriteria criteria7 = SearchCriteria.builder().key("studentCount").operation(FilterOperation.GREATER_THAN).value("0").valueType(ValueType.LONG).build();
final SearchCriteria criteria8 = SearchCriteria.builder().key("sisVendorName").condition(OR).operation(FilterOperation.EQUAL).value("Follett Software").valueType(ValueType.STRING).build();
final SearchCriteria criteria9 = SearchCriteria.builder().key("mincode").condition(OR).operation(FilterOperation.EQUAL).value("09898027").valueType(ValueType.STRING).build();
final List<SearchCriteria> criteriaList2 = new LinkedList<>();
criteriaList1.add(criteria7);
criteriaList1.add(criteria8);
criteriaList1.add(criteria9);
final List<Search> searches = new LinkedList<>();
searches.add(Search.builder().searchCriteriaList(criteriaList).build());
searches.add(Search.builder().condition(AND).searchCriteriaList(criteriaList1).build());
searches.add(Search.builder().condition(AND).searchCriteriaList(criteriaList2).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());
}
Aggregations