Package: AcceleoTraceabilityLibraryStringTests

AcceleoTraceabilityLibraryStringTests

nameinstructionbranchcomplexitylinemethod
AcceleoTraceabilityLibraryStringTests()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringCollection()
M: 273 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 56 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringCollectionFirst()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringCollectionFirst2()
M: 171 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringCollectionFirst3()
M: 171 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 35 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringCollectionLast()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringCollectionLast2()
M: 171 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringCollectionLast3()
M: 171 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 35 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringCollectionReverse()
M: 273 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 56 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringCollectionReverse2()
M: 387 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 85 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringCollectionSep()
M: 377 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 78 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringCollectionSep2()
M: 543 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 118 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringContains()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringEndsWith()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringEqualsIgnoreCase()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringFirst()
M: 171 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringIndex()
M: 171 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringIsAlpha()
M: 171 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringIsAlpha2()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringIsAlphaNum()
M: 171 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringIsAlphaNum2()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringLast()
M: 171 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringLastIndex()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringMatches()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringReplace()
M: 289 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 56 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringReplaceAll()
M: 341 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 67 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringReplaceAllFirstLast()
M: 585 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 122 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringReplaceAllQuery()
M: 481 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 100 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringReplaceAllTemplate()
M: 481 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 100 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringReplaceQuery()
M: 289 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 56 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringReplaceTemplate()
M: 289 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 56 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringStartsWith()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringStrCmp()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringStrStr()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringStrTok()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringSubstitute()
M: 289 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 56 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringSubstituteAll()
M: 585 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 122 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringSubstring()
M: 171 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringToLowerFirst()
M: 183 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringToUpperFirst()
M: 183 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringTokenize()
M: 325 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 67 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringTokenize2()
M: 533 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 111 C: 0
0%
M: 1 C: 0
0%
testTraceabilityLibraryStringTrim()
M: 169 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 34 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2009, 2012 Obeo.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * Obeo - initial API and implementation
10: *******************************************************************************/
11: package org.eclipse.acceleo.traceability.tests.unit.library;
12:
13: import static org.junit.Assert.assertEquals;
14: import static org.junit.Assert.assertTrue;
15:
16: import java.util.List;
17:
18: import org.eclipse.acceleo.traceability.GeneratedFile;
19: import org.eclipse.acceleo.traceability.GeneratedText;
20: import org.eclipse.acceleo.traceability.InputElement;
21: import org.eclipse.acceleo.traceability.ModuleElement;
22: import org.eclipse.acceleo.traceability.tests.unit.AbstractTraceabilityTest;
23: import org.eclipse.acceleo.traceability.tests.unit.AcceleoTraceabilityListener;
24: import org.eclipse.emf.ecore.EClass;
25: import org.eclipse.emf.ecore.EObject;
26: import org.eclipse.ocl.ecore.PropertyCallExp;
27: import org.eclipse.ocl.ecore.StringLiteralExp;
28: import org.eclipse.ocl.utilities.ASTNode;
29: import org.junit.Test;
30:
31: public class AcceleoTraceabilityLibraryStringTests extends AbstractTraceabilityTest {
32:
33:         @Test
34:         public void testTraceabilityLibraryStringReplace() {
35:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
36:                                 "data/library/string/stringReplace.mtl", //$NON-NLS-1$
37:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
38:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
39:                 assertEquals(4, generatedFiles.size());
40:
41:                 int cpt = 1;
42:•                for (GeneratedFile generatedFile : generatedFiles) {
43:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
44:                         assertEquals(3, generatedRegions.size());
45:                         assertEquals(("clazs" + cpt).length(), generatedFile.getLength()); //$NON-NLS-1$
46:
47:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
48:                         assertEquals(2, sourceElements.size()); // the class and its name
49:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
50:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
51:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
52:
53:                         GeneratedText generatedText = generatedRegions.get(0);
54:                         assertEquals(0, generatedText.getStartOffset());
55:                         assertEquals("cla".length(), generatedText.getEndOffset()); //$NON-NLS-1$
56:                         ModuleElement moduleElement = generatedText.getModuleElement();
57:                         EObject element = moduleElement.getModuleElement();
58:                         assertTrue(element instanceof ASTNode);
59:                         assertTrue(element instanceof PropertyCallExp);
60:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
61:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
62:                         assertEquals(180, propertyCallExp.getStartPosition());
63:                         assertEquals(180 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
64:
65:                         generatedText = generatedRegions.get(2);
66:                         assertEquals("cla".length(), generatedText.getStartOffset()); //$NON-NLS-1$
67:                         assertEquals("claz".length(), generatedText.getEndOffset()); //$NON-NLS-1$
68:                         moduleElement = generatedText.getModuleElement();
69:                         element = moduleElement.getModuleElement();
70:                         assertTrue(element instanceof ASTNode);
71:                         assertTrue(element instanceof StringLiteralExp);
72:                         StringLiteralExp string = (StringLiteralExp)element;
73:                         assertEquals("z", string.getStringSymbol()); //$NON-NLS-1$
74:                         assertEquals(205, string.getStartPosition());
75:                         assertEquals(205 + "'z'".length(), string.getEndPosition()); //$NON-NLS-1$
76:
77:                         generatedText = generatedRegions.get(1);
78:                         assertEquals("claz".length(), generatedText.getStartOffset()); //$NON-NLS-1$
79:                         assertEquals(("clazs" + cpt).length(), generatedText.getEndOffset()); //$NON-NLS-1$
80:                         moduleElement = generatedText.getModuleElement();
81:                         element = moduleElement.getModuleElement();
82:                         assertTrue(element instanceof ASTNode);
83:                         assertTrue(element instanceof PropertyCallExp);
84:                         propertyCallExp = (PropertyCallExp)element;
85:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
86:                         assertEquals(180, propertyCallExp.getStartPosition());
87:                         assertEquals(180 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
88:
89:                         InputElement sourceElement = generatedText.getSourceElement();
90:                         EObject modelElement = sourceElement.getModelElement();
91:                         assertTrue(modelElement instanceof EClass);
92:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
93:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
94:                                         modelElement.eResource().getURI().path());
95:                         cpt++;
96:                 }
97:         }
98:
99:         @Test
100:         public void testTraceabilityLibraryStringReplaceQuery() {
101:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
102:                                 "data/library/string/stringReplaceQuery.mtl", //$NON-NLS-1$
103:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
104:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
105:                 assertEquals(4, generatedFiles.size());
106:
107:                 int cpt = 1;
108:•                for (GeneratedFile generatedFile : generatedFiles) {
109:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
110:                         assertEquals(3, generatedRegions.size());
111:                         assertEquals(("clazs" + cpt).length(), generatedFile.getLength()); //$NON-NLS-1$
112:
113:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
114:                         assertEquals(2, sourceElements.size()); // the class and its name
115:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
116:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
117:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
118:
119:                         GeneratedText generatedText = generatedRegions.get(0);
120:                         assertEquals(0, generatedText.getStartOffset());
121:                         assertEquals("cla".length(), generatedText.getEndOffset()); //$NON-NLS-1$
122:                         ModuleElement moduleElement = generatedText.getModuleElement();
123:                         EObject element = moduleElement.getModuleElement();
124:                         assertTrue(element instanceof ASTNode);
125:                         assertTrue(element instanceof PropertyCallExp);
126:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
127:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
128:                         assertEquals(185, propertyCallExp.getStartPosition());
129:                         assertEquals(185 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
130:
131:                         generatedText = generatedRegions.get(2);
132:                         assertEquals("cla".length(), generatedText.getStartOffset()); //$NON-NLS-1$
133:                         assertEquals("claz".length(), generatedText.getEndOffset()); //$NON-NLS-1$
134:                         moduleElement = generatedText.getModuleElement();
135:                         element = moduleElement.getModuleElement();
136:                         assertTrue(element instanceof ASTNode);
137:                         assertTrue(element instanceof StringLiteralExp);
138:                         StringLiteralExp string = (StringLiteralExp)element;
139:                         assertEquals("z", string.getStringSymbol()); //$NON-NLS-1$
140:                         assertEquals(301, string.getStartPosition());
141:                         assertEquals(301 + "'z'".length(), string.getEndPosition()); //$NON-NLS-1$
142:
143:                         generatedText = generatedRegions.get(1);
144:                         assertEquals("claz".length(), generatedText.getStartOffset()); //$NON-NLS-1$
145:                         assertEquals(("clazs" + cpt).length(), generatedText.getEndOffset()); //$NON-NLS-1$
146:                         moduleElement = generatedText.getModuleElement();
147:                         element = moduleElement.getModuleElement();
148:                         assertTrue(element instanceof ASTNode);
149:                         assertTrue(element instanceof PropertyCallExp);
150:                         propertyCallExp = (PropertyCallExp)element;
151:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
152:                         assertEquals(185, propertyCallExp.getStartPosition());
153:                         assertEquals(185 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
154:
155:                         InputElement sourceElement = generatedText.getSourceElement();
156:                         EObject modelElement = sourceElement.getModelElement();
157:                         assertTrue(modelElement instanceof EClass);
158:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
159:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
160:                                         modelElement.eResource().getURI().path());
161:                         cpt++;
162:                 }
163:         }
164:
165:         @Test
166:         public void testTraceabilityLibraryStringReplaceTemplate() {
167:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
168:                                 "data/library/string/stringReplaceTemplate.mtl", //$NON-NLS-1$
169:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
170:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
171:                 assertEquals(4, generatedFiles.size());
172:
173:                 int cpt = 1;
174:•                for (GeneratedFile generatedFile : generatedFiles) {
175:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
176:                         assertEquals(3, generatedRegions.size());
177:                         assertEquals(("clazs" + cpt).length(), generatedFile.getLength()); //$NON-NLS-1$
178:
179:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
180:                         assertEquals(2, sourceElements.size()); // the class and its name
181:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
182:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
183:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
184:
185:                         GeneratedText generatedText = generatedRegions.get(0);
186:                         assertEquals(0, generatedText.getStartOffset());
187:                         assertEquals("cla".length(), generatedText.getEndOffset()); //$NON-NLS-1$
188:                         ModuleElement moduleElement = generatedText.getModuleElement();
189:                         EObject element = moduleElement.getModuleElement();
190:                         assertTrue(element instanceof ASTNode);
191:                         assertTrue(element instanceof PropertyCallExp);
192:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
193:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
194:                         assertEquals(188, propertyCallExp.getStartPosition());
195:                         assertEquals(188 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
196:
197:                         generatedText = generatedRegions.get(2);
198:                         assertEquals("cla".length(), generatedText.getStartOffset()); //$NON-NLS-1$
199:                         assertEquals("claz".length(), generatedText.getEndOffset()); //$NON-NLS-1$
200:                         moduleElement = generatedText.getModuleElement();
201:                         element = moduleElement.getModuleElement();
202:                         assertTrue(element instanceof ASTNode);
203:                         assertTrue(element instanceof StringLiteralExp);
204:                         StringLiteralExp string = (StringLiteralExp)element;
205:                         assertEquals("z", string.getStringSymbol()); //$NON-NLS-1$
206:                         assertEquals(296, string.getStartPosition());
207:                         assertEquals(296 + "z".length(), string.getEndPosition()); //$NON-NLS-1$
208:
209:                         generatedText = generatedRegions.get(1);
210:                         assertEquals("claz".length(), generatedText.getStartOffset()); //$NON-NLS-1$
211:                         assertEquals(("clazs" + cpt).length(), generatedText.getEndOffset()); //$NON-NLS-1$
212:                         moduleElement = generatedText.getModuleElement();
213:                         element = moduleElement.getModuleElement();
214:                         assertTrue(element instanceof ASTNode);
215:                         assertTrue(element instanceof PropertyCallExp);
216:                         propertyCallExp = (PropertyCallExp)element;
217:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
218:                         assertEquals(188, propertyCallExp.getStartPosition());
219:                         assertEquals(188 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
220:
221:                         InputElement sourceElement = generatedText.getSourceElement();
222:                         EObject modelElement = sourceElement.getModelElement();
223:                         assertTrue(modelElement instanceof EClass);
224:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
225:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
226:                                         modelElement.eResource().getURI().path());
227:                         cpt++;
228:                 }
229:         }
230:
231:         @Test
232:         public void testTraceabilityLibraryStringReplaceAll() {
233:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
234:                                 "data/library/string/stringReplaceAll.mtl", //$NON-NLS-1$
235:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
236:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
237:                 assertEquals(4, generatedFiles.size());
238:
239:                 int cpt = 1;
240:•                for (GeneratedFile generatedFile : generatedFiles) {
241:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
242:                         assertEquals(4, generatedRegions.size());
243:                         assertEquals(("clazz" + cpt).length(), generatedFile.getLength()); //$NON-NLS-1$
244:
245:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
246:                         assertEquals(2, sourceElements.size()); // the class and its name
247:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
248:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
249:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
250:
251:                         GeneratedText generatedText = generatedRegions.get(0);
252:                         assertEquals(0, generatedText.getStartOffset());
253:                         assertEquals("cla".length(), generatedText.getEndOffset()); //$NON-NLS-1$
254:                         ModuleElement moduleElement = generatedText.getModuleElement();
255:                         EObject element = moduleElement.getModuleElement();
256:                         assertTrue(element instanceof ASTNode);
257:                         assertTrue(element instanceof PropertyCallExp);
258:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
259:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
260:                         assertEquals(183, propertyCallExp.getStartPosition());
261:                         assertEquals(183 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
262:
263:                         generatedText = generatedRegions.get(2);
264:                         assertEquals("cla".length(), generatedText.getStartOffset()); //$NON-NLS-1$
265:                         assertEquals("claz".length(), generatedText.getEndOffset()); //$NON-NLS-1$
266:                         moduleElement = generatedText.getModuleElement();
267:                         element = moduleElement.getModuleElement();
268:                         assertTrue(element instanceof ASTNode);
269:                         assertTrue(element instanceof StringLiteralExp);
270:                         StringLiteralExp string = (StringLiteralExp)element;
271:                         assertEquals("z", string.getStringSymbol()); //$NON-NLS-1$
272:                         assertEquals(211, string.getStartPosition());
273:                         assertEquals(211 + "'z'".length(), string.getEndPosition()); //$NON-NLS-1$
274:
275:                         generatedText = generatedRegions.get(3);
276:                         assertEquals("claz".length(), generatedText.getStartOffset()); //$NON-NLS-1$
277:                         assertEquals("clazz".length(), generatedText.getEndOffset()); //$NON-NLS-1$
278:                         moduleElement = generatedText.getModuleElement();
279:                         element = moduleElement.getModuleElement();
280:                         assertTrue(element instanceof ASTNode);
281:                         assertTrue(element instanceof StringLiteralExp);
282:                         string = (StringLiteralExp)element;
283:                         assertEquals("z", string.getStringSymbol()); //$NON-NLS-1$
284:                         assertEquals(211, string.getStartPosition());
285:                         assertEquals(211 + "'z'".length(), string.getEndPosition()); //$NON-NLS-1$
286:
287:                         generatedText = generatedRegions.get(1);
288:                         assertEquals("clazz".length(), generatedText.getStartOffset()); //$NON-NLS-1$
289:                         assertEquals(("clazz" + cpt).length(), generatedText.getEndOffset()); //$NON-NLS-1$
290:                         moduleElement = generatedText.getModuleElement();
291:                         element = moduleElement.getModuleElement();
292:                         assertTrue(element instanceof ASTNode);
293:                         assertTrue(element instanceof PropertyCallExp);
294:                         propertyCallExp = (PropertyCallExp)element;
295:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
296:                         assertEquals(183, propertyCallExp.getStartPosition());
297:                         assertEquals(183 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
298:
299:                         InputElement sourceElement = generatedText.getSourceElement();
300:                         EObject modelElement = sourceElement.getModelElement();
301:                         assertTrue(modelElement instanceof EClass);
302:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
303:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
304:                                         modelElement.eResource().getURI().path());
305:                         cpt++;
306:                 }
307:         }
308:
309:         @Test
310:         public void testTraceabilityLibraryStringReplaceAllFirstLast() {
311:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
312:                                 "data/library/string/stringReplaceAllFirstLast.mtl", //$NON-NLS-1$
313:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
314:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
315:                 assertEquals(4, generatedFiles.size());
316:
317:                 int cpt = 1;
318:•                for (GeneratedFile generatedFile : generatedFiles) {
319:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
320:                         assertEquals(9, generatedRegions.size());
321:                         assertEquals("AbrAcAdAbrA".length(), generatedFile.getLength()); //$NON-NLS-1$
322:
323:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
324:                         assertEquals(2, sourceElements.size()); // the class and its name
325:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
326:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
327:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
328:
329:                         GeneratedText generatedText = generatedRegions.get(1);
330:                         assertEquals(0, generatedText.getStartOffset());
331:                         assertEquals("A".length(), generatedText.getEndOffset()); //$NON-NLS-1$
332:                         ModuleElement moduleElement = generatedText.getModuleElement();
333:                         EObject element = moduleElement.getModuleElement();
334:                         assertTrue(element instanceof ASTNode);
335:                         assertTrue(element instanceof StringLiteralExp);
336:                         StringLiteralExp string = (StringLiteralExp)element;
337:                         assertEquals("A", string.getStringSymbol()); //$NON-NLS-1$
338:                         assertEquals(222, string.getStartPosition());
339:                         assertEquals(222 + "'A'".length(), string.getEndPosition()); //$NON-NLS-1$
340:
341:                         generatedText = generatedRegions.get(0);
342:                         assertEquals("A".length(), generatedText.getStartOffset()); //$NON-NLS-1$
343:                         assertEquals("Abr".length(), generatedText.getEndOffset()); //$NON-NLS-1$
344:                         moduleElement = generatedText.getModuleElement();
345:                         element = moduleElement.getModuleElement();
346:                         assertTrue(element instanceof ASTNode);
347:                         assertTrue(element instanceof StringLiteralExp);
348:                         string = (StringLiteralExp)element;
349:                         assertEquals("abracadabra", string.getStringSymbol()); //$NON-NLS-1$
350:                         assertEquals(192, string.getStartPosition());
351:                         assertEquals(192 + "'abracadabra'".length(), string.getEndPosition()); //$NON-NLS-1$
352:
353:                         generatedText = generatedRegions.get(3);
354:                         assertEquals("Abr".length(), generatedText.getStartOffset()); //$NON-NLS-1$
355:                         assertEquals("AbrA".length(), generatedText.getEndOffset()); //$NON-NLS-1$
356:                         moduleElement = generatedText.getModuleElement();
357:                         element = moduleElement.getModuleElement();
358:                         assertTrue(element instanceof ASTNode);
359:                         assertTrue(element instanceof StringLiteralExp);
360:                         string = (StringLiteralExp)element;
361:                         assertEquals("A", string.getStringSymbol()); //$NON-NLS-1$
362:                         assertEquals(222, string.getStartPosition());
363:                         assertEquals(222 + "'A'".length(), string.getEndPosition()); //$NON-NLS-1$
364:
365:                         generatedText = generatedRegions.get(2);
366:                         assertEquals("AbrA".length(), generatedText.getStartOffset()); //$NON-NLS-1$
367:                         assertEquals("AbrAc".length(), generatedText.getEndOffset()); //$NON-NLS-1$
368:                         moduleElement = generatedText.getModuleElement();
369:                         element = moduleElement.getModuleElement();
370:                         assertTrue(element instanceof ASTNode);
371:                         assertTrue(element instanceof StringLiteralExp);
372:                         string = (StringLiteralExp)element;
373:                         assertEquals("abracadabra", string.getStringSymbol()); //$NON-NLS-1$
374:                         assertEquals(192, string.getStartPosition());
375:                         assertEquals(192 + "'abracadabra'".length(), string.getEndPosition()); //$NON-NLS-1$
376:
377:                         generatedText = generatedRegions.get(5);
378:                         assertEquals("AbrAc".length(), generatedText.getStartOffset()); //$NON-NLS-1$
379:                         assertEquals("AbrAcA".length(), generatedText.getEndOffset()); //$NON-NLS-1$
380:                         moduleElement = generatedText.getModuleElement();
381:                         element = moduleElement.getModuleElement();
382:                         assertTrue(element instanceof ASTNode);
383:                         assertTrue(element instanceof StringLiteralExp);
384:                         string = (StringLiteralExp)element;
385:                         assertEquals("A", string.getStringSymbol()); //$NON-NLS-1$
386:                         assertEquals(222, string.getStartPosition());
387:                         assertEquals(222 + "'A'".length(), string.getEndPosition()); //$NON-NLS-1$
388:
389:                         generatedText = generatedRegions.get(4);
390:                         assertEquals("AbrAcA".length(), generatedText.getStartOffset()); //$NON-NLS-1$
391:                         assertEquals("AbrAcAd".length(), generatedText.getEndOffset()); //$NON-NLS-1$
392:                         moduleElement = generatedText.getModuleElement();
393:                         element = moduleElement.getModuleElement();
394:                         assertTrue(element instanceof ASTNode);
395:                         assertTrue(element instanceof StringLiteralExp);
396:                         string = (StringLiteralExp)element;
397:                         assertEquals("abracadabra", string.getStringSymbol()); //$NON-NLS-1$
398:                         assertEquals(192, string.getStartPosition());
399:                         assertEquals(192 + "'abracadabra'".length(), string.getEndPosition()); //$NON-NLS-1$
400:
401:                         generatedText = generatedRegions.get(7);
402:                         assertEquals("AbrAcAd".length(), generatedText.getStartOffset()); //$NON-NLS-1$
403:                         assertEquals("AbrAcAda".length(), generatedText.getEndOffset()); //$NON-NLS-1$
404:                         moduleElement = generatedText.getModuleElement();
405:                         element = moduleElement.getModuleElement();
406:                         assertTrue(element instanceof ASTNode);
407:                         assertTrue(element instanceof StringLiteralExp);
408:                         string = (StringLiteralExp)element;
409:                         assertEquals("A", string.getStringSymbol()); //$NON-NLS-1$
410:                         assertEquals(222, string.getStartPosition());
411:                         assertEquals(222 + "'A'".length(), string.getEndPosition()); //$NON-NLS-1$
412:
413:                         generatedText = generatedRegions.get(6);
414:                         assertEquals("AbrAcAdA".length(), generatedText.getStartOffset()); //$NON-NLS-1$
415:                         assertEquals("AbrAcAdAbr".length(), generatedText.getEndOffset()); //$NON-NLS-1$
416:                         moduleElement = generatedText.getModuleElement();
417:                         element = moduleElement.getModuleElement();
418:                         assertTrue(element instanceof ASTNode);
419:                         assertTrue(element instanceof StringLiteralExp);
420:                         string = (StringLiteralExp)element;
421:                         assertEquals("abracadabra", string.getStringSymbol()); //$NON-NLS-1$
422:                         assertEquals(192, string.getStartPosition());
423:                         assertEquals(192 + "'abracadabra'".length(), string.getEndPosition()); //$NON-NLS-1$
424:
425:                         generatedText = generatedRegions.get(8);
426:                         assertEquals("AbrAcAdAbr".length(), generatedText.getStartOffset()); //$NON-NLS-1$
427:                         assertEquals("AbrAcAdAbrA".length(), generatedText.getEndOffset()); //$NON-NLS-1$
428:                         moduleElement = generatedText.getModuleElement();
429:                         element = moduleElement.getModuleElement();
430:                         assertTrue(element instanceof ASTNode);
431:                         assertTrue(element instanceof StringLiteralExp);
432:                         string = (StringLiteralExp)element;
433:                         assertEquals("A", string.getStringSymbol()); //$NON-NLS-1$
434:                         assertEquals(222, string.getStartPosition());
435:                         assertEquals(222 + "'A'".length(), string.getEndPosition()); //$NON-NLS-1$
436:
437:                         InputElement sourceElement = generatedText.getSourceElement();
438:                         EObject modelElement = sourceElement.getModelElement();
439:                         assertTrue(modelElement instanceof EClass);
440:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
441:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
442:                                         modelElement.eResource().getURI().path());
443:                         cpt++;
444:                 }
445:         }
446:
447:         @Test
448:         public void testTraceabilityLibraryStringReplaceAllTemplate() {
449:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
450:                                 "data/library/string/stringReplaceAllTemplate.mtl", //$NON-NLS-1$
451:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
452:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
453:                 assertEquals(4, generatedFiles.size());
454:
455:                 int cpt = 1;
456:•                for (GeneratedFile generatedFile : generatedFiles) {
457:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
458:                         assertEquals(7, generatedRegions.size());
459:                         assertEquals("aaanewbbbnewcccnewddd".length(), generatedFile.getLength()); //$NON-NLS-1$
460:
461:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
462:                         assertEquals(2, sourceElements.size()); // the class and its name
463:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
464:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
465:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
466:
467:                         GeneratedText generatedText = generatedRegions.get(0);
468:                         assertEquals(0, generatedText.getStartOffset());
469:                         assertEquals("aaa".length(), generatedText.getEndOffset()); //$NON-NLS-1$
470:                         ModuleElement moduleElement = generatedText.getModuleElement();
471:                         EObject element = moduleElement.getModuleElement();
472:                         assertTrue(element instanceof ASTNode);
473:                         assertTrue(element instanceof StringLiteralExp);
474:                         StringLiteralExp string = (StringLiteralExp)element;
475:                         assertEquals("aaaoldbbboldcccoldddd", string.getStringSymbol()); //$NON-NLS-1$
476:                         assertEquals(191, string.getStartPosition());
477:                         assertEquals(191 + "'aaaoldbbboldcccoldddd'".length(), string.getEndPosition()); //$NON-NLS-1$
478:
479:                         generatedText = generatedRegions.get(2);
480:                         assertEquals("aaa".length(), generatedText.getStartOffset()); //$NON-NLS-1$
481:                         assertEquals("aaanew".length(), generatedText.getEndOffset()); //$NON-NLS-1$
482:                         moduleElement = generatedText.getModuleElement();
483:                         element = moduleElement.getModuleElement();
484:                         assertTrue(element instanceof ASTNode);
485:                         assertTrue(element instanceof StringLiteralExp);
486:                         string = (StringLiteralExp)element;
487:                         assertEquals("new", string.getStringSymbol()); //$NON-NLS-1$
488:                         assertEquals(316, string.getStartPosition());
489:                         assertEquals(316 + "new".length(), string.getEndPosition()); //$NON-NLS-1$
490:
491:                         generatedText = generatedRegions.get(1);
492:                         assertEquals("aaanew".length(), generatedText.getStartOffset()); //$NON-NLS-1$
493:                         assertEquals("aaanewbbb".length(), generatedText.getEndOffset()); //$NON-NLS-1$
494:                         moduleElement = generatedText.getModuleElement();
495:                         element = moduleElement.getModuleElement();
496:                         assertTrue(element instanceof ASTNode);
497:                         assertTrue(element instanceof StringLiteralExp);
498:                         string = (StringLiteralExp)element;
499:                         assertEquals("aaaoldbbboldcccoldddd", string.getStringSymbol()); //$NON-NLS-1$
500:                         assertEquals(191, string.getStartPosition());
501:                         assertEquals(191 + "'aaaoldbbboldcccoldddd'".length(), string.getEndPosition()); //$NON-NLS-1$
502:
503:                         generatedText = generatedRegions.get(4);
504:                         assertEquals("aaanewbbb".length(), generatedText.getStartOffset()); //$NON-NLS-1$
505:                         assertEquals("aaanewbbbnew".length(), generatedText.getEndOffset()); //$NON-NLS-1$
506:                         moduleElement = generatedText.getModuleElement();
507:                         element = moduleElement.getModuleElement();
508:                         assertTrue(element instanceof ASTNode);
509:                         assertTrue(element instanceof StringLiteralExp);
510:                         string = (StringLiteralExp)element;
511:                         assertEquals("new", string.getStringSymbol()); //$NON-NLS-1$
512:                         assertEquals(316, string.getStartPosition());
513:                         assertEquals(316 + "new".length(), string.getEndPosition()); //$NON-NLS-1$
514:
515:                         generatedText = generatedRegions.get(3);
516:                         assertEquals("aaanewbbbnew".length(), generatedText.getStartOffset()); //$NON-NLS-1$
517:                         assertEquals("aaanewbbbnewccc".length(), generatedText.getEndOffset()); //$NON-NLS-1$
518:                         moduleElement = generatedText.getModuleElement();
519:                         element = moduleElement.getModuleElement();
520:                         assertTrue(element instanceof ASTNode);
521:                         assertTrue(element instanceof StringLiteralExp);
522:                         string = (StringLiteralExp)element;
523:                         assertEquals("aaaoldbbboldcccoldddd", string.getStringSymbol()); //$NON-NLS-1$
524:                         assertEquals(191, string.getStartPosition());
525:                         assertEquals(191 + "'aaaoldbbboldcccoldddd'".length(), string.getEndPosition()); //$NON-NLS-1$
526:
527:                         generatedText = generatedRegions.get(6);
528:                         assertEquals("aaanewbbbnewccc".length(), generatedText.getStartOffset()); //$NON-NLS-1$
529:                         assertEquals("aaanewbbbnewcccnew".length(), generatedText.getEndOffset()); //$NON-NLS-1$
530:                         moduleElement = generatedText.getModuleElement();
531:                         element = moduleElement.getModuleElement();
532:                         assertTrue(element instanceof ASTNode);
533:                         assertTrue(element instanceof StringLiteralExp);
534:                         string = (StringLiteralExp)element;
535:                         assertEquals("new", string.getStringSymbol()); //$NON-NLS-1$
536:                         assertEquals(316, string.getStartPosition());
537:                         assertEquals(316 + "new".length(), string.getEndPosition()); //$NON-NLS-1$
538:
539:                         generatedText = generatedRegions.get(5);
540:                         assertEquals("aaanewbbbnewcccnew".length(), generatedText.getStartOffset()); //$NON-NLS-1$
541:                         assertEquals("aaanewbbbnewcccnewddd".length(), generatedText.getEndOffset()); //$NON-NLS-1$
542:                         moduleElement = generatedText.getModuleElement();
543:                         element = moduleElement.getModuleElement();
544:                         assertTrue(element instanceof ASTNode);
545:                         assertTrue(element instanceof StringLiteralExp);
546:                         string = (StringLiteralExp)element;
547:                         assertEquals("aaaoldbbboldcccoldddd", string.getStringSymbol()); //$NON-NLS-1$
548:                         assertEquals(191, string.getStartPosition());
549:                         assertEquals(191 + "'aaaoldbbboldcccoldddd'".length(), string.getEndPosition()); //$NON-NLS-1$
550:
551:                         InputElement sourceElement = generatedText.getSourceElement();
552:                         EObject modelElement = sourceElement.getModelElement();
553:                         assertTrue(modelElement instanceof EClass);
554:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
555:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
556:                                         modelElement.eResource().getURI().path());
557:                         cpt++;
558:                 }
559:         }
560:
561:         @Test
562:         public void testTraceabilityLibraryStringReplaceAllQuery() {
563:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
564:                                 "data/library/string/stringReplaceAllQuery.mtl", //$NON-NLS-1$
565:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
566:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
567:                 assertEquals(4, generatedFiles.size());
568:
569:                 int cpt = 1;
570:•                for (GeneratedFile generatedFile : generatedFiles) {
571:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
572:                         assertEquals(7, generatedRegions.size());
573:                         assertEquals("aaanewbbbnewcccnewddd".length(), generatedFile.getLength()); //$NON-NLS-1$
574:
575:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
576:                         assertEquals(2, sourceElements.size()); // the class and its name
577:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
578:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
579:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
580:
581:                         GeneratedText generatedText = generatedRegions.get(0);
582:                         assertEquals(0, generatedText.getStartOffset());
583:                         assertEquals("aaa".length(), generatedText.getEndOffset()); //$NON-NLS-1$
584:                         ModuleElement moduleElement = generatedText.getModuleElement();
585:                         EObject element = moduleElement.getModuleElement();
586:                         assertTrue(element instanceof ASTNode);
587:                         assertTrue(element instanceof StringLiteralExp);
588:                         StringLiteralExp string = (StringLiteralExp)element;
589:                         assertEquals("aaaoldbbboldcccoldddd", string.getStringSymbol()); //$NON-NLS-1$
590:                         assertEquals(188, string.getStartPosition());
591:                         assertEquals(188 + "'aaaoldbbboldcccoldddd'".length(), string.getEndPosition()); //$NON-NLS-1$
592:
593:                         generatedText = generatedRegions.get(2);
594:                         assertEquals("aaa".length(), generatedText.getStartOffset()); //$NON-NLS-1$
595:                         assertEquals("aaanew".length(), generatedText.getEndOffset()); //$NON-NLS-1$
596:                         moduleElement = generatedText.getModuleElement();
597:                         element = moduleElement.getModuleElement();
598:                         assertTrue(element instanceof ASTNode);
599:                         assertTrue(element instanceof StringLiteralExp);
600:                         string = (StringLiteralExp)element;
601:                         assertEquals("new", string.getStringSymbol()); //$NON-NLS-1$
602:                         assertEquals(321, string.getStartPosition());
603:                         assertEquals(321 + "'new'".length(), string.getEndPosition()); //$NON-NLS-1$
604:
605:                         generatedText = generatedRegions.get(1);
606:                         assertEquals("aaanew".length(), generatedText.getStartOffset()); //$NON-NLS-1$
607:                         assertEquals("aaanewbbb".length(), generatedText.getEndOffset()); //$NON-NLS-1$
608:                         moduleElement = generatedText.getModuleElement();
609:                         element = moduleElement.getModuleElement();
610:                         assertTrue(element instanceof ASTNode);
611:                         assertTrue(element instanceof StringLiteralExp);
612:                         string = (StringLiteralExp)element;
613:                         assertEquals("aaaoldbbboldcccoldddd", string.getStringSymbol()); //$NON-NLS-1$
614:                         assertEquals(188, string.getStartPosition());
615:                         assertEquals(188 + "'aaaoldbbboldcccoldddd'".length(), string.getEndPosition()); //$NON-NLS-1$
616:
617:                         generatedText = generatedRegions.get(4);
618:                         assertEquals("aaanewbbb".length(), generatedText.getStartOffset()); //$NON-NLS-1$
619:                         assertEquals("aaanewbbbnew".length(), generatedText.getEndOffset()); //$NON-NLS-1$
620:                         moduleElement = generatedText.getModuleElement();
621:                         element = moduleElement.getModuleElement();
622:                         assertTrue(element instanceof ASTNode);
623:                         assertTrue(element instanceof StringLiteralExp);
624:                         string = (StringLiteralExp)element;
625:                         assertEquals("new", string.getStringSymbol()); //$NON-NLS-1$
626:                         assertEquals(321, string.getStartPosition());
627:                         assertEquals(321 + "'new'".length(), string.getEndPosition()); //$NON-NLS-1$
628:
629:                         generatedText = generatedRegions.get(3);
630:                         assertEquals("aaanewbbbnew".length(), generatedText.getStartOffset()); //$NON-NLS-1$
631:                         assertEquals("aaanewbbbnewccc".length(), generatedText.getEndOffset()); //$NON-NLS-1$
632:                         moduleElement = generatedText.getModuleElement();
633:                         element = moduleElement.getModuleElement();
634:                         assertTrue(element instanceof ASTNode);
635:                         assertTrue(element instanceof StringLiteralExp);
636:                         string = (StringLiteralExp)element;
637:                         assertEquals("aaaoldbbboldcccoldddd", string.getStringSymbol()); //$NON-NLS-1$
638:                         assertEquals(188, string.getStartPosition());
639:                         assertEquals(188 + "'aaaoldbbboldcccoldddd'".length(), string.getEndPosition()); //$NON-NLS-1$
640:
641:                         generatedText = generatedRegions.get(6);
642:                         assertEquals("aaanewbbbnewccc".length(), generatedText.getStartOffset()); //$NON-NLS-1$
643:                         assertEquals("aaanewbbbnewcccnew".length(), generatedText.getEndOffset()); //$NON-NLS-1$
644:                         moduleElement = generatedText.getModuleElement();
645:                         element = moduleElement.getModuleElement();
646:                         assertTrue(element instanceof ASTNode);
647:                         assertTrue(element instanceof StringLiteralExp);
648:                         string = (StringLiteralExp)element;
649:                         assertEquals("new", string.getStringSymbol()); //$NON-NLS-1$
650:                         assertEquals(321, string.getStartPosition());
651:                         assertEquals(321 + "'new'".length(), string.getEndPosition()); //$NON-NLS-1$
652:
653:                         generatedText = generatedRegions.get(5);
654:                         assertEquals("aaanewbbbnewcccnew".length(), generatedText.getStartOffset()); //$NON-NLS-1$
655:                         assertEquals("aaanewbbbnewcccnewddd".length(), generatedText.getEndOffset()); //$NON-NLS-1$
656:                         moduleElement = generatedText.getModuleElement();
657:                         element = moduleElement.getModuleElement();
658:                         assertTrue(element instanceof ASTNode);
659:                         assertTrue(element instanceof StringLiteralExp);
660:                         string = (StringLiteralExp)element;
661:                         assertEquals("aaaoldbbboldcccoldddd", string.getStringSymbol()); //$NON-NLS-1$
662:                         assertEquals(188, string.getStartPosition());
663:                         assertEquals(188 + "'aaaoldbbboldcccoldddd'".length(), string.getEndPosition()); //$NON-NLS-1$
664:
665:                         InputElement sourceElement = generatedText.getSourceElement();
666:                         EObject modelElement = sourceElement.getModelElement();
667:                         assertTrue(modelElement instanceof EClass);
668:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
669:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
670:                                         modelElement.eResource().getURI().path());
671:                         cpt++;
672:                 }
673:         }
674:
675:         @Test
676:         public void testTraceabilityLibraryStringCollection() {
677:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
678:                                 "data/library/string/stringCollection.mtl", //$NON-NLS-1$
679:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
680:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
681:                 assertEquals(4, generatedFiles.size());
682:
683:                 int cpt = 1;
684:•                for (GeneratedFile generatedFile : generatedFiles) {
685:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
686:                         assertEquals(3, generatedRegions.size());
687:                         assertEquals("abc".length(), generatedFile.getLength()); //$NON-NLS-1$
688:
689:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
690:                         assertEquals(2, sourceElements.size()); // the class and its name
691:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
692:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
693:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
694:
695:                         GeneratedText generatedText = generatedRegions.get(0);
696:                         assertEquals(0, generatedText.getStartOffset());
697:                         assertEquals("a".length(), generatedText.getEndOffset()); //$NON-NLS-1$
698:                         ModuleElement moduleElement = generatedText.getModuleElement();
699:                         EObject element = moduleElement.getModuleElement();
700:                         assertTrue(element instanceof ASTNode);
701:                         assertTrue(element instanceof StringLiteralExp);
702:                         StringLiteralExp string = (StringLiteralExp)element;
703:                         assertEquals("a", string.getStringSymbol()); //$NON-NLS-1$
704:                         assertEquals(192, string.getStartPosition());
705:                         assertEquals(192 + "'a'".length(), string.getEndPosition()); //$NON-NLS-1$
706:
707:                         generatedText = generatedRegions.get(1);
708:                         assertEquals("a".length(), generatedText.getStartOffset()); //$NON-NLS-1$
709:                         assertEquals("ab".length(), generatedText.getEndOffset()); //$NON-NLS-1$
710:                         moduleElement = generatedText.getModuleElement();
711:                         element = moduleElement.getModuleElement();
712:                         assertTrue(element instanceof ASTNode);
713:                         assertTrue(element instanceof StringLiteralExp);
714:                         string = (StringLiteralExp)element;
715:                         assertEquals("b", string.getStringSymbol()); //$NON-NLS-1$
716:                         assertEquals(197, string.getStartPosition());
717:                         assertEquals(197 + "'b'".length(), string.getEndPosition()); //$NON-NLS-1$
718:
719:                         generatedText = generatedRegions.get(2);
720:                         assertEquals("ab".length(), generatedText.getStartOffset()); //$NON-NLS-1$
721:                         assertEquals("abc".length(), generatedText.getEndOffset()); //$NON-NLS-1$
722:                         moduleElement = generatedText.getModuleElement();
723:                         element = moduleElement.getModuleElement();
724:                         assertTrue(element instanceof ASTNode);
725:                         assertTrue(element instanceof StringLiteralExp);
726:                         string = (StringLiteralExp)element;
727:                         assertEquals("c", string.getStringSymbol()); //$NON-NLS-1$
728:                         assertEquals(202, string.getStartPosition());
729:                         assertEquals(202 + "'c'".length(), string.getEndPosition()); //$NON-NLS-1$
730:
731:                         InputElement sourceElement = generatedText.getSourceElement();
732:                         EObject modelElement = sourceElement.getModelElement();
733:                         assertTrue(modelElement instanceof EClass);
734:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
735:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
736:                                         modelElement.eResource().getURI().path());
737:                         cpt++;
738:                 }
739:         }
740:
741:         @Test
742:         public void testTraceabilityLibraryStringCollectionReverse() {
743:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
744:                                 "data/library/string/stringCollectionReverse.mtl", //$NON-NLS-1$
745:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
746:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
747:                 assertEquals(4, generatedFiles.size());
748:
749:                 int cpt = 1;
750:•                for (GeneratedFile generatedFile : generatedFiles) {
751:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
752:                         assertEquals(3, generatedRegions.size());
753:                         assertEquals("cbbaaa".length(), generatedFile.getLength()); //$NON-NLS-1$
754:
755:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
756:                         assertEquals(2, sourceElements.size()); // the class and its name
757:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
758:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
759:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
760:
761:                         GeneratedText generatedText = generatedRegions.get(2);
762:                         assertEquals(0, generatedText.getStartOffset());
763:                         assertEquals("c".length(), generatedText.getEndOffset()); //$NON-NLS-1$
764:                         ModuleElement moduleElement = generatedText.getModuleElement();
765:                         EObject element = moduleElement.getModuleElement();
766:                         assertTrue(element instanceof ASTNode);
767:                         assertTrue(element instanceof StringLiteralExp);
768:                         StringLiteralExp string = (StringLiteralExp)element;
769:                         assertEquals("c", string.getStringSymbol()); //$NON-NLS-1$
770:                         assertEquals(212, string.getStartPosition());
771:                         assertEquals(212 + "'c'".length(), string.getEndPosition()); //$NON-NLS-1$
772:
773:                         generatedText = generatedRegions.get(1);
774:                         assertEquals("c".length(), generatedText.getStartOffset()); //$NON-NLS-1$
775:                         assertEquals("cbb".length(), generatedText.getEndOffset()); //$NON-NLS-1$
776:                         moduleElement = generatedText.getModuleElement();
777:                         element = moduleElement.getModuleElement();
778:                         assertTrue(element instanceof ASTNode);
779:                         assertTrue(element instanceof StringLiteralExp);
780:                         string = (StringLiteralExp)element;
781:                         assertEquals("bb", string.getStringSymbol()); //$NON-NLS-1$
782:                         assertEquals(206, string.getStartPosition());
783:                         assertEquals(206 + "'bb'".length(), string.getEndPosition()); //$NON-NLS-1$
784:
785:                         generatedText = generatedRegions.get(0);
786:                         assertEquals("cbb".length(), generatedText.getStartOffset()); //$NON-NLS-1$
787:                         assertEquals("cbbaaa".length(), generatedText.getEndOffset()); //$NON-NLS-1$
788:                         moduleElement = generatedText.getModuleElement();
789:                         element = moduleElement.getModuleElement();
790:                         assertTrue(element instanceof ASTNode);
791:                         assertTrue(element instanceof StringLiteralExp);
792:                         string = (StringLiteralExp)element;
793:                         assertEquals("aaa", string.getStringSymbol()); //$NON-NLS-1$
794:                         assertEquals(199, string.getStartPosition());
795:                         assertEquals(199 + "'aaa'".length(), string.getEndPosition()); //$NON-NLS-1$
796:
797:                         InputElement sourceElement = generatedText.getSourceElement();
798:                         EObject modelElement = sourceElement.getModelElement();
799:                         assertTrue(modelElement instanceof EClass);
800:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
801:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
802:                                         modelElement.eResource().getURI().path());
803:                         cpt++;
804:                 }
805:         }
806:
807:         @Test
808:         public void testTraceabilityLibraryStringCollectionReverse2() {
809:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
810:                                 "data/library/string/stringCollectionReverse2.mtl", //$NON-NLS-1$
811:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
812:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
813:                 assertEquals(4, generatedFiles.size());
814:
815:                 int cpt = 1;
816:•                for (GeneratedFile generatedFile : generatedFiles) {
817:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
818:                         assertEquals(4, generatedRegions.size());
819:                         assertEquals("class4class3class2class1".length(), generatedFile.getLength()); //$NON-NLS-1$
820:
821:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
822:                         assertEquals(2, sourceElements.size()); // the class and its name
823:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
824:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
825:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
826:
827:                         GeneratedText generatedText = generatedRegions.get(3);
828:                         assertEquals(0, generatedText.getStartOffset());
829:                         assertEquals("class4".length(), generatedText.getEndOffset()); //$NON-NLS-1$
830:                         ModuleElement moduleElement = generatedText.getModuleElement();
831:                         EObject element = moduleElement.getModuleElement();
832:                         assertTrue(element instanceof ASTNode);
833:                         assertTrue(element instanceof PropertyCallExp);
834:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
835:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
836:                         assertEquals(244, propertyCallExp.getStartPosition());
837:                         assertEquals(244 + "name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
838:
839:                         InputElement sourceElement = generatedText.getSourceElement();
840:                         EObject modelElement = sourceElement.getModelElement();
841:                         assertTrue(modelElement instanceof EClass);
842:                         assertEquals("class4", ((EClass)modelElement).getName()); //$NON-NLS-1$
843:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
844:                                         modelElement.eResource().getURI().path());
845:
846:                         generatedText = generatedRegions.get(2);
847:                         assertEquals("class4".length(), generatedText.getStartOffset()); //$NON-NLS-1$
848:                         assertEquals("class4class3".length(), generatedText.getEndOffset()); //$NON-NLS-1$
849:                         moduleElement = generatedText.getModuleElement();
850:                         element = moduleElement.getModuleElement();
851:                         assertTrue(element instanceof ASTNode);
852:                         assertTrue(element instanceof PropertyCallExp);
853:                         propertyCallExp = (PropertyCallExp)element;
854:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
855:                         assertEquals(244, propertyCallExp.getStartPosition());
856:                         assertEquals(244 + "name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
857:
858:                         sourceElement = generatedText.getSourceElement();
859:                         modelElement = sourceElement.getModelElement();
860:                         assertTrue(modelElement instanceof EClass);
861:                         assertEquals("class3", ((EClass)modelElement).getName()); //$NON-NLS-1$
862:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
863:                                         modelElement.eResource().getURI().path());
864:
865:                         generatedText = generatedRegions.get(1);
866:                         assertEquals("class4class3".length(), generatedText.getStartOffset()); //$NON-NLS-1$
867:                         assertEquals("class4class3class2".length(), generatedText.getEndOffset()); //$NON-NLS-1$
868:                         moduleElement = generatedText.getModuleElement();
869:                         element = moduleElement.getModuleElement();
870:                         assertTrue(element instanceof ASTNode);
871:                         assertTrue(element instanceof PropertyCallExp);
872:                         propertyCallExp = (PropertyCallExp)element;
873:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
874:                         assertEquals(244, propertyCallExp.getStartPosition());
875:                         assertEquals(244 + "name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
876:
877:                         sourceElement = generatedText.getSourceElement();
878:                         modelElement = sourceElement.getModelElement();
879:                         assertTrue(modelElement instanceof EClass);
880:                         assertEquals("class2", ((EClass)modelElement).getName()); //$NON-NLS-1$
881:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
882:                                         modelElement.eResource().getURI().path());
883:
884:                         generatedText = generatedRegions.get(0);
885:                         assertEquals("class4class3class2".length(), generatedText.getStartOffset()); //$NON-NLS-1$
886:                         assertEquals("class4class3class2class1".length(), generatedText.getEndOffset()); //$NON-NLS-1$
887:                         moduleElement = generatedText.getModuleElement();
888:                         element = moduleElement.getModuleElement();
889:                         assertTrue(element instanceof ASTNode);
890:                         assertTrue(element instanceof PropertyCallExp);
891:                         propertyCallExp = (PropertyCallExp)element;
892:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
893:                         assertEquals(244, propertyCallExp.getStartPosition());
894:                         assertEquals(244 + "name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
895:
896:                         sourceElement = generatedText.getSourceElement();
897:                         modelElement = sourceElement.getModelElement();
898:                         assertTrue(modelElement instanceof EClass);
899:                         assertEquals("class1", ((EClass)modelElement).getName()); //$NON-NLS-1$
900:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
901:                                         modelElement.eResource().getURI().path());
902:                         cpt++;
903:                 }
904:         }
905:
906:         @Test
907:         public void testTraceabilityLibraryStringCollectionSep() {
908:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
909:                                 "data/library/string/stringCollectionSep.mtl", //$NON-NLS-1$
910:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
911:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
912:                 assertEquals(4, generatedFiles.size());
913:
914:                 int cpt = 1;
915:•                for (GeneratedFile generatedFile : generatedFiles) {
916:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
917:                         assertEquals(5, generatedRegions.size());
918:                         assertEquals("a, b, c".length(), generatedFile.getLength()); //$NON-NLS-1$
919:
920:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
921:                         assertEquals(2, sourceElements.size()); // the class and its name
922:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
923:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
924:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
925:
926:                         GeneratedText generatedText = generatedRegions.get(0);
927:                         assertEquals(0, generatedText.getStartOffset());
928:                         assertEquals("a".length(), generatedText.getEndOffset()); //$NON-NLS-1$
929:                         ModuleElement moduleElement = generatedText.getModuleElement();
930:                         EObject element = moduleElement.getModuleElement();
931:                         assertTrue(element instanceof ASTNode);
932:                         assertTrue(element instanceof StringLiteralExp);
933:                         StringLiteralExp string = (StringLiteralExp)element;
934:                         assertEquals("a", string.getStringSymbol()); //$NON-NLS-1$
935:                         assertEquals(195, string.getStartPosition());
936:                         assertEquals(195 + "'a'".length(), string.getEndPosition()); //$NON-NLS-1$
937:
938:                         generatedText = generatedRegions.get(1);
939:                         assertEquals("a, ".length(), generatedText.getStartOffset()); //$NON-NLS-1$
940:                         assertEquals("a, b".length(), generatedText.getEndOffset()); //$NON-NLS-1$
941:                         moduleElement = generatedText.getModuleElement();
942:                         element = moduleElement.getModuleElement();
943:                         assertTrue(element instanceof ASTNode);
944:                         assertTrue(element instanceof StringLiteralExp);
945:                         string = (StringLiteralExp)element;
946:                         assertEquals("b", string.getStringSymbol()); //$NON-NLS-1$
947:                         assertEquals(200, string.getStartPosition());
948:                         assertEquals(200 + "'b'".length(), string.getEndPosition()); //$NON-NLS-1$
949:
950:                         generatedText = generatedRegions.get(3);
951:                         assertEquals("a".length(), generatedText.getStartOffset()); //$NON-NLS-1$
952:                         assertEquals("a, ".length(), generatedText.getEndOffset()); //$NON-NLS-1$
953:                         moduleElement = generatedText.getModuleElement();
954:                         element = moduleElement.getModuleElement();
955:                         assertTrue(element instanceof ASTNode);
956:                         assertTrue(element instanceof StringLiteralExp);
957:                         string = (StringLiteralExp)element;
958:                         assertEquals(", ", string.getStringSymbol()); //$NON-NLS-1$
959:                         assertEquals(215, string.getStartPosition());
960:                         assertEquals(215 + "', '".length(), string.getEndPosition()); //$NON-NLS-1$
961:
962:                         generatedText = generatedRegions.get(2);
963:                         assertEquals("a, b, ".length(), generatedText.getStartOffset()); //$NON-NLS-1$
964:                         assertEquals("a, b, c".length(), generatedText.getEndOffset()); //$NON-NLS-1$
965:                         moduleElement = generatedText.getModuleElement();
966:                         element = moduleElement.getModuleElement();
967:                         assertTrue(element instanceof ASTNode);
968:                         assertTrue(element instanceof StringLiteralExp);
969:                         string = (StringLiteralExp)element;
970:                         assertEquals("c", string.getStringSymbol()); //$NON-NLS-1$
971:                         assertEquals(205, string.getStartPosition());
972:                         assertEquals(205 + "'c'".length(), string.getEndPosition()); //$NON-NLS-1$
973:
974:                         generatedText = generatedRegions.get(4);
975:                         assertEquals("a, b".length(), generatedText.getStartOffset()); //$NON-NLS-1$
976:                         assertEquals("a, b, ".length(), generatedText.getEndOffset()); //$NON-NLS-1$
977:                         moduleElement = generatedText.getModuleElement();
978:                         element = moduleElement.getModuleElement();
979:                         assertTrue(element instanceof ASTNode);
980:                         assertTrue(element instanceof StringLiteralExp);
981:                         string = (StringLiteralExp)element;
982:                         assertEquals(", ", string.getStringSymbol()); //$NON-NLS-1$
983:                         assertEquals(215, string.getStartPosition());
984:                         assertEquals(215 + "', '".length(), string.getEndPosition()); //$NON-NLS-1$
985:
986:                         InputElement sourceElement = generatedText.getSourceElement();
987:                         EObject modelElement = sourceElement.getModelElement();
988:                         assertTrue(modelElement instanceof EClass);
989:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
990:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
991:                                         modelElement.eResource().getURI().path());
992:                         cpt++;
993:                 }
994:         }
995:
996:         @Test
997:         public void testTraceabilityLibraryStringCollectionSep2() {
998:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
999:                                 "data/library/string/stringCollectionSep2.mtl", //$NON-NLS-1$
1000:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1001:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1002:                 assertEquals(4, generatedFiles.size());
1003:
1004:                 int cpt = 1;
1005:•                for (GeneratedFile generatedFile : generatedFiles) {
1006:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1007:                         assertEquals(7, generatedRegions.size());
1008:                         assertEquals("class1, class2, class3, class4".length(), generatedFile.getLength()); //$NON-NLS-1$
1009:
1010:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1011:                         assertEquals(2, sourceElements.size()); // the class and its name
1012:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1013:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1014:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1015:
1016:                         GeneratedText generatedText = generatedRegions.get(0);
1017:                         assertEquals(0, generatedText.getStartOffset());
1018:                         assertEquals("class1".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1019:                         ModuleElement moduleElement = generatedText.getModuleElement();
1020:                         EObject element = moduleElement.getModuleElement();
1021:                         assertTrue(element instanceof ASTNode);
1022:                         assertTrue(element instanceof PropertyCallExp);
1023:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
1024:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1025:                         assertEquals(240, propertyCallExp.getStartPosition());
1026:                         assertEquals(240 + "name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
1027:
1028:                         InputElement sourceElement = generatedText.getSourceElement();
1029:                         EObject modelElement = sourceElement.getModelElement();
1030:                         assertTrue(modelElement instanceof EClass);
1031:                         assertEquals("class1", ((EClass)modelElement).getName()); //$NON-NLS-1$
1032:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1033:                                         modelElement.eResource().getURI().path());
1034:
1035:                         generatedText = generatedRegions.get(4);
1036:                         assertEquals("class1".length(), generatedText.getStartOffset()); //$NON-NLS-1$
1037:                         assertEquals("class1, ".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1038:                         moduleElement = generatedText.getModuleElement();
1039:                         element = moduleElement.getModuleElement();
1040:                         assertTrue(element instanceof ASTNode);
1041:                         assertTrue(element instanceof StringLiteralExp);
1042:                         StringLiteralExp string = (StringLiteralExp)element;
1043:                         assertEquals(", ", string.getStringSymbol()); //$NON-NLS-1$
1044:                         assertEquals(250, string.getStartPosition());
1045:                         assertEquals(250 + "', '".length(), string.getEndPosition()); //$NON-NLS-1$
1046:
1047:                         generatedText = generatedRegions.get(1);
1048:                         assertEquals("class1, ".length(), generatedText.getStartOffset()); //$NON-NLS-1$
1049:                         assertEquals("class1, class2".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1050:                         moduleElement = generatedText.getModuleElement();
1051:                         element = moduleElement.getModuleElement();
1052:                         assertTrue(element instanceof ASTNode);
1053:                         assertTrue(element instanceof PropertyCallExp);
1054:                         propertyCallExp = (PropertyCallExp)element;
1055:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1056:                         assertEquals(240, propertyCallExp.getStartPosition());
1057:                         assertEquals(240 + "name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
1058:
1059:                         sourceElement = generatedText.getSourceElement();
1060:                         modelElement = sourceElement.getModelElement();
1061:                         assertTrue(modelElement instanceof EClass);
1062:                         assertEquals("class2", ((EClass)modelElement).getName()); //$NON-NLS-1$
1063:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1064:                                         modelElement.eResource().getURI().path());
1065:
1066:                         generatedText = generatedRegions.get(5);
1067:                         assertEquals("class1, class2".length(), generatedText.getStartOffset()); //$NON-NLS-1$
1068:                         assertEquals("class1, class2, ".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1069:                         moduleElement = generatedText.getModuleElement();
1070:                         element = moduleElement.getModuleElement();
1071:                         assertTrue(element instanceof ASTNode);
1072:                         assertTrue(element instanceof StringLiteralExp);
1073:                         string = (StringLiteralExp)element;
1074:                         assertEquals(", ", string.getStringSymbol()); //$NON-NLS-1$
1075:                         assertEquals(250, string.getStartPosition());
1076:                         assertEquals(250 + "', '".length(), string.getEndPosition()); //$NON-NLS-1$
1077:
1078:                         generatedText = generatedRegions.get(2);
1079:                         assertEquals("class1, class2, ".length(), generatedText.getStartOffset()); //$NON-NLS-1$
1080:                         assertEquals("class1, class2, class3".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1081:                         moduleElement = generatedText.getModuleElement();
1082:                         element = moduleElement.getModuleElement();
1083:                         assertTrue(element instanceof ASTNode);
1084:                         assertTrue(element instanceof PropertyCallExp);
1085:                         propertyCallExp = (PropertyCallExp)element;
1086:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1087:                         assertEquals(240, propertyCallExp.getStartPosition());
1088:                         assertEquals(240 + "name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
1089:
1090:                         sourceElement = generatedText.getSourceElement();
1091:                         modelElement = sourceElement.getModelElement();
1092:                         assertTrue(modelElement instanceof EClass);
1093:                         assertEquals("class3", ((EClass)modelElement).getName()); //$NON-NLS-1$
1094:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1095:                                         modelElement.eResource().getURI().path());
1096:
1097:                         generatedText = generatedRegions.get(6);
1098:                         assertEquals("class1, class2, class3".length(), generatedText.getStartOffset()); //$NON-NLS-1$
1099:                         assertEquals("class1, class2, class3, ".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1100:                         moduleElement = generatedText.getModuleElement();
1101:                         element = moduleElement.getModuleElement();
1102:                         assertTrue(element instanceof ASTNode);
1103:                         assertTrue(element instanceof StringLiteralExp);
1104:                         string = (StringLiteralExp)element;
1105:                         assertEquals(", ", string.getStringSymbol()); //$NON-NLS-1$
1106:                         assertEquals(250, string.getStartPosition());
1107:                         assertEquals(250 + "', '".length(), string.getEndPosition()); //$NON-NLS-1$
1108:
1109:                         generatedText = generatedRegions.get(3);
1110:                         assertEquals("class1, class2, class3, ".length(), generatedText.getStartOffset()); //$NON-NLS-1$
1111:                         assertEquals("class1, class2, class3, class4".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1112:                         moduleElement = generatedText.getModuleElement();
1113:                         element = moduleElement.getModuleElement();
1114:                         assertTrue(element instanceof ASTNode);
1115:                         assertTrue(element instanceof PropertyCallExp);
1116:                         propertyCallExp = (PropertyCallExp)element;
1117:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1118:                         assertEquals(240, propertyCallExp.getStartPosition());
1119:                         assertEquals(240 + "name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
1120:
1121:                         sourceElement = generatedText.getSourceElement();
1122:                         modelElement = sourceElement.getModelElement();
1123:                         assertTrue(modelElement instanceof EClass);
1124:                         assertEquals("class4", ((EClass)modelElement).getName()); //$NON-NLS-1$
1125:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1126:                                         modelElement.eResource().getURI().path());
1127:                         cpt++;
1128:                 }
1129:         }
1130:
1131:         @Test
1132:         public void testTraceabilityLibraryStringCollectionFirst() {
1133:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1134:                                 "data/library/string/stringCollectionFirst.mtl", //$NON-NLS-1$
1135:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1136:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1137:                 assertEquals(4, generatedFiles.size());
1138:
1139:                 int cpt = 1;
1140:•                for (GeneratedFile generatedFile : generatedFiles) {
1141:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1142:                         assertEquals(1, generatedRegions.size());
1143:                         assertEquals("a".length(), generatedFile.getLength()); //$NON-NLS-1$
1144:
1145:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1146:                         assertEquals(2, sourceElements.size()); // the class and its name
1147:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1148:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1149:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1150:
1151:                         GeneratedText generatedText = generatedRegions.get(0);
1152:                         assertEquals(0, generatedText.getStartOffset());
1153:                         assertEquals("a".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1154:                         ModuleElement moduleElement = generatedText.getModuleElement();
1155:                         EObject element = moduleElement.getModuleElement();
1156:                         assertTrue(element instanceof ASTNode);
1157:                         assertTrue(element instanceof StringLiteralExp);
1158:                         StringLiteralExp string = (StringLiteralExp)element;
1159:                         assertEquals("a", string.getStringSymbol()); //$NON-NLS-1$
1160:                         assertEquals(197, string.getStartPosition());
1161:                         assertEquals(197 + "'a'".length(), string.getEndPosition()); //$NON-NLS-1$
1162:
1163:                         InputElement sourceElement = generatedText.getSourceElement();
1164:                         EObject modelElement = sourceElement.getModelElement();
1165:                         assertTrue(modelElement instanceof EClass);
1166:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1167:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1168:                                         modelElement.eResource().getURI().path());
1169:                         cpt++;
1170:                 }
1171:         }
1172:
1173:         @Test
1174:         public void testTraceabilityLibraryStringCollectionFirst2() {
1175:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1176:                                 "data/library/string/stringCollectionFirst2.mtl", //$NON-NLS-1$
1177:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1178:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1179:                 assertEquals(4, generatedFiles.size());
1180:
1181:                 int cpt = 1;
1182:•                for (GeneratedFile generatedFile : generatedFiles) {
1183:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1184:                         assertEquals(1, generatedRegions.size());
1185:                         assertEquals(("class" + cpt).length(), generatedFile.getLength()); //$NON-NLS-1$
1186:
1187:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1188:                         assertEquals(2, sourceElements.size()); // the class and its name
1189:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1190:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1191:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1192:
1193:                         GeneratedText generatedText = generatedRegions.get(0);
1194:                         assertEquals(0, generatedText.getStartOffset());
1195:                         assertEquals("class1".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1196:                         ModuleElement moduleElement = generatedText.getModuleElement();
1197:                         EObject element = moduleElement.getModuleElement();
1198:                         assertTrue(element instanceof ASTNode);
1199:                         assertTrue(element instanceof PropertyCallExp);
1200:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
1201:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1202:                         assertEquals(242, propertyCallExp.getStartPosition());
1203:                         assertEquals(242 + "name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
1204:
1205:                         InputElement sourceElement = generatedText.getSourceElement();
1206:                         EObject modelElement = sourceElement.getModelElement();
1207:                         assertTrue(modelElement instanceof EClass);
1208:                         assertEquals("class1", ((EClass)modelElement).getName()); //$NON-NLS-1$
1209:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1210:                                         modelElement.eResource().getURI().path());
1211:                         cpt++;
1212:                 }
1213:         }
1214:
1215:         @Test
1216:         public void testTraceabilityLibraryStringCollectionFirst3() {
1217:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1218:                                 "data/library/string/stringCollectionFirst3.mtl", //$NON-NLS-1$
1219:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1220:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1221:                 assertEquals(4, generatedFiles.size());
1222:
1223:                 int cpt = 1;
1224:•                for (GeneratedFile generatedFile : generatedFiles) {
1225:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1226:                         assertEquals(1, generatedRegions.size());
1227:                         assertEquals(("class" + cpt).length(), generatedFile.getLength()); //$NON-NLS-1$
1228:
1229:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1230:                         assertEquals(2, sourceElements.size()); // the class and its name
1231:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1232:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1233:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1234:
1235:                         GeneratedText generatedText = generatedRegions.get(0);
1236:                         assertEquals(0, generatedText.getStartOffset());
1237:                         assertEquals("class1".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1238:                         ModuleElement moduleElement = generatedText.getModuleElement();
1239:                         EObject element = moduleElement.getModuleElement();
1240:                         assertTrue(element instanceof ASTNode);
1241:                         assertTrue(element instanceof PropertyCallExp);
1242:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
1243:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1244:                         assertEquals(189, propertyCallExp.getStartPosition());
1245:                         assertEquals(189 + "eClass.eContainer().oclAsType(EPackage).eClassifiers->first().name".length(), //$NON-NLS-1$
1246:                                         propertyCallExp.getEndPosition());
1247:
1248:                         InputElement sourceElement = generatedText.getSourceElement();
1249:                         EObject modelElement = sourceElement.getModelElement();
1250:                         assertTrue(modelElement instanceof EClass);
1251:                         assertEquals("class1", ((EClass)modelElement).getName()); //$NON-NLS-1$
1252:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1253:                                         modelElement.eResource().getURI().path());
1254:                         cpt++;
1255:                 }
1256:         }
1257:
1258:         @Test
1259:         public void testTraceabilityLibraryStringCollectionLast() {
1260:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1261:                                 "data/library/string/stringCollectionLast.mtl", //$NON-NLS-1$
1262:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1263:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1264:                 assertEquals(4, generatedFiles.size());
1265:
1266:                 int cpt = 1;
1267:•                for (GeneratedFile generatedFile : generatedFiles) {
1268:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1269:                         assertEquals(1, generatedRegions.size());
1270:                         assertEquals("c".length(), generatedFile.getLength()); //$NON-NLS-1$
1271:
1272:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1273:                         assertEquals(2, sourceElements.size()); // the class and its name
1274:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1275:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1276:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1277:
1278:                         GeneratedText generatedText = generatedRegions.get(0);
1279:                         assertEquals(0, generatedText.getStartOffset());
1280:                         assertEquals("c".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1281:                         ModuleElement moduleElement = generatedText.getModuleElement();
1282:                         EObject element = moduleElement.getModuleElement();
1283:                         assertTrue(element instanceof ASTNode);
1284:                         assertTrue(element instanceof StringLiteralExp);
1285:                         StringLiteralExp string = (StringLiteralExp)element;
1286:                         assertEquals("c", string.getStringSymbol()); //$NON-NLS-1$
1287:                         assertEquals(206, string.getStartPosition());
1288:                         assertEquals(206 + "'c'".length(), string.getEndPosition()); //$NON-NLS-1$
1289:
1290:                         InputElement sourceElement = generatedText.getSourceElement();
1291:                         EObject modelElement = sourceElement.getModelElement();
1292:                         assertTrue(modelElement instanceof EClass);
1293:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1294:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1295:                                         modelElement.eResource().getURI().path());
1296:                         cpt++;
1297:                 }
1298:         }
1299:
1300:         @Test
1301:         public void testTraceabilityLibraryStringCollectionLast2() {
1302:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1303:                                 "data/library/string/stringCollectionLast2.mtl", //$NON-NLS-1$
1304:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1305:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1306:                 assertEquals(4, generatedFiles.size());
1307:
1308:                 int cpt = 1;
1309:•                for (GeneratedFile generatedFile : generatedFiles) {
1310:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1311:                         assertEquals(1, generatedRegions.size());
1312:                         assertEquals(("class" + cpt).length(), generatedFile.getLength()); //$NON-NLS-1$
1313:
1314:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1315:                         assertEquals(2, sourceElements.size()); // the class and its name
1316:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1317:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1318:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1319:
1320:                         GeneratedText generatedText = generatedRegions.get(0);
1321:                         assertEquals(0, generatedText.getStartOffset());
1322:                         assertEquals("class4".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1323:                         ModuleElement moduleElement = generatedText.getModuleElement();
1324:                         EObject element = moduleElement.getModuleElement();
1325:                         assertTrue(element instanceof ASTNode);
1326:                         assertTrue(element instanceof PropertyCallExp);
1327:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
1328:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1329:                         assertEquals(241, propertyCallExp.getStartPosition());
1330:                         assertEquals(241 + "name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
1331:
1332:                         InputElement sourceElement = generatedText.getSourceElement();
1333:                         EObject modelElement = sourceElement.getModelElement();
1334:                         assertTrue(modelElement instanceof EClass);
1335:                         assertEquals("class4", ((EClass)modelElement).getName()); //$NON-NLS-1$
1336:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1337:                                         modelElement.eResource().getURI().path());
1338:                         cpt++;
1339:                 }
1340:         }
1341:
1342:         @Test
1343:         public void testTraceabilityLibraryStringCollectionLast3() {
1344:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1345:                                 "data/library/string/stringCollectionLast3.mtl", //$NON-NLS-1$
1346:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1347:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1348:                 assertEquals(4, generatedFiles.size());
1349:
1350:                 int cpt = 1;
1351:•                for (GeneratedFile generatedFile : generatedFiles) {
1352:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1353:                         assertEquals(1, generatedRegions.size());
1354:                         assertEquals(("class" + cpt).length(), generatedFile.getLength()); //$NON-NLS-1$
1355:
1356:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1357:                         assertEquals(2, sourceElements.size()); // the class and its name
1358:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1359:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1360:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1361:
1362:                         GeneratedText generatedText = generatedRegions.get(0);
1363:                         assertEquals(0, generatedText.getStartOffset());
1364:                         assertEquals("class4".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1365:                         ModuleElement moduleElement = generatedText.getModuleElement();
1366:                         EObject element = moduleElement.getModuleElement();
1367:                         assertTrue(element instanceof ASTNode);
1368:                         assertTrue(element instanceof PropertyCallExp);
1369:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
1370:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1371:                         assertEquals(188, propertyCallExp.getStartPosition());
1372:                         assertEquals(188 + "eClass.eContainer().oclAsType(EPackage).eClassifiers->last().name".length(), //$NON-NLS-1$
1373:                                         propertyCallExp.getEndPosition());
1374:
1375:                         InputElement sourceElement = generatedText.getSourceElement();
1376:                         EObject modelElement = sourceElement.getModelElement();
1377:                         assertTrue(modelElement instanceof EClass);
1378:                         assertEquals("class4", ((EClass)modelElement).getName()); //$NON-NLS-1$
1379:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1380:                                         modelElement.eResource().getURI().path());
1381:                         cpt++;
1382:                 }
1383:         }
1384:
1385:         @Test
1386:         public void testTraceabilityLibraryStringContains() {
1387:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1388:                                 "data/library/string/stringContains.mtl", //$NON-NLS-1$
1389:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1390:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1391:                 assertEquals(4, generatedFiles.size());
1392:
1393:                 int cpt = 1;
1394:•                for (GeneratedFile generatedFile : generatedFiles) {
1395:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1396:                         assertEquals(1, generatedRegions.size());
1397:                         assertEquals("true".length(), generatedFile.getLength()); //$NON-NLS-1$
1398:
1399:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1400:                         assertEquals(2, sourceElements.size()); // the class and its name
1401:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1402:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1403:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1404:
1405:                         GeneratedText generatedText = generatedRegions.get(0);
1406:                         assertEquals(0, generatedText.getStartOffset());
1407:                         assertEquals("true".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1408:                         ModuleElement moduleElement = generatedText.getModuleElement();
1409:                         EObject element = moduleElement.getModuleElement();
1410:                         assertTrue(element instanceof ASTNode);
1411:                         assertTrue(element instanceof StringLiteralExp);
1412:                         StringLiteralExp string = (StringLiteralExp)element;
1413:                         assertEquals("contains operation", string.getStringSymbol()); //$NON-NLS-1$
1414:                         assertEquals(181, string.getStartPosition());
1415:                         assertEquals(181 + "'contains operation'".length(), string.getEndPosition()); //$NON-NLS-1$
1416:
1417:                         InputElement sourceElement = generatedText.getSourceElement();
1418:                         EObject modelElement = sourceElement.getModelElement();
1419:                         assertTrue(modelElement instanceof EClass);
1420:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1421:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1422:                                         modelElement.eResource().getURI().path());
1423:                         cpt++;
1424:                 }
1425:         }
1426:
1427:         @Test
1428:         public void testTraceabilityLibraryStringEndsWith() {
1429:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1430:                                 "data/library/string/stringEndsWith.mtl", //$NON-NLS-1$
1431:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1432:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1433:                 assertEquals(4, generatedFiles.size());
1434:
1435:                 int cpt = 1;
1436:•                for (GeneratedFile generatedFile : generatedFiles) {
1437:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1438:                         assertEquals(1, generatedRegions.size());
1439:                         assertEquals("true".length(), generatedFile.getLength()); //$NON-NLS-1$
1440:
1441:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1442:                         assertEquals(2, sourceElements.size()); // the class and its name
1443:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1444:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1445:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1446:
1447:                         GeneratedText generatedText = generatedRegions.get(0);
1448:                         assertEquals(0, generatedText.getStartOffset());
1449:                         assertEquals("true".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1450:                         ModuleElement moduleElement = generatedText.getModuleElement();
1451:                         EObject element = moduleElement.getModuleElement();
1452:                         assertTrue(element instanceof ASTNode);
1453:                         assertTrue(element instanceof StringLiteralExp);
1454:                         StringLiteralExp string = (StringLiteralExp)element;
1455:                         assertEquals("endsWith operation", string.getStringSymbol()); //$NON-NLS-1$
1456:                         assertEquals(181, string.getStartPosition());
1457:                         assertEquals(181 + "'endsWith operation'".length(), string.getEndPosition()); //$NON-NLS-1$
1458:
1459:                         InputElement sourceElement = generatedText.getSourceElement();
1460:                         EObject modelElement = sourceElement.getModelElement();
1461:                         assertTrue(modelElement instanceof EClass);
1462:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1463:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1464:                                         modelElement.eResource().getURI().path());
1465:                         cpt++;
1466:                 }
1467:         }
1468:
1469:         @Test
1470:         public void testTraceabilityLibraryStringEqualsIgnoreCase() {
1471:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1472:                                 "data/library/string/stringEqualsIgnoreCase.mtl", //$NON-NLS-1$
1473:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1474:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1475:                 assertEquals(4, generatedFiles.size());
1476:
1477:                 int cpt = 1;
1478:•                for (GeneratedFile generatedFile : generatedFiles) {
1479:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1480:                         assertEquals(1, generatedRegions.size());
1481:                         assertEquals("true".length(), generatedFile.getLength()); //$NON-NLS-1$
1482:
1483:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1484:                         assertEquals(2, sourceElements.size()); // the class and its name
1485:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1486:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1487:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1488:
1489:                         GeneratedText generatedText = generatedRegions.get(0);
1490:                         assertEquals(0, generatedText.getStartOffset());
1491:                         assertEquals("true".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1492:                         ModuleElement moduleElement = generatedText.getModuleElement();
1493:                         EObject element = moduleElement.getModuleElement();
1494:                         assertTrue(element instanceof ASTNode);
1495:                         assertTrue(element instanceof StringLiteralExp);
1496:                         StringLiteralExp string = (StringLiteralExp)element;
1497:                         assertEquals("lowercase", string.getStringSymbol()); //$NON-NLS-1$
1498:                         assertEquals(189, string.getStartPosition());
1499:                         assertEquals(189 + "'lowercase'".length(), string.getEndPosition()); //$NON-NLS-1$
1500:
1501:                         InputElement sourceElement = generatedText.getSourceElement();
1502:                         EObject modelElement = sourceElement.getModelElement();
1503:                         assertTrue(modelElement instanceof EClass);
1504:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1505:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1506:                                         modelElement.eResource().getURI().path());
1507:                         cpt++;
1508:                 }
1509:         }
1510:
1511:         @Test
1512:         public void testTraceabilityLibraryStringIsAlpha() {
1513:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1514:                                 "data/library/string/stringIsAlpha.mtl", //$NON-NLS-1$
1515:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1516:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1517:                 assertEquals(4, generatedFiles.size());
1518:
1519:                 int cpt = 1;
1520:•                for (GeneratedFile generatedFile : generatedFiles) {
1521:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1522:                         assertEquals(1, generatedRegions.size());
1523:                         assertEquals("false".length(), generatedFile.getLength()); //$NON-NLS-1$
1524:
1525:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1526:                         assertEquals(2, sourceElements.size()); // the class and its name
1527:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1528:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1529:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1530:
1531:                         GeneratedText generatedText = generatedRegions.get(0);
1532:                         assertEquals(0, generatedText.getStartOffset());
1533:                         assertEquals("false".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1534:                         ModuleElement moduleElement = generatedText.getModuleElement();
1535:                         EObject element = moduleElement.getModuleElement();
1536:                         assertTrue(element instanceof ASTNode);
1537:                         assertTrue(element instanceof PropertyCallExp);
1538:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
1539:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1540:                         assertEquals(180, propertyCallExp.getStartPosition());
1541:                         assertEquals(180 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
1542:
1543:                         InputElement sourceElement = generatedText.getSourceElement();
1544:                         EObject modelElement = sourceElement.getModelElement();
1545:                         assertTrue(modelElement instanceof EClass);
1546:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1547:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1548:                                         modelElement.eResource().getURI().path());
1549:                         cpt++;
1550:                 }
1551:         }
1552:
1553:         @Test
1554:         public void testTraceabilityLibraryStringIsAlpha2() {
1555:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1556:                                 "data/library/string/stringIsAlpha2.mtl", //$NON-NLS-1$
1557:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1558:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1559:                 assertEquals(4, generatedFiles.size());
1560:
1561:                 int cpt = 1;
1562:•                for (GeneratedFile generatedFile : generatedFiles) {
1563:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1564:                         assertEquals(1, generatedRegions.size());
1565:                         assertEquals("false".length(), generatedFile.getLength()); //$NON-NLS-1$
1566:
1567:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1568:                         assertEquals(2, sourceElements.size()); // the class and its name
1569:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1570:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1571:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1572:
1573:                         GeneratedText generatedText = generatedRegions.get(0);
1574:                         assertEquals(0, generatedText.getStartOffset());
1575:                         assertEquals("false".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1576:                         ModuleElement moduleElement = generatedText.getModuleElement();
1577:                         EObject element = moduleElement.getModuleElement();
1578:                         assertTrue(element instanceof ASTNode);
1579:                         assertTrue(element instanceof StringLiteralExp);
1580:                         StringLiteralExp stringLiteralExp = (StringLiteralExp)element;
1581:                         assertEquals(" ljdql ", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
1582:                         assertEquals(181, stringLiteralExp.getStartPosition());
1583:                         assertEquals(181 + "' ljdql '".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
1584:
1585:                         InputElement sourceElement = generatedText.getSourceElement();
1586:                         EObject modelElement = sourceElement.getModelElement();
1587:                         assertTrue(modelElement instanceof EClass);
1588:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1589:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1590:                                         modelElement.eResource().getURI().path());
1591:                         cpt++;
1592:                 }
1593:         }
1594:
1595:         @Test
1596:         public void testTraceabilityLibraryStringIsAlphaNum() {
1597:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1598:                                 "data/library/string/stringIsAlphaNum.mtl", //$NON-NLS-1$
1599:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1600:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1601:                 assertEquals(4, generatedFiles.size());
1602:
1603:                 int cpt = 1;
1604:•                for (GeneratedFile generatedFile : generatedFiles) {
1605:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1606:                         assertEquals(1, generatedRegions.size());
1607:                         assertEquals("clas".length(), generatedFile.getLength()); //$NON-NLS-1$
1608:
1609:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1610:                         assertEquals(2, sourceElements.size()); // the class and its name
1611:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1612:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1613:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1614:
1615:                         GeneratedText generatedText = generatedRegions.get(0);
1616:                         assertEquals(0, generatedText.getStartOffset());
1617:                         assertEquals("clas".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1618:                         ModuleElement moduleElement = generatedText.getModuleElement();
1619:                         EObject element = moduleElement.getModuleElement();
1620:                         assertTrue(element instanceof ASTNode);
1621:                         assertTrue(element instanceof PropertyCallExp);
1622:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
1623:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1624:                         assertEquals(183, propertyCallExp.getStartPosition());
1625:                         assertEquals(183 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
1626:
1627:                         InputElement sourceElement = generatedText.getSourceElement();
1628:                         EObject modelElement = sourceElement.getModelElement();
1629:                         assertTrue(modelElement instanceof EClass);
1630:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1631:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1632:                                         modelElement.eResource().getURI().path());
1633:                         cpt++;
1634:                 }
1635:         }
1636:
1637:         @Test
1638:         public void testTraceabilityLibraryStringIsAlphaNum2() {
1639:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1640:                                 "data/library/string/stringIsAlphaNum2.mtl", //$NON-NLS-1$
1641:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1642:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1643:                 assertEquals(4, generatedFiles.size());
1644:
1645:                 int cpt = 1;
1646:•                for (GeneratedFile generatedFile : generatedFiles) {
1647:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1648:                         assertEquals(1, generatedRegions.size());
1649:                         assertEquals("false".length(), generatedFile.getLength()); //$NON-NLS-1$
1650:
1651:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1652:                         assertEquals(2, sourceElements.size()); // the class and its name
1653:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1654:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1655:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1656:
1657:                         GeneratedText generatedText = generatedRegions.get(0);
1658:                         assertEquals(0, generatedText.getStartOffset());
1659:                         assertEquals("false".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1660:                         ModuleElement moduleElement = generatedText.getModuleElement();
1661:                         EObject element = moduleElement.getModuleElement();
1662:                         assertTrue(element instanceof ASTNode);
1663:                         assertTrue(element instanceof StringLiteralExp);
1664:                         StringLiteralExp stringLiteralExp = (StringLiteralExp)element;
1665:                         assertEquals(" hsdkhs 545", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
1666:                         assertEquals(184, stringLiteralExp.getStartPosition());
1667:                         assertEquals(184 + "' hsdkhs 545'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
1668:
1669:                         InputElement sourceElement = generatedText.getSourceElement();
1670:                         EObject modelElement = sourceElement.getModelElement();
1671:                         assertTrue(modelElement instanceof EClass);
1672:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1673:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1674:                                         modelElement.eResource().getURI().path());
1675:                         cpt++;
1676:                 }
1677:         }
1678:
1679:         @Test
1680:         public void testTraceabilityLibraryStringFirst() {
1681:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1682:                                 "data/library/string/stringFirst.mtl", //$NON-NLS-1$
1683:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1684:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1685:                 assertEquals(4, generatedFiles.size());
1686:
1687:                 int cpt = 1;
1688:•                for (GeneratedFile generatedFile : generatedFiles) {
1689:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1690:                         assertEquals(1, generatedRegions.size());
1691:                         assertEquals("clas".length(), generatedFile.getLength()); //$NON-NLS-1$
1692:
1693:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1694:                         assertEquals(2, sourceElements.size()); // the class and its name
1695:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1696:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1697:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1698:
1699:                         GeneratedText generatedText = generatedRegions.get(0);
1700:                         assertEquals(0, generatedText.getStartOffset());
1701:                         assertEquals("clas".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1702:                         ModuleElement moduleElement = generatedText.getModuleElement();
1703:                         EObject element = moduleElement.getModuleElement();
1704:                         assertTrue(element instanceof ASTNode);
1705:                         assertTrue(element instanceof PropertyCallExp);
1706:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
1707:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1708:                         assertEquals(178, propertyCallExp.getStartPosition());
1709:                         assertEquals(178 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
1710:
1711:                         InputElement sourceElement = generatedText.getSourceElement();
1712:                         EObject modelElement = sourceElement.getModelElement();
1713:                         assertTrue(modelElement instanceof EClass);
1714:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1715:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1716:                                         modelElement.eResource().getURI().path());
1717:                         cpt++;
1718:                 }
1719:         }
1720:
1721:         @Test
1722:         public void testTraceabilityLibraryStringLast() {
1723:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1724:                                 "data/library/string/stringLast.mtl", //$NON-NLS-1$
1725:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1726:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1727:                 assertEquals(4, generatedFiles.size());
1728:
1729:                 int cpt = 1;
1730:•                for (GeneratedFile generatedFile : generatedFiles) {
1731:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1732:                         assertEquals(1, generatedRegions.size());
1733:                         assertEquals("clas".length(), generatedFile.getLength()); //$NON-NLS-1$
1734:
1735:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1736:                         assertEquals(2, sourceElements.size()); // the class and its name
1737:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1738:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1739:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1740:
1741:                         GeneratedText generatedText = generatedRegions.get(0);
1742:                         assertEquals(0, generatedText.getStartOffset());
1743:                         assertEquals("clas".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1744:                         ModuleElement moduleElement = generatedText.getModuleElement();
1745:                         EObject element = moduleElement.getModuleElement();
1746:                         assertTrue(element instanceof ASTNode);
1747:                         assertTrue(element instanceof PropertyCallExp);
1748:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
1749:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1750:                         assertEquals(177, propertyCallExp.getStartPosition());
1751:                         assertEquals(177 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
1752:
1753:                         InputElement sourceElement = generatedText.getSourceElement();
1754:                         EObject modelElement = sourceElement.getModelElement();
1755:                         assertTrue(modelElement instanceof EClass);
1756:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1757:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1758:                                         modelElement.eResource().getURI().path());
1759:                         cpt++;
1760:                 }
1761:         }
1762:
1763:         @Test
1764:         public void testTraceabilityLibraryStringLastIndex() {
1765:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1766:                                 "data/library/string/stringLastIndex.mtl", //$NON-NLS-1$
1767:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1768:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1769:                 assertEquals(4, generatedFiles.size());
1770:
1771:                 int cpt = 1;
1772:•                for (GeneratedFile generatedFile : generatedFiles) {
1773:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1774:                         assertEquals(1, generatedRegions.size());
1775:                         assertEquals("14".length(), generatedFile.getLength()); //$NON-NLS-1$
1776:
1777:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1778:                         assertEquals(2, sourceElements.size()); // the class and its name
1779:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1780:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1781:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1782:
1783:                         GeneratedText generatedText = generatedRegions.get(0);
1784:                         assertEquals(0, generatedText.getStartOffset());
1785:                         assertEquals("14".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1786:                         ModuleElement moduleElement = generatedText.getModuleElement();
1787:                         EObject element = moduleElement.getModuleElement();
1788:                         assertTrue(element instanceof ASTNode);
1789:                         assertTrue(element instanceof StringLiteralExp);
1790:                         StringLiteralExp stringLiteralExp = (StringLiteralExp)element;
1791:                         assertEquals("index operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
1792:                         assertEquals(182, stringLiteralExp.getStartPosition());
1793:                         assertEquals(182 + "'index operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
1794:
1795:                         InputElement sourceElement = generatedText.getSourceElement();
1796:                         EObject modelElement = sourceElement.getModelElement();
1797:                         assertTrue(modelElement instanceof EClass);
1798:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1799:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1800:                                         modelElement.eResource().getURI().path());
1801:                         cpt++;
1802:                 }
1803:         }
1804:
1805:         @Test
1806:         public void testTraceabilityLibraryStringMatches() {
1807:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1808:                                 "data/library/string/stringMatches.mtl", //$NON-NLS-1$
1809:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1810:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1811:                 assertEquals(4, generatedFiles.size());
1812:
1813:                 int cpt = 1;
1814:•                for (GeneratedFile generatedFile : generatedFiles) {
1815:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1816:                         assertEquals(1, generatedRegions.size());
1817:                         assertEquals("true".length(), generatedFile.getLength()); //$NON-NLS-1$
1818:
1819:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1820:                         assertEquals(2, sourceElements.size()); // the class and its name
1821:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1822:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1823:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1824:
1825:                         GeneratedText generatedText = generatedRegions.get(0);
1826:                         assertEquals(0, generatedText.getStartOffset());
1827:                         assertEquals("true".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1828:                         ModuleElement moduleElement = generatedText.getModuleElement();
1829:                         EObject element = moduleElement.getModuleElement();
1830:                         assertTrue(element instanceof ASTNode);
1831:                         assertTrue(element instanceof StringLiteralExp);
1832:                         StringLiteralExp stringLiteralExp = (StringLiteralExp)element;
1833:                         assertEquals("characters and spaces", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
1834:                         assertEquals(180, stringLiteralExp.getStartPosition());
1835:                         assertEquals(180 + "'characters and spaces'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
1836:
1837:                         InputElement sourceElement = generatedText.getSourceElement();
1838:                         EObject modelElement = sourceElement.getModelElement();
1839:                         assertTrue(modelElement instanceof EClass);
1840:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1841:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1842:                                         modelElement.eResource().getURI().path());
1843:                         cpt++;
1844:                 }
1845:         }
1846:
1847:         @Test
1848:         public void testTraceabilityLibraryStringIndex() {
1849:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1850:                                 "data/library/string/stringIndex.mtl", //$NON-NLS-1$
1851:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1852:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1853:                 assertEquals(4, generatedFiles.size());
1854:
1855:                 int cpt = 1;
1856:•                for (GeneratedFile generatedFile : generatedFiles) {
1857:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1858:                         assertEquals(1, generatedRegions.size());
1859:                         assertEquals("4".length(), generatedFile.getLength()); //$NON-NLS-1$
1860:
1861:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1862:                         assertEquals(2, sourceElements.size()); // the class and its name
1863:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1864:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1865:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1866:
1867:                         GeneratedText generatedText = generatedRegions.get(0);
1868:                         assertEquals(0, generatedText.getStartOffset());
1869:                         assertEquals("2".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1870:                         ModuleElement moduleElement = generatedText.getModuleElement();
1871:                         EObject element = moduleElement.getModuleElement();
1872:                         assertTrue(element instanceof ASTNode);
1873:                         assertTrue(element instanceof PropertyCallExp);
1874:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
1875:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
1876:                         assertEquals(178, propertyCallExp.getStartPosition());
1877:                         assertEquals(178 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
1878:
1879:                         InputElement sourceElement = generatedText.getSourceElement();
1880:                         EObject modelElement = sourceElement.getModelElement();
1881:                         assertTrue(modelElement instanceof EClass);
1882:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1883:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1884:                                         modelElement.eResource().getURI().path());
1885:                         cpt++;
1886:                 }
1887:         }
1888:
1889:         @Test
1890:         public void testTraceabilityLibraryStringStartsWith() {
1891:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1892:                                 "data/library/string/stringStartsWith.mtl", //$NON-NLS-1$
1893:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1894:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1895:                 assertEquals(4, generatedFiles.size());
1896:
1897:                 int cpt = 1;
1898:•                for (GeneratedFile generatedFile : generatedFiles) {
1899:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1900:                         assertEquals(1, generatedRegions.size());
1901:                         assertEquals("true".length(), generatedFile.getLength()); //$NON-NLS-1$
1902:
1903:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1904:                         assertEquals(2, sourceElements.size()); // the class and its name
1905:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1906:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1907:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1908:
1909:                         GeneratedText generatedText = generatedRegions.get(0);
1910:                         assertEquals(0, generatedText.getStartOffset());
1911:                         assertEquals("true".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1912:                         ModuleElement moduleElement = generatedText.getModuleElement();
1913:                         EObject element = moduleElement.getModuleElement();
1914:                         assertTrue(element instanceof ASTNode);
1915:                         assertTrue(element instanceof StringLiteralExp);
1916:                         StringLiteralExp stringLiteralExp = (StringLiteralExp)element;
1917:                         assertEquals("startsWith operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
1918:                         assertEquals(183, stringLiteralExp.getStartPosition());
1919:                         assertEquals(183 + "'startsWith operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
1920:
1921:                         InputElement sourceElement = generatedText.getSourceElement();
1922:                         EObject modelElement = sourceElement.getModelElement();
1923:                         assertTrue(modelElement instanceof EClass);
1924:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1925:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1926:                                         modelElement.eResource().getURI().path());
1927:                         cpt++;
1928:                 }
1929:         }
1930:
1931:         @Test
1932:         public void testTraceabilityLibraryStringStrCmp() {
1933:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1934:                                 "data/library/string/stringStrCmp.mtl", //$NON-NLS-1$
1935:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1936:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1937:                 assertEquals(4, generatedFiles.size());
1938:
1939:                 int cpt = 1;
1940:•                for (GeneratedFile generatedFile : generatedFiles) {
1941:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1942:                         assertEquals(1, generatedRegions.size());
1943:                         assertEquals("10".length(), generatedFile.getLength()); //$NON-NLS-1$
1944:
1945:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1946:                         assertEquals(2, sourceElements.size()); // the class and its name
1947:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1948:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1949:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1950:
1951:                         GeneratedText generatedText = generatedRegions.get(0);
1952:                         assertEquals(0, generatedText.getStartOffset());
1953:                         assertEquals("10".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1954:                         ModuleElement moduleElement = generatedText.getModuleElement();
1955:                         EObject element = moduleElement.getModuleElement();
1956:                         assertTrue(element instanceof ASTNode);
1957:                         assertTrue(element instanceof StringLiteralExp);
1958:                         StringLiteralExp stringLiteralExp = (StringLiteralExp)element;
1959:                         assertEquals("strcmp operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
1960:                         assertEquals(179, stringLiteralExp.getStartPosition());
1961:                         assertEquals(179 + "'strcmp operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
1962:
1963:                         InputElement sourceElement = generatedText.getSourceElement();
1964:                         EObject modelElement = sourceElement.getModelElement();
1965:                         assertTrue(modelElement instanceof EClass);
1966:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
1967:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
1968:                                         modelElement.eResource().getURI().path());
1969:                         cpt++;
1970:                 }
1971:         }
1972:
1973:         @Test
1974:         public void testTraceabilityLibraryStringStrStr() {
1975:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
1976:                                 "data/library/string/stringStrStr.mtl", //$NON-NLS-1$
1977:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
1978:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
1979:                 assertEquals(4, generatedFiles.size());
1980:
1981:                 int cpt = 1;
1982:•                for (GeneratedFile generatedFile : generatedFiles) {
1983:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
1984:                         assertEquals(1, generatedRegions.size());
1985:                         assertEquals("true".length(), generatedFile.getLength()); //$NON-NLS-1$
1986:
1987:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
1988:                         assertEquals(2, sourceElements.size()); // the class and its name
1989:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
1990:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
1991:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
1992:
1993:                         GeneratedText generatedText = generatedRegions.get(0);
1994:                         assertEquals(0, generatedText.getStartOffset());
1995:                         assertEquals("true".length(), generatedText.getEndOffset()); //$NON-NLS-1$
1996:                         ModuleElement moduleElement = generatedText.getModuleElement();
1997:                         EObject element = moduleElement.getModuleElement();
1998:                         assertTrue(element instanceof ASTNode);
1999:                         assertTrue(element instanceof StringLiteralExp);
2000:                         StringLiteralExp stringLiteralExp = (StringLiteralExp)element;
2001:                         assertEquals("strstr operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2002:                         assertEquals(179, stringLiteralExp.getStartPosition());
2003:                         assertEquals(179 + "'strstr operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2004:
2005:                         InputElement sourceElement = generatedText.getSourceElement();
2006:                         EObject modelElement = sourceElement.getModelElement();
2007:                         assertTrue(modelElement instanceof EClass);
2008:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
2009:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
2010:                                         modelElement.eResource().getURI().path());
2011:                         cpt++;
2012:                 }
2013:         }
2014:
2015:         @Test
2016:         public void testTraceabilityLibraryStringStrTok() {
2017:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
2018:                                 "data/library/string/stringStrTok.mtl", //$NON-NLS-1$
2019:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
2020:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
2021:                 assertEquals(4, generatedFiles.size());
2022:
2023:                 int cpt = 1;
2024:•                for (GeneratedFile generatedFile : generatedFiles) {
2025:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
2026:                         assertEquals(1, generatedRegions.size());
2027:                         assertEquals("strt".length(), generatedFile.getLength()); //$NON-NLS-1$
2028:
2029:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
2030:                         assertEquals(2, sourceElements.size()); // the class and its name
2031:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
2032:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
2033:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
2034:
2035:                         GeneratedText generatedText = generatedRegions.get(0);
2036:                         assertEquals(0, generatedText.getStartOffset());
2037:                         assertEquals("strt".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2038:                         ModuleElement moduleElement = generatedText.getModuleElement();
2039:                         EObject element = moduleElement.getModuleElement();
2040:                         assertTrue(element instanceof ASTNode);
2041:                         assertTrue(element instanceof StringLiteralExp);
2042:                         StringLiteralExp stringLiteralExp = (StringLiteralExp)element;
2043:                         assertEquals("strtok operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2044:                         assertEquals(179, stringLiteralExp.getStartPosition());
2045:                         assertEquals(179 + "'strtok operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2046:
2047:                         InputElement sourceElement = generatedText.getSourceElement();
2048:                         EObject modelElement = sourceElement.getModelElement();
2049:                         assertTrue(modelElement instanceof EClass);
2050:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
2051:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
2052:                                         modelElement.eResource().getURI().path());
2053:                         cpt++;
2054:                 }
2055:         }
2056:
2057:         @Test
2058:         public void testTraceabilityLibraryStringSubstitute() {
2059:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
2060:                                 "data/library/string/stringSubstitute.mtl", //$NON-NLS-1$
2061:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
2062:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
2063:                 assertEquals(4, generatedFiles.size());
2064:
2065:                 int cpt = 1;
2066:•                for (GeneratedFile generatedFile : generatedFiles) {
2067:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
2068:                         assertEquals(3, generatedRegions.size());
2069:                         assertEquals(("clazs" + cpt).length(), generatedFile.getLength()); //$NON-NLS-1$
2070:
2071:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
2072:                         assertEquals(2, sourceElements.size()); // the class and its name
2073:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
2074:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
2075:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
2076:
2077:                         GeneratedText generatedText = generatedRegions.get(0);
2078:                         assertEquals(0, generatedText.getStartOffset());
2079:                         assertEquals("cla".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2080:                         ModuleElement moduleElement = generatedText.getModuleElement();
2081:                         EObject element = moduleElement.getModuleElement();
2082:                         assertTrue(element instanceof ASTNode);
2083:                         assertTrue(element instanceof PropertyCallExp);
2084:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
2085:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
2086:                         assertEquals(183, propertyCallExp.getStartPosition());
2087:                         assertEquals(183 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
2088:
2089:                         generatedText = generatedRegions.get(2);
2090:                         assertEquals("cla".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2091:                         assertEquals("claz".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2092:                         moduleElement = generatedText.getModuleElement();
2093:                         element = moduleElement.getModuleElement();
2094:                         assertTrue(element instanceof ASTNode);
2095:                         assertTrue(element instanceof StringLiteralExp);
2096:                         StringLiteralExp string = (StringLiteralExp)element;
2097:                         assertEquals("z", string.getStringSymbol()); //$NON-NLS-1$
2098:                         assertEquals(211, string.getStartPosition());
2099:                         assertEquals(211 + "'z'".length(), string.getEndPosition()); //$NON-NLS-1$
2100:
2101:                         generatedText = generatedRegions.get(1);
2102:                         assertEquals("claz".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2103:                         assertEquals(("clazs" + cpt).length(), generatedText.getEndOffset()); //$NON-NLS-1$
2104:                         moduleElement = generatedText.getModuleElement();
2105:                         element = moduleElement.getModuleElement();
2106:                         assertTrue(element instanceof ASTNode);
2107:                         assertTrue(element instanceof PropertyCallExp);
2108:                         propertyCallExp = (PropertyCallExp)element;
2109:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
2110:                         assertEquals(183, propertyCallExp.getStartPosition());
2111:                         assertEquals(183 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
2112:
2113:                         InputElement sourceElement = generatedText.getSourceElement();
2114:                         EObject modelElement = sourceElement.getModelElement();
2115:                         assertTrue(modelElement instanceof EClass);
2116:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
2117:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
2118:                                         modelElement.eResource().getURI().path());
2119:                         cpt++;
2120:                 }
2121:         }
2122:
2123:         @Test
2124:         public void testTraceabilityLibraryStringSubstituteAll() {
2125:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
2126:                                 "data/library/string/stringSubstituteAll.mtl", //$NON-NLS-1$
2127:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
2128:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
2129:                 assertEquals(4, generatedFiles.size());
2130:
2131:                 int cpt = 1;
2132:•                for (GeneratedFile generatedFile : generatedFiles) {
2133:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
2134:                         assertEquals(9, generatedRegions.size());
2135:                         assertEquals("subsTiTuTeAll operaTion".length(), generatedFile.getLength()); //$NON-NLS-1$
2136:
2137:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
2138:                         assertEquals(2, sourceElements.size()); // the class and its name
2139:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
2140:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
2141:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
2142:
2143:                         GeneratedText generatedText = generatedRegions.get(0);
2144:                         assertEquals(0, generatedText.getStartOffset());
2145:                         assertEquals("subs".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2146:                         ModuleElement moduleElement = generatedText.getModuleElement();
2147:                         EObject element = moduleElement.getModuleElement();
2148:                         assertTrue(element instanceof ASTNode);
2149:                         assertTrue(element instanceof StringLiteralExp);
2150:                         StringLiteralExp stringLiteralExp = (StringLiteralExp)element;
2151:                         assertEquals("substituteAll operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2152:                         assertEquals(186, stringLiteralExp.getStartPosition());
2153:                         assertEquals(186 + "'substituteAll operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2154:
2155:                         generatedText = generatedRegions.get(2);
2156:                         assertEquals("subs".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2157:                         assertEquals("subsT".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2158:                         moduleElement = generatedText.getModuleElement();
2159:                         element = moduleElement.getModuleElement();
2160:                         assertTrue(element instanceof ASTNode);
2161:                         assertTrue(element instanceof StringLiteralExp);
2162:                         stringLiteralExp = (StringLiteralExp)element;
2163:                         assertEquals("T", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2164:                         assertEquals(231, stringLiteralExp.getStartPosition());
2165:                         assertEquals(231 + "'T'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2166:
2167:                         generatedText = generatedRegions.get(1);
2168:                         assertEquals("subsT".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2169:                         assertEquals("subsTi".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2170:                         moduleElement = generatedText.getModuleElement();
2171:                         element = moduleElement.getModuleElement();
2172:                         assertTrue(element instanceof ASTNode);
2173:                         assertTrue(element instanceof StringLiteralExp);
2174:                         stringLiteralExp = (StringLiteralExp)element;
2175:                         assertEquals("substituteAll operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2176:                         assertEquals(186, stringLiteralExp.getStartPosition());
2177:                         assertEquals(186 + "'substituteAll operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2178:
2179:                         generatedText = generatedRegions.get(4);
2180:                         assertEquals("subsTi".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2181:                         assertEquals("subsTiT".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2182:                         moduleElement = generatedText.getModuleElement();
2183:                         element = moduleElement.getModuleElement();
2184:                         assertTrue(element instanceof ASTNode);
2185:                         assertTrue(element instanceof StringLiteralExp);
2186:                         stringLiteralExp = (StringLiteralExp)element;
2187:                         assertEquals("T", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2188:                         assertEquals(231, stringLiteralExp.getStartPosition());
2189:                         assertEquals(231 + "'T'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2190:
2191:                         generatedText = generatedRegions.get(3);
2192:                         assertEquals("subsTiT".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2193:                         assertEquals("subsTiTu".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2194:                         moduleElement = generatedText.getModuleElement();
2195:                         element = moduleElement.getModuleElement();
2196:                         assertTrue(element instanceof ASTNode);
2197:                         assertTrue(element instanceof StringLiteralExp);
2198:                         stringLiteralExp = (StringLiteralExp)element;
2199:                         assertEquals("substituteAll operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2200:                         assertEquals(186, stringLiteralExp.getStartPosition());
2201:                         assertEquals(186 + "'substituteAll operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2202:
2203:                         generatedText = generatedRegions.get(6);
2204:                         assertEquals("subsTiTu".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2205:                         assertEquals("subsTiTuT".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2206:                         moduleElement = generatedText.getModuleElement();
2207:                         element = moduleElement.getModuleElement();
2208:                         assertTrue(element instanceof ASTNode);
2209:                         assertTrue(element instanceof StringLiteralExp);
2210:                         stringLiteralExp = (StringLiteralExp)element;
2211:                         assertEquals("T", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2212:                         assertEquals(231, stringLiteralExp.getStartPosition());
2213:                         assertEquals(231 + "'T'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2214:
2215:                         generatedText = generatedRegions.get(5);
2216:                         assertEquals("subsTiTuT".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2217:                         assertEquals("subsTiTuTeAll opera".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2218:                         moduleElement = generatedText.getModuleElement();
2219:                         element = moduleElement.getModuleElement();
2220:                         assertTrue(element instanceof ASTNode);
2221:                         assertTrue(element instanceof StringLiteralExp);
2222:                         stringLiteralExp = (StringLiteralExp)element;
2223:                         assertEquals("substituteAll operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2224:                         assertEquals(186, stringLiteralExp.getStartPosition());
2225:                         assertEquals(186 + "'substituteAll operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2226:
2227:                         generatedText = generatedRegions.get(8);
2228:                         assertEquals("subsTiTuTeAll opera".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2229:                         assertEquals("subsTiTuTeAll operaT".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2230:                         moduleElement = generatedText.getModuleElement();
2231:                         element = moduleElement.getModuleElement();
2232:                         assertTrue(element instanceof ASTNode);
2233:                         assertTrue(element instanceof StringLiteralExp);
2234:                         stringLiteralExp = (StringLiteralExp)element;
2235:                         assertEquals("T", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2236:                         assertEquals(231, stringLiteralExp.getStartPosition());
2237:                         assertEquals(231 + "'T'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2238:
2239:                         generatedText = generatedRegions.get(7);
2240:                         assertEquals("subsTiTuTeAll operaT".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2241:                         assertEquals("subsTiTuTeAll operaTion".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2242:                         moduleElement = generatedText.getModuleElement();
2243:                         element = moduleElement.getModuleElement();
2244:                         assertTrue(element instanceof ASTNode);
2245:                         assertTrue(element instanceof StringLiteralExp);
2246:                         stringLiteralExp = (StringLiteralExp)element;
2247:                         assertEquals("substituteAll operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2248:                         assertEquals(186, stringLiteralExp.getStartPosition());
2249:                         assertEquals(186 + "'substituteAll operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2250:
2251:                         InputElement sourceElement = generatedText.getSourceElement();
2252:                         EObject modelElement = sourceElement.getModelElement();
2253:                         assertTrue(modelElement instanceof EClass);
2254:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
2255:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
2256:                                         modelElement.eResource().getURI().path());
2257:                         cpt++;
2258:                 }
2259:         }
2260:
2261:         @Test
2262:         public void testTraceabilityLibraryStringSubstring() {
2263:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
2264:                                 "data/library/string/stringSubstring.mtl", //$NON-NLS-1$
2265:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
2266:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
2267:                 assertEquals(4, generatedFiles.size());
2268:
2269:                 int cpt = 1;
2270:•                for (GeneratedFile generatedFile : generatedFiles) {
2271:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
2272:                         assertEquals(1, generatedRegions.size());
2273:                         assertEquals("clas".length(), generatedFile.getLength()); //$NON-NLS-1$
2274:
2275:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
2276:                         assertEquals(2, sourceElements.size()); // the class and its name
2277:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
2278:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
2279:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
2280:
2281:                         GeneratedText generatedText = generatedRegions.get(0);
2282:                         assertEquals(0, generatedText.getStartOffset());
2283:                         assertEquals("clas".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2284:                         ModuleElement moduleElement = generatedText.getModuleElement();
2285:                         EObject element = moduleElement.getModuleElement();
2286:                         assertTrue(element instanceof ASTNode);
2287:                         assertTrue(element instanceof PropertyCallExp);
2288:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
2289:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
2290:                         assertEquals(182, propertyCallExp.getStartPosition());
2291:                         assertEquals(182 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
2292:
2293:                         InputElement sourceElement = generatedText.getSourceElement();
2294:                         EObject modelElement = sourceElement.getModelElement();
2295:                         assertTrue(modelElement instanceof EClass);
2296:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
2297:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
2298:                                         modelElement.eResource().getURI().path());
2299:                         cpt++;
2300:                 }
2301:         }
2302:
2303:         @Test
2304:         public void testTraceabilityLibraryStringTokenize() {
2305:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
2306:                                 "data/library/string/stringTokenize.mtl", //$NON-NLS-1$
2307:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
2308:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
2309:                 assertEquals(4, generatedFiles.size());
2310:
2311:                 int cpt = 1;
2312:•                for (GeneratedFile generatedFile : generatedFiles) {
2313:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
2314:                         assertEquals(4, generatedRegions.size());
2315:                         assertEquals("tokniz opration".length(), generatedFile.getLength()); //$NON-NLS-1$
2316:
2317:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
2318:                         assertEquals(2, sourceElements.size()); // the class and its name
2319:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
2320:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
2321:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
2322:
2323:                         GeneratedText generatedText = generatedRegions.get(0);
2324:                         assertEquals(0, generatedText.getStartOffset());
2325:                         assertEquals("tok".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2326:                         ModuleElement moduleElement = generatedText.getModuleElement();
2327:                         EObject element = moduleElement.getModuleElement();
2328:                         assertTrue(element instanceof ASTNode);
2329:                         assertTrue(element instanceof StringLiteralExp);
2330:                         StringLiteralExp stringLiteralExp = (StringLiteralExp)element;
2331:                         assertEquals("tokenize operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2332:                         assertEquals(181, stringLiteralExp.getStartPosition());
2333:                         assertEquals(181 + "'tokenize operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2334:
2335:                         generatedText = generatedRegions.get(1);
2336:                         assertEquals("tok".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2337:                         assertEquals("tokniz".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2338:                         moduleElement = generatedText.getModuleElement();
2339:                         element = moduleElement.getModuleElement();
2340:                         assertTrue(element instanceof ASTNode);
2341:                         assertTrue(element instanceof StringLiteralExp);
2342:                         stringLiteralExp = (StringLiteralExp)element;
2343:                         assertEquals("tokenize operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2344:                         assertEquals(181, stringLiteralExp.getStartPosition());
2345:                         assertEquals(181 + "'tokenize operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2346:
2347:                         generatedText = generatedRegions.get(2);
2348:                         assertEquals("tokniz".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2349:                         assertEquals("tokniz op".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2350:                         moduleElement = generatedText.getModuleElement();
2351:                         element = moduleElement.getModuleElement();
2352:                         assertTrue(element instanceof ASTNode);
2353:                         assertTrue(element instanceof StringLiteralExp);
2354:                         stringLiteralExp = (StringLiteralExp)element;
2355:                         assertEquals("tokenize operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2356:                         assertEquals(181, stringLiteralExp.getStartPosition());
2357:                         assertEquals(181 + "'tokenize operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2358:
2359:                         generatedText = generatedRegions.get(3);
2360:                         assertEquals("tokniz op".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2361:                         assertEquals("tokniz opration".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2362:                         moduleElement = generatedText.getModuleElement();
2363:                         element = moduleElement.getModuleElement();
2364:                         assertTrue(element instanceof ASTNode);
2365:                         assertTrue(element instanceof StringLiteralExp);
2366:                         stringLiteralExp = (StringLiteralExp)element;
2367:                         assertEquals("tokenize operation", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2368:                         assertEquals(181, stringLiteralExp.getStartPosition());
2369:                         assertEquals(181 + "'tokenize operation'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2370:
2371:                         InputElement sourceElement = generatedText.getSourceElement();
2372:                         EObject modelElement = sourceElement.getModelElement();
2373:                         assertTrue(modelElement instanceof EClass);
2374:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
2375:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
2376:                                         modelElement.eResource().getURI().path());
2377:                         cpt++;
2378:                 }
2379:         }
2380:
2381:         @Test
2382:         public void testTraceabilityLibraryStringTokenize2() {
2383:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
2384:                                 "data/library/string/stringTokenize2.mtl", //$NON-NLS-1$
2385:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
2386:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
2387:                 assertEquals(4, generatedFiles.size());
2388:
2389:                 int cpt = 1;
2390:•                for (GeneratedFile generatedFile : generatedFiles) {
2391:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
2392:                         assertEquals(8, generatedRegions.size());
2393:                         assertEquals("rihrrymlipoupoupidoupou".length(), generatedFile.getLength()); //$NON-NLS-1$
2394:
2395:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
2396:                         assertEquals(2, sourceElements.size()); // the class and its name
2397:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
2398:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
2399:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
2400:
2401:                         GeneratedText generatedText = generatedRegions.get(0);
2402:                         assertEquals(0, generatedText.getStartOffset());
2403:                         assertEquals("ri".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2404:                         ModuleElement moduleElement = generatedText.getModuleElement();
2405:                         EObject element = moduleElement.getModuleElement();
2406:                         assertTrue(element instanceof ASTNode);
2407:                         assertTrue(element instanceof StringLiteralExp);
2408:                         StringLiteralExp stringLiteralExp = (StringLiteralExp)element;
2409:                         assertEquals("aria", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2410:                         assertEquals(197, stringLiteralExp.getStartPosition());
2411:                         assertEquals(197 + "'aria'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2412:
2413:                         generatedText = generatedRegions.get(1);
2414:                         assertEquals("ri".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2415:                         assertEquals("rih".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2416:                         moduleElement = generatedText.getModuleElement();
2417:                         element = moduleElement.getModuleElement();
2418:                         assertTrue(element instanceof ASTNode);
2419:                         assertTrue(element instanceof StringLiteralExp);
2420:                         stringLiteralExp = (StringLiteralExp)element;
2421:                         assertEquals("harry", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2422:                         assertEquals(213, stringLiteralExp.getStartPosition());
2423:                         assertEquals(213 + "'harry'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2424:
2425:                         generatedText = generatedRegions.get(2);
2426:                         assertEquals("rih".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2427:                         assertEquals("rihrry".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2428:                         moduleElement = generatedText.getModuleElement();
2429:                         element = moduleElement.getModuleElement();
2430:                         assertTrue(element instanceof ASTNode);
2431:                         assertTrue(element instanceof StringLiteralExp);
2432:                         stringLiteralExp = (StringLiteralExp)element;
2433:                         assertEquals("harry", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2434:                         assertEquals(213, stringLiteralExp.getStartPosition());
2435:                         assertEquals(213 + "'harry'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2436:
2437:                         generatedText = generatedRegions.get(3);
2438:                         assertEquals("rihrry".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2439:                         assertEquals("rihrrym".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2440:                         moduleElement = generatedText.getModuleElement();
2441:                         element = moduleElement.getModuleElement();
2442:                         assertTrue(element instanceof ASTNode);
2443:                         assertTrue(element instanceof StringLiteralExp);
2444:                         stringLiteralExp = (StringLiteralExp)element;
2445:                         assertEquals("malia", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2446:                         assertEquals(223, stringLiteralExp.getStartPosition());
2447:                         assertEquals(223 + "'malia'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2448:
2449:                         generatedText = generatedRegions.get(4);
2450:                         assertEquals("rihrrym".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2451:                         assertEquals("rihrrymli".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2452:                         moduleElement = generatedText.getModuleElement();
2453:                         element = moduleElement.getModuleElement();
2454:                         assertTrue(element instanceof ASTNode);
2455:                         assertTrue(element instanceof StringLiteralExp);
2456:                         stringLiteralExp = (StringLiteralExp)element;
2457:                         assertEquals("malia", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2458:                         assertEquals(223, stringLiteralExp.getStartPosition());
2459:                         assertEquals(223 + "'malia'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2460:
2461:                         generatedText = generatedRegions.get(5);
2462:                         assertEquals("rihrrymli".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2463:                         assertEquals("rihrrymlipou".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2464:                         moduleElement = generatedText.getModuleElement();
2465:                         element = moduleElement.getModuleElement();
2466:                         assertTrue(element instanceof ASTNode);
2467:                         assertTrue(element instanceof StringLiteralExp);
2468:                         stringLiteralExp = (StringLiteralExp)element;
2469:                         assertEquals("pou", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2470:                         assertEquals(240, stringLiteralExp.getStartPosition());
2471:                         assertEquals(240 + "'pou'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2472:
2473:                         generatedText = generatedRegions.get(6);
2474:                         assertEquals("rihrrymlipou".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2475:                         assertEquals("rihrrymlipoupoupidou".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2476:                         moduleElement = generatedText.getModuleElement();
2477:                         element = moduleElement.getModuleElement();
2478:                         assertTrue(element instanceof ASTNode);
2479:                         assertTrue(element instanceof StringLiteralExp);
2480:                         stringLiteralExp = (StringLiteralExp)element;
2481:                         assertEquals("poupidou", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2482:                         assertEquals(248, stringLiteralExp.getStartPosition());
2483:                         assertEquals(248 + "'poupidou'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2484:
2485:                         generatedText = generatedRegions.get(7);
2486:                         assertEquals("rihrrymlipoupoupidou".length(), generatedText.getStartOffset()); //$NON-NLS-1$
2487:                         assertEquals("rihrrymlipoupoupidoupou".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2488:                         moduleElement = generatedText.getModuleElement();
2489:                         element = moduleElement.getModuleElement();
2490:                         assertTrue(element instanceof ASTNode);
2491:                         assertTrue(element instanceof StringLiteralExp);
2492:                         stringLiteralExp = (StringLiteralExp)element;
2493:                         assertEquals("pou", stringLiteralExp.getStringSymbol()); //$NON-NLS-1$
2494:                         assertEquals(261, stringLiteralExp.getStartPosition());
2495:                         assertEquals(261 + "'pou'".length(), stringLiteralExp.getEndPosition()); //$NON-NLS-1$
2496:
2497:                         InputElement sourceElement = generatedText.getSourceElement();
2498:                         EObject modelElement = sourceElement.getModelElement();
2499:                         assertTrue(modelElement instanceof EClass);
2500:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
2501:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
2502:                                         modelElement.eResource().getURI().path());
2503:                         cpt++;
2504:                 }
2505:         }
2506:
2507:         @Test
2508:         public void testTraceabilityLibraryStringToLowerFirst() {
2509:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
2510:                                 "data/library/string/stringToLowerFirst.mtl", //$NON-NLS-1$
2511:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
2512:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
2513:                 assertEquals(4, generatedFiles.size());
2514:
2515:                 int cpt = 1;
2516:•                for (GeneratedFile generatedFile : generatedFiles) {
2517:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
2518:                         assertEquals(1, generatedRegions.size());
2519:                         assertEquals(("class" + cpt).length(), generatedFile.getLength()); //$NON-NLS-1$
2520:
2521:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
2522:                         assertEquals(2, sourceElements.size()); // the class and its name
2523:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
2524:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
2525:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
2526:
2527:                         GeneratedText generatedText = generatedRegions.get(0);
2528:                         assertEquals(0, generatedText.getStartOffset());
2529:                         assertEquals(("class" + cpt).length(), generatedText.getEndOffset()); //$NON-NLS-1$
2530:                         ModuleElement moduleElement = generatedText.getModuleElement();
2531:                         EObject element = moduleElement.getModuleElement();
2532:                         assertTrue(element instanceof ASTNode);
2533:                         assertTrue(element instanceof PropertyCallExp);
2534:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
2535:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
2536:                         assertEquals(185, propertyCallExp.getStartPosition());
2537:                         assertEquals(185 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
2538:
2539:                         InputElement sourceElement = generatedText.getSourceElement();
2540:                         EObject modelElement = sourceElement.getModelElement();
2541:                         assertTrue(modelElement instanceof EClass);
2542:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
2543:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
2544:                                         modelElement.eResource().getURI().path());
2545:                         cpt++;
2546:                 }
2547:         }
2548:
2549:         @Test
2550:         public void testTraceabilityLibraryStringToUpperFirst() {
2551:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
2552:                                 "data/library/string/stringToUpperFirst.mtl", //$NON-NLS-1$
2553:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
2554:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
2555:                 assertEquals(4, generatedFiles.size());
2556:
2557:                 int cpt = 1;
2558:•                for (GeneratedFile generatedFile : generatedFiles) {
2559:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
2560:                         assertEquals(1, generatedRegions.size());
2561:                         assertEquals(("class" + cpt).length(), generatedFile.getLength()); //$NON-NLS-1$
2562:
2563:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
2564:                         assertEquals(2, sourceElements.size()); // the class and its name
2565:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
2566:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
2567:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
2568:
2569:                         GeneratedText generatedText = generatedRegions.get(0);
2570:                         assertEquals(0, generatedText.getStartOffset());
2571:                         assertEquals(("class" + cpt).length(), generatedText.getEndOffset()); //$NON-NLS-1$
2572:                         ModuleElement moduleElement = generatedText.getModuleElement();
2573:                         EObject element = moduleElement.getModuleElement();
2574:                         assertTrue(element instanceof ASTNode);
2575:                         assertTrue(element instanceof PropertyCallExp);
2576:                         PropertyCallExp propertyCallExp = (PropertyCallExp)element;
2577:                         assertEquals("name", propertyCallExp.getReferredProperty().getName()); //$NON-NLS-1$
2578:                         assertEquals(185, propertyCallExp.getStartPosition());
2579:                         assertEquals(185 + "eClass.name".length(), propertyCallExp.getEndPosition()); //$NON-NLS-1$
2580:
2581:                         InputElement sourceElement = generatedText.getSourceElement();
2582:                         EObject modelElement = sourceElement.getModelElement();
2583:                         assertTrue(modelElement instanceof EClass);
2584:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
2585:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
2586:                                         modelElement.eResource().getURI().path());
2587:                         cpt++;
2588:                 }
2589:         }
2590:
2591:         @Test
2592:         public void testTraceabilityLibraryStringTrim() {
2593:                 AcceleoTraceabilityListener traceabilityListener = this.parseAndGenerate(
2594:                                 "data/library/string/stringTrim.mtl", //$NON-NLS-1$
2595:                                 "main", "data/library/string/model.ecore", true); //$NON-NLS-1$ //$NON-NLS-2$
2596:                 List<GeneratedFile> generatedFiles = traceabilityListener.getGeneratedFiles();
2597:                 assertEquals(4, generatedFiles.size());
2598:
2599:                 int cpt = 1;
2600:•                for (GeneratedFile generatedFile : generatedFiles) {
2601:                         List<GeneratedText> generatedRegions = generatedFile.getGeneratedRegions();
2602:                         assertEquals(1, generatedRegions.size());
2603:                         assertEquals("trim operation".length(), generatedFile.getLength()); //$NON-NLS-1$
2604:
2605:                         List<InputElement> sourceElements = generatedFile.getSourceElements();
2606:                         assertEquals(2, sourceElements.size()); // the class and its name
2607:                         assertEquals("class" + cpt + ", feature='name'", sourceElements.get(0).toString()); //$NON-NLS-1$ //$NON-NLS-2$
2608:                         assertEquals("class" + cpt, sourceElements.get(1).toString()); //$NON-NLS-1$
2609:                         assertEquals("class" + cpt + ".txt", generatedFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
2610:
2611:                         GeneratedText generatedText = generatedRegions.get(0);
2612:                         assertEquals(0, generatedText.getStartOffset());
2613:                         assertEquals("trim operation".length(), generatedText.getEndOffset()); //$NON-NLS-1$
2614:                         ModuleElement moduleElement = generatedText.getModuleElement();
2615:                         EObject element = moduleElement.getModuleElement();
2616:                         assertTrue(element instanceof ASTNode);
2617:                         assertTrue(element instanceof StringLiteralExp);
2618:                         StringLiteralExp string = (StringLiteralExp)element;
2619:                         assertEquals(" trim operation ", string.getStringSymbol()); //$NON-NLS-1$
2620:                         assertEquals(177, string.getStartPosition());
2621:                         assertEquals(177 + "' trim operation '".length(), string.getEndPosition()); //$NON-NLS-1$
2622:
2623:                         InputElement sourceElement = generatedText.getSourceElement();
2624:                         EObject modelElement = sourceElement.getModelElement();
2625:                         assertTrue(modelElement instanceof EClass);
2626:                         assertEquals("class" + cpt, ((EClass)modelElement).getName()); //$NON-NLS-1$
2627:                         assertEquals("/plugin/org.eclipse.acceleo.traceability.tests/data/library/string/model.ecore", //$NON-NLS-1$
2628:                                         modelElement.eResource().getURI().path());
2629:                         cpt++;
2630:                 }
2631:         }
2632: }