Package br.com.caelum.example.model

Examples of br.com.caelum.example.model.Item


  }

  @Get
  @Path("/items/{id}")
  public void show(int id) {
    Item item = database.get(id);
    result.use(representation()).from(item).serialize();
  }
View Full Code Here


  }

  @Get
  @Path("/items/{id}")
  public void show(int id) {
    Item item = database.get(id);
    result.use(representation()).from(item).serialize();
  }
View Full Code Here

  private int contador = 0;
  private final List<Item> items;

  public Database() {
    this.items = new ArrayList<Item>();
    this.adiciona(new Item("Chave", 20.0));
    this.adiciona(new Item("Lousa", 35.0));
  }
View Full Code Here

  @Test
  public void shouldBeAbleToGetAnItemWithHypermedia() throws Exception {

    Response response = restfulie.at("http://localhost:8080/restfulie/items/2").accept("application/xml").get();
    Item item = response.getResource();

    assertNotNull(item);
    assertNotNull(item.getName());

    System.out.println(item.getName());

    assertTrue(resource(item).hasLink("self"));

    System.out.println(resource(item).getLink("self").getHref());
View Full Code Here

  }

  @Test
  public void shouldBeAbleToPostAnItemWithHypermedia() throws Exception {
    Item item = new Item("pipa", 299.0);
    Response response = restfulie.at("http://localhost:8080/restfulie/items").as("application/xml").post(item);

    Item savedItem = response.getResource();
    assertNotSame(item, savedItem);

    assertEquals("pipa", savedItem.getName());
    assertEquals(Double.valueOf(299.0), savedItem.getPrice());
    assertNotNull(savedItem.getId());
    System.out.println(savedItem.getId());

    assertTrue(resource(savedItem).hasLink("self"));
    System.out.println(savedItem.getName());
  }
View Full Code Here

  @Test
  public void shouldBeAbleToGetAnItem() throws Exception {

    Response response = restfulie.at("http://localhost:8080/restfulie/items/2").accept("application/xml").get();
    Item item = response.getResource();

    assertNotNull(item);

    assertNotNull(item.getName());

    System.out.println(item.getName());

  }
View Full Code Here

  }

  @Test
  public void shouldBeAbleToPostAnItem() throws Exception {
    Item item = new Item("pipa", 299.0);
    Response response = restfulie.at("http://localhost:8080/restfulie/items")
      .accept("application/xml")
      .as("application/xml")
      .post(item);

    Item savedItem = response.getResource();
    assertNotSame(item, savedItem);

    assertEquals("pipa", savedItem.getName());
    assertEquals(Double.valueOf(299.0), savedItem.getPrice());
    assertNotNull(savedItem.getId());
    System.out.println(savedItem.getId());

  }
View Full Code Here

TOP

Related Classes of br.com.caelum.example.model.Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.