Search in sources :

Example 1 with PersonDTO

use of com.example.helloworld.dto.PersonDTO in project liftwizard by motlin.

the class PeopleResource method createPerson.

@POST
@UnitOfWork
public PersonDTO createPerson(PersonDTO personDTO) {
    Person person = new Person();
    person.setFullName(personDTO.getFullName());
    person.setJobTitle(personDTO.getJobTitle());
    Person result = this.peopleDAO.create(person);
    return new PersonDTO(result.getId(), result.getFullName(), result.getJobTitle());
}
Also used : PersonDTO(com.example.helloworld.dto.PersonDTO) Person(com.example.helloworld.core.Person) UnitOfWork(io.dropwizard.hibernate.UnitOfWork) POST(javax.ws.rs.POST)

Example 2 with PersonDTO

use of com.example.helloworld.dto.PersonDTO in project liftwizard by motlin.

the class PersonResource method getPerson.

@GET
@UnitOfWork
public PersonDTO getPerson(@PathParam("personId") LongParam personId) {
    Person person = this.findSafely(personId.get());
    PersonDTO personDTO = new PersonDTO(personId.get(), person.getFullName(), person.getJobTitle());
    personDTO.setId(person.getId());
    return personDTO;
}
Also used : PersonDTO(com.example.helloworld.dto.PersonDTO) Person(com.example.helloworld.core.Person) UnitOfWork(io.dropwizard.hibernate.UnitOfWork) GET(javax.ws.rs.GET)

Example 3 with PersonDTO

use of com.example.helloworld.dto.PersonDTO in project liftwizard by motlin.

the class IntegrationTest method testPostPerson.

@Test
public void testPostPerson() throws Exception {
    final PersonDTO person = new PersonDTO("Dr. IntegrationTest", "Chief Wizard");
    final PersonDTO newPerson = this.postPerson(person);
    assertThat(newPerson.getId()).isNotNull();
    assertThat(newPerson.getFullName()).isEqualTo(person.getFullName());
    assertThat(newPerson.getJobTitle()).isEqualTo(person.getJobTitle());
}
Also used : PersonDTO(com.example.helloworld.dto.PersonDTO) Test(org.junit.Test)

Example 4 with PersonDTO

use of com.example.helloworld.dto.PersonDTO in project liftwizard by motlin.

the class IntegrationTest method testRenderingPerson.

private void testRenderingPerson(String viewName) throws Exception {
    final PersonDTO person = new PersonDTO("Dr. IntegrationTest", "Chief Wizard");
    final PersonDTO newPerson = this.postPerson(person);
    final String url = "http://localhost:" + dropwizardAppRule.getLocalPort() + "/people/" + newPerson.getId() + "/" + viewName;
    Response response = dropwizardAppRule.client().target(url).request().get();
    assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
}
Also used : Response(javax.ws.rs.core.Response) PersonDTO(com.example.helloworld.dto.PersonDTO)

Aggregations

PersonDTO (com.example.helloworld.dto.PersonDTO)4 Person (com.example.helloworld.core.Person)2 UnitOfWork (io.dropwizard.hibernate.UnitOfWork)2 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 Response (javax.ws.rs.core.Response)1 Test (org.junit.Test)1