diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-rest-runtime/src/test')
2 files changed, 23 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java index f30176f70a..9ffe8fe931 100644 --- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java +++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/Catalog.java @@ -19,9 +19,12 @@ package services.store; +import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; import org.oasisopen.sca.annotation.Remotable; @@ -30,11 +33,19 @@ import org.oasisopen.sca.annotation.Remotable; public interface Catalog { @GET - Item[] get(); + Item[] getItem(); + + @GET + @Path("{id}") + Item getItemById(@PathParam("id") String itemId); @POST void addItem(Item item); @PUT void updateItem(Item item); + + @DELETE + @Path("{id}") + void deleteItem(@PathParam("id") String itemId); } diff --git a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java index b71bb28596..c7a9807878 100644 --- a/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java +++ b/sca-java-2.x/trunk/modules/binding-rest-runtime/src/test/java/services/store/FruitsCatalogImpl.java @@ -46,12 +46,16 @@ public class FruitsCatalogImpl implements Catalog { catalog.put("Pear", new Item("Pear", currencySymbol + currencyConverter.getConversion("USD", currencyCode, 1.55))); } - public Item[] get() { + public Item[] getItem() { Item[] catalogArray = new Item[catalog.size()]; catalog.values().toArray(catalogArray); return catalogArray; } + public Item getItemById(String itemId) { + return catalog.get(itemId); + } + public void addItem(Item item) { catalog.put(item.getName(),item); } @@ -61,4 +65,10 @@ public class FruitsCatalogImpl implements Catalog { catalog.put(item.getName(), item); } } + + public void deleteItem(String itemId) { + if(catalog.get(itemId) != null) { + catalog.remove(itemId); + } + } } |