use of org.jboss.arquillian.junit.InSequence in project quickstart by wildfly.
the class ContactRegistrationIT method shouldCreateAndDeleteAContact.
@Test
@RunAsClient
@InSequence(6)
public void shouldCreateAndDeleteAContact(@ArquillianResource URL contextPath) throws JAXBException {
Contact contact = createContactInstance("Jason", "Smith", "jason@mailinator.com", "2125551234", date);
// POSTs a Contact
Client client = ClientBuilder.newClient();
URI uri = UriBuilder.fromUri(contextPath + REST_ROOT).port(8080).build();
Response response = client.target(uri).request().post(Entity.entity(contact, MediaType.APPLICATION_JSON));
assertEquals(Response.Status.CREATED, response.getStatusInfo());
URI contactURI = response.getLocation();
// With the location, GETs the Contact
client.close();
client = ClientBuilder.newClient();
response = client.target(contactURI).request().get();
contact = response.readEntity(Contact.class);
assertEquals(Response.Status.OK, response.getStatusInfo());
assertEquals("Jason", contact.getFirstName());
// GETs the Contact ID and DELETEs it
String contactID = contactURI.toString().split("/")[6];
response = client.target(uri).path(contactID).request().delete();
assertEquals(Response.Status.NO_CONTENT, response.getStatusInfo());
// GETs the Contact and checks if it has been deleted
client.close();
client = ClientBuilder.newClient();
response = client.target(uri).path(contactID).request().get();
assertEquals(Response.Status.NOT_FOUND, response.getStatusInfo());
client.close();
}
use of org.jboss.arquillian.junit.InSequence in project quickstart by wildfly.
the class ContactRegistrationIT method shouldNotCreateANullContact.
@Test
@RunAsClient
@InSequence(4)
public void shouldNotCreateANullContact(@ArquillianResource URL contextPath) throws JAXBException, URISyntaxException {
// POSTs a null Contact
Client client = ClientBuilder.newClient();
URI uri = UriBuilder.fromUri(contextPath.toURI()).path(REST_ROOT).port(8080).build();
Response response = client.target(uri).request().post(Entity.entity("{}", MediaType.APPLICATION_JSON));
assertEquals(Response.Status.BAD_REQUEST, response.getStatusInfo());
client.close();
}
use of org.jboss.arquillian.junit.InSequence in project quickstart by wildfly.
the class TaskDaoIT method taskDao_should_remove_task_from_detachedUser.
@Test
@InSequence(5)
public void taskDao_should_remove_task_from_detachedUser() {
// given
Task task = new Task();
task.setId(1L);
task.setOwner(detachedUser);
assertEquals(2, taskDao.getAll(detachedUser).size());
// when
taskDao.deleteTask(task);
// then
assertEquals(1, taskDao.getAll(detachedUser).size());
}
use of org.jboss.arquillian.junit.InSequence in project quickstart by wildfly.
the class TaskDaoIT method user_should_be_created_with_one_task_attached.
@Test
@InSequence(1)
public void user_should_be_created_with_one_task_attached() throws Exception {
// given
User user = new User("New user");
Task task = new Task("New task");
// when
em.persist(user);
taskDao.createTask(user, task);
List<Task> userTasks = em.createQuery("SELECT t FROM Task t WHERE t.owner = :owner", Task.class).setParameter("owner", user).getResultList();
// then
assertEquals(1, userTasks.size());
assertEquals(task, userTasks.get(0));
}
use of org.jboss.arquillian.junit.InSequence in project javaee7-samples by javaee-samples.
the class ApplicationSingletonResourceTest method testDelete.
@Test
@InSequence(3)
public void testDelete() {
target.path("kiwi").request().delete();
String list = target.request().get(String.class);
StringTokenizer tokens = new StringTokenizer(list, ",");
assertEquals(3, tokens.countTokens());
}
Aggregations