Commit 07e67b03 authored by Mike Grüne's avatar Mike Grüne
Browse files

Added Porttypes to TaggingTest

parent c94fdc67
Pipeline #187389 passed with stage
in 2 minutes and 26 seconds
/** /**
* (c) https://github.com/MontiCore/monticore
* *
* ****************************************************************************** * The license generally applicable for this project
* MontiCAR Modeling Family, www.se-rwth.de * can be found under https://github.com/MontiCore/monticore.
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/ */
/* (c) https://github.com/MontiCore/monticore */ /* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.embeddedmontiarc.tagging.middleware.mqtt; package de.monticore.lang.embeddedmontiarc.tagging.middleware.mqtt;
...@@ -145,7 +131,7 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator { ...@@ -145,7 +131,7 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator {
} }
Log.error(String.format("'%s' does not match the specified regex pattern '%s'", Log.error(String.format("'%s' does not match the specified regex pattern '%s'",
regex, regex,
"{topic = ({name}, {type}), msgField = {msgField}}")); "{topic = {name}, msgField = {msgField}}"));
return null; return null;
} }
......
/** /**
* (c) https://github.com/MontiCore/monticore
* *
* ****************************************************************************** * The license generally applicable for this project
* MontiCAR Modeling Family, www.se-rwth.de * can be found under https://github.com/MontiCore/monticore.
* Copyright (c) 2017, Software Engineering Group at RWTH Aachen,
* All rights reserved.
*
* This project is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this project. If not, see <http://www.gnu.org/licenses/>.
* *******************************************************************************
*/ */
/* (c) https://github.com/MontiCore/monticore */ /* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.embeddedmontiarc.middleware.mqtt; package de.monticore.lang.embeddedmontiarc.middleware.mqtt;
...@@ -44,27 +30,89 @@ public class TaggingTest extends AbstractTaggingResolverTest { ...@@ -44,27 +30,89 @@ public class TaggingTest extends AbstractTaggingResolverTest {
EMAComponentInstanceSymbol component = symtab.<EMAComponentInstanceSymbol>resolve("middleware.mqtt.basicParsing", EMAComponentInstanceSymbol.KIND).orElse(null); EMAComponentInstanceSymbol component = symtab.<EMAComponentInstanceSymbol>resolve("middleware.mqtt.basicParsing", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(component); assertNotNull(component);
//mqttIn //mqttInQ
EMAPortSymbol mqttIn = component.getPortInstance("mqttIn").orElse(null); EMAPortSymbol mqttInQ = component.getPortInstance("mqttInQ").orElse(null);
assertNotNull(mqttIn); assertNotNull(mqttInQ);
Collection<TagSymbol> tags = symtab.getTags(mqttIn, MqttConnectionSymbol.KIND); Collection<TagSymbol> tags = symtab.getTags(mqttInQ, MqttConnectionSymbol.KIND);
assertTrue(tags.size() == 1); assertTrue(tags.size() == 1);
MqttConnectionSymbol tag = (MqttConnectionSymbol) tags.iterator().next(); MqttConnectionSymbol tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName().get(), "/clock"); assertEquals(tag.getTopicName().get(), "/echoQ");
assertEquals(tag.getMsgField().get(), "clock.toSec()"); assertEquals(tag.getMsgField().get(), "dataQ");
//mqttInN
EMAPortSymbol mqttInN = component.getPortInstance("mqttInN").orElse(null);
assertNotNull(mqttInN);
tags = symtab.getTags(mqttInN, MqttConnectionSymbol.KIND);
assertTrue(tags.size() == 1);
tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName().get(), "/echoN");
assertEquals(tag.getMsgField().get(), "dataN");
//mqttInZ
EMAPortSymbol mqttInZ = component.getPortInstance("mqttInZ").orElse(null);
assertNotNull(mqttInZ);
tags = symtab.getTags(mqttInZ, MqttConnectionSymbol.KIND);
assertTrue(tags.size() == 1);
tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName().get(), "/echoZ");
assertEquals(tag.getMsgField().get(), "dataZ");
//mqttInB
EMAPortSymbol mqttInB = component.getPortInstance("mqttInB").orElse(null);
assertNotNull(mqttInB);
tags = symtab.getTags(mqttInB, MqttConnectionSymbol.KIND);
assertTrue(tags.size() == 1);
tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName().get(), "/echoB");
assertEquals(tag.getMsgField().get(), "true");
//mqttOutQ
EMAPortSymbol mqttOutQ = component.getPortInstance("mqttOutQ").orElse(null);
assertNotNull(mqttOutQ);
tags = symtab.getTags(mqttOutQ, MqttConnectionSymbol.KIND);
assertTrue(tags.size() == 1);
tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName().get(), "/echoQ");
//mqttOutN
EMAPortSymbol mqttOutN = component.getPortInstance("mqttOutN").orElse(null);
assertNotNull(mqttOutN);
tags = symtab.getTags(mqttOutN, MqttConnectionSymbol.KIND);
assertTrue(tags.size() == 1);
tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName().get(), "/echoN");
//mqttOutZ
EMAPortSymbol mqttOutZ = component.getPortInstance("mqttOutZ").orElse(null);
assertNotNull(mqttOutZ);
tags = symtab.getTags(mqttOutZ, MqttConnectionSymbol.KIND);
assertTrue(tags.size() == 1);
tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName().get(), "/echoZ");
//mqttOut //mqttOutB
EMAPortSymbol mqttOut = component.getPortInstance("mqttOut").orElse(null); EMAPortSymbol mqttOutB = component.getPortInstance("mqttOutB").orElse(null);
assertNotNull(mqttOut); assertNotNull(mqttOutB);
tags = symtab.getTags(mqttOut, MqttConnectionSymbol.KIND); tags = symtab.getTags(mqttOutB, MqttConnectionSymbol.KIND);
assertTrue(tags.size() == 1); assertTrue(tags.size() == 1);
tag = (MqttConnectionSymbol) tags.iterator().next(); tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName().get(), "/echo"); assertEquals(tag.getTopicName().get(), "/echoB");
assertEquals(tag.getMsgField().get(), "data");
//emptyTagIn //emptyTagIn
EMAPortSymbol emptyTagIn = component.getPortInstance("emptyTagIn").orElse(null); EMAPortSymbol emptyTagIn = component.getPortInstance("emptyTagIn").orElse(null);
......
package middleware.mqtt; package middleware.mqtt;
component BasicParsing{ component BasicParsing{
port in Q mqttIn; port in Q mqttInQ;
port in Q noMqttIn; port in Q noMqttInQ;
port in Q emptyTagIn; port in Q emptyTagIn;
port out Q mqttOut; port in N mqttInN;
port in Z mqttInZ;
port in B mqttInB;
port out Q mqttOutQ;
port out Q noMqttOut; port out Q noMqttOut;
port out N mqttOutN;
port out Z mqttOutZ;
port out B mqttOutB;
} }
...@@ -2,7 +2,13 @@ package middleware.mqtt; ...@@ -2,7 +2,13 @@ package middleware.mqtt;
conforms to middleware.mqtt.MqttToEmamTagSchema; conforms to middleware.mqtt.MqttToEmamTagSchema;
tags Echo { tags Echo {
tag basicParsing.mqttIn with MqttConnection = {topic = /clock, msgField = clock.toSec()}; tag basicParsing.mqttInQ with MqttConnection = {topic = /echoQ, msgField = dataQ};
tag basicParsing.mqttOut with MqttConnection = {topic = /echo, msgField = data}; tag basicParsing.mqttOutQ with MqttConnection = {topic = /echoQ};
tag basicParsing.mqttInN with MqttConnection = {topic = /echoN, msgField = dataN};
tag basicParsing.mqttOutN with MqttConnection = {topic = /echoN};
tag basicParsing.mqttInZ with MqttConnection = {topic = /echoZ, msgField = dataZ};
tag basicParsing.mqttOutZ with MqttConnection = {topic = /echoZ};
tag basicParsing.mqttInB with MqttConnection = {topic = /echoB, msgField = true};
tag basicParsing.mqttOutB with MqttConnection = {topic = /echoB};
tag basicParsing.emptyTagIn with MqttConnection; tag basicParsing.emptyTagIn with MqttConnection;
} }
Supports Markdown
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