diff --git a/src/test/java/br/unc/cic/analysis/test/DefinitionFactory.java b/src/test/java/br/unc/cic/analysis/test/DefinitionFactory.java index fc6438fc..439972a0 100644 --- a/src/test/java/br/unc/cic/analysis/test/DefinitionFactory.java +++ b/src/test/java/br/unc/cic/analysis/test/DefinitionFactory.java @@ -2,7 +2,10 @@ import br.unb.cic.analysis.AbstractMergeConflictDefinition; -import java.util.*; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; public class DefinitionFactory { @@ -12,22 +15,37 @@ public static AbstractMergeConflictDefinition definition(String className, int s } public static AbstractMergeConflictDefinition definition(String className, int sourceLines[], int sinkLines[], boolean recursive) { + return definition(Arrays.asList(new MarkingClass(className, sourceLines, sinkLines)), recursive); + }; + + /** + * + * @param markingClassList It is a list of tags. Each tag as lines marked as source and as lines marked as sink + * and the name of the class where the lines were marked. + * @param recursive Indicates whether the loading of statements will be done recursively or not. + * @return + */ + public static AbstractMergeConflictDefinition definition(List markingClassList, boolean recursive) { return new AbstractMergeConflictDefinition(recursive) { - @Override - protected Map> sourceDefinitions() { - Map> res = new HashMap<>(); - List lines = Arrays.stream(sourceLines).boxed().collect(Collectors.toList()); - res.put(className, lines); - return res; + @Override + protected Map> sourceDefinitions() { + Map> res = new HashMap<>(); + for(MarkingClass m: markingClassList){ + List lines = Arrays.stream(m.getSourceLines()).boxed().collect(Collectors.toList()); + res.put(m.getClassName(), lines); } + return res; + } - @Override - protected Map> sinkDefinitions() { - Map> res = new HashMap<>(); - List lines = Arrays.stream(sinkLines).boxed().collect(Collectors.toList()); - res.put(className, lines); - return res; + @Override + protected Map> sinkDefinitions() { + Map> res = new HashMap<>(); + for(MarkingClass m: markingClassList) { + List lines = Arrays.stream(m.getSinkLines()).boxed().collect(Collectors.toList()); + res.put(m.getClassName(), lines); } - }; - } -} + return res; + } + }; + } +} \ No newline at end of file diff --git a/src/test/java/br/unc/cic/analysis/test/MarkingClass.java b/src/test/java/br/unc/cic/analysis/test/MarkingClass.java new file mode 100644 index 00000000..a0997c39 --- /dev/null +++ b/src/test/java/br/unc/cic/analysis/test/MarkingClass.java @@ -0,0 +1,37 @@ +package br.unc.cic.analysis.test; + +public class MarkingClass { + String className; + int sourceLines[]; + int sinkLines[]; + + public MarkingClass(String className, int[] sourceLines, int[] sinkLines) { + this.className = className; + this.sourceLines = sourceLines; + this.sinkLines = sinkLines; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public int[] getSourceLines() { + return sourceLines; + } + + public void setSourceLines(int[] sourceLines) { + this.sourceLines = sourceLines; + } + + public int[] getSinkLines() { + return sinkLines; + } + + public void setSinkLines(int[] sinkLines) { + this.sinkLines = sinkLines; + } +} \ No newline at end of file