Commit b226bdda authored by Georg Vinogradov's avatar Georg Vinogradov
Browse files

Fix parsing errors

parent f2e2ec3f
Pipeline #175987 passed with stage
in 2 minutes and 52 seconds
...@@ -48,7 +48,8 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator { ...@@ -48,7 +48,8 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator {
* at http://www.regexplanet.com/advanced/java/index.html * at http://www.regexplanet.com/advanced/java/index.html
*/ */
public static final Pattern pattern = Pattern.compile("\\s*\\{\\s*topic\\s*=\\s*\\(\\s*([a-z|A-Z|~|/][0-9|a-z|A-Z|_|/]*)\\s*,\\s*([a-z|A-Z][0-9|a-z|A-Z|_|/]*)\\s*\\)\\s*(s*,\\s*msgField\\s*=\\s*([a-z|A-Z][a-z|A-Z|1-9|_|\\.|::|\\(|\\)]*)\\s*)?\\s*\\}\\s*"); // \s*\{\s*topic\s*=\s*([a-z|A-Z|~|/][0-9|a-z|A-Z|_|/]*)\s*(s*,\s*msgField\s*=\s*([a-z|A-Z][a-z|A-Z|1-9|_|\.|::|\(|\)]*)\s*)?\s*\}\s*
public static final Pattern pattern = Pattern.compile("\\s*\\{\\s*topic\\s*=\\s*([a-z|A-Z|~|/][0-9|a-z|A-Z|_|/]*)\\s*(s*,\\s*msgField\\s*=\\s*([a-z|A-Z][a-z|A-Z|1-9|_|\\.|::|\\(|\\)]*)\\s*)?\\s*\\}\\s*");
public static Scope getGlobalScope(final Scope scope) { public static Scope getGlobalScope(final Scope scope) {
Scope s = scope; Scope s = scope;
...@@ -124,7 +125,7 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator { ...@@ -124,7 +125,7 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator {
.forEachOrdered(m -> .forEachOrdered(m ->
taggedSymbols.stream() taggedSymbols.stream()
.forEachOrdered(s -> { .forEachOrdered(s -> {
MqttConnectionSymbol tmpSymbol = new MqttConnectionSymbol(m.group(1), m.group(4)); // topicName, msgField MqttConnectionSymbol tmpSymbol = new MqttConnectionSymbol(m.group(1), m.group(3)); // topicName, msgField
tagging.addTag(s, tmpSymbol); tagging.addTag(s, tmpSymbol);
if (s.isKindOf(EMAPortSymbol.KIND)) { if (s.isKindOf(EMAPortSymbol.KIND)) {
EMAPortSymbol p = (EMAPortSymbol) s; EMAPortSymbol p = (EMAPortSymbol) s;
......
...@@ -54,7 +54,7 @@ public class TaggingTest extends AbstractTaggingResolverTest { ...@@ -54,7 +54,7 @@ public class TaggingTest extends AbstractTaggingResolverTest {
MqttConnectionSymbol tag = (MqttConnectionSymbol) tags.iterator().next(); MqttConnectionSymbol tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName().get(), "/clock"); assertEquals(tag.getTopicName().get(), "/clock");
assertEquals(tag.getMsgField().get(), "clock.toSec()"); assertEquals(tag.getMsgField().get(), "clock.toSec()");
//mqttOut //mqttOut
EMAPortSymbol mqttOut = component.getPortInstance("mqttOut").orElse(null); EMAPortSymbol mqttOut = component.getPortInstance("mqttOut").orElse(null);
assertNotNull(mqttOut); assertNotNull(mqttOut);
...@@ -65,17 +65,18 @@ public class TaggingTest extends AbstractTaggingResolverTest { ...@@ -65,17 +65,18 @@ public class TaggingTest extends AbstractTaggingResolverTest {
tag = (MqttConnectionSymbol) tags.iterator().next(); tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName().get(), "/echo"); assertEquals(tag.getTopicName().get(), "/echo");
assertEquals(tag.getMsgField().get(), "data"); assertEquals(tag.getMsgField().get(), "data");
//emptyTagIn //emptyTagIn
EMAPortSymbol emptyTagIn = component.getPortInstance("emptyTagIn").orElse(null); EMAPortSymbol emptyTagIn = component.getPortInstance("emptyTagIn").orElse(null);
assertNotNull(emptyTagIn); assertNotNull(emptyTagIn);
tags = symtab.getTags(emptyTagIn, MqttConnectionSymbol.KIND); tags = symtab.getTags(emptyTagIn, MqttConnectionSymbol.KIND);
assertTrue(tags.size() == 1); assertTrue(tags.size() == 1);
tag = (MqttConnectionSymbol) tags.iterator().next(); tag = (MqttConnectionSymbol) tags.iterator().next();
assertEquals(tag.getTopicName(), Optional.empty()); assertEquals(tag.getTopicName(), Optional.empty());
assertEquals(tag.getMsgField(), Optional.empty()); assertEquals(tag.getMsgField(), Optional.empty());
} }
@Test @Test
......
package middleware.mqtt;
component BasicParsing{
port in Q mqttIn;
port in Q noMqttIn;
port in Q emptyTagIn;
port out Q mqttOut;
port out Q noMqttOut;
}
\ No newline at end of file
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.emptyTagIn with MqttConnection;
}
\ No newline at end of file
package middleware.mqtt;
component OptionalMsgField{
port in Q in1;
port out Q out1;
}
\ No newline at end of file
package middleware.mqtt;
conforms to middleware.mqtt.MqttToEmamTagSchema;
tags OptionalMsgField{
tag optionalMsgField.in1 with MqttConnection = {topic = name1};
tag optionalMsgField.out1 with MqttConnection = {topic = name1, msgField = msgField1};
}
\ No newline at end of file
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