use of ca.bc.gov.educ.penreg.api.struct.v1.external.PenRequestBatchSubmission in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchAPIControllerTest method testBatchSubmissionResult_GivenValidBatchSubmissionAndNotProcessed_ShouldReturnAccepted.
@Test
public void testBatchSubmissionResult_GivenValidBatchSubmissionAndNotProcessed_ShouldReturnAccepted() throws Exception {
final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("ExternalBatchSubmission.json")).getFile());
final PenRequestBatchSubmission entity = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).readValue(file, PenRequestBatchSubmission.class);
this.mockMvc.perform(post("/api/v1/pen-request-batch/pen-request-batch-submission").with(jwt().jwt((jwt) -> jwt.claim("scope", "WRITE_PEN_REQUEST_BATCH"))).content(JsonUtil.getJsonStringFromObject(entity)).contentType(APPLICATION_JSON)).andDo(print()).andExpect(status().isCreated()).andExpect(jsonPath("$", isA(String.class)));
val savedEntity = this.penRequestBatchRepository.findBySubmissionNumber(entity.getSubmissionNumber()).get(0);
this.mockMvc.perform(get("/api/v1/pen-request-batch/pen-request-batch-submission/" + savedEntity.getPenRequestBatchID() + "/result").with(jwt().jwt((jwt) -> jwt.claim("scope", "READ_PEN_REQUEST_BATCH"))).contentType(APPLICATION_JSON)).andDo(print()).andExpect(status().isAccepted());
}
use of ca.bc.gov.educ.penreg.api.struct.v1.external.PenRequestBatchSubmission in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchAPIControllerTest method testCreateNewBatchSubmissionDiacritical_GivenValidBatchSubmission_ShouldCreateNewRecordInDBUppercase.
@Test
public void testCreateNewBatchSubmissionDiacritical_GivenValidBatchSubmission_ShouldCreateNewRecordInDBUppercase() throws Exception {
final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("ExternalBatchSubmissionMixedCaseDiacritical.json")).getFile());
final PenRequestBatchSubmission entity = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).readValue(file, PenRequestBatchSubmission.class);
this.mockMvc.perform(post("/api/v1/pen-request-batch/pen-request-batch-submission").with(jwt().jwt((jwt) -> jwt.claim("scope", "WRITE_PEN_REQUEST_BATCH"))).content(JsonUtil.getJsonStringFromObject(entity)).contentType(APPLICATION_JSON)).andDo(print()).andExpect(status().isCreated()).andExpect(jsonPath("$", isA(String.class)));
}
use of ca.bc.gov.educ.penreg.api.struct.v1.external.PenRequestBatchSubmission in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchAPIControllerTest method testCreateNewBatchSubmission_GivenValidBatchSubmission_ShouldCreateNewRecordInDB.
@Test
public void testCreateNewBatchSubmission_GivenValidBatchSubmission_ShouldCreateNewRecordInDB() throws Exception {
final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("ExternalBatchSubmission.json")).getFile());
final PenRequestBatchSubmission entity = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).readValue(file, PenRequestBatchSubmission.class);
this.mockMvc.perform(post("/api/v1/pen-request-batch/pen-request-batch-submission").with(jwt().jwt((jwt) -> jwt.claim("scope", "WRITE_PEN_REQUEST_BATCH"))).content(JsonUtil.getJsonStringFromObject(entity)).contentType(APPLICATION_JSON)).andDo(print()).andExpect(status().isCreated()).andExpect(jsonPath("$", isA(String.class)));
}
use of ca.bc.gov.educ.penreg.api.struct.v1.external.PenRequestBatchSubmission in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchAPIControllerTest method testCreateNewBatchSubmissionLowercase_GivenValidBatchSubmission_ShouldCreateNewRecordInDBUppercase.
@Test
public void testCreateNewBatchSubmissionLowercase_GivenValidBatchSubmission_ShouldCreateNewRecordInDBUppercase() throws Exception {
final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("ExternalBatchSubmissionMixedCase.json")).getFile());
final PenRequestBatchSubmission entity = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).readValue(file, PenRequestBatchSubmission.class);
this.mockMvc.perform(post("/api/v1/pen-request-batch/pen-request-batch-submission").with(jwt().jwt((jwt) -> jwt.claim("scope", "WRITE_PEN_REQUEST_BATCH"))).content(JsonUtil.getJsonStringFromObject(entity)).contentType(APPLICATION_JSON)).andDo(print()).andExpect(status().isCreated()).andExpect(jsonPath("$", isA(String.class)));
}
use of ca.bc.gov.educ.penreg.api.struct.v1.external.PenRequestBatchSubmission in project EDUC-PEN-REG-BATCH-API by bcgov.
the class PenRequestBatchAPIControllerTest method testCreateNewBatchSubmission_GivenSameSubmissionTwice_ShouldReturnConflictForTheSecond.
@Test
public void testCreateNewBatchSubmission_GivenSameSubmissionTwice_ShouldReturnConflictForTheSecond() throws Exception {
final File file = new File(Objects.requireNonNull(this.getClass().getClassLoader().getResource("ExternalBatchSubmission.json")).getFile());
final PenRequestBatchSubmission entity = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).readValue(file, PenRequestBatchSubmission.class);
this.mockMvc.perform(post("/api/v1/pen-request-batch/pen-request-batch-submission").with(jwt().jwt((jwt) -> jwt.claim("scope", "WRITE_PEN_REQUEST_BATCH"))).content(JsonUtil.getJsonStringFromObject(entity)).contentType(APPLICATION_JSON)).andDo(print()).andExpect(status().isCreated()).andExpect(jsonPath("$", isA(String.class)));
this.mockMvc.perform(post("/api/v1/pen-request-batch/pen-request-batch-submission").with(jwt().jwt((jwt) -> jwt.claim("scope", "WRITE_PEN_REQUEST_BATCH"))).content(JsonUtil.getJsonStringFromObject(entity)).contentType(APPLICATION_JSON)).andDo(print()).andExpect(status().isConflict());
}
Aggregations