Exemplo n.º 1
0
 public void test_toLTK_Change_SourceChange() throws Exception {
   Source source = createTestFileSource();
   // fill SourceChange
   SourceChange sourceChange = new SourceChange("My change", source);
   sourceChange.addEdit(new Edit(10, 1, "a"));
   sourceChange.addEdit(new Edit(20, 2, "b"));
   // toLTK
   TextFileChange ltkChange = (TextFileChange) ServiceUtils.toLTK((Change) sourceChange);
   assertEquals("My change", ltkChange.getName());
 }
Exemplo n.º 2
0
 public void test_toLTK_SourceChange_noGroups() throws Exception {
   Source source = createTestFileSource();
   // fill SourceChange
   SourceChange sourceChange = new SourceChange("My change", source);
   sourceChange.addEdit(new Edit(10, 1, "a"));
   sourceChange.addEdit(new Edit(20, 2, "b"));
   // toLTK
   TextFileChange ltkChange = ServiceUtils.toLTK(sourceChange);
   assertEquals("My change", ltkChange.getName());
   // no groups
   TextEditBasedChangeGroup[] changeGroups = ltkChange.getChangeGroups();
   assertThat(changeGroups).isEmpty();
   // check edits
   MultiTextEdit multiTextEdit = (MultiTextEdit) ltkChange.getEdit();
   TextEdit[] textEdits = multiTextEdit.getChildren();
   assertThat(textEdits).hasSize(2);
   assertEquals("a", ((ReplaceEdit) textEdits[0]).getText());
   assertEquals("b", ((ReplaceEdit) textEdits[1]).getText());
 }
Exemplo n.º 3
0
 public void test_toLTK_SourceChange_withGroups() throws Exception {
   Source source = createTestFileSource();
   // fill SourceChange
   SourceChange sourceChange = new SourceChange("My change", source);
   sourceChange.addEdit(new Edit(10, 1, "a1"), "groupA");
   sourceChange.addEdit(new Edit(20, 2, "a2"), "groupA");
   sourceChange.addEdit(new Edit(30, 3, "b"), "groupB");
   // toLTK
   TextFileChange ltkChange = ServiceUtils.toLTK(sourceChange);
   assertEquals("My change", ltkChange.getName());
   TextEditBasedChangeGroup[] changeGroups = ltkChange.getChangeGroups();
   assertThat(changeGroups).hasSize(2);
   {
     TextEditBasedChangeGroup group = changeGroups[0];
     assertEquals("groupA", group.getName());
     TextEdit[] textEdits = group.getTextEdits();
     assertThat(textEdits).hasSize(2);
     assertEquals("a1", ((ReplaceEdit) textEdits[0]).getText());
     assertEquals("a2", ((ReplaceEdit) textEdits[1]).getText());
   }
 }