@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));
 }
 @Before
 public void setUp() throws Exception {
   db = new DatabaseController(":memory:");
   t = new Training("Training");
   s1 = iset(1);
   s2 = iset(2);
   s3 = iset(3);
   db.getTblTraining().addTraining(t);
   db.getTblSet().addSet(s1.getSet());
   db.getTblSet().addSet(s2.getSet());
   db.getTblSet().addSet(s3.getSet());
 }
Example #3
0
 private void populate() {
   try {
     allStrokes =
         new FilteredList<>(
             FXCollections.observableArrayList(db.getTblSetStroke().getAllStrokes()));
     strokes.setItems(allStrokes);
   } catch (Exception e) {
     ExceptionAlert.showError(LOGGER, lang.format("error.load", "error.subj.stroke"), e);
   }
 }
Example #4
0
 private void onDelete() {
   SetStroke item = strokes.getSelectionModel().getSelectedItem();
   if (item != null) {
     try {
       db.getTblSetStroke().deleteSetStroke(item);
     } catch (Exception e) {
       ExceptionAlert.showError(LOGGER, lang.format("error.load", "error.subj.stroke"), e);
     }
     eventBus.post(new StrokeEvent.StrokeDeleteEvent(item));
   }
 }
  @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;
    }
  }
 @After
 public void tearDown() throws Exception {
   db.close();
 }