From f05109c996e2a93feb5562b283db4e24e7425ab8 Mon Sep 17 00:00:00 2001 From: anquetil Date: Fri, 29 Nov 2024 18:17:33 +0100 Subject: [PATCH 1/4] removing dependency to net.sf.jexample:4.4-378 which causes dependency to junit:4.3 in VerveineJ --- lib/build.gradle.kts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 9a7af0a..10bf66e 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -22,17 +22,16 @@ repositories { dependencies { // Use JUnit test framework. testImplementation("org.junit.jupiter:junit-jupiter:5.7.1") - + + // https://mvnrepository.com/artifact/net.sf.jexample/jexample + testImplementation("net.sf.jexample:jexample:4.4-378") + // This dependency is exported to consumers, that is to say found on their compile classpath. api(libs.commons.math3) // This dependency is used internally, and not exposed to consumers on their own compile classpath. implementation(libs.guava) - // https://mvnrepository.com/artifact/net.sf.jexample/jexample - implementation("net.sf.jexample:jexample:4.4-378") - - implementation(fileTree("lib") { include("*.jar") }) } From b16d1cefc00d6e605b717436941abbbefc7f00bd Mon Sep 17 00:00:00 2001 From: anquetil Date: Fri, 29 Nov 2024 18:20:02 +0100 Subject: [PATCH 2/4] also setting execution rights on gradlew --- gradlew | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 gradlew diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 From 441533308940b5d339de7a04f679485c6b3ccf55 Mon Sep 17 00:00:00 2001 From: Benoit Verhaeghe Date: Mon, 2 Dec 2024 10:27:00 +0100 Subject: [PATCH 3/4] do not commit lib bin --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cfcf30c..673d222 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /bin/ +lib/bin fame-rUnversioned directory.jar fame-lib.jar From c77cc6eb9c28c5701e7ab0d85ce5d2cfee23ccbe Mon Sep 17 00:00:00 2001 From: Benoit Verhaeghe Date: Tue, 3 Dec 2024 17:21:04 +0100 Subject: [PATCH 4/4] kill usage of jexample --- lib/build.gradle.kts | 8 +- .../ch/akuhn/fame/test/CompositeExample.java | 168 ++++++++++-------- 2 files changed, 95 insertions(+), 81 deletions(-) diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 10bf66e..909410f 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -20,18 +20,12 @@ repositories { } dependencies { - // Use JUnit test framework. - testImplementation("org.junit.jupiter:junit-jupiter:5.7.1") - - // https://mvnrepository.com/artifact/net.sf.jexample/jexample - testImplementation("net.sf.jexample:jexample:4.4-378") - + testImplementation("junit:junit:4.13.2") // This dependency is exported to consumers, that is to say found on their compile classpath. api(libs.commons.math3) // This dependency is used internally, and not exposed to consumers on their own compile classpath. implementation(libs.guava) - implementation(fileTree("lib") { include("*.jar") }) } diff --git a/lib/src/test/java/ch/akuhn/fame/test/CompositeExample.java b/lib/src/test/java/ch/akuhn/fame/test/CompositeExample.java index 12084dc..ff29f96 100644 --- a/lib/src/test/java/ch/akuhn/fame/test/CompositeExample.java +++ b/lib/src/test/java/ch/akuhn/fame/test/CompositeExample.java @@ -3,15 +3,12 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.Collection; -import org.junit.Ignore; import org.junit.Test; -import org.junit.runner.RunWith; import ch.akuhn.fame.FameDescription; import ch.akuhn.fame.FamePackage; @@ -20,13 +17,8 @@ import ch.akuhn.fame.Repository; import ch.akuhn.fame.Tower; import ch.akuhn.fame.fm3.PropertyDescription; -import ch.unibe.jexample.Given; -import ch.unibe.jexample.Injection; -import ch.unibe.jexample.InjectionPolicy; -import ch.unibe.jexample.JExample; -@RunWith(JExample.class) -@Injection(InjectionPolicy.NONE) + public class CompositeExample { @FameDescription @@ -46,7 +38,7 @@ static abstract class Composite { static class Container extends Composite { @FameProperty(opposite = "parent") - public Collection children = new ArrayList(); + public Collection children = new ArrayList<>(); @Override public int getTotalCount() { @@ -72,147 +64,166 @@ public int getTotalCount() { } - @Test public Tower createTower() { Tower t = new Tower(); + return t; + } + + @Test + public void testCreateTower() { + Tower t = createTower(); assertNotNull(t.getMetaMetamodel()); assertNotNull(t.getMetamodel()); assertNotNull(t.getModel()); - return t; } @Test - @Given("#createTower") - public Tower towerHasLayers(Tower t) { + public void towerHasLayers() { + Tower t = this.createTower(); assertEquals(t.getModel().getMetamodel(), t.getMetamodel()); assertEquals(t.getMetamodel().getMetamodel(), t.getMetaMetamodel()); assertEquals(t.getMetaMetamodel().getMetamodel(), t.getMetaMetamodel()); - return t; } @Test - @Given("#towerHasLayers") - public Tower tower(Tower t) { + public void tower() { + Tower t = this.createTower(); assertEquals(0, t.getModel().size()); assertEquals(0, t.getMetamodel().size()); assertEquals(31, t.getMetaMetamodel().size()); - return t; } - @Test - @Ignore // FIXME - @Given("model;newParent;newChildA;newChildB") - public Repository createInstances(Repository $) { - assertEquals(3, $.getElements().size()); - return $; - } + // @Test + // @Ignore // FIXME + // public Repository createInstances(Repository $) { + // assertEquals(3, $.getElements().size()); + // return $; + // } - @Test - @Given("model;parentWithChildren") - public String exportMSE(Repository m) { + public String exportMSE() { + Repository m = model(); + setParentWithChildren(m); String mse = m.exportMSE(); return mse; } @Test - @Ignore // FIXME - @Given("tower;exportMSE;metamodel") - public Repository importMSE(Tower t, String mse) { - t.getModel().importMSE(mse); - Repository m = t.getModel(); - assertEquals(3, m.getElements().size()); - return m; + public void testExportMSE() { + String mse = exportMSE(); + // 165 is the magic number of the size of the string. I wanted to test that the string size is more than 2 char (not empty model) + assertEquals(165, mse.length()); + } @Test - @Ignore // FIXME - @Given("model;model") - public void jexampleKeepWorksFine(Repository m1, Repository m2) { - assertSame(m1, m2); + public void importMSE() { + String mse = exportMSE(); + Repository model = model(); + model.importMSE(mse); + assertEquals(3, model.getElements().size()); } - @Test - @Given("#tower") - public MetaRepository metamodel(Tower t) { + public MetaRepository metamodel () { + Tower t = new Tower(); t.getMetamodel().withAll(Composite.class, Container.class, Leaf.class); MetaRepository $ = t.getMetamodel(); + return $; + } + + @Test + public void testMetamodel() { + MetaRepository $ = metamodel(); assertEquals(3, $.allClassDescriptions().size()); assertEquals(4, $.all(PropertyDescription.class).size()); + } + + public Repository model() { + MetaRepository metamodel = metamodel(); + Repository $ = new Repository(metamodel); return $; } @Test - @Given("metamodelNames") - public Repository model(MetaRepository metamodel) { + public void testModel() { + MetaRepository metamodel = metamodel(); Repository $ = new Repository(metamodel); assertEquals(metamodel, $.getMetamodel()); - return $; } + @Test - @Given("metamodel") - public MetaRepository metamodelNames(MetaRepository mm) { - assertNull(mm.descriptionNamed("FAME")); - assertNotNull(mm.descriptionNamed("TEST.Container")); - assertNotNull(mm.descriptionNamed("TEST.Leaf")); - assertNotNull(mm.descriptionNamed("TEST.Composite")); - return mm; + public void testMetamodelNames() { + MetaRepository metamodel = metamodel(); + assertNull(metamodel.descriptionNamed("FAME")); + assertNotNull(metamodel.descriptionNamed("TEST.Container")); + assertNotNull(metamodel.descriptionNamed("TEST.Leaf")); + assertNotNull(metamodel.descriptionNamed("TEST.Composite")); } - @Test - @Given("model") public Leaf newChildA(Repository repo) { Object $ = repo.newInstance("TEST.Leaf"); - assertNotNull($); - assertEquals(Leaf.class, $.getClass()); return (Leaf) $; } @Test - @Given("model") - public Leaf newChildB(Repository repo) { - Object $ = repo.newInstance("TEST.Leaf"); + public void testNewChildA() { + Object $ = newChildA(model()); assertNotNull($); assertEquals(Leaf.class, $.getClass()); + } + + public Leaf newChildB(Repository repo) { + Object $ = repo.newInstance("TEST.Leaf"); return (Leaf) $; } @Test - @Given("model") + public void testNewChildB() { + Object $ = newChildB(model()); + assertNotNull($); + assertEquals(Leaf.class, $.getClass()); + } + public Container newParent(Repository repo) { Object $ = repo.newInstance("TEST.Container"); + return (Container) $; + } + + @Test + public void testNewParent() { + Object $ = newParent(model()); assertNotNull($); assertEquals(Container.class, $.getClass()); - return (Container) $; + } @Test - @Given("model;newChildA") - public Leaf numberPropertyA(Repository m, Leaf a) { + public void numberPropertyA() { + Repository m = model(); + Leaf a = newChildA(m); assertEquals((Integer) 0, (Integer) a.count); assertEquals((Integer) 0, (Integer) m.read("count", a)); m.write("count", a, 42); assertEquals(42, a.count); assertEquals((Integer)42, (Integer)m.read("count", a)); - return a; } @Test - @Given("model;newChildB") - public Leaf numberPropertyB(Repository m, Leaf b) { + public void numberPropertyB() { + Repository m = model(); + Leaf b = newChildB(m); assertEquals(0, b.count); assertEquals((Integer) 0, m.read("count", b)); m.write("count", b, 23); assertEquals(23, b.count); assertEquals((Integer) 23, m.read("count", b)); - return b; } @Test - @Given("metamodel;metamodelNames") - public void parentChildrenAreOpposite(MetaRepository mm) { - PropertyDescription parent = mm.descriptionNamed("TEST.Composite").attributeNamed("parent"); - PropertyDescription children = mm.descriptionNamed("TEST.Container").attributeNamed("children"); + public void parentChildrenAreOpposite() { + MetaRepository metamodel = metamodel(); + PropertyDescription parent = metamodel.descriptionNamed("TEST.Composite").attributeNamed("parent"); + PropertyDescription children = metamodel.descriptionNamed("TEST.Container").attributeNamed("children"); assertNotNull(parent); assertNotNull(children); assertTrue(parent.hasOpposite()); @@ -221,9 +232,19 @@ public void parentChildrenAreOpposite(MetaRepository mm) { assertEquals(children, parent.getOpposite()); } + public void setParentWithChildren(Repository m) { + Container p = newParent(m); + Leaf a = newChildA(m); + Leaf b = newChildB(m); + m.write("children", p, a, b); + } + @Test - @Given("model;newParent;newChildA;newChildB;parentChildrenAreOpposite") - public Container parentWithChildren(Repository m, Container p, Leaf a, Leaf b) { + public void parentWithChildren() { + Repository m = model(); + Container p = newParent(m); + Leaf a = newChildA(m); + Leaf b = newChildB(m); assertEquals(0, p.children.size()); assertEquals(null, a.parent); assertEquals(null, b.parent); @@ -231,6 +252,5 @@ public Container parentWithChildren(Repository m, Container p, Leaf a, Leaf b) { assertEquals(2, p.children.size()); assertEquals(p, a.parent); assertEquals(p, b.parent); - return p; } }