package com.temenos.interaction.rimdsl; /* * #%L * com.temenos.interaction.rimdsl.tests * %% * Copyright (C) 2012 - 2013 Temenos Holdings N.V. * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * #L% */ import static org.junit.Assert.*; import org.eclipse.xtext.generator.IFileSystemAccess; import org.eclipse.xtext.generator.IGenerator; import org.eclipse.xtext.generator.InMemoryFileSystemAccess; import org.eclipse.xtext.junit4.InjectWith; import org.eclipse.xtext.junit4.XtextRunner; import org.eclipse.xtext.junit4.util.ParseHelper; import org.junit.Test; import org.junit.runner.RunWith; import com.google.inject.Inject; import com.temenos.interaction.rimdsl.rim.DomainModel; @InjectWith(RIMDslInjectorProvider.class) @RunWith(XtextRunner.class) public class PackagesGeneratorTest { @Inject IGenerator underTest; @Inject ParseHelper<DomainModel> parseHelper; private final static String LINE_SEP = System.getProperty("line.separator"); private final static String MULTIPLE_RIMS = "" + "domain blah {" + LINE_SEP + "rim Test {" + LINE_SEP + " command GetEntity" + LINE_SEP + "initial resource A {" + LINE_SEP + " type: collection" + LINE_SEP + " entity: ENTITY" + LINE_SEP + " view: GetEntity" + LINE_SEP + "}" + LINE_SEP + "}" + LINE_SEP + "rim Test2 {" + LINE_SEP + " command GetEntity" + LINE_SEP + "initial resource A {" + LINE_SEP + " type: collection" + LINE_SEP + " entity: ENTITY" + LINE_SEP + " view: GetEntity" + LINE_SEP + "}" + LINE_SEP + "}" + LINE_SEP + "}" + LINE_SEP + ""; /* * doGenerate should produce one file per rim */ @Test public void testGenerateMulti() throws Exception { DomainModel domainModel = parseHelper.parse(MULTIPLE_RIMS); InMemoryFileSystemAccess fsa = new InMemoryFileSystemAccess(); underTest.doGenerate(domainModel.eResource(), fsa); System.out.println(fsa.getFiles()); assertEquals(4, fsa.getFiles().size()); assertTrue(fsa.getFiles().containsKey(IFileSystemAccess.DEFAULT_OUTPUT + "blah/TestBehaviour.java")); assertTrue(fsa.getFiles().containsKey(IFileSystemAccess.DEFAULT_OUTPUT + "blah/Test/AResourceState.java")); assertTrue(fsa.getFiles().containsKey(IFileSystemAccess.DEFAULT_OUTPUT + "blah/Test2Behaviour.java")); assertTrue(fsa.getFiles().containsKey(IFileSystemAccess.DEFAULT_OUTPUT + "blah/Test2/AResourceState.java")); } }