diff --git a/src/main/java/avatartranslator/AvatarMethod.java b/src/main/java/avatartranslator/AvatarMethod.java index a8d5c41d10c0e90aa0d12cd4371f31b40141fa9c..28614607d660762ff513312c9b560535573412a2 100644 --- a/src/main/java/avatartranslator/AvatarMethod.java +++ b/src/main/java/avatartranslator/AvatarMethod.java @@ -82,10 +82,18 @@ public class AvatarMethod extends AvatarElement { return parameters; } + public void removeAttributes() { + parameters = new LinkedList<AvatarAttribute>(); + } + public List<AvatarAttribute> getListOfReturnAttributes() { return returnParameters; } + public void removeReturnAttributes() { + returnParameters = new LinkedList<AvatarAttribute>(); + } + public static boolean isAValidMethodName(String _method) { return AvatarTerm.isValidName (_method); } diff --git a/src/main/java/avatartranslator/mutation/AddAttributeMutation.java b/src/main/java/avatartranslator/mutation/AddAttributeMutation.java index 0d5214e4e4228a4892b9b5b36bf79412cb00bbce..f5fa57bb895801c7d9a42fde6e41ec12e8df1d28 100644 --- a/src/main/java/avatartranslator/mutation/AddAttributeMutation.java +++ b/src/main/java/avatartranslator/mutation/AddAttributeMutation.java @@ -1,3 +1,41 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + package avatartranslator.mutation; import avatartranslator.*; @@ -5,7 +43,6 @@ import avatartranslator.*; /** * Class AddAttributeMutation - * Mutation that adds an attribute to a block * Creation: 23/06/2022 * * @author Léon FRENOT diff --git a/src/main/java/avatartranslator/mutation/AddMethodMutation.java b/src/main/java/avatartranslator/mutation/AddMethodMutation.java new file mode 100644 index 0000000000000000000000000000000000000000..34293460534571b5aaaf6ee463eeb2ea3cf92c06 --- /dev/null +++ b/src/main/java/avatartranslator/mutation/AddMethodMutation.java @@ -0,0 +1,83 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package avatartranslator.mutation; + +import avatartranslator.*; + +/** + * Class AddMethodMutation + * Creation: 24/06/2022 + * + * @author Léon FRENOT + * @version 1.0 24/06/2022 + */ +public class AddMethodMutation extends MethodMutation implements AddMutation { + + public AddMethodMutation(String _name, String _blockName, boolean _imp) { + setName(_name); + setBlockName(_blockName); + initParameters(); + setImplementationProvided(_imp); + } + + public AddMethodMutation(String _name, String _blockName) { + this(_name, _blockName, false); + } + + public AvatarMethod createElement(AvatarSpecification _avspec) { + AvatarBlock block = getBlock(_avspec); + AvatarMethod am = new AvatarMethod(getName(), null); + for(String s : getReturnParameters()) { + AvatarAttribute aa = new AvatarAttribute("", AvatarType.getType(s), block, null); + am.addReturnParameter(aa); + } + for(String[] s : getParameters()) { + AvatarAttribute aa = new AvatarAttribute(s[1], AvatarType.getType(s[0]), block, null); + am.addParameter(aa); + } + am.setImplementationProvided(isImplementationProvided()); + return am; + } + + public void apply(AvatarSpecification _avspec) { + AvatarMethod am = createElement(_avspec); + AvatarBlock block = getBlock(_avspec); + block.addMethod(am); + } +} \ No newline at end of file diff --git a/src/main/java/avatartranslator/mutation/AddMutation.java b/src/main/java/avatartranslator/mutation/AddMutation.java index 93af5b20092d7e8928429ea2774c63776dac020a..caf3b96278601909a57b2c7441f5ff96c29a5b7d 100644 --- a/src/main/java/avatartranslator/mutation/AddMutation.java +++ b/src/main/java/avatartranslator/mutation/AddMutation.java @@ -1,7 +1,52 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + package avatartranslator.mutation; import avatartranslator.*; +/** + * Interface AddMutation + * Creation: 23/06/2022 + * + * @author Léon FRENOT + * @version 1.0 23/06/2022 + */ public interface AddMutation { AvatarElement createElement(AvatarSpecification _avspec); diff --git a/src/main/java/avatartranslator/mutation/AddSignalMutation.java b/src/main/java/avatartranslator/mutation/AddSignalMutation.java new file mode 100644 index 0000000000000000000000000000000000000000..682e41602992188c3fb2a3ae2892275a5585b9a2 --- /dev/null +++ b/src/main/java/avatartranslator/mutation/AddSignalMutation.java @@ -0,0 +1,74 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package avatartranslator.mutation; + +import avatartranslator.*; + +/** + * Class AddSignalMutation + * Creation: 24/06/2022 + * + * @author Léon FRENOT + * @version 1.0 24/06/2022 + */ +public class AddSignalMutation extends SignalMutation implements AddMutation { + + public AddSignalMutation(String _name, String _blockName, int _inout) { + setName(_name); + setBlockName(_blockName); + setInOut(_inout); + initParameters(); + } + + public AvatarSignal createElement(AvatarSpecification _avspec) { + AvatarBlock block = getBlock(_avspec); + AvatarSignal as = new AvatarSignal(getName(), getInOut(), null); + for(String[] s : getParameters()) { + AvatarAttribute aa = new AvatarAttribute(s[1], AvatarType.getType(s[0]), block, null); + as.addParameter(aa); + } + return as; + } + + public void apply(AvatarSpecification _avspec) { + AvatarSignal as = createElement(_avspec); + AvatarBlock block = getBlock(_avspec); + block.addSignal(as); + } +} diff --git a/src/main/java/avatartranslator/mutation/AttributeMutation.java b/src/main/java/avatartranslator/mutation/AttributeMutation.java index 7a6516e81cecf9ab2f2261f3bd004c2a7e879967..4b876ed6ac95c226e84c030e884e73d1fcbddeab 100644 --- a/src/main/java/avatartranslator/mutation/AttributeMutation.java +++ b/src/main/java/avatartranslator/mutation/AttributeMutation.java @@ -1,8 +1,53 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + package avatartranslator.mutation; import avatartranslator.*; import java.util.List; +/** + * Class AttributeMutation + * Creation: 23/06/2022 + * + * @author Léon FRENOT + * @version 1.0 23/06/2022 + */ public abstract class AttributeMutation extends BlockStructMutation { private String type; @@ -45,10 +90,6 @@ public abstract class AttributeMutation extends BlockStructMutation { public AvatarAttribute findElement(AvatarSpecification _avspec) { AvatarBlock block = getBlock(_avspec); - List<AvatarAttribute> attr = block.getAttributes(); - for(AvatarAttribute aa : attr) { - if(aa.getName().equals(this.getName())) return aa; - } - return null; + return block.getAvatarAttributeWithName(getName()); } } \ No newline at end of file diff --git a/src/main/java/avatartranslator/mutation/AvatarMutation.java b/src/main/java/avatartranslator/mutation/AvatarMutation.java index d77b2360e19ab03a54719e81c1c4dfdb4546ac02..bc2d80d3926cda811cce97b4962a778cf03e5288 100644 --- a/src/main/java/avatartranslator/mutation/AvatarMutation.java +++ b/src/main/java/avatartranslator/mutation/AvatarMutation.java @@ -1,7 +1,52 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + package avatartranslator.mutation; import avatartranslator.*; +/** + * Class AvatarMutation + * Creation: 23/06/2022 + * + * @author Léon FRENOT + * @version 1.0 23/06/2022 + */ public abstract class AvatarMutation { public abstract void apply(AvatarSpecification _avspec); diff --git a/src/main/java/avatartranslator/mutation/BlockStructMutation.java b/src/main/java/avatartranslator/mutation/BlockStructMutation.java index 3afb66c96cbcd100d5c49cb0fe386da340ea69df..7f94b2a2135f3c3a73fc17d1aaf4c15122680ea3 100644 --- a/src/main/java/avatartranslator/mutation/BlockStructMutation.java +++ b/src/main/java/avatartranslator/mutation/BlockStructMutation.java @@ -1,7 +1,51 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + package avatartranslator.mutation; import avatartranslator.*; - +/** + * Class BlockStructMutation + * Creation: 23/06/2022 + * + * @author Léon FRENOT + * @version 1.0 23/06/2022 + */ public abstract class BlockStructMutation extends AvatarMutation { private String blockName; diff --git a/src/main/java/avatartranslator/mutation/MdAttributeMutation.java b/src/main/java/avatartranslator/mutation/MdAttributeMutation.java index eb157a4db7c5a31c7bac898a33668a085ede72bf..e00a032dda24f504e98b3c0da0528ebc01dc76d9 100644 --- a/src/main/java/avatartranslator/mutation/MdAttributeMutation.java +++ b/src/main/java/avatartranslator/mutation/MdAttributeMutation.java @@ -1,9 +1,54 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + package avatartranslator.mutation; import avatartranslator.*; import myutil.TraceManager; +/** + * Class MdAttributeMutation + * Creation: 23/06/2022 + * + * @author Léon FRENOT + * @version 1.0 23/06/2022 + */ public class MdAttributeMutation extends AttributeMutation implements MdMutation { public MdAttributeMutation(String _name, String _initialValue, String _blockName) { diff --git a/src/main/java/avatartranslator/mutation/MdMethodMutation.java b/src/main/java/avatartranslator/mutation/MdMethodMutation.java new file mode 100644 index 0000000000000000000000000000000000000000..dcdd201963acf2920286428002b405d58d057c13 --- /dev/null +++ b/src/main/java/avatartranslator/mutation/MdMethodMutation.java @@ -0,0 +1,116 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package avatartranslator.mutation; + +import avatartranslator.*; + +import myutil.TraceManager; + +/** + * Class MdMethodMutation + * Creation: 24/06/2022 + * + * @author Léon FRENOT + * @version 1.0 24/06/2022 + */ +public class MdMethodMutation extends MethodMutation implements MdMutation { + + private boolean implementationChanged = false; + private boolean returnParametersChanged = false; + private boolean parametersChanged = false; + + public MdMethodMutation(String _name, String _blockName) { + setName(_name); + setBlockName(_blockName); + initParameters(); + } + + public MdMethodMutation(String _name, String _blockName, boolean _imp) { + this(_name, _blockName); + setImplementationProvided(_imp); + } + + @Override + public void addReturnParameter(String _returnParameter) { + returnParametersChanged = true; + super.addReturnParameter(_returnParameter); + } + + @Override + public void addParameter(String[] _parameter) { + parametersChanged = true; + super.addParameter(_parameter); + } + + @Override + public void setImplementationProvided(boolean _imp) { + implementationChanged = true; + super.setImplementationProvided(_imp); + } + + public void apply(AvatarSpecification _avspec) { + AvatarBlock block = getBlock(_avspec); + AvatarMethod am = findElement(_avspec); + + if(am == null) { + TraceManager.addDev("Methode inexistante"); + return; + } + + if(implementationChanged) { + am.setImplementationProvided(isImplementationProvided()); + } + + if(returnParametersChanged) { + am.removeReturnAttributes(); + for(String s : getReturnParameters()) { + AvatarAttribute aa = new AvatarAttribute("", AvatarType.getType(s), block, null); + am.addReturnParameter(aa); + } + } + + if(parametersChanged) { + am.removeAttributes(); + for(String[] s : getParameters()) { + AvatarAttribute aa = new AvatarAttribute(s[1], AvatarType.getType(s[0]), block, null); + am.addParameter(aa); + } + } + } +} diff --git a/src/main/java/avatartranslator/mutation/MdMutation.java b/src/main/java/avatartranslator/mutation/MdMutation.java index bb61796c94870b5eeac3d67f99ee933761ed1741..76819e8be7869e3dd65978eaf78d610f3b3b91f3 100644 --- a/src/main/java/avatartranslator/mutation/MdMutation.java +++ b/src/main/java/avatartranslator/mutation/MdMutation.java @@ -1,7 +1,52 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + package avatartranslator.mutation; import avatartranslator.*; +/** + * Interface MdMutation + * Creation: 23/06/2022 + * + * @author Léon FRENOT + * @version 1.0 23/06/2022 + */ public interface MdMutation { AvatarElement findElement(AvatarSpecification _avspec); diff --git a/src/main/java/avatartranslator/mutation/MdSignalMutation.java b/src/main/java/avatartranslator/mutation/MdSignalMutation.java new file mode 100644 index 0000000000000000000000000000000000000000..2fabb27ae9fc8705efac9a70fdbb8edf661322fe --- /dev/null +++ b/src/main/java/avatartranslator/mutation/MdSignalMutation.java @@ -0,0 +1,103 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package avatartranslator.mutation; + +import avatartranslator.*; + +import myutil.TraceManager; + +/** + * Class MdSignalMutation + * Creation: 24/06/2022 + * + * @author Léon FRENOT + * @version 1.0 24/06/2022 + */ +public class MdSignalMutation extends SignalMutation implements MdMutation{ + + private boolean inoutChanged = false; + private boolean parametersChanged = false; + + public MdSignalMutation(String _name, String _blockName) { + setName(_name); + setBlockName(_blockName); + initParameters(); + } + + public MdSignalMutation(String _name, String _blockName, int _inout) { + this(_name, _blockName); + setInOut(_inout); + } + + @Override + public void addParameter(String[] _parameter) { + parametersChanged = true; + super.addParameter(_parameter); + } + + @Override + public void setInOut(int _inout) { + inoutChanged = true; + super.setInOut(_inout); + } + + public void apply(AvatarSpecification _avspec) { + + AvatarBlock block = getBlock(_avspec); + AvatarSignal as = findElement(_avspec); + + if(as == null) { + TraceManager.addDev("Signal Inexistant"); + return; + } + + if(parametersChanged) { + as.removeAttributes(); + for(String[] s : getParameters()) { + AvatarAttribute aa = new AvatarAttribute(s[1], AvatarType.getType(s[0]), block, null); + as.addParameter(aa); + } + } + + if(inoutChanged) { + as.setInOut(getInOut()); + } + } + +} diff --git a/src/main/java/avatartranslator/mutation/MethodMutation.java b/src/main/java/avatartranslator/mutation/MethodMutation.java new file mode 100644 index 0000000000000000000000000000000000000000..e7699ca38948824b10262dca8182d3a64cac0f75 --- /dev/null +++ b/src/main/java/avatartranslator/mutation/MethodMutation.java @@ -0,0 +1,104 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package avatartranslator.mutation; + +import avatartranslator.*; +import java.util.List; +import java.util.LinkedList; + +/** + * Class MethodMutation + * Creation: 24/06/2022 + * + * @author Léon FRENOT + * @version 1.0 24/06/2022 + */ + +public abstract class MethodMutation extends BlockStructMutation { + + private String name; + + private boolean implementationProvided; + + protected List<String> returnParameters; + + protected List<String[]> parameters; + + public void setName(String _name) { + name = _name; + } + + public String getName() { + return name; + } + + public void initParameters() { + returnParameters = new LinkedList<>(); + parameters = new LinkedList<>(); + } + + public void addReturnParameter(String _returnParameter) { + returnParameters.add(_returnParameter); + } + + public List<String> getReturnParameters() { + return returnParameters; + } + + public void addParameter(String[] _parameter) { + parameters.add(_parameter); + } + + public List<String[]> getParameters() { + return parameters; + } + + public void setImplementationProvided(boolean _imp) { + implementationProvided = _imp; + } + + public boolean isImplementationProvided() { + return implementationProvided; + } + + public AvatarMethod findElement(AvatarSpecification _avspec) { + AvatarBlock block = getBlock(_avspec); + return block.getAvatarMethodWithName(getName()); + } +} \ No newline at end of file diff --git a/src/main/java/avatartranslator/mutation/RmAttributeMutation.java b/src/main/java/avatartranslator/mutation/RmAttributeMutation.java index 703b42a9054a2e63264965c2de3e670c1e2d6367..6c5fd3e1c93f6f034912c8614b89ac7ae870415a 100644 --- a/src/main/java/avatartranslator/mutation/RmAttributeMutation.java +++ b/src/main/java/avatartranslator/mutation/RmAttributeMutation.java @@ -1,10 +1,55 @@ -package avatartranslator.mutation; +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + package avatartranslator.mutation; import avatartranslator.*; import java.util.List; import myutil.TraceManager; +/** + * Class RmAttributeMutation + * Creation: 23/06/2022 + * + * @author Léon FRENOT + * @version 1.0 23/06/2022 + */ public class RmAttributeMutation extends AttributeMutation implements RmMutation { public RmAttributeMutation(String _name, String _blockName) { diff --git a/src/main/java/avatartranslator/mutation/RmMethodMutation.java b/src/main/java/avatartranslator/mutation/RmMethodMutation.java new file mode 100644 index 0000000000000000000000000000000000000000..deea65be9c4f5f1ea4d91500dc36cee90d67bb63 --- /dev/null +++ b/src/main/java/avatartranslator/mutation/RmMethodMutation.java @@ -0,0 +1,71 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package avatartranslator.mutation; + +import avatartranslator.*; +import java.util.List; + +import myutil.TraceManager; + +/** + * Class RmMethodMutation + * Creation: 24/06/2022 + * + * @author Léon FRENOT + * @version 1.0 24/06/2022 + */ +public class RmMethodMutation extends MethodMutation implements RmMutation { + + public RmMethodMutation(String _name, String _blockName) { + setName(_name); + setBlockName(_blockName); + initParameters(); + } + + public void apply(AvatarSpecification _avspec) { + AvatarBlock block = getBlock(_avspec); + List<AvatarMethod> meth = block.getMethods(); + AvatarMethod am = findElement(_avspec); + if(am == null) { + TraceManager.addDev("Methode inexistante"); + return; + } + if(!meth.remove(am)) TraceManager.addDev("Methode dans un super-bloc"); + } +} diff --git a/src/main/java/avatartranslator/mutation/RmMutation.java b/src/main/java/avatartranslator/mutation/RmMutation.java index 9f647ec4b63fceb2aee259e5b3852cb84e1de178..16f63e18793149f2a301530dc4c4f2107c450c24 100644 --- a/src/main/java/avatartranslator/mutation/RmMutation.java +++ b/src/main/java/avatartranslator/mutation/RmMutation.java @@ -1,7 +1,52 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + package avatartranslator.mutation; import avatartranslator.*; +/** + * Interface RmMutation + * Creation: 23/06/2022 + * + * @author Léon FRENOT + * @version 1.0 23/06/2022 + */ public interface RmMutation { AvatarElement findElement(AvatarSpecification _avspec); diff --git a/src/main/java/avatartranslator/mutation/RmSignalMutation.java b/src/main/java/avatartranslator/mutation/RmSignalMutation.java new file mode 100644 index 0000000000000000000000000000000000000000..4823320901ee28bd8415a5f44683501bc0218ba5 --- /dev/null +++ b/src/main/java/avatartranslator/mutation/RmSignalMutation.java @@ -0,0 +1,71 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package avatartranslator.mutation; + +import avatartranslator.*; +import java.util.List; + +import myutil.TraceManager; + +/** + * Class RmSignalMutation + * Creation: 24/06/2022 + * + * @author Léon FRENOT + * @version 1.0 24/06/2022 + */ +public class RmSignalMutation extends SignalMutation implements RmMutation { + + public RmSignalMutation(String _name, String _blockName) { + setName(_name); + setBlockName(_blockName); + initParameters(); + } + + public void apply(AvatarSpecification _avspec) { + AvatarBlock block = getBlock(_avspec); + List<AvatarSignal> sign = block.getSignals(); + AvatarSignal as = findElement(_avspec); + if(as == null) { + TraceManager.addDev("Signal inexistant"); + return; + } + if(!sign.remove(as)) TraceManager.addDev("Signal dans un super-bloc"); + } +} diff --git a/src/main/java/avatartranslator/mutation/SignalMutation.java b/src/main/java/avatartranslator/mutation/SignalMutation.java new file mode 100644 index 0000000000000000000000000000000000000000..b7a394e898b09f4bf010e3527f83de5d3848b75d --- /dev/null +++ b/src/main/java/avatartranslator/mutation/SignalMutation.java @@ -0,0 +1,71 @@ +/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + +package avatartranslator.mutation; + +import avatartranslator.*; + +/** + * Class SignalMutation + * Creation: 24/06/2022 + * + * @author Léon FRENOT + * @version 1.0 24/06/2022 + */ + +public abstract class SignalMutation extends MethodMutation { + + private int inout; + + public final static int IN = AvatarSignal.IN; + public final static int OUT = AvatarSignal.OUT; + + public void setInOut(int _inout) { + inout = _inout; + } + + public int getInOut() { + return inout; + } + + @Override + public AvatarSignal findElement(AvatarSpecification _avspec) { + AvatarBlock block = getBlock(_avspec); + return block.getAvatarSignalWithName(getName()); + } +} diff --git a/ttool/src/test/java/avatartranslator/AvatarMutationTests.java b/ttool/src/test/java/avatartranslator/AvatarMutationTests.java index 75e30f0efe8356c24cfecb84ca00da48b051a420..3f527747fb0055ad3eea65c2ce2db0dba53a8246 100644 --- a/ttool/src/test/java/avatartranslator/AvatarMutationTests.java +++ b/ttool/src/test/java/avatartranslator/AvatarMutationTests.java @@ -1,3 +1,47 @@ +/**Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille + * + * ludovic.apvrille AT enst.fr + * + * This software is a computer program whose purpose is to allow the + * edition of TURTLE analysis, design and deployment diagrams, to + * allow the generation of RT-LOTOS or Java code from this diagram, + * and at last to allow the analysis of formal validation traces + * obtained from external tools, e.g. RTL from LAAS-CNRS and CADP + * from INRIA Rhone-Alpes. + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + * + * /** + * Class AvatarMutationTests + * Creation: 23/06/2022 + * @version 1.0 23/06/2022 + * @author Léon FRENOT + */ + package avatartranslator; import static org.junit.Assert.*; @@ -22,6 +66,7 @@ public class AvatarMutationTests { block = new AvatarBlock("block", as, null); as.addBlock(block); AvatarAttribute x1 = new AvatarAttribute("x", AvatarType.INTEGER, block, null); + block.addAttribute(x1); x1.setInitialValue("10"); } @@ -59,4 +104,139 @@ public class AvatarMutationTests { mutation.apply(as); assertTrue(block.getAttribute(0).getInitialValue().equals("42")); } + + @Test + public void testAddMethod() { + MethodMutation mutation = new AddMethodMutation("f", "block"); + String[] tmp = {"int", "x"}; + String[] tmp2 = {"bool", "y"}; + mutation.addReturnParameter("int"); + mutation.addReturnParameter("bool"); + mutation.addParameter(tmp); + + MethodMutation mutation2 = new AddMethodMutation("g", "block", true); + mutation2.addReturnParameter("int"); + + mutation.apply(as); + mutation2.apply(as); + + assertTrue(block.getMethods().size() == 2); + + AvatarMethod meth = block.getMethods().get(0); + AvatarMethod meth2 = block.getMethods().get(1); + + assertTrue(meth.getName().equals("f")); + TraceManager.addDev(meth.toString()); + assertTrue(meth2.isImplementationProvided()); + } + + @Test + public void testRmMethod() { + MethodMutation mutation = new AddMethodMutation("f", "block"); + String[] tmp = {"int", "x"}; + String[] tmp2 = {"bool", "y"}; + mutation.addReturnParameter("int"); + mutation.addReturnParameter("bool"); + mutation.addParameter(tmp); + mutation.apply(as); + + MethodMutation mutation2 = new RmMethodMutation("f", "block"); + mutation2.apply(as); + + + assertTrue(block.getMethods().size() == 0); + } + + @Test + public void testMdMethod() { + MethodMutation mutation = new AddMethodMutation("f", "block"); + String[] tmp = {"int", "x"}; + String[] tmp2 = {"bool", "y"}; + mutation.addReturnParameter("int"); + mutation.addReturnParameter("bool"); + mutation.addParameter(tmp); + mutation.apply(as); + + MethodMutation mutation2 = new MdMethodMutation("f", "block", true); + mutation2.apply(as); + + AvatarMethod meth = block.getMethods().get(0); + assertTrue(meth.isImplementationProvided()); + assertTrue(meth.getListOfAttributes().size() == 1); + assertTrue(meth.getListOfReturnAttributes().size() == 2); + TraceManager.addDev(meth.toString()); + + mutation2 = new MdMethodMutation("f", "block"); + mutation2.addReturnParameter("int"); + mutation2.addParameter(tmp2); + mutation2.apply(as); + + meth = block.getMethods().get(0); + assertTrue(meth.isImplementationProvided()); + assertTrue(meth.getListOfAttributes().size() == 1); + assertTrue(meth.getListOfReturnAttributes().size() == 1); + TraceManager.addDev(meth.toString()); + } + + @Test + public void testAddSignal() { + SignalMutation mutation = new AddSignalMutation("cin", "block", SignalMutation.IN); + String[] tmp = {"int", "x"}; + String[] tmp2 = {"bool", "y"}; + mutation.addParameter(tmp); + mutation.addParameter(tmp2); + + SignalMutation mutation2 = new AddSignalMutation("cout", "block", SignalMutation.OUT); + + mutation.apply(as); + mutation2.apply(as); + + assertTrue(block.getSignals().size() == 2); + + TraceManager.addDev(block.getSignals().get(0).toString()); + TraceManager.addDev(block.getSignals().get(1).toString()); + } + + @Test + public void testRmSignal() { + SignalMutation mutation = new AddSignalMutation("cin", "block", SignalMutation.IN); + String[] tmp = {"int", "x"}; + String[] tmp2 = {"bool", "y"}; + mutation.addParameter(tmp); + mutation.addParameter(tmp2); + mutation.apply(as); + + assertTrue(block.getSignals().size() == 1); + + SignalMutation mutation2 = new RmSignalMutation("cin", "block"); + mutation2.apply(as); + + assertTrue(block.getSignals().size() == 0); + + } + + @Test + public void testMdSignal() { + SignalMutation mutation = new AddSignalMutation("cin", "block", SignalMutation.IN); + String[] tmp = {"int", "x"}; + String[] tmp2 = {"bool", "y"}; + mutation.addParameter(tmp); + mutation.addParameter(tmp2); + mutation.apply(as); + + assertTrue(block.getSignals().size() == 1); + + SignalMutation mutation2 = new MdSignalMutation("cin", "block", SignalMutation.OUT); + mutation2.apply(as); + + assertTrue(block.getSignals().get(0).getInOut() == SignalMutation.OUT); + + SignalMutation mutation3 = new MdSignalMutation("cin", "block"); + mutation3.addParameter(tmp); + mutation3.apply(as); + + assertTrue(block.getSignals().get(0).getListOfAttributes().size() == 1); + TraceManager.addDev(block.getSignals().get(0).toString()); + + } } \ No newline at end of file