Search in sources :

Example 11 with Person

use of com.example.helloworld.core.Person in project dropwizard by dropwizard.

the class PersonDAOTest method findAll.

@Test
void findAll() {
    daoTestRule.inTransaction(() -> {
        personDAO.create(new Person("Jeff", "The plumber", 1975));
        personDAO.create(new Person("Jim", "The cook", 1985));
        personDAO.create(new Person("Randy", "The watchman", 1995));
    });
    final List<Person> persons = personDAO.findAll();
    assertThat(persons).extracting("fullName").containsOnly("Jeff", "Jim", "Randy");
    assertThat(persons).extracting("jobTitle").containsOnly("The plumber", "The cook", "The watchman");
    assertThat(persons).extracting("yearBorn").containsOnly(1975, 1985, 1995);
}
Also used : Person(com.example.helloworld.core.Person) Test(org.junit.jupiter.api.Test)

Example 12 with Person

use of com.example.helloworld.core.Person in project dropwizard by dropwizard.

the class PersonDAOTest method createPerson.

@Test
void createPerson() {
    final Person jeff = daoTestRule.inTransaction(() -> personDAO.create(new Person("Jeff", "The plumber", 1995)));
    assertThat(jeff.getId()).isPositive();
    assertThat(jeff.getFullName()).isEqualTo("Jeff");
    assertThat(jeff.getJobTitle()).isEqualTo("The plumber");
    assertThat(jeff.getYearBorn()).isEqualTo(1995);
    assertThat(personDAO.findById(jeff.getId())).isEqualTo(Optional.of(jeff));
}
Also used : Person(com.example.helloworld.core.Person) Test(org.junit.jupiter.api.Test)

Example 13 with Person

use of com.example.helloworld.core.Person in project dropwizard by dropwizard.

the class PeopleResourceTest method setUp.

@BeforeEach
void setUp() {
    person = new Person();
    person.setFullName("Full Name");
    person.setJobTitle("Job Title");
    person.setYearBorn(1995);
}
Also used : Person(com.example.helloworld.core.Person) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with Person

use of com.example.helloworld.core.Person in project dropwizard by dropwizard.

the class PersonResourceTest method getPersonSuccess.

@Test
void getPersonSuccess() {
    final Person person = new Person();
    person.setId(1L);
    when(DAO.findById(1L)).thenReturn(Optional.of(person));
    Person found = RULE.target("/people/1").request().get(Person.class);
    assertThat(found.getId()).isEqualTo(person.getId());
    verify(DAO).findById(1L);
}
Also used : Person(com.example.helloworld.core.Person) Test(org.junit.jupiter.api.Test)

Aggregations

Person (com.example.helloworld.core.Person)14 Test (org.junit.jupiter.api.Test)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 Response (javax.ws.rs.core.Response)3 PersonDTO (com.example.helloworld.dto.PersonDTO)2 UnitOfWork (io.dropwizard.hibernate.UnitOfWork)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ValueSource (org.junit.jupiter.params.provider.ValueSource)2 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1