Permalink
Browse files

improved coverage by 10%

  • Loading branch information...
Albert Zuendorf
Albert Zuendorf committed Aug 8, 2014
1 parent 72b0763 commit 4d7587f1ce2f3b48a33e939e98986154067922ca
Showing with 6,216 additions and 42 deletions.
  1. +1 −2 .classpath
  2. +36 −0 Adapter/GuiAdapter.java
  3. +10 −0 Drawer/GuiFileDrawer.java
  4. +7 −0 src/main/java/org/sdmlib/models/classes/ClassModel.java
  5. +1 −0 src/main/java/org/sdmlib/models/classes/Enumeration.java
  6. +1 −0 src/main/java/org/sdmlib/models/classes/SDMLibClass.java
  7. +2 −0 src/main/java/org/sdmlib/models/classes/util/EnumerationSet.java
  8. +3 −0 src/main/java/org/sdmlib/models/classes/util/MethodSet.java
  9. +14 −0 src/main/java/org/sdmlib/models/pattern/Pattern.java
  10. +11 −3 src/main/java/org/sdmlib/storyboards/LogEntryStoryBoard.java
  11. +95 −17 src/main/java/org/sdmlib/storyboards/Storyboard.java
  12. +9 −14 src/test/java/org/sdmlib/examples/mancala/MancalaModel.java
  13. +115 −0 src/test/java/org/sdmlib/examples/mancala/model/Kalah.java
  14. +287 −0 src/test/java/org/sdmlib/examples/mancala/model/Mancala.java
  15. +424 −0 src/test/java/org/sdmlib/examples/mancala/model/Pit.java
  16. +390 −0 src/test/java/org/sdmlib/examples/mancala/model/Player.java
  17. +30 −0 src/test/java/org/sdmlib/examples/mancala/model/PlayerState.java
  18. +115 −0 src/test/java/org/sdmlib/examples/mancala/model/Stone.java
  19. +27 −0 src/test/java/org/sdmlib/examples/mancala/model/util/CreatorCreator.java
  20. +169 −0 src/test/java/org/sdmlib/examples/mancala/model/util/KalahCreator.java
  21. +301 −0 src/test/java/org/sdmlib/examples/mancala/model/util/KalahPO.java
  22. +22 −0 src/test/java/org/sdmlib/examples/mancala/model/util/KalahPOCreator.java
  23. +495 −0 src/test/java/org/sdmlib/examples/mancala/model/util/KalahSet.java
  24. +132 −0 src/test/java/org/sdmlib/examples/mancala/model/util/MancalaCreator.java
  25. +167 −0 src/test/java/org/sdmlib/examples/mancala/model/util/MancalaPO.java
  26. +22 −0 src/test/java/org/sdmlib/examples/mancala/model/util/MancalaPOCreator.java
  27. +260 −0 src/test/java/org/sdmlib/examples/mancala/model/util/MancalaSet.java
  28. +156 −0 src/test/java/org/sdmlib/examples/mancala/model/util/PitCreator.java
  29. +276 −0 src/test/java/org/sdmlib/examples/mancala/model/util/PitPO.java
  30. +22 −0 src/test/java/org/sdmlib/examples/mancala/model/util/PitPOCreator.java
  31. +458 −0 src/test/java/org/sdmlib/examples/mancala/model/util/PitSet.java
  32. +152 −0 src/test/java/org/sdmlib/examples/mancala/model/util/PlayerCreator.java
  33. +236 −0 src/test/java/org/sdmlib/examples/mancala/model/util/PlayerPO.java
  34. +22 −0 src/test/java/org/sdmlib/examples/mancala/model/util/PlayerPOCreator.java
  35. +331 −0 src/test/java/org/sdmlib/examples/mancala/model/util/PlayerSet.java
  36. +82 −0 src/test/java/org/sdmlib/examples/mancala/model/util/PointCreator.java
  37. +36 −0 src/test/java/org/sdmlib/examples/mancala/model/util/PointPO.java
  38. +22 −0 src/test/java/org/sdmlib/examples/mancala/model/util/PointPOCreator.java
  39. +66 −0 src/test/java/org/sdmlib/examples/mancala/model/util/PointSet.java
  40. +95 −0 src/test/java/org/sdmlib/examples/mancala/model/util/StoneCreator.java
  41. +73 −0 src/test/java/org/sdmlib/examples/mancala/model/util/StonePO.java
  42. +22 −0 src/test/java/org/sdmlib/examples/mancala/model/util/StonePOCreator.java
  43. +117 −0 src/test/java/org/sdmlib/examples/mancala/model/util/StoneSet.java
  44. +95 −0 src/test/java/org/sdmlib/examples/simpleEnumModel/model/Alex.java
  45. +95 −0 src/test/java/org/sdmlib/examples/simpleEnumModel/model/Mac.java
  46. +38 −0 src/test/java/org/sdmlib/examples/simpleEnumModel/model/TEnum.java
  47. +94 −0 src/test/java/org/sdmlib/examples/simpleEnumModel/model/util/AlexCreator.java
  48. +90 −0 src/test/java/org/sdmlib/examples/simpleEnumModel/model/util/AlexPO.java
  49. +22 −0 src/test/java/org/sdmlib/examples/simpleEnumModel/model/util/AlexPOCreator.java
  50. +119 −0 src/test/java/org/sdmlib/examples/simpleEnumModel/model/util/AlexSet.java
  51. +19 −0 src/test/java/org/sdmlib/examples/simpleEnumModel/model/util/CreatorCreator.java
  52. +94 −0 src/test/java/org/sdmlib/examples/simpleEnumModel/model/util/MacCreator.java
  53. +90 −0 src/test/java/org/sdmlib/examples/simpleEnumModel/model/util/MacPO.java
  54. +22 −0 src/test/java/org/sdmlib/examples/simpleEnumModel/model/util/MacPOCreator.java
  55. +119 −0 src/test/java/org/sdmlib/examples/simpleEnumModel/model/util/MacSet.java
  56. +7 −6 src/test/java/org/sdmlib/examples/studyrightWithAssignments/StoryboardTests.java
View
@@ -6,7 +6,6 @@
<classpathentry kind="src" path="src/test/java"/>
<classpathentry kind="src" path="Adapter/GraphViz/Java"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" exported="true" kind="src" path="/NetworkParser"/>
- <classpathentry exported="true" kind="con" path="org.springsource.ide.eclipse.gradle.classpathcontainer"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/NetworkParser"/>
<classpathentry kind="output" path="bin"/>
</classpath>
View
@@ -0,0 +1,36 @@
+package org.sdmlib.doc.interfaze.Adapter;
+
+import java.util.LinkedHashMap;
+
+import org.sdmlib.doc.interfaze.Drawer.GuiFileDrawer;
+import org.sdmlib.model.taskflows.util.LogEntrySet;
+import org.sdmlib.models.classes.ClassModel;
+import org.sdmlib.models.objects.GenericGraph;
+import org.sdmlib.models.objects.util.GenericObjectSet;
+
+import de.uniks.networkparser.json.JsonArray;
+
+public interface GuiAdapter
+{
+ public GuiAdapter withRootDir(String rootDir);
+
+ public GuiAdapter withDrawer(GuiFileDrawer drawer);
+
+ public String getName();
+
+ public GuiAdapter withIconMap(LinkedHashMap<String, String> iconMap);
+
+ public String toImg(String imgName, JsonArray objects);
+
+ public String addGenericObjectDiag(String diagramName, GenericGraph graph, GenericObjectSet hiddenObjects);
+
+ public String dumpSwimlanes(String name, LogEntrySet entries);
+
+ public void fillNodeAndEdgeBuilders(String imgName, JsonArray objects,
+ StringBuilder nodeBuilder, StringBuilder edgeBuilder,
+ boolean omitRoot, String... aggregationRoles);
+
+ public String dumpDiagram(String diagramName, String fileText);
+
+ public String dumpClassDiagram(String diagName, ClassModel model);
+}
View
@@ -0,0 +1,10 @@
+package org.sdmlib.doc.interfaze.Drawer;
+
+import java.io.File;
+
+public interface GuiFileDrawer
+{
+ public boolean drawImg(String fileName, String context);
+ public GuiFileDrawer withPlugin(File path, String plusinName);
+ public String getVersion();
+}
@@ -421,4 +421,11 @@ public ClassModel withoutEnumerations(Enumeration... value)
}
return this;
}
+
+ public Enumeration createEnumerations()
+ {
+ Enumeration value = new Enumeration();
+ withEnumerations(value);
+ return value;
+ }
}
@@ -27,6 +27,7 @@ and associated documentation files (the "Software"), to deal in the Software wit
import org.sdmlib.models.classes.util.ArrayListSet;
import org.sdmlib.models.classes.util.EnumerationSet;
import org.sdmlib.models.classes.util.MethodSet;
+import java.util.TreeSet;
public class Enumeration extends SDMLibClass {
@@ -25,6 +25,7 @@ and associated documentation files (the "Software"), to deal in the Software wit
import org.sdmlib.StrUtil;
import org.sdmlib.serialization.PropertyChangeInterface;
+import java.beans.PropertyChangeListener;
public abstract class SDMLibClass implements PropertyChangeInterface
{
@@ -30,6 +30,8 @@ and associated documentation files (the "Software"), to deal in the Software wit
import org.sdmlib.models.modelsets.ObjectSet;
import org.sdmlib.models.modelsets.SDMSet;
import org.sdmlib.models.modelsets.StringList;
+import org.sdmlib.models.classes.util.ClassModelSet;
+import org.sdmlib.models.classes.util.MethodSet;
public class EnumerationSet extends SDMSet<Enumeration>
{
@@ -33,6 +33,9 @@ and associated documentation files (the "Software"), to deal in the Software wit
import org.sdmlib.models.modelsets.ObjectSet;
import org.sdmlib.models.modelsets.SDMSet;
import org.sdmlib.models.modelsets.StringList;
+import org.sdmlib.models.classes.util.EnumerationSet;
+import org.sdmlib.models.classes.util.ParameterSet;
+import org.sdmlib.models.classes.util.ClazzSet;
public class MethodSet extends SDMSet<Method> implements org.sdmlib.models.modelsets.ModelSet
{
@@ -38,6 +38,20 @@ and associated documentation files (the "Software"), to deal in the Software wit
import de.uniks.networkparser.interfaces.SendableEntityCreator;
import de.uniks.networkparser.json.JsonArray;
import de.uniks.networkparser.json.JsonIdMap;
+import org.sdmlib.models.pattern.Pattern;
+import org.sdmlib.models.pattern.PatternObject;
+import org.sdmlib.models.pattern.PatternLink;
+import org.sdmlib.models.pattern.AttributeConstraint;
+import org.sdmlib.models.pattern.MatchIsomorphicConstraint;
+import org.sdmlib.models.pattern.CloneOp;
+import org.sdmlib.models.pattern.UnifyGraphsOp;
+import org.sdmlib.models.pattern.DestroyObjectElem;
+import org.sdmlib.models.pattern.CardinalityConstraint;
+import org.sdmlib.models.pattern.MatchOtherThen;
+import org.sdmlib.models.pattern.GenericConstraint;
+import org.sdmlib.models.pattern.NegativeApplicationCondition;
+import org.sdmlib.models.pattern.OptionalSubPattern;
+import org.sdmlib.models.pattern.LinkConstraint;
public class Pattern<MP> extends PatternElement<MP> implements PropertyChangeInterface, Iterable<Match>
{
@@ -65,15 +65,23 @@ public void setDate(String value) {
String oldValue = this.date;
this.date = value;
- SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
+ SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss z");
try
{
this.parsedDate = dateFormat.parse(this.date);
}
catch (ParseException e)
{
- // TODO Auto-generated catch block
- e.printStackTrace();
+ dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
+ try
+ {
+ this.parsedDate = dateFormat.parse(this.date);
+ }
+ catch (ParseException e2)
+ {
+ // TODO Auto-generated catch block
+ e2.printStackTrace();
+ }
}
getPropertyChangeSupport().firePropertyChange(PROPERTY_DATE, oldValue, value);
}
@@ -31,6 +31,7 @@ and associated documentation files (the "Software"), to deal in the Software wit
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.util.ArrayList;
@@ -531,24 +532,70 @@ public void coverage4GeneratedModelCode(Object root)
coverPOClasses(copyMap);
coverSetClasses(copyMap);
- for (String key : copyMap.keySet())
- {
- Object object = copyMap.getObject(key);
+ coverSeldomModelMethods(copyMap);
- object.toString();
+ }
+ catch (Exception e)
+ {
+ // cannot find creator creator class, sorry.
+ e.printStackTrace();
+ }
+ }
- Class<? extends Object> objectClass = object.getClass();
+ private void coverSeldomModelMethods(JsonIdMap copyMap) throws NoSuchMethodException, IllegalAccessException,
+ InvocationTargetException
+ {
+ LinkedHashSet<String> handledClassesNames = new LinkedHashSet<String>();
+
+
+ // loop through objects
+ for (String key : copyMap.keySet())
+ {
+ Object object = copyMap.getObject(key);
- Method removeMethod = objectClass.getMethod("removeYou");
+ // that class is already handled?
+ String className = object.getClass().getName();
+
+ if (handledClassesNames.contains(className))
+ {
+ continue;
+ }
+
+ handledClassesNames.add(className);
+
+ // call toString
+ object.toString();
+
+ Class<? extends Object> objectClass = object.getClass();
- removeMethod.invoke(object);
+ try
+ {
+ Method addPropertyChangeListenerMetod = objectClass.getMethod("addPropertyChangeListener", PropertyChangeListener.class);
+ addPropertyChangeListenerMetod.invoke(object, new Object[] {null});
+ }
+ catch (Exception e)
+ {
+ // dont worry
+ }
+
+ // call createXY methods (some of them are not used in practice, e.g student.createUniversity)
+ for (Method m : objectClass.getMethods())
+ {
+ String methodName = m.getName();
+ if (methodName.startsWith("create") && m.getParameterCount() == 0)
+ {
+ m.invoke(object);
+ }
+
+ if (methodName.startsWith("get") && methodName.endsWith("Transitive"))
+ {
+ m.invoke(object);
+ }
}
+
+ Method removeMethod = objectClass.getMethod("removeYou");
- }
- catch (Exception e)
- {
- // cannot find creator creator class, sorry.
- // e.printStackTrace();
+ removeMethod.invoke(object);
}
}
@@ -719,8 +766,14 @@ private void coverSetClasses(JsonIdMap copyMap)
String entryType = setObject.getEntryType();
// add entry
- Method withMethod = setClass.getMethod("with", object.getClass());
+ Method withMethod = setClass.getMethod("with", new Class[] {Object.class});
withMethod.invoke(setObject, object);
+ withMethod.invoke(setObject, setObject);
+
+ try {
+ Method hasPOMethod = setClass.getMethod("has" + CGUtil.shortClassName(className) + "PO");
+ hasPOMethod.invoke(setObject);
+ } catch (Exception e) {}
// toString
String text = setObject.toString();
@@ -732,11 +785,13 @@ private void coverSetClasses(JsonIdMap copyMap)
{
// call getter
Method getMethod = setClass.getMethod("get" + StrUtil.upFirstChar(attrName));
+
Object value = getMethod.invoke(setObject);
-
+ Object setValue = null;
// get direct value
if (value instanceof Collection)
{
+ setValue = value;
value = ((Collection<?>) value).iterator().next();
}
@@ -758,17 +813,40 @@ else if (value instanceof Float)
{
valueClass = float.class;
}
+ else if (value instanceof Boolean)
+ {
+ valueClass = boolean.class;
+ }
// call setter
Method setMethod = setClass.getMethod("with" + StrUtil.upFirstChar(attrName), valueClass);
setMethod.invoke(setObject, value);
- Method unsetMethod = setClass.getMethod("without" + StrUtil.upFirstChar(attrName), valueClass);
- unsetMethod.invoke(setObject, value);
+ try {
+ Method unsetMethod = setClass.getMethod("without" + StrUtil.upFirstChar(attrName), valueClass);
+ unsetMethod.invoke(setObject, value);
+ } catch (Exception e) {}
+
+ try {
+ Method hasMethod = setClass.getMethod("has" + StrUtil.upFirstChar(attrName), valueClass);
+ hasMethod.invoke(setObject, value);
+
+ hasMethod = setClass.getMethod("has" + StrUtil.upFirstChar(attrName), valueClass, valueClass);
+ hasMethod.invoke(setObject, value, value);
+ } catch (Exception e) {}
+
+ try {
+ Method hasMethod = setClass.getMethod("has" + StrUtil.upFirstChar(attrName), Object.class);
+ hasMethod.invoke(setObject, value);
+ if (setValue != null) {
+ hasMethod.invoke(setObject, setValue);
+ }
+ } catch (Exception e) {}
+
}
catch (Exception e)
{
- // no prolem, go on with next attr
+ // no problem, go on with next attr
}
}
@@ -69,7 +69,13 @@ public void MancalaModelReverse() {
/* add method */
new Method("initGame", new Parameter(DataType.ref("String")), new Parameter(DataType.ref("String")))
.with(mancalaClass);
-
+ /* add method */
+ new Method("createPitsKalah")
+ .with(mancalaClass);
+ /* add method */
+ new Method("createKalah")
+ .with(mancalaClass);
+
Clazz playerStateClass = model.createClazz("org.sdmlib.examples.mancala.model.PlayerState");
/* add method */
@@ -85,18 +91,7 @@ public void MancalaModelReverse() {
new Method("checkEnd")
.with(mancalaClass);
- new Method("checkEnd")
- .with(mancalaClass);
-
- new Method("initGame", new Parameter(DataType.ref("String")), new Parameter(DataType.ref("String")))
- .with(mancalaClass);
-
- new Method("createKalah")
- .with(mancalaClass);
-
- new Method("createPitsKalah")
- .with(mancalaClass);
-
+
Clazz pitClass = model.createClazz("org.sdmlib.examples.mancala.model.Pit")
.with(new Attribute("nr", DataType.ref("int")) );
/* add method */
@@ -126,7 +121,7 @@ public void MancalaModelReverse() {
pitClass.withAssoc(pitClass, "counterpart", Card.ONE, "counterpart", Card.ONE);
model.getGenerator().updateFromCode("src/test/java", "org.sdmlib.examples.mancala.model");
- model.getGenerator().insertModelCreationCodeHere("src/test/java");
+ // model.getGenerator().insertModelCreationCodeHere("src/test/java");
}
}
Oops, something went wrong.

0 comments on commit 4d7587f

Please sign in to comment.