Exemplo n.º 1
0
  public static AgileList createAgileList() {
    AgileList agileList = new AgileList();

    agileList.setTitle(randomString("title", 40));
    agileList.setStoryId((long) 0);

    return agileList;
  }
Exemplo n.º 2
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();
      }
    }
  }
Exemplo n.º 3
0
  public static void modifyRecord(AgileList agileList) {

    agileList.setTitle(randomString("title", 40));
    agileList.setStoryId((long) 0);
  }
Exemplo n.º 4
0
  public static void compareRecords(AgileList agileList, AgileList readRecord) {

    assertEquals(agileList.getTitle(), readRecord.getTitle());
    assertEquals(agileList.getStoryId(), readRecord.getStoryId());
  }