use of org.eclipse.vorto.editor.mapping.MappingStandaloneSetup in project vorto by eclipse.
the class ModelSerializerTest method testSerializeMappingWithVortolang.
@Test
public void testSerializeMappingWithVortolang() throws Exception {
final Injector injector = new MappingStandaloneSetup().createInjectorAndDoEMFRegistration();
final XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
ModelWorkspaceReader.init();
IModelWorkspace workspace = IModelWorkspace.newReader().addFile(getClass().getClassLoader().getResourceAsStream("dsls/sample.mapping"), org.eclipse.vorto.model.ModelType.Mapping).read();
Model model = workspace.get().get(0);
final Resource resource = resourceSet.createResource(URI.createURI(model.getName() + ".mapping"));
resource.getContents().add(model);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
final Map<Object, Object> optionsMap = SaveOptions.newBuilder().format().getOptions().toOptionsMap();
optionsMap.put(XtextResource.OPTION_ENCODING, StandardCharsets.UTF_8);
resource.save(baos, optionsMap);
assertTrue(equalsIgnoreNewlineStyle(IOUtils.toString(Thread.currentThread().getContextClassLoader().getResourceAsStream("dsls/sample.mapping")), new String(baos.toByteArray(), StandardCharsets.UTF_8)));
}
Aggregations