Commit a3266c41 authored by Dongyue Mou's avatar Dongyue Mou
Browse files

Included designated Requirement validations.

Changed the button name to "Validate".
refs 65
parent 8e5d68f5
......@@ -195,7 +195,7 @@ public class RequirementEditor extends EditorBase<Requirement> {
IAction.AS_PUSH_BUTTON, this);
validate.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(
AF3MiraUIActivator.PLUGIN_ID, "icons/Icon_Validate.png"));
validate.setToolTipText("Verification");
validate.setToolTipText("Verify");
form.getToolBarManager().add(hierachy);
form.getToolBarManager().add(report);
......
......@@ -49,6 +49,20 @@ public class IsConsistentVisitor extends Visitor {
// TODO Verfeinerung von Use Case zu Systemmodell
// noch nicht mglich
@Override
public void visitRequirement(Requirement r) {
if (!(r instanceof UseCase)) {
if (r.getStatus() == RequirementStatus.IDENTIFIED
|| r.getStatus() == RequirementStatus.IN_ANALYSIS) {
String message = "Requirement " + r.getId()
+ " is not analyzed yet (E7.2)";
VerificationUtil.createMarker(r, message);
}
}
super.visitRequirement(r);
}
/**
* {@inheritDoc} Checks if a UseCase is analyzed yet(M). Checks if every
* Actor in a UseCase is assigned to a ScenarioStep(no phase assigned,
......@@ -96,9 +110,9 @@ public class IsConsistentVisitor extends Visitor {
if (target.getStatus() == RequirementStatus.DECLINED
&& source.getStatus() != RequirementStatus.DECLINED) {
String message = "Use Case " + target.getId()
+ " is declined, but is refined by Use Case "
+ source.getId()
String message = this.reqOrUseCase(target) + " "
+ target.getId() + " is declined, but is refined by "
+ this.reqOrUseCase(source) + " " + source.getId()
+ " which is not declinded itself (E10.3)";
VerificationUtil.createMarker(rel, message);
}
......@@ -118,9 +132,9 @@ public class IsConsistentVisitor extends Visitor {
if (source.getStatus() != RequirementStatus.DECLINED
&& target.getStatus() != RequirementStatus.DECLINED) {
String message = "Use Case " + source.getId()
+ " and Use Case " + target.getId()
+ " are conflicted (E9.1)";
String message = this.reqOrUseCase(source) + " "
+ source.getId() + " and " + this.reqOrUseCase(target)
+ " " + target.getId() + " are conflicted (E9.1)";
VerificationUtil.createMarker(rel, message);
}
}
......
......@@ -17,6 +17,7 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
+--------------------------------------------------------------------------*/
package org.fortiss.af3.mira.verification;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
/**
......@@ -30,30 +31,59 @@ public class IsEmptyVisitor extends Visitor {
/**
* {@inheritDoc} Checks is a Requirement is comprehensively described, by
* comparing relevant field with "null"
* comparing relevant field with "null" and/or "isEmpty()"
*/
// @Override
// public void visit(Requirement r) {
//
// if (r.getDescription() == null || r.getDescription().trim().isEmpty()
// || r.getAuthor() == null || r.getAuthor().trim().isEmpty()
// || r.getRationale() == null
// || r.getRationale().trim().isEmpty() || r.getSources() == null
// || r.getSources().trim().isEmpty()) {
// message =
// "One or more of the fields: description, author, rationale and source of Requirement "
// + r.getId()
// + " is not comprehensively described";
// this.reportQualityViolation(r, message);
// }
//
// super.visit(r);
// }
@Override
public void visitRequirement(Requirement r) {
if (!(r instanceof UseCase)) {
/** (D) */
if (VerificationUtil.isNullOrEmptyString(r.getName())) {
String message = "Requirement " + r.getId()
+ " has no name (E1.4)";
VerificationUtil.createMarker(r, message);
}
/** (D) */
if (VerificationUtil.isNullOrEmptyString(r.getDescription())) {
String message = "Requirement " + r.getId()
+ " has no description (E1.4)";
VerificationUtil.createMarker(r, message);
}
/** (C) */
if (VerificationUtil.isNullOrEmptyString(r.getAuthor())
|| VerificationUtil.isNullOrEmptyString(r.getRationale())
|| VerificationUtil.isNullOrEmptyString(r.getSources())) {
String message = "One or more of the fields: author, rationale and source of Requirement "
+ r.getId() + " is not comprehensively described(E1.5)";
VerificationUtil.createMarker(r, message);
}
/** (D) */
if (r.getPriority() == null) {
String message = "Requirement " + r.getId()
+ " has no priority assigned (E8)";
VerificationUtil.createMarker(r, message);
}
/** (P) */
if (r.getStatus() == null) {
String message = "Requirement " + r.getId()
+ " has no status assigned (E7.2)";
VerificationUtil.createMarker(r, message);
}
if (!VerificationUtil.isNullOrEmptyString(r.getTodo())) {
String message = "Requirement " + r.getId()
+ " has still a ToDo entry: \"" + r.getTodo()
+ "\" (E1.5)";
VerificationUtil.createMarker(r, message);
}
}
super.visitRequirement(r);
}
/**
* {@inheritDoc} Checks if a UseCase has name, description, priority and
* status. Checks if every Actor is part of a scenario step.
* status.
*/
@Override
public void visitUseCase(UseCase u) {
......@@ -92,8 +122,7 @@ public class IsEmptyVisitor extends Visitor {
if (!VerificationUtil.isNullOrEmptyString(u.getTodo())) {
String message = "Use Case " + u.getId()
+ " has still an ToDo entry: \"" + u.getTodo()
+ "\" (E1.5)";
+ " has still a ToDo entry: \"" + u.getTodo() + "\" (E1.5)";
VerificationUtil.createMarker(u, message);
}
......
......@@ -20,6 +20,7 @@ package org.fortiss.af3.mira.verification;
import java.util.ArrayList;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.Actor;
import org.fortiss.af3.mira.model.usecase.Scenario;
import org.fortiss.af3.mira.model.usecase.ScenarioStep;
......@@ -39,25 +40,30 @@ public class IsRedundantVisitor extends Visitor {
@Override
public void visitAnalysis(Analysis a) {
for (int i = 0; i < a.getContainedElementsLength(); i++) {
if (!(a.getContainedElements(i) instanceof UseCase))
if (!(a.getContainedElements(i) instanceof Requirement))
continue;
UseCase iStep = (UseCase) a.getContainedElements(i);
Requirement iStep = (Requirement) a.getContainedElements(i);
ArrayList<String> iStepActors = new ArrayList<String>();
for (Actor iActor : iStep.getActorList()) {
iStepActors.add(iActor.getName());
}
if (iStep instanceof UseCase) {
for (Actor iActor : ((UseCase) iStep).getActorList()) {
iStepActors.add(iActor.getName());
}
}
for (int j = i + 1; j < a.getContainedElementsLength(); j++) {
if (!(a.getContainedElements(j) instanceof UseCase))
if (!(a.getContainedElements(j) instanceof Requirement))
continue;
UseCase jStep = (UseCase) a.getContainedElements(j);
Requirement jStep = (Requirement) a.getContainedElements(j);
ArrayList<String> jStepActors = new ArrayList<String>();
for (Actor jActor : jStep.getActorList()) {
jStepActors.add(jActor.getName());
if (jStep instanceof UseCase) {
for (Actor jActor : ((UseCase) jStep).getActorList()) {
jStepActors.add(jActor.getName());
}
}
// check duplicate name
......@@ -65,10 +71,11 @@ public class IsRedundantVisitor extends Visitor {
&& !VerificationUtil.isNullOrEmptyString(jStep
.getName())
&& iStep.getName().equalsIgnoreCase(jStep.getName())) {
String message = "Use Cases with ID: " + iStep.getId()
+ " and ID: " + jStep.getId()
+ " have both the same name: \"" + iStep.getName()
+ "\" (E2.1)";
String message = this.reqOrUseCase(iStep) + " with ID: "
+ iStep.getId() + " and "
+ this.reqOrUseCase(jStep) + " with ID: "
+ jStep.getId() + " have both the same name: \""
+ iStep.getName() + "\" (E2.1)";
VerificationUtil.createMarker(a, message);
}
......@@ -79,8 +86,10 @@ public class IsRedundantVisitor extends Visitor {
.getDescription())
&& iStep.getDescription().equalsIgnoreCase(
jStep.getDescription())) {
String message = "Use Cases with ID: " + iStep.getId()
+ " and ID: " + jStep.getId()
String message = this.reqOrUseCase(iStep) + " with ID: "
+ iStep.getId() + " and "
+ this.reqOrUseCase(jStep) + " with ID: "
+ jStep.getId()
+ " have both the same description: \""
+ iStep.getDescription() + "\" (E2.1)";
VerificationUtil.createMarker(a, message);
......@@ -91,8 +100,8 @@ public class IsRedundantVisitor extends Visitor {
&& iStepActors.size() == jStepActors.size()
&& iStepActors.containsAll(jStepActors)
&& jStepActors.containsAll(iStepActors)) {
String message = "Use Cases with ID: " + iStep.getId()
+ " and ID: " + jStep.getId()
String message = "Use Case with ID: " + iStep.getId()
+ " and Use Case with ID: " + jStep.getId()
+ " have both the same name:\" " + iStep.getName()
+ "\" and the same actors (E2.2)";
VerificationUtil.createMarker(a, message);
......
......@@ -143,4 +143,12 @@ public abstract class Visitor {
public void visitSuccessGuarantee(ICondition c) {
}
public String reqOrUseCase(Requirement req) {
if (req instanceof UseCase) {
return "Use Case";
}
return "Requirement";
}
}
......@@ -18,6 +18,7 @@ $Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $
package org.fortiss.af3.mira.verification.checker;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.extension.IConstraintChecker;
/**
......@@ -35,4 +36,11 @@ public abstract class RequirementCheckerBase implements
public boolean isApplicable(Requirement modelElement) {
return modelElement != null;
}
public String reqOrUseCase(Requirement req) {
if (req instanceof UseCase) {
return "Use Case";
}
return "Requirement";
}
}
......@@ -36,19 +36,24 @@ public class RequirementComprehensiveDescripedChecker extends
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (C) */
if (modelElement instanceof UseCase) {
if (modelElement.getAuthor() == null
|| modelElement.getAuthor().trim().isEmpty()
|| modelElement.getRationale() == null
|| modelElement.getRationale().trim().isEmpty()
|| modelElement.getSources() == null
|| modelElement.getSources().trim().isEmpty()) {
String violation = "One or more of the fields: author, rationale and source of Use Case "
String violation;
if (modelElement.getAuthor() == null
|| modelElement.getAuthor().trim().isEmpty()
|| modelElement.getRationale() == null
|| modelElement.getRationale().trim().isEmpty()
|| modelElement.getSources() == null
|| modelElement.getSources().trim().isEmpty()) {
if (modelElement instanceof UseCase) {
violation = "One or more of the fields: author, rationale and source of Use Case "
+ modelElement.getId()
+ " is not comprehensively described(E1.5)";
} else {
violation = "One or more of the fields: author, rationale and source of Requirement "
+ modelElement.getId()
+ " is not comprehensively described(E1.5)";
return new RequirementConstraintViolation(modelElement,
violation);
}
return new RequirementConstraintViolation(modelElement, violation);
}
return null;
}
......
......@@ -39,40 +39,42 @@ public class RequirementConflictChecker extends RequirementCheckerBase {
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (D) */
if (modelElement instanceof UseCase) {
for (IConnector iC : modelElement.getConnectorsList()) {
for (IConnection i : iC.getOutgoingList()) {
if (i instanceof ConflictedRequirementRelation) {
if (i.getTarget().eContainer() instanceof UseCase) {
if (checkConflict((UseCase) modelElement,
(UseCase) i.getTarget().eContainer())) {
String violation = "Use Case "
+ modelElement.getId()
+ " and "
+ ((UseCase) i.getTarget().eContainer())
.getId()
+ " are conflicted (E9.1)";
return new RequirementConstraintViolation(
modelElement, violation);
}
String violation;
for (IConnector iC : modelElement.getConnectorsList()) {
for (IConnection i : iC.getOutgoingList()) {
if (i instanceof ConflictedRequirementRelation) {
if (i.getTarget().eContainer() instanceof UseCase) {
if (checkConflict((UseCase) modelElement, (UseCase) i
.getTarget().eContainer())) {
violation = this.reqOrUseCase(modelElement)
+ " "
+ modelElement.getId()
+ " and "
+ this.reqOrUseCase((Requirement) i
.getTarget().eContainer())
+ " "
+ ((Requirement) i.getTarget().eContainer())
.getId() + " are conflicted (E9.1)";
return new RequirementConstraintViolation(
modelElement, violation);
}
}
}
}
}
return null;
}
/**
* Helper Method to check conflicts between UseCases
* Helper Method to check conflicts between Requirements
*
* @param u
* @param relatedUseCase
* @param r
* @param relatedRequirement
*/
private boolean checkConflict(UseCase u, UseCase relatedUseCase) {
if (u.getStatus().equals(RequirementStatus.DECLINED)
|| relatedUseCase.equals(RequirementStatus.DECLINED))
private boolean checkConflict(Requirement r, Requirement relatedRequirement) {
if (r.getStatus().equals(RequirementStatus.DECLINED)
|| relatedRequirement.equals(RequirementStatus.DECLINED))
return false;
return true;
......
......@@ -40,20 +40,20 @@ public class RequirementDeclinedSourceChecker extends RequirementCheckerBase {
Requirement modelElement) {
/** (CMP) */
if (modelElement instanceof UseCase) {
if (modelElement.getStatus().equals(RequirementStatus.DECLINED)) {
for (IConnector iCSource : modelElement.getConnectorsList()) {
for (IConnection iConnect : iCSource.getIncomingList()) {
if (iConnect instanceof RefinementRequirementRelationImpl) {
if (iConnect.getSource().eContainer() instanceof UseCase) {
if (checkIfDeclined((UseCase) iConnect
.getSource().eContainer())) {
String violation = "Use Case "
+ modelElement.getId()
+ " has a source UseCase which is declined, but is not declinded itself (E10.3)";
return new RequirementConstraintViolation(
modelElement, violation);
}
if (modelElement.getStatus().equals(RequirementStatus.DECLINED)) {
for (IConnector iCSource : modelElement.getConnectorsList()) {
for (IConnection iConnect : iCSource.getIncomingList()) {
if (iConnect instanceof RefinementRequirementRelationImpl) {
if (iConnect.getSource().eContainer() instanceof UseCase) {
if (checkIfDeclined((Requirement) iConnect
.getSource().eContainer())) {
String violation = this
.reqOrUseCase(modelElement)
+ " "
+ modelElement.getId()
+ " has a source which is declined, but is not declinded itself (E10.3)";
return new RequirementConstraintViolation(
modelElement, violation);
}
}
}
......@@ -67,8 +67,8 @@ public class RequirementDeclinedSourceChecker extends RequirementCheckerBase {
* Helper method to check if a UseCase is declined (in this case: whose
* source is declined), creates a MIRA marker if so
*/
public boolean checkIfDeclined(UseCase u) {
if (u.getStatus() != RequirementStatus.DECLINED) {
public boolean checkIfDeclined(Requirement r) {
if (r.getStatus() != RequirementStatus.DECLINED) {
return true;
}
return false;
......
......@@ -19,7 +19,6 @@ package org.fortiss.af3.mira.verification.checker;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
/**
......@@ -36,14 +35,11 @@ public class RequirementDescriptionIsEmptyChecker extends
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (D) */
if (modelElement instanceof UseCase) {
if (modelElement.getDescription() == null
|| modelElement.getDescription().trim().isEmpty()) {
String violation = "Use Case " + modelElement.getId()
+ " has no description (E1.4)";
return new RequirementConstraintViolation(modelElement,
violation);
}
if (modelElement.getDescription() == null
|| modelElement.getDescription().trim().isEmpty()) {
String violation = this.reqOrUseCase(modelElement) + " "
+ modelElement.getId() + " has no description (E1.4)";
return new RequirementConstraintViolation(modelElement, violation);
}
return null;
}
......
......@@ -19,7 +19,6 @@ package org.fortiss.af3.mira.verification.checker;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
/**
......@@ -35,14 +34,11 @@ public class RequirementNameIsEmptyChecker extends RequirementCheckerBase {
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (D) */
if (modelElement instanceof UseCase) {
if (modelElement.getName() == null
|| modelElement.getName().trim().isEmpty()) {
String violation = "Use Case " + modelElement.getId()
+ " has no name (E1.4)";
return new RequirementConstraintViolation(modelElement,
violation);
}
if (modelElement.getName() == null
|| modelElement.getName().trim().isEmpty()) {
String violation = this.reqOrUseCase(modelElement) + " "
+ modelElement.getId() + " has no name (E1.4)";
return new RequirementConstraintViolation(modelElement, violation);
}
return null;
}
......
......@@ -19,7 +19,6 @@ package org.fortiss.af3.mira.verification.checker;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
/**
......@@ -35,13 +34,10 @@ public class RequirementPriorityIsEmptyChecker extends RequirementCheckerBase {
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
/** (D) */
if (modelElement instanceof UseCase) {
if (modelElement.getPriority() == null) {
String violation = "Use Case " + modelElement.getId()
+ " has no priority assigned (E8)";
return new RequirementConstraintViolation(modelElement,
violation);
}
if (modelElement.getPriority() == null) {
String violation = this.reqOrUseCase(modelElement) + " "
+ modelElement.getId() + " has no priority assigned (E8)";
return new RequirementConstraintViolation(modelElement, violation);
}
return null;
}
......
......@@ -22,7 +22,6 @@ import java.util.ArrayList;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.af3.mira.model.Analysis;
import org.fortiss.af3.mira.model.Requirement;
import org.fortiss.af3.mira.model.usecase.UseCase;
import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
......@@ -36,39 +35,38 @@ import org.fortiss.tooling.kernel.extension.data.IConstraintViolation;
public class RequirementRedundantDescriptionChecker extends
RequirementCheckerBase {
ArrayList<UseCase> useCaseList = new ArrayList<UseCase>();
ArrayList<Requirement> requirementList = new ArrayList<Requirement>();
/** {@inheritDoc} */
@Override
public IConstraintViolation<? extends EObject> apply(
Requirement modelElement) {
if (modelElement instanceof UseCase) {
Analysis root = (Analysis) modelElement.eContainer();
for (IHierarchicElement he : root.getContainedElementsList()) {
if (he instanceof UseCase)
useCaseList.add((UseCase) he);
}
Analysis root = (Analysis) modelElement.eContainer();
for (IHierarchicElement he : root.getContainedElementsList()) {
if (he instanceof Requirement)
requirementList.add((Requirement) he);
}
/** (D) */
for (int i = 0; i < useCaseList.size(); i++) {
if (!(modelElement.getDescription() == null
|| modelElement.getDescription().trim().length() == 0 || useCaseList
.get(i).getDescription() == null)
&& modelElement
.getDescription()
.trim()
.equalsIgnoreCase(
useCaseList.get(i).getDescription()
.trim())) {
String violation = "Use Case with ID: "
+ modelElement.getId