Ejemplo n.º 1
0
  @Test
  public void test() throws Exception {

    SqlSession session = SessionFactory.getSession();
    AgileListDao agileListDao = session.getMapper(AgileListDao.class);

    try {

      AgileList agileList = TestAgileListDao.createAgileList();
      String where = "KEY='" + agileList.getKey() + "' ";
      Map<String, Object> map = new HashMap<String, Object>();
      map.put("where", where);

      int count = agileListDao.create(agileList);
      assertEquals(1, count);
      assertNotNull(agileList.getKey());

      AgileList readRecord = agileListDao.read(map);
      assertNotNull(readRecord.getKey());

      compareRecords(agileList, readRecord);

      List<AgileList> list1 = agileListDao.getListByStoryId(agileList.getStoryId());
      assertEquals(1, list1.size());
      compareRecords(agileList, list1.get(0));

      modifyRecord(agileList);
      count = agileListDao.update(agileList);
      assertEquals(1, count);

      readRecord = agileListDao.read(map);
      assertNotNull(readRecord.getKey());

      compareRecords(agileList, readRecord);

      count = agileListDao.delete(map);
      assertEquals(1, count);

      readRecord = agileListDao.read(map);
      assertNull(readRecord);

    } finally {
      if (session != null) {
        session.rollback();
        session.close();
      }
    }
  }