コード例 #1
0
 @Test
 public void testDeleteSet() throws Exception {
   db.getTblTrainingContent().addSet(t, s1.getSet(), s1.getIndex());
   db.getTblTrainingContent().addSet(t, s2.getSet(), s2.getIndex());
   db.getTblTrainingContent().deleteSet(t, s1.getSet(), s1.getIndex());
   List<IndexedSet> sets = db.getTblTrainingContent().getSets(t);
   assertEquals(1, sets.size());
   assertTrue(sets.contains(s2));
 }
コード例 #2
0
  @Test
  public void testUpdateIndexUp() throws Exception {

    db.getTblTrainingContent().addSet(t, s1.getSet(), s1.getIndex());
    db.getTblTrainingContent().addSet(t, s2.getSet(), s2.getIndex());

    List<IndexedSet> before = db.getTblTrainingContent().getSets(t);
    db.getTblTrainingContent().updateIndex(t, s2.getIndex(), true);
    List<IndexedSet> sets = db.getTblTrainingContent().getSets(t);
    Assert.assertNotEquals(before, sets);
    IndexedSet i1 = sets.get(0).getSet().getId() == 1 ? sets.get(0) : sets.get(1);
    IndexedSet i2 = sets.get(1).getSet().getId() == 2 ? sets.get(1) : sets.get(0);
    try {
      Assert.assertEquals(2, i1.getIndex());
      Assert.assertEquals(1, i2.getIndex());
    } catch (AssertionError e) {
      LOGGER.warn(s1);
      LOGGER.warn(s2);
      LOGGER.warn(i1);
      LOGGER.warn(i2);
      throw e;
    }
  }