use of org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.ChildWithSubChild in project xtext-core by eclipse.
the class ChangeSerializerTest method testAddElements.
@Test
public void testAddElements() {
String uri = "inmemory:/file-add.pstl";
InMemoryURIHandler fs = new InMemoryURIHandler();
changeSerializerTestHelper.operator_add(fs, Pair.of(uri, "#23"));
ResourceSet rs = changeSerializerTestHelper.createResourceSet(fs);
ChildWithSubChilds model = changeSerializerTestHelper.findFirstOfTypeInFile(rs, uri, ChildWithSubChilds.class);
IChangeSerializer serializer = changeSerializerTestHelper.newChangeSerializer();
serializer.addModification(model.eResource(), (Resource it) -> {
ChildWithSubChild newChildWithSubChild = fac.createChildWithSubChild();
SubChild newSubChild1 = fac.createSubChild();
newSubChild1.setName("A");
newChildWithSubChild.getSubChilds().add(newSubChild1);
model.getChildren().add(newChildWithSubChild);
SubChild newSubChild = fac.createSubChild();
newSubChild.setName("A2");
model.getChildren().get(0).getSubChilds().add(newSubChild);
});
Collection<IEmfResourceChange> changes = changeSerializerTestHelper.endRecordChangesToTextDocuments(serializer);
String expectation = "--------------- inmemory:/file-add.pstl (syntax: <offset|text>) ----------------\n" + "<0:3|#23 subs A A2>\n" + "--------------------------------------------------------------------------------\n" + "0 3 \"#23\" -> \"#23 subs A A2\"\n";
changeSerializerTestHelper.operator_tripleEquals(changes, expectation);
}
Aggregations