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
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* 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/>.
* *******************************************************************************
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.embeddedmontiarc.tagging.middleware.mqtt;
......@@ -145,7 +131,7 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator {
}
Log.error(String.format("'%s' does not match the specified regex pattern '%s'",
regex,
"{topic = ({name}, {type}), msgField = {msgField}}"));
"{topic = {name}, msgField = {msgField}}"));
return null;
}
......
/**
* (c) https://github.com/MontiCore/monticore
*
* ******************************************************************************
* MontiCAR Modeling Family, www.se-rwth.de
* 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/>.
* *******************************************************************************
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.embeddedmontiarc.middleware.mqtt;
......@@ -44,39 +30,101 @@ public class TaggingTest extends AbstractTaggingResolverTest {
EMAComponentInstanceSymbol component = symtab.<EMAComponentInstanceSymbol>resolve("middleware.mqtt.basicParsing", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(component);
//mqttIn
EMAPortSymbol mqttIn = component.getPortInstance("mqttIn").orElse(null);
assertNotNull(mqttIn);
//mqttInQ
EMAPortSymbol mqttInQ = component.getPortInstance("mqttInQ").orElse(null);
assertNotNull(mqttInQ);
Collection<TagSymbol> tags = symtab.getTags(mqttIn, MqttConnectionSymbol.KIND);
Collection<TagSymbol> tags = symtab.getTags(mqttInQ, MqttConnectionSymbol.KIND);
assertTrue(tags.size() == 1);
MqttConnectionSymbol tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName().get(), "/clock");
assertEquals(tag.getMsgField().get(), "clock.toSec()");
//mqttOut
EMAPortSymbol mqttOut = component.getPortInstance("mqttOut").orElse(null);
assertNotNull(mqttOut);
tags = symtab.getTags(mqttOut, MqttConnectionSymbol.KIND);
assertEquals(tag.getTopicName().get(), "/echoQ");
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(), "/echo");
assertEquals(tag.getMsgField().get(), "data");
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");
//mqttOutB
EMAPortSymbol mqttOutB = component.getPortInstance("mqttOutB").orElse(null);
assertNotNull(mqttOutB);
tags = symtab.getTags(mqttOutB, MqttConnectionSymbol.KIND);
assertTrue(tags.size() == 1);
tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName().get(), "/echoB");
//emptyTagIn
EMAPortSymbol emptyTagIn = component.getPortInstance("emptyTagIn").orElse(null);
assertNotNull(emptyTagIn);
tags = symtab.getTags(emptyTagIn, MqttConnectionSymbol.KIND);
assertTrue(tags.size() == 1);
tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName(), Optional.empty());
assertEquals(tag.getMsgField(), Optional.empty());
}
@Test
......
package middleware.mqtt;
component BasicParsing{
port in Q mqttIn;
port in Q noMqttIn;
port in Q mqttInQ;
port in Q noMqttInQ;
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;
}
\ No newline at end of file
port out N mqttOutN;
port out Z mqttOutZ;
port out B mqttOutB;
}
......@@ -2,7 +2,13 @@ package middleware.mqtt;
conforms to middleware.mqtt.MqttToEmamTagSchema;
tags Echo {
tag basicParsing.mqttIn with MqttConnection = {topic = /clock, msgField = clock.toSec()};
tag basicParsing.mqttOut with MqttConnection = {topic = /echo, msgField = data};
tag basicParsing.mqttInQ with MqttConnection = {topic = /echoQ, msgField = dataQ};
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;
}
\ 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