
com.ecfeed.core.operations.MethodOperationMakeConsistent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ecfeed.junit Show documentation
Show all versions of ecfeed.junit Show documentation
An open library used to connect to the ecFeed service. It can be also used as a standalone testing tool. It is integrated with Junit5 and generates a stream of test cases using a selected algorithm (e.g. Cartesian, N-Wise). There are no limitations associated with the off-line version but the user cannot access the on-line computation servers and the model database.
The newest version!
/*******************************************************************************
*
* Copyright (c) 2016 ecFeed AS.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*******************************************************************************/
package com.ecfeed.core.operations;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.ecfeed.core.model.ConstraintNode;
import com.ecfeed.core.model.MethodNode;
import com.ecfeed.core.model.ModelOperationException;
import com.ecfeed.core.model.TestCaseNode;
public class MethodOperationMakeConsistent extends AbstractModelOperation {
private MethodNode fMethodNode;
private List fOriginalConstraints;
private List fOriginalTestCases;
private class ReverseOperation extends AbstractModelOperation{
public ReverseOperation() {
super(OperationNames.MAKE_CONSISTENT);
}
@Override
public void execute() throws ModelOperationException {
setOneNodeToSelect(fMethodNode);
fMethodNode.replaceTestCases(fOriginalTestCases);
fMethodNode.replaceConstraints(fOriginalConstraints);
markModelUpdated();
}
@Override
public IModelOperation getReverseOperation() {
return new MethodOperationMakeConsistent(fMethodNode);
}
}
public MethodOperationMakeConsistent(MethodNode target) {
super(OperationNames.MAKE_CONSISTENT);
fMethodNode = target;
fOriginalConstraints = new ArrayList(target.getConstraintNodes());
fOriginalTestCases = new ArrayList(target.getTestCases());
}
@Override
public void execute() throws ModelOperationException {
setOneNodeToSelect(fMethodNode);
boolean modelUpdated = false;
Iterator tcIt = fMethodNode.getTestCases().iterator();
while (tcIt.hasNext()) {
if (tcIt.next().isConsistent() == false) {
tcIt.remove();
modelUpdated = true;
}
}
MethodNode.ConstraintsItr constraintItr = fMethodNode.getIterator();
while (fMethodNode.hasNextConstraint(constraintItr)) {
if (!fMethodNode.getNextConstraint(constraintItr).isConsistent()) {
fMethodNode.removeConstraint(constraintItr);
modelUpdated = true;
}
}
if (modelUpdated) {
markModelUpdated();
}
}
@Override
public IModelOperation getReverseOperation() {
return new ReverseOperation();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy