use of io.undertree.symptom.domain.Patient in project spring-boot-jpa by ssherwood.
the class PatientController method updatePatientIncludingNulls.
/**
* Update an existing resource with a new representation. The entire state of the entity is
* replaced with that provided with the RequestBody (this means that null or excluded fields are
* updated to null on the entity itself).
*
* @param patientId unique patient UUID to find
* @param patient the Patient to update with
* @return the Patient as modified by the update
*/
@PutMapping("/{id}")
public Patient updatePatientIncludingNulls(@PathVariable("id") final UUID patientId, @Valid @RequestBody final Patient patient) {
Patient originalPatient = this.getPatient(patientId);
updateProperties(patientId, originalPatient, patient);
return this.patientRepository.save(originalPatient);
}
use of io.undertree.symptom.domain.Patient in project spring-boot-jpa by ssherwood.
the class PatientControllerWebTests method test_PatientController_addPatient_WithEmpty_Expect_BadRequest.
@Test
public void test_PatientController_addPatient_WithEmpty_Expect_BadRequest() throws Exception {
ResponseEntity<String> json = restTemplate.postForEntity("/patients", new Patient(), String.class);
assertThat(json.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
JSONAssert.assertEquals("{exception:\"org.springframework.web.bind.MethodArgumentNotValidException\"}", json.getBody(), false);
}
use of io.undertree.symptom.domain.Patient in project spring-boot-jpa by ssherwood.
the class PatientControllerWebTests method test_PatientController_addPatient_WithEmptyGivenName_Expect_BadRequest.
@Test
public void test_PatientController_addPatient_WithEmptyGivenName_Expect_BadRequest() throws Exception {
Patient build = new TestPatientBuilder().withGivenName(new GivenName("")).build();
ResponseEntity<String> json = restTemplate.postForEntity("/patients", build, String.class);
assertThat(json.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
JSONAssert.assertEquals("{exception:\"org.springframework.web.bind.MethodArgumentNotValidException\"}", json.getBody(), false);
}
use of io.undertree.symptom.domain.Patient in project spring-boot-jpa by ssherwood.
the class PatientRepositoryTests method test_PatientRepository_SaveWithEmpty_ExpectException.
@Test
public void test_PatientRepository_SaveWithEmpty_ExpectException() throws Exception {
thrown.expect(ConstraintViolationException.class);
thrown.expectMessage(containsString("'may not be empty'"));
patientRepository.saveAndFlush(new Patient());
}
use of io.undertree.symptom.domain.Patient in project spring-boot-jpa by ssherwood.
the class PatientRepositoryTests method test_PatientRepository_findByPatientId_ExpectExists.
@Test
public void test_PatientRepository_findByPatientId_ExpectExists() throws Exception {
Patient patient = entityManager.persistFlushFind(new TestPatientBuilder().build());
Patient aPatient = patientRepository.findByPatientId(patient.getPatientId()).orElseThrow(NotFoundException::new);
assertThat(aPatient).isEqualTo(patient);
}
Aggregations