Commit 13375269 authored by Faezeh KHORRAM's avatar Faezeh KHORRAM 💬
Browse files

update rules based on the new interface

parent c7a332e7
package org.imt.pssm.reactive.coverage; package org.imt.pssm.reactive.coverage;
import java.util.ArrayList; import org.eclipse.emf.common.util.ECollections;
import java.util.List; import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.Resource;
import org.imt.pssm.reactive.model.statemachines.BooleanBinaryExpression; import org.imt.pssm.reactive.model.statemachines.StatemachinesPackage;
import org.imt.pssm.reactive.model.statemachines.BooleanConstraint; import org.imt.tdl.coverage.dslSpecific.DSLSpecificCoverageRule;
import org.imt.pssm.reactive.model.statemachines.BooleanExpression;
import org.imt.pssm.reactive.model.statemachines.BooleanUnaryExpression;
import org.imt.pssm.reactive.model.statemachines.CallEventType;
import org.imt.pssm.reactive.model.statemachines.Constraint;
import org.imt.pssm.reactive.model.statemachines.CustomSystem;
import org.imt.pssm.reactive.model.statemachines.EventType;
import org.imt.pssm.reactive.model.statemachines.Expression;
import org.imt.pssm.reactive.model.statemachines.FinalState;
import org.imt.pssm.reactive.model.statemachines.IntegerComparisonExpression;
import org.imt.pssm.reactive.model.statemachines.IntegerConstraint;
import org.imt.pssm.reactive.model.statemachines.Operation;
import org.imt.pssm.reactive.model.statemachines.Pseudostate;
import org.imt.pssm.reactive.model.statemachines.Region;
import org.imt.pssm.reactive.model.statemachines.Signal;
import org.imt.pssm.reactive.model.statemachines.SignalEventType;
import org.imt.pssm.reactive.model.statemachines.State;
import org.imt.pssm.reactive.model.statemachines.StateMachine;
import org.imt.pssm.reactive.model.statemachines.StringComparisonExpression;
import org.imt.pssm.reactive.model.statemachines.StringConstraint;
import org.imt.pssm.reactive.model.statemachines.Transition;
import org.imt.pssm.reactive.model.statemachines.Trigger;
import org.imt.pssm.reactive.model.statemachines.Vertex;
import org.imt.tdl.coverage.TDLCoverageUtil;
import org.imt.tdl.coverage.TDLTestCaseCoverage;
import org.imt.tdl.coverage.dslSpecific.IDSLSpecificCoverage; import org.imt.tdl.coverage.dslSpecific.IDSLSpecificCoverage;
public class PSSMCoverageComputation implements IDSLSpecificCoverage{ public class PSSMCoverageComputation implements IDSLSpecificCoverage{
private List<EObject> modelObjects ;
private TDLTestCaseCoverage testCaseCoverage;
@Override
public List<String> getNewCoverableClasses() {
List<String> coverableClasses = new ArrayList<>();
coverableClasses.add(CustomSystem.class.getName());
coverableClasses.add(StateMachine.class.getName());
coverableClasses.add(Region.class.getName());
coverableClasses.add(Vertex.class.getName());
coverableClasses.add(State.class.getName());
coverableClasses.add(FinalState.class.getName());
coverableClasses.add(Pseudostate.class.getName());
coverableClasses.add(Constraint.class.getName());
coverableClasses.add(BooleanConstraint.class.getName());
coverableClasses.add(IntegerConstraint.class.getName());
coverableClasses.add(StringConstraint.class.getName());
coverableClasses.add(Expression.class.getName());
coverableClasses.add(BooleanExpression.class.getName());
coverableClasses.add(BooleanUnaryExpression.class.getName());
coverableClasses.add(BooleanBinaryExpression.class.getName());
coverableClasses.add(IntegerComparisonExpression.class.getName());
coverableClasses.add(StringComparisonExpression.class.getName());
coverableClasses.add(Trigger.class.getName());
coverableClasses.add(EventType.class.getName());
coverableClasses.add(SignalEventType.class.getName());
coverableClasses.add(CallEventType.class.getName());
coverableClasses.add(Signal.class.getName());
coverableClasses.add(Operation.class.getName());
return coverableClasses;
}
@Override @Override
public void specializeCoverage(TDLTestCaseCoverage testCaseCoverage) { public EList<DSLSpecificCoverageRule> getDSLSpecificCoverageRules() {
this.testCaseCoverage = testCaseCoverage;
this.modelObjects = testCaseCoverage.getModelObjects();
for (int i=0; i<this.modelObjects.size(); i++) {
EObject modelObject = this.modelObjects.get(i);
String coverage = this.testCaseCoverage.getTcObjectCoverageStatus().get(i);
if (modelObject instanceof CustomSystem && coverage != TDLCoverageUtil.COVERED) {
customSystemCoverage ((CustomSystem) modelObject);
}
else if (modelObject instanceof StateMachine && coverage != TDLCoverageUtil.COVERED) {
stateMachineCoverage ((StateMachine) modelObject);
}
else if (modelObject instanceof Region && coverage != TDLCoverageUtil.COVERED) {
regionCoverage ((Region) modelObject);
}
else if (modelObject instanceof Vertex && coverage != TDLCoverageUtil.COVERED) {
vertexCoverage ((Vertex) modelObject);
}
else if (modelObject instanceof Transition) {
transitionCoverage((Transition) modelObject);
}
else if (modelObject instanceof Constraint && coverage != TDLCoverageUtil.COVERED) {
constraintCoverage ((Constraint) modelObject);
}
else if (modelObject instanceof Expression && coverage != TDLCoverageUtil.COVERED) {
expressionCoverage ((Expression) modelObject);
}
else if (modelObject instanceof Trigger && coverage != TDLCoverageUtil.COVERED) {
triggerCoverage ((Trigger) modelObject);
}
}
}
private void customSystemCoverage(CustomSystem customSystem) {
//a customSystem is covered when its inner stateMachine is covered //a customSystem is covered when its inner stateMachine is covered
int index = this.modelObjects.indexOf(customSystem.getStatemachine()); DSLSpecificCoverageRule rule4customSystem = new DSLSpecificCoverageRule();
String smCoverage = this.testCaseCoverage.getTcObjectCoverageStatus().get(index); rule4customSystem.setContext(StatemachinesPackage.eINSTANCE.getCustomSystem());
if (smCoverage != TDLCoverageUtil.COVERED) { rule4customSystem.setReferenceCoverage(StatemachinesPackage.eINSTANCE.getCustomSystem_Statemachine());
//if stateMachine is not covered, check its coverage first
smCoverage = stateMachineCoverage(customSystem.getStatemachine());
}
if (smCoverage == TDLCoverageUtil.COVERED) {
index = this.modelObjects.indexOf(customSystem);
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.COVERED);
}
}
private String stateMachineCoverage(StateMachine statemachine) {
//a stateMachine is covered when all of its inner regions are covered //a stateMachine is covered when all of its inner regions are covered
for (Region innerRegion: statemachine.getRegions()) { DSLSpecificCoverageRule rule4stateMachine = new DSLSpecificCoverageRule();
int index = this.modelObjects.indexOf(innerRegion); rule4stateMachine.setContext(StatemachinesPackage.eINSTANCE.getStateMachine());
String regionCoverage = this.testCaseCoverage.getTcObjectCoverageStatus().get(index); rule4stateMachine.setContainerCoverageByAll(StatemachinesPackage.eINSTANCE.getStateMachine_Regions());
//if the region is not covered, first check its coverage
if (regionCoverage != TDLCoverageUtil.COVERED) {
regionCoverage = regionCoverage(innerRegion);
}
//if after checking its coverage, it is still not covered, the state machine is also not covered
if (regionCoverage != TDLCoverageUtil.COVERED) {
index = this.modelObjects.indexOf(statemachine);
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.NOT_COVERED);
return TDLCoverageUtil.NOT_COVERED;
}
}
//all the regions are covered, so the state machine is covered
int index = this.modelObjects.indexOf(statemachine);
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.COVERED);
//a region is covered if at least one of its transitions is covered
DSLSpecificCoverageRule rule4region = new DSLSpecificCoverageRule();
rule4region.setContext(StatemachinesPackage.eINSTANCE.getRegion());
rule4region.setContainerCoverageByOne(StatemachinesPackage.eINSTANCE.getRegion_Transitions());
return TDLCoverageUtil.COVERED; //if a transition is covered, its source state, target state, and constraint are also covered
} DSLSpecificCoverageRule rule4transition = new DSLSpecificCoverageRule();
rule4transition.setContext(StatemachinesPackage.eINSTANCE.getTransition());
private String regionCoverage(Region innerRegion) { rule4transition.setReferenceCoverage(ECollections.asEList(StatemachinesPackage.eINSTANCE.getTransition_Source(),
for (Transition transition: innerRegion.getTransitions()) { StatemachinesPackage.eINSTANCE.getTransition_Target(),
int index = this.modelObjects.indexOf(transition); StatemachinesPackage.eINSTANCE.getTransition_Constraint(),
String transitionCoverage = this.testCaseCoverage.getTcObjectCoverageStatus().get(index); StatemachinesPackage.eINSTANCE.getTransition_Triggers()));
//if at least one transition is covered, the region is entered, so it is covered too
if (transitionCoverage == TDLCoverageUtil.COVERED) { //if a constraint is covered, its expression is also covered
index = this.modelObjects.indexOf(innerRegion); DSLSpecificCoverageRule rule4booleanConstraint = new DSLSpecificCoverageRule();
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.COVERED); rule4booleanConstraint.setContext(StatemachinesPackage.eINSTANCE.getBooleanConstraint());
return TDLCoverageUtil.COVERED; rule4booleanConstraint.setReferenceCoverage(StatemachinesPackage.eINSTANCE.getBooleanConstraint_Expression());
}
} DSLSpecificCoverageRule rule4integerConstraint = new DSLSpecificCoverageRule();
//if there is no covered transition for the region, the region is not covered rule4integerConstraint.setContext(StatemachinesPackage.eINSTANCE.getIntegerConstraint());
int index = this.modelObjects.indexOf(innerRegion); rule4integerConstraint.setReferenceCoverage(StatemachinesPackage.eINSTANCE.getIntegerConstraint_Expression());
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.NOT_COVERED);
return TDLCoverageUtil.NOT_COVERED;
}
private void transitionCoverage(Transition transition) { DSLSpecificCoverageRule rule4stringConstraint = new DSLSpecificCoverageRule();
int index = this.modelObjects.indexOf(transition); rule4stringConstraint.setContext(StatemachinesPackage.eINSTANCE.getStringConstraint());
String coverage = this.testCaseCoverage.getTcObjectCoverageStatus().get(index); rule4stringConstraint.setReferenceCoverage(StatemachinesPackage.eINSTANCE.getStringConstraint_Expression());
//if a transition is covered, check its related elements
if (coverage == TDLCoverageUtil.COVERED) { //if a trigger is covered, its EventType is also covered
//When a transition is covered, its source and target states are also covered DSLSpecificCoverageRule rule4trigger = new DSLSpecificCoverageRule();
vertexCoverage(transition, transition.getSource()); rule4trigger.setContext(StatemachinesPackage.eINSTANCE.getTrigger());
vertexCoverage(transition, transition.getTarget()); rule4trigger.setReferenceCoverage(StatemachinesPackage.eINSTANCE.getTrigger_EventType());
//When a transition is covered, its constraint (if any) is also covered //if a SignalEventType is covered, its Signal is also covered
if (transition.getConstraint() != null) { DSLSpecificCoverageRule rule4signalEvent = new DSLSpecificCoverageRule();
constraintCoverage(transition, transition.getConstraint()); rule4signalEvent.setContext(StatemachinesPackage.eINSTANCE.getSignalEventType());
} rule4signalEvent.setReferenceCoverage(StatemachinesPackage.eINSTANCE.getSignalEventType_Signal());
//When a transition is covered, if it has only one trigger, the trigger and its eventType are also covered //if a CallEventType is covered, its Operation is also covered
if (transition.getTriggers().size() == 1) { DSLSpecificCoverageRule rule4callEvent = new DSLSpecificCoverageRule();
triggerCoverage (transition, transition.getTriggers().get(0)); rule4callEvent.setContext(StatemachinesPackage.eINSTANCE.getCallEventType());
} rule4callEvent.setReferenceCoverage(StatemachinesPackage.eINSTANCE.getCallEventType_Operation());
}
} return ECollections.asEList(rule4customSystem, rule4stateMachine, rule4region, rule4transition, rule4trigger, rule4stringConstraint,
rule4booleanConstraint, rule4integerConstraint, rule4callEvent, rule4signalEvent);
private void constraintCoverage(Constraint constraint) {
int index = this.modelObjects.indexOf(constraint);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) == TDLCoverageUtil.NOT_COVERABLE) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.NOT_COVERED);
}
}
private void constraintCoverage(Transition coveredTransition, Constraint constraint) {
int index = this.modelObjects.indexOf(constraint);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) != TDLCoverageUtil.COVERED) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.COVERED);
}
if (constraint instanceof BooleanConstraint) {
expressionCoverage(constraint, ((BooleanConstraint) constraint).getExpression());
}
else if (constraint instanceof IntegerConstraint) {
expressionCoverage(constraint, ((IntegerConstraint) constraint).getExpression());
}
else if (constraint instanceof StringConstraint) {
expressionCoverage(constraint, ((StringConstraint) constraint).getExpression());
}
}
private void expressionCoverage(Expression expression) {
int index = this.modelObjects.indexOf(expression);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) == TDLCoverageUtil.NOT_COVERABLE) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.NOT_COVERED);
}
}
private void expressionCoverage(Constraint constraint, Expression expression) {
int index = this.modelObjects.indexOf(expression);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) != TDLCoverageUtil.COVERED) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.COVERED);
}
}
private void vertexCoverage(Vertex vertex) {
int index = this.modelObjects.indexOf(vertex);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) == TDLCoverageUtil.NOT_COVERABLE) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.NOT_COVERED);
}
}
private void vertexCoverage(Transition coveredTransition, Vertex vertex) {
int index = this.modelObjects.indexOf(vertex);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) != TDLCoverageUtil.COVERED) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.COVERED);
}
}
private void triggerCoverage(Trigger trigger) {
int index = this.modelObjects.indexOf(trigger);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) == TDLCoverageUtil.NOT_COVERABLE) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.NOT_COVERED);
}
EventType triggerEventType = trigger.getEventType();
if (triggerEventType instanceof SignalEventType) {
signalEventTypeCoverage ((SignalEventType) triggerEventType);
}
else if (triggerEventType instanceof CallEventType) {
callEventTypeCoverage ((CallEventType) triggerEventType);
}
}
private void triggerCoverage(Transition coveredTransition, Trigger trigger) {
int index = this.modelObjects.indexOf(trigger);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) != TDLCoverageUtil.COVERED) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.COVERED);
}
EventType triggerEventType = trigger.getEventType();
if (triggerEventType instanceof SignalEventType) {
signalEventTypeCoverage (trigger, (SignalEventType) triggerEventType);
}
else if (triggerEventType instanceof CallEventType) {
callEventTypeCoverage (trigger, (CallEventType) triggerEventType);
}
}
private void signalEventTypeCoverage(SignalEventType signalEventType) {
int index = this.modelObjects.indexOf(signalEventType);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) == TDLCoverageUtil.NOT_COVERABLE) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.NOT_COVERED);
}
signalCoverage(signalEventType.getSignal());
}
private void signalEventTypeCoverage(Trigger coveredTrigger, SignalEventType signalEventType) {
int index = this.modelObjects.indexOf(signalEventType);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) != TDLCoverageUtil.COVERED) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.COVERED);
}
signalCoverage(signalEventType, signalEventType.getSignal());
}
private void callEventTypeCoverage(CallEventType callEventType) {
int index = this.modelObjects.indexOf(callEventType);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) == TDLCoverageUtil.NOT_COVERABLE) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.NOT_COVERED);
}
operationCoverage(callEventType.getOperation());
}
private void callEventTypeCoverage(Trigger coveredTrigger, CallEventType callEventType) {
int index = this.modelObjects.indexOf(callEventType);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) != TDLCoverageUtil.COVERED) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.COVERED);
}
operationCoverage(callEventType, callEventType.getOperation());
}
private void signalCoverage(Signal signal) {
int index = this.modelObjects.indexOf(signal);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) == TDLCoverageUtil.NOT_COVERABLE) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.NOT_COVERED);
}
}
private void signalCoverage(SignalEventType coveredEventType, Signal signal) {
int index = this.modelObjects.indexOf(signal);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) != TDLCoverageUtil.COVERED) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.COVERED);
}
}
private void operationCoverage(Operation operation) {
int index = this.modelObjects.indexOf(operation);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) == TDLCoverageUtil.NOT_COVERABLE) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.NOT_COVERED);
}
} }
private void operationCoverage(CallEventType coveredEventType, Operation operation) {
int index = this.modelObjects.indexOf(operation);
if (this.testCaseCoverage.getTcObjectCoverageStatus().get(index) != TDLCoverageUtil.COVERED) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.COVERED);
}
}
@Override @Override
public void ignoreModelObjects(Resource MUTResource) { public void ignoreModelObjects(Resource MUTResource) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
......
package org.imt.arduino.reactive.coverage; package org.imt.arduino.reactive.coverage;
import java.util.List; import org.eclipse.emf.common.util.ECollections;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.resource.Resource;
import org.imt.arduino.reactive.arduino.AnalogPin; import org.imt.arduino.reactive.arduino.ArduinoPackage;
import org.imt.arduino.reactive.arduino.Block; import org.imt.tdl.coverage.dslSpecific.DSLSpecificCoverageRule;
import org.imt.arduino.reactive.arduino.Board;
import org.imt.arduino.reactive.arduino.DigitalPin;
import org.imt.arduino.reactive.arduino.Instruction;
import org.imt.arduino.reactive.arduino.Module;
import org.imt.arduino.reactive.arduino.Pin;
import org.imt.arduino.reactive.arduino.Project;
import org.imt.arduino.reactive.arduino.Sketch;
import org.imt.tdl.coverage.TDLCoverageUtil;
import org.imt.tdl.coverage.TDLTestCaseCoverage;
import org.imt.tdl.coverage.dslSpecific.IDSLSpecificCoverage; import org.imt.tdl.coverage.dslSpecific.IDSLSpecificCoverage;
public class ArduinoCoverageComputation implements IDSLSpecificCoverage{ public class ArduinoCoverageComputation implements IDSLSpecificCoverage{
private List<EObject> modelObjects;
private TDLTestCaseCoverage testCaseCoverage;
@Override @Override
public List<String> getNewCoverableClasses() { public EList<DSLSpecificCoverageRule> getDSLSpecificCoverageRules() {
// TODO Auto-generated method stub //a Project is covered if at least one of its Sketches are covered
return null; DSLSpecificCoverageRule rule4sketch = new DSLSpecificCoverageRule();
} rule4sketch.setContext(ArduinoPackage.eINSTANCE.getSketch());
rule4sketch.setContainerCoverageByOne(ECollections.asEList(ArduinoPackage.eINSTANCE.getProject_Sketches()));
@Override
public void specializeCoverage(TDLTestCaseCoverage testCaseCoverage) { //a Sketch is covered if at least one of its Blocks is covered
this.testCaseCoverage = testCaseCoverage; DSLSpecificCoverageRule rule4block = new DSLSpecificCoverageRule();
this.modelObjects = testCaseCoverage.getModelObjects(); rule4block.setContext(ArduinoPackage.eINSTANCE.getBlock());
for (int i=0; i<this.modelObjects.size(); i++) { rule4block.setContainerCoverageByOne(ECollections.asEList(ArduinoPackage.eINSTANCE.getSketch_Block()));
EObject modelObject = this.modelObjects.get(i);
String coverage = this.testCaseCoverage.getTcObjectCoverageStatus().get(i); //a Block is covered if at least one of its instructions is covered
if (modelObject instanceof Project && coverage != TDLCoverageUtil.COVERED) { DSLSpecificCoverageRule rule4instruction = new DSLSpecificCoverageRule();
projectCoverage ((Project) modelObject); rule4instruction.setContext(ArduinoPackage.eINSTANCE.getInstruction());
} rule4instruction.setContainerCoverageByOne(ECollections.asEList(ArduinoPackage.eINSTANCE.getBlock_Instructions()));
else if (modelObject instanceof Sketch && coverage != TDLCoverageUtil.COVERED) {
sketchCoverage ((Sketch) modelObject); //ignore physical-related elements from coverage computation
} DSLSpecificCoverageRule rule4board = new DSLSpecificCoverageRule();
else if (modelObject instanceof Block && coverage != TDLCoverageUtil.COVERED) { rule4board.setContext(ArduinoPackage.eINSTANCE.getBoard());
blockCoverage ((Block) modelObject); rule4board.ignoreClass_subClassesFromCoverage();
}
//The board and its contained elements must be ignored from coverage computation because only the sketch is important DSLSpecificCoverageRule rule4pin = new DSLSpecificCoverageRule();
else if (modelObject instanceof Board) { rule4pin.setContext(ArduinoPackage.eINSTANCE.getPin());
boardCoverage ((Board) modelObject); rule4pin.ignoreClass_subClassesFromCoverage();
}
else if (modelObject instanceof Pin) { DSLSpecificCoverageRule rule4module = new DSLSpecificCoverageRule();
pinCoverage ((Pin) modelObject); rule4module.setContext(ArduinoPackage.eINSTANCE.getModule());
} rule4module.ignoreClass_subClassesFromCoverage();
else if (modelObject instanceof Module) {
moduleCoverage ((Module) modelObject); return ECollections.asEList(rule4sketch, rule4block, rule4board, rule4instruction, rule4module, rule4pin);
}
}
}
private void boardCoverage(Board modelObject) {
// TODO Auto-generated method stub
Board board = (Board) modelObject;
int index = this.modelObjects.indexOf(board);
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.NOT_COVERABLE);
}
private void projectCoverage(Project project) {
//Project is the root element of the model, so if there is at least one covered element, it is also covered
if (this.testCaseCoverage.getTcObjectCoverageStatus().contains(TDLCoverageUtil.COVERED)) {
int index = this.modelObjects.indexOf(project);
this.testCaseCoverage.getTcObjectCoverageStatus().set(index, TDLCoverageUtil.COVERED);
}
}
private void sketchCoverage(Sketch modelObject) {
//if at least one of the contained objects of the sketch is covered, the sketch is also covered
Sketch sketch = (Sketch) modelObject;
Block block = sketch.getBlock();
if (block != null) {
int blockIndex = this.modelObjects.indexOf(block);
String blockCoverage = this.testCaseCoverage.getTcObjectCoverageStatus().get(blockIndex);
if (blockCoverage != TDLCoverageUtil.COVERED) {
blockCoverage(block);
blockCoverage = this.testCaseCoverage.getTcObjectCoverageStatus().get(blockIndex);
}
if (blockCoverage == TDLCoverageUtil.COVERED) {
int sketchIndex = this.modelObjects.indexOf(sketch);
this.testCaseCoverage.getTcObjectCoverageStatus().set(sketchIndex, TDLCoverageUtil.COVERED);
}
}
}
private void blockCoverage(Block modelObject) {
//if at least one of its instructions is covered, the block is also covered
Block block = (Block) modelObject;
for (Instruction instruction: block.getInstructions()) {
int instructionIndex = this.modelObjects.indexOf(instruction);
String instrcutionCoverge = this.testCaseCoverage.getTcObjectCoverageStatus().get(instructionIndex);
if (instrcutionCoverge == TDLCoverageUtil.COVERED) {
int blockIndex = this.modelObjects.indexOf(block);
this.testCaseCoverage.getTcObjectCoverageStatus().set(blockIndex, TDLCoverageUtil.COVERED);
break;
}
}
int blockIndex = this.modelObjects.indexOf(block);
String blockCoverage = this.testCaseCoverage.getTcObjectCoverageStatus().get(blockIndex);
if (blockCoverage != TDLCoverageUtil.COVERED) {
this.testCaseCoverage.getTcObjectCoverageStatus().set(blockIndex, TDLCoverageUtil.NOT_COVERED);
}