Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Adds test for string comparison (==/equals) #4

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions gipsl.string.compare.filter/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
25 changes: 25 additions & 0 deletions gipsl.string.compare.filter/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>gipsl.string.compare.filter</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.emoflon.gips.gipsl.ui.gipsNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
10 changes: 10 additions & 0 deletions gipsl.string.compare.filter/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
18 changes: 18 additions & 0 deletions gipsl.string.compare.filter/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Manifest-Version: 1.0
Automatic-Module-Name: gipsl.string.compare.filter
Bundle-ManifestVersion: 2
Bundle-Name: gipsl.string.compare.filter
Bundle-Vendor: My Company
Bundle-Version: 1.0.0.qualifier
Bundle-SymbolicName: gipsl.string.compare.filter; singleton:=true
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-16
Require-Bundle: org.emoflon.ibex.common,
org.emoflon.ibex.gt,
org.emoflon.gips.core,
org.emoflon.ibex.gt.democles,
org.emoflon.ibex.gt.hipe,
test.suite.utils;bundle-version="1.0.0"
Import-Package: stringmodel,
stringmodel.impl
Export-Package: gipsl.string.compare.filter.connector
5 changes: 5 additions & 0 deletions gipsl.string.compare.filter/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source.. = src/,\
src-gen/
bin.includes = META-INF/,\
.,\
plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package "gipsl.string.compare.filter"
import "platform:/resource/gipsl.string.stringmodel/model/Stringmodel.ecore"

config {
solver := GLPK [home:="fu", license:="bar"];
launchConfig := true [main := "TODO"];
timeLimit := true [value := 42.0];
randomSeed := true [value := 73];
presolve := true;
debugOutput := true;
}

//condition guestNotMapped = forbid guestIsMapped
//pattern guestIsMapped {
// h: Host
//
// g: Guest {
// -host -> h
// }
//}
//
//pattern guestNotMapped {
// g: Guest
//}
//when guestNotMapped

rule mapGuest {
root: Root {
-elements -> g
-elements -> h
}

h: Host {
++ -guests -> g
}

g: Guest {
++ -host -> h
}

// intentionally left out every condition
}

//
// GIPSL starts here!
//

mapping n2n with mapGuest;

// There must be exactly one mapping for every non-mapped guest
constraint -> class::Guest {
mappings.n2n->filter(m | m.nodes().g.name == self.name)->count() <= 1
}

objective gObj -> mapping::n2n {
1
}

global objective : max {
gObj
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package gipsl.string.compare.filter.connector;

import org.emoflon.gips.core.ilp.ILPSolverOutput;

import gipsl.string.compare.filter.api.gips.FilterGipsAPI;
import test.suite.gips.utils.AConnector;
import test.suite.gips.utils.GipsTestUtils;

public class StringCompareFilterConnector extends AConnector {

public StringCompareFilterConnector(final String modelPath) {
api = new FilterGipsAPI();
api.init(GipsTestUtils.pathToAbsUri(modelPath));
}

@Override
public ILPSolverOutput run(final String outputPath) {
final ILPSolverOutput output = solve();
((FilterGipsAPI) api).getN2n().applyNonZeroMappings();
save(outputPath);
return output;
}

}
8 changes: 8 additions & 0 deletions gipsl.string.compare.nonmappingcontext/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
25 changes: 25 additions & 0 deletions gipsl.string.compare.nonmappingcontext/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>gipsl.string.compare.nonmappingcontext</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.emoflon.gips.gipsl.ui.gipsNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
17 changes: 17 additions & 0 deletions gipsl.string.compare.nonmappingcontext/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Manifest-Version: 1.0
Automatic-Module-Name: gipsl.string.compare.nonmappingcontext
Bundle-ManifestVersion: 2
Bundle-Name: gipsl.string.compare.nonmappingcontext
Bundle-Vendor: My Company
Bundle-Version: 1.0.0.qualifier
Export-Package: gipsl.string.compare.nonmappingcontext.connector
Import-Package: test.suite.gips.utils
Bundle-SymbolicName: gipsl.string.compare.nonmappingcontext; singleton:=true
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-16
Require-Bundle: org.emoflon.ibex.common,
org.emoflon.ibex.gt,
org.emoflon.gips.core,
org.emoflon.ibex.gt.democles,
org.emoflon.ibex.gt.hipe,
gipsl.string.stringmodel;bundle-version="0.0.1"
5 changes: 5 additions & 0 deletions gipsl.string.compare.nonmappingcontext/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source.. = src/,\
src-gen/
bin.includes = META-INF/,\
.,\
plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package "gipsl.string.compare.nonmappingcontext"
import "platform:/resource/gipsl.string.stringmodel/model/Stringmodel.ecore"

config {
solver := GLPK [home:="fu", license:="bar"];
timeLimit := true [value := 10.0];
randomSeed := true [value := 0];
presolve := true;
debugOutput := true;
}

condition guestNotMapped = forbid guestIsMapped
pattern guestIsMapped {
h: Host

g: Guest {
-host -> h
}
}

pattern guestNotMapped {
g: Guest
}
when guestNotMapped

rule mapGuest {
root: Root {
-elements -> g
-elements -> h
}

h: Host {
++ -guests -> g
}

g: Guest {
++ -host -> h
}

// intentionally left out condition that both names must be equal
}

//
// GIPSL starts here!
//

mapping n2n with mapGuest;

// Every non-mapped guest must be mapped
constraint -> pattern::guestNotMapped {
mappings.n2n->filter(m | m.nodes().g == self.nodes().g)->count() <= 1
}

// Name of the guest must be equal to the name of the host
// Context = pattern
constraint -> pattern::mapGuest {
self.nodes().g.name == self.nodes().h.name
}

objective gObj -> mapping::n2n {
1
}

global objective : max {
gObj
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package gipsl.string.compare.nonmappingcontext.connector;

import org.emoflon.gips.core.ilp.ILPSolverOutput;

import gipsl.string.compare.nonmappingcontext.api.gips.NonmappingcontextGipsAPI;
import test.suite.gips.utils.AConnector;
import test.suite.gips.utils.GipsTestUtils;

public class StringCompareNonMappingContextConnector extends AConnector {

public StringCompareNonMappingContextConnector(final String modelPath) {
api = new NonmappingcontextGipsAPI();
api.init(GipsTestUtils.pathToAbsUri(modelPath));
}

@Override
public ILPSolverOutput run(final String outputPath) {
final ILPSolverOutput output = solve();
((NonmappingcontextGipsAPI) api).getN2n().applyNonZeroMappings();
save(outputPath);
return output;
}

}
8 changes: 8 additions & 0 deletions gipsl.string.compare/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src-gen"/>
<classpathentry kind="output" path="bin"/>
</classpath>
25 changes: 25 additions & 0 deletions gipsl.string.compare/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>gipsl.string.compare</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.emoflon.gips.gipsl.ui.gipsNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
</natures>
</projectDescription>
10 changes: 10 additions & 0 deletions gipsl.string.compare/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=17
org.eclipse.jdt.core.compiler.compliance=17
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=17
17 changes: 17 additions & 0 deletions gipsl.string.compare/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Manifest-Version: 1.0
Automatic-Module-Name: gipsl.string.compare
Bundle-ManifestVersion: 2
Bundle-Name: gipsl.string.compare
Bundle-Vendor: My Company
Bundle-Version: 1.0.0.qualifier
Bundle-SymbolicName: gipsl.string.compare; singleton:=true
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-16
Require-Bundle: org.emoflon.ibex.common,
org.emoflon.ibex.gt,
org.emoflon.gips.core,
org.emoflon.ibex.gt.democles,
org.emoflon.ibex.gt.hipe,
gipsl.string.stringmodel;bundle-version="0.0.1"
Import-Package: test.suite.gips.utils
Export-Package: gipsl.string.compare.connector
5 changes: 5 additions & 0 deletions gipsl.string.compare/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source.. = src/,\
src-gen/
bin.includes = META-INF/,\
.,\
plugin.xml
Loading