fixed more tests

parent 6e11cf14
Pipeline #197624 failed with stage
in 35 seconds
......@@ -22,8 +22,10 @@ package de.monticore.lang.embeddedmontiarc.embeddedmontiarc;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.EMAComponentSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.IEmbeddedMontiArcScope;
import de.monticore.lang.monticar.stream._symboltable.IStreamScope;
import de.monticore.lang.monticar.stream._symboltable.StreamLanguage;
import de.monticore.lang.monticar.streamunits._symboltable.ComponentStreamUnitsSymbol;
import de.monticore.lang.monticar.streamunits._symboltable.IStreamUnitsScope;
import de.monticore.symboltable.Scope;
import de.se_rwth.commons.Names;
import de.se_rwth.commons.logging.Log;
......@@ -47,10 +49,14 @@ public final class StreamScanner {
private final Path basePath;
private final IEmbeddedMontiArcScope symTab;
private final IStreamScope symTabStream;
private final IStreamUnitsScope symTabStreamUnits;
public StreamScanner(Path basePath, IEmbeddedMontiArcScope symTab) {
public StreamScanner(Path basePath, IEmbeddedMontiArcScope symTab, IStreamScope symTabStream, IStreamUnitsScope symTabStreamUnits) {
this.basePath = Log.errorIfNull(basePath);
this.symTab = Log.errorIfNull(symTab);
this.symTabStream = Log.errorIfNull(symTabStream);
this.symTabStreamUnits = Log.errorIfNull(symTabStreamUnits);
}
public Map<EMAComponentSymbol, Set<ComponentStreamUnitsSymbol>> scan() {
......@@ -87,9 +93,8 @@ public final class StreamScanner {
}
Path relativePath = scanner.basePath.relativize(file);
String streamModelName = getStreamModelName(relativePath);
ComponentStreamUnitsSymbol s = null;
//TODO IMPLEMENT ME!F
//ComponentStreamUnitsSymbol s = scanner.symTab.<ComponentStreamUnitsSymbol>resolve(streamModelName, ComponentStreamUnitsSymbol.KIND).orElse(null);
//TODO IMPLEMENT ME!D
ComponentStreamUnitsSymbol s = scanner.symTabStreamUnits.resolveComponentStreamUnits(streamModelName).orElse(null);
if (s != null) {
processComponentStreamUnitsSymbol(s, f);
} else {
......@@ -99,9 +104,9 @@ public final class StreamScanner {
}
private void processComponentStreamUnitsSymbol(ComponentStreamUnitsSymbol s, File f) {
EMAComponentSymbol relatedComponent = null;
//TODO IMPLEMENT ME!F
//EMAComponentSymbol relatedComponent = s.<EMAComponentSymbol>getComponentSymbol(EMAComponentSymbol.KIND).orElse(null);
//TODO IMPLEMENT ME!D
EMAComponentSymbol relatedComponent = scanner.symTab.resolveEMAComponent(s.getPackageName() +"." + s.getComponentName()).orElse(null);
//s.<Symbol>getComponentSymbol(EMAComponentSymbol.KIND).orElse(null);
if (relatedComponent == null) {
Log.warn("could not resolve component for which stream is defined in " + f.getAbsolutePath());
return;
......
......@@ -109,7 +109,7 @@ public class ASTEMAConnector extends ASTEMAConnectorTOP {
public void addTarget(String name) {
if (targets == null) {
targets = new ASTConnectorTargets();
targets = EmbeddedMontiArcMill.connectorTargetsBuilder().build();
}
try {
if (name.equals(
......@@ -130,6 +130,9 @@ public class ASTEMAConnector extends ASTEMAConnectorTOP {
}
public void addTargets(Collection<String> names) {
if(targets == null){
targets = EmbeddedMontiArcMill.connectorTargetsBuilder().build();
}
for (String name : names) {
try {
targets.qualifiedNameWithArrayAndStars.add(
......
......@@ -62,7 +62,8 @@ public class EMAComponentInstantiationSymbolBuilder
return ret;
}
//TODO IMPLEMENT ME!F clone needs to handle additional information like genericParameters
//TODO IMPLEMENT ME!D cloning is not supported anymore as this would modify enclosing scope symbol amount
@Deprecated
public static EMAComponentInstantiationSymbol clone(EMAComponentInstantiationSymbol inst) {
Collection<EMAComponentInstantiationSymbol> subcomps =
inst.getSubComponents().stream().map(EMAComponentInstantiationSymbolBuilder::clone)
......@@ -73,7 +74,7 @@ public class EMAComponentInstantiationSymbolBuilder
Collection<EMAPortSymbol> ports =
inst.getPortInstanceList().stream().map(EMAPortBuilder::clone).collect(Collectors.toList());
EMAComponentInstantiationSymbolBuilder res = (new EMAComponentInstantiationSymbolBuilder());
EMAComponentInstantiationSymbolBuilder res = EmbeddedMontiArcSymTabMill.eMAComponentInstantiationSymbolBuilder();
res.setEnclosingScope(inst.getEnclosingScope());
res.setName(inst.getName()).setSymbolReference(inst.getComponentType()).addPorts(ports)
......@@ -348,14 +349,14 @@ public class EMAComponentInstantiationSymbolBuilder
for (ASTEMAConnector connector : connectors) {
sym.addConnector(EMAConnectorBuilder.instantiate(connector, sym.getSpannedScope()));
}
//TODO IMPLEMENT ME!F
//TODO IMPLEMENT ME!D
//subComponents.stream().forEachOrdered(s -> {scope.add(s);});
for (EMAComponentInstantiationSymbol subComponent : subComponents) {
if (subComponent.enclosingScope != scope) {
subComponent.setEnclosingScope(scope);//sets enclosing scope variable fo sym
scope.add(subComponent);
subComponent.getSpannedScope()
.setEnclosingScope(scope);//sets enclosing scope variable fo sym
/*subComponent.getSpannedScope()
.setEnclosingScope(scope);//sets enclosing scope variable fo sym*/
}
}
......
......@@ -70,13 +70,15 @@ public class EMAConnectorBuilder {
}
public ASTEMAConnector build() {
if (source.isPresent() && target.isPresent() && definingScope != null) {
if (source.isPresent() && (target.isPresent() || targets.size() > 0)&& definingScope != null) {
ASTEMAConnector con = new ASTEMAConnector();
con.setSource(this.source.get());
if (target.isPresent()) {
con.addTarget(target.get());
}
con.addTargets(this.targets);
if(targets.size() > 0) {
con.addTargets(this.targets);
}
if (portSymbol.orElse(null) != null) {
//TODO IMPLEMENT ME!D
//con.setConstantPortSymbol(portSymbol.get());
......
......@@ -23,7 +23,12 @@ package de.monticore.lang.embeddedmontiarc;
import de.monticore.ModelingLanguageFamily;
import de.monticore.io.paths.ModelPath;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.*;
import de.monticore.lang.monticar.stream._symboltable.IStreamScope;
import de.monticore.lang.monticar.stream._symboltable.StreamGlobalScope;
import de.monticore.lang.monticar.stream._symboltable.StreamLanguage;
import de.monticore.lang.monticar.streamunits._symboltable.IStreamUnitsScope;
import de.monticore.lang.monticar.streamunits._symboltable.StreamUnitsGlobalScope;
import de.monticore.lang.monticar.streamunits._symboltable.StreamUnitsLanguage;
import de.monticore.lang.monticar.struct._symboltable.IStructScope;
import de.monticore.lang.monticar.struct._symboltable.StructGlobalScope;
import de.monticore.lang.monticar.struct._symboltable.StructLanguage;
......@@ -62,6 +67,33 @@ public class AbstractSymtabTest {
return scope;
}
protected static IStreamScope createSymTabStream(String... modelPath) {
final ModelPath mp = new ModelPath();
for (String m : modelPath) {
mp.addEntry(Paths.get(m));
}
StreamGlobalScope scope = new StreamGlobalScope(mp,
new StreamLanguage());
//TODO IMPLEMENT ME!D
//de.monticore.lang.monticar.Utils.addBuiltInTypes(scope);
return scope;
}
protected static IStreamUnitsScope createSymTabStreamUnits(String... modelPath) {
final ModelPath mp = new ModelPath();
for (String m : modelPath) {
mp.addEntry(Paths.get(m));
}
StreamUnitsGlobalScope scope = new StreamUnitsGlobalScope(mp,
new StreamUnitsLanguage());
//TODO IMPLEMENT ME!D
//de.monticore.lang.monticar.Utils.addBuiltInTypes(scope);
return scope;
}
public static StructGlobalScope createStructSymTab(String... modelPath) {
//TODO IMPLEMENT ME!F create general class which combines these
/*ModelingLanguageFamily fam = new ModelingLanguageFamily();
......
......@@ -52,6 +52,9 @@ public class ExpandedComponentInstanceTest extends AbstractSymtabTest {
Log.enableFailQuick(false);
}
//Cloning is not supported anymore as this would modify enclosing scope
@Ignore
@Deprecated
@Test
public void testClone() {
IEmbeddedMontiArcScope symTab = createSymTab("src/test/resources");
......@@ -59,12 +62,20 @@ public class ExpandedComponentInstanceTest extends AbstractSymtabTest {
".subComponentConnector2").orElse(null);
assertNotNull(inst);
//TODO IMPLEMENT ME!
/*EMAComponentInstantiationSymbol inst2 = EMAComponentInstantiationSymbolBuilder.clone(inst);
assertEquals(2, inst.getConnectors().size());
assertEquals(1, inst.getSubComponents().size());
Iterator<ASTEMAConnector> iter = inst.getConnectors().iterator();
while(iter.hasNext()){
ASTEMAConnector connector = iter.next();
}
//TODO IMPLEMENT ME!D
EMAComponentInstantiationSymbol inst2 = EMAComponentInstantiationSymbolBuilder.clone(inst);
assertEquals(inst.toString().trim(), inst2.toString().trim());
*/
}
//TODO IMPLEMENT ME!
......@@ -660,24 +671,24 @@ public class ExpandedComponentInstanceTest extends AbstractSymtabTest {
private void testConnectorCorrectnessForComponent(EMAComponentInstantiationSymbol inst) {
inst.getConnectorInstances().forEach(connectorSymbol -> {
assertNotNull(connectorSymbol.getSourcePort());
//TODO IMPLEMENT ME!
//TODO IMPLEMENT ME!D
assertNotNull(connectorSymbol.getTargetPortSymbols());
EMAPortSymbol sourcePort = connectorSymbol.getSourcePort();
//TODO IMPLEMENT ME!
//TODO IMPLEMENT ME!D
for (EMAPortSymbol targetPort : connectorSymbol
.getTargetPortSymbols()) {
System.out.println("source: " + sourcePort.getFullName());
//TODO IMPLEMENT ME!
//TODO IMPLEMENT ME!D
System.out.println("target: " + targetPort.getFullName() + "\n");
//TODO IMPLEMENT ME!
//TODO IMPLEMENT ME!D
assertNotEquals(sourcePort.getFullName(), targetPort.getFullName());
}
});
//TODO IMPLEMENT ME!
//TODO IMPLEMENT ME!D
inst.getSubComponents().forEach((a) -> {
testConnectorCorrectnessForComponent(a);
});
......
......@@ -26,7 +26,9 @@ import de.monticore.lang.embeddedmontiarc.embeddedmontiarc.StreamScanner;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.EMAComponentSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.EmbeddedMontiArcLanguage;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.IEmbeddedMontiArcScope;
import de.monticore.lang.monticar.stream._symboltable.IStreamScope;
import de.monticore.lang.monticar.streamunits._symboltable.ComponentStreamUnitsSymbol;
import de.monticore.lang.monticar.streamunits._symboltable.IStreamUnitsScope;
import de.monticore.lang.monticar.streamunits._symboltable.StreamUnitsLanguage;
import de.monticore.lang.monticar.struct._symboltable.StructLanguage;
import de.monticore.symboltable.GlobalScope;
......@@ -44,11 +46,13 @@ public class StreamScannerTest extends AbstractSymtabTest{
private static final Path BASE_PATH = Paths.get("src/test/resources");
@Ignore //TODO IMPLEMENT ME! NEEDS TO BE ENABLED
//TODO IMPLEMENT ME!D Is ENABLED Again
@Test
public void testMySuperNiceComponent() {
IEmbeddedMontiArcScope symTab = createSymTab(BASE_PATH.toString());
StreamScanner scanner = new StreamScanner(BASE_PATH, symTab);
IStreamScope symTabStream = createSymTabStream(BASE_PATH.toString());
IStreamUnitsScope symTabStreamUnits = createSymTabStreamUnits(BASE_PATH.toString());
StreamScanner scanner = new StreamScanner(BASE_PATH, symTab, symTabStream, symTabStreamUnits);
Map<EMAComponentSymbol, Set<ComponentStreamUnitsSymbol>> result = scanner.scan();
Assert.assertNotNull(result);
Assert.assertFalse(result.isEmpty());
......@@ -71,7 +75,7 @@ public class StreamScannerTest extends AbstractSymtabTest{
Assert.assertEquals(6, mySuperNiceStream1.getNamedStreams().size());
Assert.assertEquals(6, mySuperNiceStream2.getNamedStreams().size());
}
//TODO IMPLEMENT ME! different to abstractsymtabtest?, just extending abstractsymtab test for now
//TODO IMPLEMENT ME!D not different to abstractsymtabtest, just extending abstractsymtab test for now
/*private static IEmbeddedMontiArcScope createSymTab(String... modelPath) {
ModelingLanguageFamily fam = new ModelingLanguageFamily();
fam.addModelingLanguage(new EmbeddedMontiArcLanguage());
......
......@@ -38,7 +38,7 @@ public class InRosPortRosSenderTest extends AbstractTaggingCoCoTest {
Log.getFindings().clear();
}
//TODO IMPLEMENT ME!
//TODO IMPLEMENT ME!F
/*@Test
public void testValidRosToRos() {
testCoCosOnComponent("middleware.ros.cocos.RosToRosComp");
......
......@@ -35,7 +35,7 @@ import static org.junit.Assert.*;
public class TaggingTest extends AbstractTaggingResolverTest {
//TODO IMPLEMENT ME!
//TODO IMPLEMENT ME!F
/*@Test
public void testRosConnectionParsing() {
TaggingResolver symtab = createSymTabAndTaggingResolver("src/test/resources");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment