Ejemplo n.º 1
0
 /** Tests delete a User */
 public static void testDelete() {
   try {
     TimeTableModel model = new TimeTableModel();
     long pk = 1L;
     model.setId(pk);
     model.delete();
     System.out.println("Test Delete success " + model.getId());
     TimeTableModel deletedModel = model.findByPK(pk);
     if (deletedModel == null) {
       System.out.println("Test Delete fail");
     }
   } catch (ApplicationException e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 2
0
 /** Tests find a User by PK. */
 public static void testFindByPK() {
   try {
     TimeTableModel model = new TimeTableModel();
     model = model.findByPK(1L);
     if (model == null) {
       System.out.println("Test Find By PK fail");
     } else {
       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();
   }
 }
Ejemplo n.º 3
0
 /**
  * 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();
   }
 }
Ejemplo n.º 4
0
 /** Tests get List. */
 public static void testList() {
   try {
     TimeTableModel model = new TimeTableModel();
     List list = new ArrayList();
     list = model.list(1, 10);
     if (list.size() < 0) {
       System.out.println("Test list 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();
   }
 }
Ejemplo n.º 5
0
 /** 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();
   }
 }