use of br.com.caelum.example.model.Payment in project restfulie-java by caelum.
the class ClientTests method shouldBeAbleToNavigateThroughLinks.
@Test
public void shouldBeAbleToNavigateThroughLinks() throws Exception {
Response response = restfulie.at("http://localhost:8080/restfulie/items").accept(XML).get();
List<Item> items = response.getResource();
assertNotNull(items);
assertFalse(items.isEmpty());
List<Item> selectedItems = items.subList(0, 2);
assertTrue(resource(items).hasLink("basket"));
response = resource(items).getLink("basket").follow().as(XML).accept(XML).post(new Basket(selectedItems));
Basket basket = response.getResource();
assertNotNull(basket.getId());
assertEquals(basket.getItems().size(), selectedItems.size());
System.out.println(basket.getItems());
assertTrue(resource(basket).hasLink("payment"));
response = resource(basket).getLink("payment").follow().as(XML).accept(XML).post(new Payment(basket.getCost()));
Payment payment = response.getResource();
assertEquals(Status.ACCEPTED, payment.getStatus());
System.out.println(payment.getStatus());
}