Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code changes required for testgenerator plugin #396

Draft
wants to merge 31 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
280968c
Extracted required functionalities for testgenerator as separate met…
rakshitkr May 18, 2020
6c01d28
Merge remote-tracking branch 'upstream/develop' into testgen
rakshitkr May 18, 2020
30879b5
Added condition to check if project is opened
rakshitkr May 19, 2020
293d82b
Read latest JCA ruleset version downloaded during code generation
rakshitkr May 20, 2020
42f1da4
Merge branch 'read-latest-ruleset-fix' into testgen
rakshitkr May 26, 2020
ef32653
Merge branch 'develop' into testgen
rakshitkr May 29, 2020
9152419
Determine exceptions for constructor calls
rakshitkr Jun 3, 2020
cd0c9de
Added method for retrieving simple class name
rakshitkr Jun 3, 2020
ce64c5b
Bug fix
rakshitkr Jun 3, 2020
63f550d
Bug fix
rakshitkr Jun 3, 2020
e831646
Merge branch 'testgen' of https://github.com/rakshitkr/CogniCrypt int…
rakshitkr Jun 3, 2020
efce764
Included getInstance in fetchEnsuringMethod
rakshitkr Jun 3, 2020
9be296d
Added addVariablesToBody method
rakshitkr Jun 3, 2020
2adc9dd
Updated retrieveOnlyClassName to retrieve interface inside class
rakshitkr Jun 4, 2020
3f8c2d5
Changed type of test inputs to simple
rakshitkr Jun 4, 2020
6982488
Moved addVariablesToBody method to GeneratorTest class
rakshitkr Jun 5, 2020
9c75648
Changed scope of addAddtionalFile method
rakshitkr Jun 11, 2020
4060058
Changed the scope of body
rakshitkr Jun 11, 2020
362cdfb
Added return type to imports
rakshitkr Jun 11, 2020
e84bbbf
Added getter for killStatements
rakshitkr Jul 2, 2020
3660fa6
Deleted empty.txt
rakshitkr Jul 2, 2020
81938c3
Handle non primitive array type
rakshitkr Jul 2, 2020
6fd9d5e
Added support for string array constriants
rakshitkr Jul 2, 2020
b71f66a
Added support for parameters of type BigInteger
rakshitkr Jul 10, 2020
696f2af
Created getter for parameterCache
rakshitkr Jul 15, 2020
4f01a4b
Fix for requiredPars during test generation
rakshitkr Jul 31, 2020
5629ee3
Changed some access modifiers
rakshitkr Aug 19, 2020
6980b97
Exporting common.base & collect packages for test generator
rakshitkr Aug 19, 2020
e178cb8
Changed getTransitions method to handle multiple initial transitions
rakshitkr Sep 2, 2020
63c2c74
Changed some modifiers
rakshitkr Sep 20, 2020
2562c68
Merge branch 'testgen_base' into testgen
krinara86 Apr 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ protected boolean addAdditionalFiles(final String source) {
* @throws IOException
* @throws CoreException
*/
protected boolean addAddtionalFile(final File fileToBeAdded) throws IOException, CoreException {
public boolean addAddtionalFile(final File fileToBeAdded) throws IOException, CoreException {
final IFolder libFolder = this.project.getFolder(Constants.pathsForLibrariesInDevProject);
if (!libFolder.exists()) {
libFolder.create(true, true, null);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

public class GeneratorClass {

private String packageName;
private Set<String> imports;
private String modifier;
private String className;
private List<GeneratorMethod> methods;
protected String packageName;
protected Set<String> imports;
protected String modifier;
protected String className;
protected List<GeneratorMethod> methods;
private File associatedFile;

public GeneratorClass() {
Expand Down Expand Up @@ -122,5 +122,4 @@ public String toString() {
classContent.append("}");
return classContent.toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
import java.util.Map.Entry;
import java.util.Set;

import de.cognicrypt.utils.Utils;

public class GeneratorMethod {

private String modifier;
private String returnType;
private String name;
protected String modifier;
protected String returnType;
protected String name;
private List<Entry<String, String>> parameters;
private Set<String> exceptions;
private StringBuilder body;
private List<Entry<String, String>> variableDeclarations;
protected Set<String> exceptions;
protected StringBuilder body;
protected List<Entry<String, String>> variableDeclarations;
private List<Entry<String, String>> postCGVars;
private StringBuilder killStatements;
private int templateVariables;
Expand Down Expand Up @@ -190,5 +192,8 @@ public void addPostCGVars(Entry<String, String> postCGVar) {
public List<Entry<String, String>> getPostCGVars() {
return postCGVars;
}


public StringBuilder getKillStatements() {
return killStatements;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.util.List;

import crypto.rules.StateMachineGraph;
import crypto.rules.StateNode;
import crypto.rules.TransitionEdge;
import de.cognicrypt.utils.CrySLUtils;

Expand All @@ -30,9 +29,9 @@
*/
public class StateMachineGraphAnalyser {

private StateMachineGraph stateMachine;
private ArrayList<String> usedTransitions = new ArrayList<String>();
private ArrayList<List<TransitionEdge>> allTransitions;
protected StateMachineGraph stateMachine;
protected ArrayList<String> usedTransitions = new ArrayList<String>();
protected ArrayList<List<TransitionEdge>> allTransitions;

public StateMachineGraphAnalyser(StateMachineGraph stateMachine) {
this.stateMachine = stateMachine;
Expand All @@ -42,23 +41,20 @@ public StateMachineGraphAnalyser(StateMachineGraph stateMachine) {
// Current solution: Take every loop once.
// This solution does not distinguish between the two operates
// + and * of the crysl language
public ArrayList<List<TransitionEdge>> getTransitions() throws Exception {
public ArrayList<List<TransitionEdge>> getTransitions() {
allTransitions = new ArrayList<List<TransitionEdge>>();

//Collection<StateNode> nodes = stateMachine.getNodes();
List<TransitionEdge> edges = stateMachine.getEdges();
//Collection<StateNode> acceptingNodes = stateMachine.getAcceptingStates();

TransitionEdge initialTransition = stateMachine.getInitialTransition();
StateNode initialState = initialTransition.getLeft();
List<TransitionEdge> initialTransitions = stateMachine.getInitialTransitions();
for (TransitionEdge initialTransition : initialTransitions) {

if (!initialState.getInit()) {
throw new Exception("No initial state found for state machine!");
}

List<TransitionEdge> transitions = new ArrayList<TransitionEdge>();
List<TransitionEdge> transitions = new ArrayList<TransitionEdge>();

visitNode(edges, initialTransition, transitions);
visitNode(edges, initialTransition, transitions);
}

return allTransitions;
}
Expand Down
2 changes: 2 additions & 0 deletions plugins/de.cognicrypt.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ Export-Package: boomerang;
com.google.common.collect,
sync.pds.solver,
wpds.impl",
com.google.common.base,
com.google.common.collect,
crypto;
uses:="ideal,
crypto.rules,
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions plugins/de.cognicrypt.core/src/de/cognicrypt/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,11 @@ public static boolean isSubType(String typeOne, String typeTwo) {
}
return subTypes;
}

public static String retrieveOnlyClassName(String className) {
String[] values = className.split("\\.");
String value = values[values.length-1];
String[] names = value.split("\\$");
return names[names.length-1];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,11 @@ public void resourceChanged(IResourceChangeEvent event) {
&& (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED)) {
IProject project = (IProject) deltaResource;
try {
if (!CrySLBuilderUtils.hasCrySLBuilder(project) && CrySLBuilderUtils.hasCrySLFiles(project)) {
CrySLBuilderUtils.addCrySLBuilderToProject(project);
if(project.isOpen())
{
if (!CrySLBuilderUtils.hasCrySLBuilder(project) && CrySLBuilderUtils.hasCrySLFiles(project)) {
CrySLBuilderUtils.addCrySLBuilderToProject(project);
}
}
}
catch (CoreException e) {
Expand Down