/** Tests get Search */ public static void testSearch() { try { TimeTableModel model = new TimeTableModel(); List list = new ArrayList(); model.setSubject("O"); list = model.search(0, 0); if (list.size() < 0) { System.out.println("Test Serach fail"); } Iterator it = list.iterator(); while (it.hasNext()) { model = (TimeTableModel) it.next(); System.out.println(model.getId()); System.out.println(model.getBranch()); System.out.println(model.getSemester()); System.out.println(model.getYear()); System.out.println(model.getSubject()); System.out.println(model.getDate()); System.out.println(model.getTime()); System.out.println(model.getFaculty()); } } catch (ApplicationException e) { e.printStackTrace(); } }
/** Tests update a User */ public static void testUpdate() { try { TimeTableModel model = new TimeTableModel(); model = model.findByPK(1L); model.setSubject("OOT"); model.update(); TimeTableModel updatedModel = model.findByPK(1L); if (!"OOT".equals(updatedModel.getSubject())) { System.out.println("Test Update fail"); } } catch (ApplicationException e) { e.printStackTrace(); } }
/** * Tests add a User * * @throws ParseException * @throws DuplicateRecordException */ public static void testAdd() throws Exception { try { TimeTableModel model = new TimeTableModel(); model.setBranch("CS"); model.setSemester(1); model.setYear(2015); model.setSubject("DBMS"); model.setDate(new Date()); model.setTime("10:00 - 12:00 PM"); model.setFaculty("Ram"); long pk = model.add(); TimeTableModel addedModel = model.findByPK(pk); System.out.println("Test add success"); if (addedModel == null) { System.out.println("Test add fail"); } } catch (ApplicationException e) { e.printStackTrace(); } }