Search in sources :

Example 6 with TestPatientBuilder

use of io.undertree.symptom.domain.TestPatientBuilder in project spring-boot-jpa by ssherwood.

the class PatientRepositoryTests method test_PatientRepository_SaveWithEmptyFamilyName_ExpectException.

@Test
public void test_PatientRepository_SaveWithEmptyFamilyName_ExpectException() throws Exception {
    thrown.expect(ConstraintViolationException.class);
    thrown.expectMessage(allOf(containsString("familyName"), containsString("'may not be empty'")));
    patientRepository.saveAndFlush(new TestPatientBuilder().withFamilyName("").build());
}
Also used : TestPatientBuilder(io.undertree.symptom.domain.TestPatientBuilder) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 7 with TestPatientBuilder

use of io.undertree.symptom.domain.TestPatientBuilder in project spring-boot-jpa by ssherwood.

the class PatientRepositoryTests method test_PatientRepository_SaveWithLessThanMinHeight_ExpectException.

@Test
public void test_PatientRepository_SaveWithLessThanMinHeight_ExpectException() throws Exception {
    thrown.expect(ConstraintViolationException.class);
    thrown.expectMessage(allOf(containsString("height"), containsString("'must be greater than or equal to 0'")));
    patientRepository.saveAndFlush(new TestPatientBuilder().withHeight((short) -1).build());
}
Also used : TestPatientBuilder(io.undertree.symptom.domain.TestPatientBuilder) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 8 with TestPatientBuilder

use of io.undertree.symptom.domain.TestPatientBuilder in project spring-boot-jpa by ssherwood.

the class PatientRepositoryTests method test_PatientRepository_SaveWithEmptyGivenName_ExpectException.

@Test
public void test_PatientRepository_SaveWithEmptyGivenName_ExpectException() throws Exception {
    thrown.expect(ConstraintViolationException.class);
    thrown.expectMessage(allOf(containsString("givenName.givenName"), containsString("'The given name should only contain alphanumeric values.'")));
    thrown.expectMessage(allOf(containsString("givenName.givenName"), containsString("'size must be between 2 and 50'")));
    patientRepository.saveAndFlush(new TestPatientBuilder().withGivenName(new GivenName("")).build());
}
Also used : TestPatientBuilder(io.undertree.symptom.domain.TestPatientBuilder) GivenName(io.undertree.symptom.domain.GivenName) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 9 with TestPatientBuilder

use of io.undertree.symptom.domain.TestPatientBuilder in project spring-boot-jpa by ssherwood.

the class PatientRepositoryTests method test_PatientRepository_SaveWithInvalidEmail_ExpectException.

@Test
public void test_PatientRepository_SaveWithInvalidEmail_ExpectException() throws Exception {
    thrown.expect(ConstraintViolationException.class);
    thrown.expectMessage(allOf(containsString("email"), containsString("'not a well-formed email address'")));
    patientRepository.saveAndFlush(new TestPatientBuilder().withEmail("baz").build());
}
Also used : TestPatientBuilder(io.undertree.symptom.domain.TestPatientBuilder) Test(org.junit.Test) DataJpaTest(org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)

Example 10 with TestPatientBuilder

use of io.undertree.symptom.domain.TestPatientBuilder in project spring-boot-jpa by ssherwood.

the class PatientControllerWebTests method test_PatientController_addPatient_WithEmptyFamilyName_Expect_BadRequest.

@Test
public void test_PatientController_addPatient_WithEmptyFamilyName_Expect_BadRequest() throws Exception {
    ResponseEntity<String> json = restTemplate.postForEntity("/patients", new TestPatientBuilder().withFamilyName("").build(), String.class);
    assertThat(json.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
    JSONAssert.assertEquals("{exception:\"org.springframework.web.bind.MethodArgumentNotValidException\"}", json.getBody(), false);
}
Also used : TestPatientBuilder(io.undertree.symptom.domain.TestPatientBuilder) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

TestPatientBuilder (io.undertree.symptom.domain.TestPatientBuilder)12 Test (org.junit.Test)12 DataJpaTest (org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest)8 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 GivenName (io.undertree.symptom.domain.GivenName)3 Patient (io.undertree.symptom.domain.Patient)3 NotFoundException (io.undertree.symptom.exceptions.NotFoundException)1