use of io.undertree.symptom.domain.TestPatientBuilder in project spring-boot-jpa by ssherwood.
the class PatientControllerWebTests method test_PatientController_addPatient_WithBirthDate_Expect_ValidAge.
@Test
public void test_PatientController_addPatient_WithBirthDate_Expect_ValidAge() throws Exception {
ResponseEntity<Patient> entity = restTemplate.postForEntity("/patients", new TestPatientBuilder().withBirthDate(LocalDate.of(1980, 1, 1)).build(), Patient.class);
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(entity.getBody()).isNotNull().hasFieldOrPropertyWithValue("age", LocalDate.now().getYear() - 1980);
}
use of io.undertree.symptom.domain.TestPatientBuilder in project spring-boot-jpa by ssherwood.
the class PatientControllerWebTests method test_PatientController_addPatient_WithInvalidEmail_Expect_BadRequest.
@Test
public void test_PatientController_addPatient_WithInvalidEmail_Expect_BadRequest() throws Exception {
ResponseEntity<String> json = restTemplate.postForEntity("/patients", new TestPatientBuilder().withEmail("bad/email").build(), String.class);
assertThat(json.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
JSONAssert.assertEquals("{exception:\"org.springframework.web.bind.MethodArgumentNotValidException\"}", json.getBody(), false);
}
Aggregations