Review corrections
This commit is contained in:
parent
987c55e934
commit
15f3c94023
|
@ -1,5 +1,8 @@
|
|||
package com.baeldung.openliberty.person.resource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.transaction.Transactional;
|
||||
|
@ -16,7 +19,7 @@ import com.baeldung.openliberty.person.dao.PersonDao;
|
|||
import com.baeldung.openliberty.person.model.Person;
|
||||
|
||||
@RequestScoped
|
||||
@Path("person")
|
||||
@Path("persons")
|
||||
public class PersonResource {
|
||||
|
||||
@Inject
|
||||
|
@ -24,9 +27,11 @@ public class PersonResource {
|
|||
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Person getPerson() {
|
||||
Person person = new Person(1, "normanlewis", "normanlewis@email.com");
|
||||
return person;
|
||||
public List<Person> getAllPerson() {
|
||||
Person person = new Person(1, "normanlewis", "normanlewis@email.com");
|
||||
List<Person> persons = new ArrayList<>();
|
||||
persons.add(person);
|
||||
return persons;
|
||||
}
|
||||
|
||||
@POST
|
||||
|
@ -35,7 +40,7 @@ public class PersonResource {
|
|||
public Response addPerson(Person person) {
|
||||
personDao.createPerson(person);
|
||||
String respMessage = "Person #" + person.getId() + " created successfully.";
|
||||
return Response.status(Response.Status.OK).entity(respMessage).build();
|
||||
return Response.status(Response.Status.CREATED).entity(respMessage).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
|
|
|
@ -14,7 +14,7 @@ public class RestClientTest {
|
|||
|
||||
private static String BASE_URL;
|
||||
|
||||
private final String API_PERSON = "api/person";
|
||||
private final String API_PERSON = "api/persons";
|
||||
|
||||
@BeforeClass
|
||||
public static void oneTimeSetup() {
|
||||
|
@ -24,11 +24,11 @@ public class RestClientTest {
|
|||
@Test
|
||||
public void testSuite() {
|
||||
//run the test only when liberty server is started
|
||||
//this.whenConsumeWithJsonb_thenGetPerson();
|
||||
this.whenConsumeWithJsonb_thenGetPerson();
|
||||
}
|
||||
|
||||
public void whenConsumeWithJsonb_thenGetPerson() {
|
||||
String url = BASE_URL + API_PERSON;
|
||||
String url = BASE_URL + API_PERSON + "/1";
|
||||
String result = RestConsumer.consumeWithJsonb(url);
|
||||
|
||||
Person person = JsonbBuilder.create().fromJson(result, Person.class);
|
||||
|
|
Loading…
Reference in New Issue