Browse Source

Test and validator update

benjamin.schwertfeger@gmail.com 13 years ago
parent
commit
37bbb5e780

+ 5 - 5
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextJavaValidator.java

@@ -282,14 +282,14 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 			for (InterfaceScope scope : defaultInterfaces) {
 				error(ONLY_ONE_INTERFACE, scope, grammarAccess
 						.getInterfaceScopeAccess().getInterfaceKeyword_1(),
-						ValidationMessageAcceptor.INSIGNIFICANT_INDEX);
+						ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
+						ONLY_ONE_INTERFACE);
 			}
 		}
 	}
 
 	protected void error(String message, EObject source, Keyword keyword,
-			int index) {
-		final String code = null;
+			int index, String code) {
 		final String[] issueData = null;
 		ICompositeNode rootNode = NodeModelUtils.findActualNodeFor(source);
 		if (rootNode != null) {
@@ -304,8 +304,8 @@ public class STextJavaValidator extends AbstractSTextJavaValidator {
 			}
 		}
 
-		error(ONLY_ONE_INTERFACE, source, (EStructuralFeature) null,
-				ValidationMessageAcceptor.INSIGNIFICANT_INDEX);
+		error(message, source, (EStructuralFeature) null,
+				ValidationMessageAcceptor.INSIGNIFICANT_INDEX, code);
 
 	}
 

+ 6 - 3
test-plugins/org.yakindu.sct.model.stext.test/src/org/yakindu/sct/model/stext/test/STextJavaValidatorTest.java

@@ -20,12 +20,14 @@ import static org.yakindu.sct.model.stext.validation.STextJavaValidator.IN_OUT_D
 import static org.yakindu.sct.model.stext.validation.STextJavaValidator.LOCAL_DECLARATIONS;
 import static org.yakindu.sct.model.stext.validation.STextJavaValidator.LOCAL_REACTIONS_NOT_ALLOWED;
 import static org.yakindu.sct.model.stext.validation.STextJavaValidator.ONLY_ONE_INTERFACE;
+import static org.eclipse.xtext.junit4.validation.AssertableDiagnostics.errorCode;
 
 import java.lang.reflect.Method;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
+import org.eclipse.emf.common.util.Diagnostic;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.xtext.junit4.InjectWith;
 import org.eclipse.xtext.junit4.XtextRunner;
@@ -251,7 +253,7 @@ public class STextJavaValidatorTest extends AbstractSTextTest {
 	 */
 	@Test
 	public void checkLocalReaction() throws ParseException {
-		if (new Date().after(new SimpleDateFormat().parse("01.05.12 12:00"))) {
+		if (new Date().after(new Date(1335866400000l))) { // 1.5.2012 12:00
 			fail("Local Reaction should be activated for Statecharts again");
 		}
 	}
@@ -265,8 +267,9 @@ public class STextJavaValidatorTest extends AbstractSTextTest {
 				"interface: in event event1 interface: in event event2", null,
 				StatechartSpecification.class.getSimpleName());
 		AssertableDiagnostics result = tester.validate(model);
-		result.assertDiagnosticsCount(1);
-		result.assertErrorContains(ONLY_ONE_INTERFACE);
+		result.assertDiagnosticsCount(2);
+		result.assertAll(errorCode(ONLY_ONE_INTERFACE),
+				errorCode(ONLY_ONE_INTERFACE));
 	}
 
 	/**