@Test(expected = IllegalArgumentException.class) public void shouldNotAllowSpecifyingDefaultTypeOnGetAll() throws Exception { context.setType("order"); resource.getAll(context); }
@Test public void shouldGetAll() throws Exception { SimpleObject all = resource.getAll(context); Util.log("Get all", all); Assert.assertEquals(6, Util.getResultsSize(all)); // ensure the type property gets added when we return multiple Object typeForFirst = Util.getByPath(all, "results[0]/type"); Assert.assertTrue("drugorder".equals(typeForFirst) || "order".equals(typeForFirst)); }
/** * @see OrderResource1_8#doGetAll(RequestContext) * @verifies return all Orders (including retired) if context.includeAll is set */ @SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void doGetAll_shouldReturnAllOrdersIncludingRetiredIfContextincludeAllIsSet() throws Exception { OrderResource1_8 or = getResource(); RequestContext ctx = new RequestContext(); List<Object> orderList = (List) or.getAll(ctx).get("results"); Assert.assertEquals("getAll should return all not voided orders from sample data", 5, orderList.size()); voidOneOrder(); orderList = (List) or.getAll(ctx).get("results"); Assert.assertEquals("getAll should return all not voided orders from sample data", 4, orderList.size()); ctx.setIncludeAll(true); orderList = (List) or.getAll(ctx).get("results"); Assert.assertEquals("getAll should return all orders from sample data", 5, orderList.size()); }
@Test public void shouldGetAllOfSubclass() throws Exception { context.setType("drugorder"); SimpleObject all = resource.getAll(context); Util.log("Get all of subclass", all); Assert.assertEquals(5, Util.getResultsSize(all)); Assert.assertEquals("drugorder", Util.getByPath(all, "results[0]/type")); }