Quellcode durchsuchen

renamed validation issue codes for RegionValidator

Axel Terfloth vor 7 Jahren
Ursprung
Commit
e5603fa79f

+ 17 - 13
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/validation/RegionValidator.java

@@ -28,24 +28,24 @@ import org.yakindu.sct.model.sgraph.Vertex;
 /**
 /**
  * 
  * 
  * All validation contraints for the meta model elements {@link Region}
  * All validation contraints for the meta model elements {@link Region}
+ * 
+ * 
  *
  *
  */
  */
 public class RegionValidator extends AbstractSGraphValidator {
 public class RegionValidator extends AbstractSGraphValidator {
 
 
 
 
-	private static final String REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY_MSG = "The region can't be entered using the shallow history. Add a default entry node.";
-	public static final String REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY_CODE = "entry.region.default";
+	private static final String REGION_REQUIRES_DEFAULT_ENTRY_IF_ENTERED_BY_SHALLOW_HISTORY_MSG  = "The region can't be entered using the shallow history. Add a default entry node.";
+	public static final String  REGION_REQUIRES_DEFAULT_ENTRY_IF_ENTERED_BY_SHALLOW_HISTORY_CODE = "region.RequiresDefaultEntryIfEnteredByShallowHistory";
 
 
 	private static final String REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_MSG = "The region can't be entered using the shallow history. Add a transition from default entry to a state.";
 	private static final String REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_MSG = "The region can't be entered using the shallow history. Add a transition from default entry to a state.";
-	public static final String REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_CODE = "entry.in.transition";
-
-	private final static String REGION_MULTIPLE_DEFAULT_ENTRIES_MSG = "There are multiple default entry nodes (one without a name and one named 'default') in this region.";
-	public final static String REGION_MULTIPLE_DEFAULT_ENTRIES_CODE = "region.duplicate.entry";
-
-
-	
-	
+	public static final String REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_CODE = "region.CantBeEnteredUsingShallowHistoryNonConnectedDefaultEntry";
 
 
+	/**
+	 * TODO: remove second message as this is not required. Every default entry must have a target transition.
+	 * 
+	 * @param e
+	 */
 	@Check(CheckType.FAST)
 	@Check(CheckType.FAST)
 	public void regionCantBeEnteredUsingShallowHistory(Entry e) {
 	public void regionCantBeEnteredUsingShallowHistory(Entry e) {
 		if (e.getKind() == EntryKind.SHALLOW_HISTORY) {
 		if (e.getKind() == EntryKind.SHALLOW_HISTORY) {
@@ -67,8 +67,8 @@ public class RegionValidator extends AbstractSGraphValidator {
 					}
 					}
 				}
 				}
 				if (defaultEntry == null) {
 				if (defaultEntry == null) {
-					error(REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY_MSG, r, null, -1,
-							REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY_CODE);
+					error(REGION_REQUIRES_DEFAULT_ENTRY_IF_ENTERED_BY_SHALLOW_HISTORY_MSG, r, null, -1,
+							REGION_REQUIRES_DEFAULT_ENTRY_IF_ENTERED_BY_SHALLOW_HISTORY_CODE);
 				} else if (defaultEntry.getOutgoingTransitions().size() != 1) {
 				} else if (defaultEntry.getOutgoingTransitions().size() != 1) {
 					error(REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_MSG, r, null, -1,
 					error(REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_MSG, r, null, -1,
 							REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_CODE);
 							REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_CODE);
@@ -79,6 +79,10 @@ public class RegionValidator extends AbstractSGraphValidator {
 
 
 	}
 	}
 
 
+	
+	private final static String REGION_NO_MULTIPLE_DEFAULT_ENTRIES_MSG = "There are multiple default entry nodes (one without a name and one named 'default') in this region.";
+	public final static String REGION_NO_MULTIPLE_DEFAULT_ENTRIES_CODE = "region.NoMultipleDefaultEntries";
+
 	@Check
 	@Check
 	public void checkOnlyOneDefaultEntryPermitted(Entry entry) {
 	public void checkOnlyOneDefaultEntryPermitted(Entry entry) {
 		Region region = (Region) entry.eContainer();
 		Region region = (Region) entry.eContainer();
@@ -88,7 +92,7 @@ public class RegionValidator extends AbstractSGraphValidator {
 		boolean defaultNamedEntryExists = initialEntires.stream()
 		boolean defaultNamedEntryExists = initialEntires.stream()
 				.filter(v -> v.getName().trim().equalsIgnoreCase("default")).count() > 0;
 				.filter(v -> v.getName().trim().equalsIgnoreCase("default")).count() > 0;
 		if (unamedEntryExists && defaultNamedEntryExists) {
 		if (unamedEntryExists && defaultNamedEntryExists) {
-			error(REGION_MULTIPLE_DEFAULT_ENTRIES_MSG, region, null, -1, REGION_MULTIPLE_DEFAULT_ENTRIES_CODE);
+			error(REGION_NO_MULTIPLE_DEFAULT_ENTRIES_MSG, region, null, -1, REGION_NO_MULTIPLE_DEFAULT_ENTRIES_CODE);
 		}
 		}
 	}
 	}
 
 

+ 2 - 2
test-plugins/org.yakindu.sct.model.sgraph.test/src/org/yakindu/sct/model/sgraph/test/validation/RegionValidatorTest.java

@@ -47,7 +47,7 @@ public class RegionValidatorTest extends AbstractSGraphValidatorTest {
 		region.getVertices().add(entry2);
 		region.getVertices().add(entry2);
 		createTransition(entry, state);
 		createTransition(entry, state);
 		createTransition(entry2, state);
 		createTransition(entry2, state);
-		tester.validate(entry).assertError(REGION_MULTIPLE_DEFAULT_ENTRIES_CODE);
+		tester.validate(entry).assertError(REGION_NO_MULTIPLE_DEFAULT_ENTRIES_CODE);
 	}
 	}
 
 
 	@Test
 	@Test
@@ -57,7 +57,7 @@ public class RegionValidatorTest extends AbstractSGraphValidatorTest {
 		result.assertDiagnosticsCount(2);
 		result.assertDiagnosticsCount(2);
 
 
 		result.assertAny(
 		result.assertAny(
-				AssertableDiagnostics.errorCode(REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY_CODE));
+				AssertableDiagnostics.errorCode(REGION_REQUIRES_DEFAULT_ENTRY_IF_ENTERED_BY_SHALLOW_HISTORY_CODE));
 		result.assertAny(AssertableDiagnostics
 		result.assertAny(AssertableDiagnostics
 				.errorCode(REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_CODE));
 				.errorCode(REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY_CODE));
 	}
 	}