Added test for RosHelper::inferRosConnectionIfPossible

parent c57db55a
package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.ExpandedComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.PortSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.RosConnectionSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.RosToEmamTagSchema;
import de.monticore.lang.monticar.generator.middleware.helpers.RosHelper;
import de.monticore.lang.monticar.generator.roscpp.helper.TagHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import org.junit.Test;
import static org.junit.Assert.*;
public class MiddlewareSymbolTest extends AbstractSymtabTest {
@Test
public void testMWInferFromTags() {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver("src/test/resources/");
RosToEmamTagSchema.registerTagTypes(taggingResolver);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("tests.infer.inferComp", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
ExpandedComponentInstanceSymbol sub1 = componentInstanceSymbol.getSubComponent("sub1").orElse(null);
assertNotNull(sub1);
PortSymbol rosIn = componentInstanceSymbol.getPort("rosIn").orElse(null);
PortSymbol rosOut = componentInstanceSymbol.getPort("rosOut").orElse(null);
PortSymbol sub1RosIn = sub1.getPort("rosIn").orElse(null);
PortSymbol sub1RosOut = sub1.getPort("rosOut").orElse(null);
assertNotNull(rosIn);
assertNotNull(rosOut);
assertNotNull(sub1RosIn);
assertNotNull(sub1RosOut);
RosConnectionSymbol rosInRCS = (RosConnectionSymbol) rosIn.getMiddlewareSymbol().orElse(null);
RosConnectionSymbol rosOutRCS = (RosConnectionSymbol) rosOut.getMiddlewareSymbol().orElse(null);
RosConnectionSymbol sub1RosInRCS = (RosConnectionSymbol) sub1RosIn.getMiddlewareSymbol().orElse(null);
RosConnectionSymbol sub1RosOutRCS = (RosConnectionSymbol) sub1RosOut.getMiddlewareSymbol().orElse(null);
assertNotEquals(rosInRCS, sub1RosInRCS);
assertNotEquals(rosOutRCS, sub1RosOutRCS);
RosHelper.fixRosConnectionSymbols(componentInstanceSymbol);
assertEquals(rosInRCS, sub1RosInRCS);
assertEquals(rosOutRCS, sub1RosOutRCS);
}
}
package tests.infer;
component InferComp{
ports in Q rosIn,
out Q rosOut;
component Sub1{
ports in Q rosIn,
out Q rosOut;
}
instance Sub1 sub1;
connect rosIn -> sub1.rosIn;
connect sub1.rosOut -> rosOut;
}
\ No newline at end of file
package tests.infer;
conforms to de.monticore.lang.monticar.generator.roscpp.RosToEmamTagSchema;
tags InferTags{
tag inferComp.rosIn with RosConnection = {topic = (/topic1, std_msgs/Float32), msgField = data};
tag inferComp.rosOut with RosConnection = {topic = (/topic2, std_msgs/Float32)};
tag inferComp.sub1.rosIn with RosConnection;
tag inferComp.sub1.rosOut with RosConnection;
}
\ No newline at end of file
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