Search in sources :

Example 1 with Person

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

the class IntegrationTest method testRenderingPerson.

@ParameterizedTest
@ValueSource(strings = { "view_freemarker", "view_mustache" })
void testRenderingPerson(String viewName) {
    final Person person = new Person("Dr. IntegrationTest", "Chief Wizard", 1525);
    final Person newPerson = postPerson(person);
    final String url = "http://localhost:" + APP.getLocalPort() + "/people/" + newPerson.getId() + "/" + viewName;
    Response response = APP.client().target(url).request().get();
    assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
}
Also used : Response(javax.ws.rs.core.Response) Person(com.example.helloworld.core.Person) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with Person

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

the class PersonDAOIntegrationTest 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 3 with Person

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

the class PeopleResourceTest method createPerson.

@Test
void createPerson() {
    when(PERSON_DAO.create(any(Person.class))).thenReturn(person);
    final Response response = RESOURCES.target("/people").request(MediaType.APPLICATION_JSON_TYPE).post(Entity.entity(person, MediaType.APPLICATION_JSON_TYPE));
    assertThat(response.getStatusInfo()).isEqualTo(Response.Status.OK);
    verify(PERSON_DAO).create(personCaptor.capture());
    assertThat(personCaptor.getValue()).isEqualTo(person);
}
Also used : Response(javax.ws.rs.core.Response) Person(com.example.helloworld.core.Person) Test(org.junit.jupiter.api.Test)

Example 4 with Person

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

the class DockerIntegrationTest method testRenderingPerson.

@ParameterizedTest
@ValueSource(strings = { "view_freemarker", "view_mustache" })
void testRenderingPerson(String viewName) {
    final Person person = new Person("Dr. IntegrationTest", "Chief Wizard", 1525);
    final Person newPerson = postPerson(person);
    final String url = "http://localhost:" + APP.getLocalPort() + "/people/" + newPerson.getId() + "/" + viewName;
    Response response = APP.client().target(url).request().get();
    assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
}
Also used : Response(javax.ws.rs.core.Response) Person(com.example.helloworld.core.Person) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with Person

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

the class IntegrationTest method testPostPerson.

@Test
void testPostPerson() {
    final Person person = new Person("Dr. IntegrationTest", "Chief Wizard", 1525);
    final Person newPerson = postPerson(person);
    assertThat(newPerson.getFullName()).isEqualTo(person.getFullName());
    assertThat(newPerson.getJobTitle()).isEqualTo(person.getJobTitle());
}
Also used : Person(com.example.helloworld.core.Person) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Person (com.example.helloworld.core.Person)12 Test (org.junit.jupiter.api.Test)8 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 Response (javax.ws.rs.core.Response)3 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ValueSource (org.junit.jupiter.params.provider.ValueSource)2