From 996d568049e01b3e10e1553741695868234da974 Mon Sep 17 00:00:00 2001 From: lfrenot <lfrenot@LAPTOP-2HO88BUG.localdomain> Date: Fri, 24 Jun 2022 16:12:27 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20des=20en-t=C3=AAtes=20et=20add/rm/md=20?= =?UTF-8?q?method=20et=20signal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/avatartranslator/AvatarMethod.java | 8 + .../mutation/AddAttributeMutation.java | 39 +++- .../mutation/AddMethodMutation.java | 83 ++++++++ .../mutation/AddMutation.java | 45 +++++ .../mutation/AddSignalMutation.java | 74 +++++++ .../mutation/AttributeMutation.java | 51 ++++- .../mutation/AvatarMutation.java | 45 +++++ .../mutation/BlockStructMutation.java | 46 ++++- .../mutation/MdAttributeMutation.java | 45 +++++ .../mutation/MdMethodMutation.java | 116 +++++++++++ .../avatartranslator/mutation/MdMutation.java | 45 +++++ .../mutation/MdSignalMutation.java | 103 ++++++++++ .../mutation/MethodMutation.java | 104 ++++++++++ .../mutation/RmAttributeMutation.java | 47 ++++- .../mutation/RmMethodMutation.java | 71 +++++++ .../avatartranslator/mutation/RmMutation.java | 45 +++++ .../mutation/RmSignalMutation.java | 71 +++++++ .../mutation/SignalMutation.java | 71 +++++++ .../avatartranslator/AvatarMutationTests.java | 180 ++++++++++++++++++ 19 files changed, 1281 insertions(+), 8 deletions(-) create mode 100644 src/main/java/avatartranslator/mutation/AddMethodMutation.java create mode 100644 src/main/java/avatartranslator/mutation/AddSignalMutation.java create mode 100644 src/main/java/avatartranslator/mutation/MdMethodMutation.java create mode 100644 src/main/java/avatartranslator/mutation/MdSignalMutation.java create mode 100644 src/main/java/avatartranslator/mutation/MethodMutation.java create mode 100644 src/main/java/avatartranslator/mutation/RmMethodMutation.java create mode 100644 src/main/java/avatartranslator/mutation/RmSignalMutation.java create mode 100644 src/main/java/avatartranslator/mutation/SignalMutation.java diff --git a/src/main/java/avatartranslator/AvatarMethod.java b/src/main/java/avatartranslator/AvatarMethod.java index a8d5c41d10..28614607d6 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 0d5214e4e4..f5fa57bb89 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 0000000000..3429346053 --- /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 93af5b2009..caf3b96278 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 0000000000..682e416029 --- /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 7a6516e81c..4b876ed6ac 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 d77b2360e1..bc2d80d392 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 3afb66c96c..7f94b2a213 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 eb157a4db7..e00a032dda 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 0000000000..dcdd201963 --- /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 bb61796c94..76819e8be7 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 0000000000..2fabb27ae9 --- /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 0000000000..e7699ca389 --- /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 703b42a905..6c5fd3e1c9 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 0000000000..deea65be9c --- /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 9f647ec4b6..16f63e1879 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 0000000000..4823320901 --- /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 0000000000..b7a394e898 --- /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 75e30f0efe..3f527747fb 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 -- GitLab