@Test public void testGetOrderId() { EntityManager em = mytools.DBUtil.getEmFactory().createEntityManager(); try { DemoOrder order = em.find(DemoOrder.class, (long) 1); assertEquals(order.getOrderId(), 1); } catch (Exception e) { fail(e.getMessage()); } }
@Test public void testGetOrderTotal() { EntityManager em = mytools.DBUtil.getEmFactory().createEntityManager(); try { BigDecimal bd = new BigDecimal(1890); DemoOrder order = em.find(DemoOrder.class, (long) 1); assertEquals(order.getOrderTotal(), bd); } catch (Exception e) { fail(e.getMessage()); fail("Not yet implemented"); } }
@Test public void testGetOrderTimestamp() { Calendar calendar = new GregorianCalendar(2015, 6, 9); Date date = calendar.getTime(); EntityManager em = mytools.DBUtil.getEmFactory().createEntityManager(); try { DemoOrder order = em.find(DemoOrder.class, (long) 1); assertEquals(order.getOrderTimestamp(), date); } catch (Exception e) { fail(e.getMessage()); fail("Not yet implemented"); } }
@Test public void testGetDemoUser() { EntityManager em = mytools.DBUtil.getEmFactory().createEntityManager(); try { DemoOrder order = em.find(DemoOrder.class, (long) 1); DemoUser user = em.find(DemoUser.class, (long) 2); assertEquals(order.getDemoUser().getUserId(), user.getUserId()); } catch (Exception e) { fail(e.getMessage()); fail("Not yet implemented"); } }
@Test public void testGetDemoOrderItems() { EntityManager em = mytools.DBUtil.getEmFactory().createEntityManager(); try { DemoOrder order = em.find(DemoOrder.class, (long) 1); List<DemoOrderItem> orderitemList = order.getDemoOrderItems(); System.out.println(orderitemList); assertEquals(orderitemList.size(), 3); } catch (Exception e) { fail(e.getMessage()); fail("Not yet implemented"); } }
@Test public void testSetDemoCustomer() { EntityManager em = mytools.DBUtil.getEmFactory().createEntityManager(); try { DemoOrder order = em.find(DemoOrder.class, (long) 1); DemoCustomer cust = em.find(DemoCustomer.class, (long) 7); cust.setCustomerId((long) 100); assertEquals(order.getDemoCustomer().getCustomerId(), cust.getCustomerId()); } catch (Exception e) { fail(e.getMessage()); fail("Not yet implemented"); } }