Commit f128999c authored by Andreas Bayha's avatar Andreas Bayha
Browse files

MIRA: Added Duplicate Id Check

Added check for duplicate IDs in Requirements.

Issue-Ref: 3987
Issue-Url: https://af3-developer.fortiss.org/issues/3987

Signed-off-by: Andreas Bayha's avatarAndreas Bayha <bayha@fortiss.org>
parent 5f049423
AnalysisRedundantRequirementChecker.java a3afd6e4b003f97104b3e348138aa8ec6db74345 GREEN
ConstraintMessage.java e9ded590ec0fbabf547c29251ee7e0d829f73e59 GREEN
RequirementConstraintViolation.java 9a21e7c397645eb00603cfb5dc376f3b8bd62b95 GREEN
AnalysisRedundantRequirementChecker.java 4a5b3d7ea150c761392fcd80ee90d287115ecd21 YELLOW
ConstraintMessage.java 6823a203d81da003b2524bfe49e8df53b2c9e4f7 YELLOW
RequirementConstraintViolation.java 1e13c74b2c02f6591220243a5865c4f1cdc54fa5 YELLOW
......@@ -16,6 +16,7 @@
package org.fortiss.af3.mira.verification;
import static org.fortiss.af3.mira.verification.ConstraintMessage.createSameDescriptionViolation;
import static org.fortiss.af3.mira.verification.ConstraintMessage.createSameIdViolation;
import static org.fortiss.af3.mira.verification.ConstraintMessage.createSameNameAndActorsViolation;
import static org.fortiss.af3.mira.verification.ConstraintMessage.createSameNameViolation;
......@@ -52,6 +53,7 @@ public class AnalysisRedundantRequirementChecker extends ConstraintCheckerBase<A
Requirement req2 = requirementsList.get(j);
boolean duplicatedName = false;
boolean duplicatedId = false;
boolean duplicatedDescription = false;
boolean duplicatedActor = false;
......@@ -60,6 +62,11 @@ public class AnalysisRedundantRequirementChecker extends ConstraintCheckerBase<A
duplicatedName = true;
}
if(!StringUtils.isEmpty(req1.getReqId()) && !StringUtils.isEmpty(req2.getReqId()) &&
req1.getReqId().strip().equalsIgnoreCase(req2.getReqId().strip())) {
duplicatedId = true;
}
if(!StringUtils.isEmpty(req1.getDescription()) &&
!StringUtils.isEmpty(req2.getDescription()) &&
req1.getDescription().equalsIgnoreCase(req2.getDescription())) {
......@@ -74,6 +81,10 @@ public class AnalysisRedundantRequirementChecker extends ConstraintCheckerBase<A
}
}
if(duplicatedId) {
result.add(createSameIdViolation(req1, req2));
}
if(duplicatedDescription) {
result.add(createSameDescriptionViolation(req1, req2));
}
......
......@@ -16,6 +16,7 @@
package org.fortiss.af3.mira.verification;
import static org.fortiss.af3.mira.utils.MiraUtils.getRequirementsShortInfo;
import static org.fortiss.tooling.kernel.extension.data.IConstraintViolation.ESeverity.ERROR;
import java.util.List;
......@@ -33,6 +34,9 @@ public class ConstraintMessage {
/** Violation string for same name. */
static String sameNameViolation = "%s and %s have both the same title: %s (E2.1)";
/** Violation string for same id. */
static String sameIdViolation = "%s and %s have both the same id: %s (E2.1)";
/** Violation string for same name and actors. */
static String sameNameActorsViolation =
"%s and %s have both the same title: %s and the same actors (E2.2)";
......@@ -84,6 +88,15 @@ public class ConstraintMessage {
shortInfo2, req1.getName());
}
/** Creates the violation for requirements with duplicated name. */
public static RequirementConstraintViolation<Requirement>
createSameIdViolation(Requirement req1, Requirement req2) {
String shortInfo1 = req1.getRequirementShortInfo();
String shortInfo2 = req2.getRequirementShortInfo();
return new RequirementConstraintViolation<Requirement>(req1, ERROR, sameIdViolation,
shortInfo1, shortInfo2, req1.getName());
}
/** Creates the violation for requirements with duplicated actors. */
public static RequirementConstraintViolation<Requirement>
createSameNameAndActorsViolation(Requirement req1, Requirement req2) {
......
......@@ -28,13 +28,24 @@ import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
*/
public class RequirementConstraintViolation<T extends EObject> extends ConstraintViolationBase<T> {
/** Default constructor */
/** Default constructor with severity WARNING */
public RequirementConstraintViolation(T modelElement, String explanation) {
super(modelElement, WARNING, explanation);
}
/** Constructor with formatted message */
/** Constructor with formatted message with severity WARNING */
public RequirementConstraintViolation(T modelElement, String format, Object... args) {
super(modelElement, WARNING, String.format(format, args));
}
/** Default constructor with given severity */
public RequirementConstraintViolation(T modelElement, ESeverity severity, String explanation) {
super(modelElement, severity, explanation);
}
/** Constructor with formatted message and the given severity */
public RequirementConstraintViolation(T modelElement, ESeverity severity, String format,
Object... args) {
super(modelElement, severity, String.format(format, args));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment