Skip to content

Commit

Permalink
Merge pull request #384 from eclipse-basyx/development-fix
Browse files Browse the repository at this point in the history
Development fix
  • Loading branch information
FrankSchnicke authored Dec 14, 2023
2 parents ee98fc8 + 6b2da29 commit ebf6efa
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.eclipse.basyx</groupId>
<artifactId>basyx.sdk</artifactId>
<version>1.5.0</version>
<version>1.5.1-SNAPSHOT</version>
<name>BaSyx SDK</name>
<description>BaSyx Software Development Kit</description>
<url>https://www.eclipse.org/basyx/</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public void createSubmodel(Submodel submodel) {
@Override
public void createSubmodel(ISubmodelAPI submodelAPI) {
submodelAggregator.createSubmodel(submodelAPI);
observers.stream().forEach(observer -> observer.submodelCreated(getParentAASId(submodelAPI.getSubmodel()), submodelAPI.getSubmodel(), this.aasServerId));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class MqttTestListener implements InterceptHandler {
public String lastTopic;
public String lastPayload;
private ArrayList<String> topics = new ArrayList<>();
public int msgCounter;

@Override
public String getID() {
Expand Down Expand Up @@ -80,6 +81,7 @@ public synchronized void onPublish(InterceptPublishMessage msg) {
topics.add(msg.getTopicName());
lastTopic = msg.getTopicName();
lastPayload = msg.getPayload().toString(StandardCharsets.UTF_8);
msgCounter++;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@
import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier;
import org.eclipse.basyx.submodel.metamodel.map.submodelelement.SubmodelElementCollection;
import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property;
import org.eclipse.basyx.submodel.restapi.api.ISubmodelAPI;
import org.eclipse.basyx.submodel.restapi.vab.VABSubmodelAPI;
import org.eclipse.basyx.testsuite.regression.extensions.shared.mqtt.MqttTestListener;
import org.eclipse.basyx.vab.coder.json.serialization.DefaultTypeFactory;
import org.eclipse.basyx.vab.coder.json.serialization.GSONTools;
import org.eclipse.basyx.vab.modelprovider.generic.VABModelProvider;
import org.eclipse.basyx.vab.modelprovider.map.VABMapHandler;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.junit.After;
Expand All @@ -62,7 +66,7 @@
/**
* Tests events emitting with the MqttSubmodelAggregatorObserver
*
* @author fischer, jungjan, siebert
* @author fischer, jungjan, siebert, mateusmolina
*
*/
public class TestMqttV2SubmodelAggregatorObserver {
Expand Down Expand Up @@ -120,18 +124,24 @@ public void tearDown() {

@Test
public void testCreateSubmodel() {
String newSubmodelIdShort = "newSubmodelIdShort";
String newSubmodelId = "newSubmodelId";
Identifier newSubmodelIdentifier = new Identifier(IdentifierType.IRDI, newSubmodelId);
Submodel newSubmodel = new Submodel(newSubmodelIdShort, newSubmodelIdentifier);
newSubmodel.addSubmodelElement(new SubmodelElementCollection("smeColl"));
newSubmodel.addSubmodelElement(new Property("prop", false));
Submodel newSubmodel = createTestSubmodel();
observedSubmodelAggregator.createSubmodel(newSubmodel);

assertEquals(removeSubmodelElements(newSubmodel), deserializePayload(listener.lastPayload));
assertEquals(payloadFactory.createCreateSubmodelTopic(null, observedSubmodelAggregator.getAasServerId()), listener.lastTopic);
}

@Test
public void noEventExpectedWhenSubmodelIsCreatedViaAPI() {
ISubmodelAPI smApi = new VABSubmodelAPI(new VABModelProvider(createTestSubmodel(), new VABMapHandler()));

String lastPayload = listener.lastPayload;

observedSubmodelAggregator.createSubmodel(smApi);

assertEquals(lastPayload, listener.lastPayload);
}

@Test
public void testUpdateSubmodel() {
submodel.setCategory("newCategory");
Expand Down Expand Up @@ -174,4 +184,18 @@ private Submodel removeSubmodelElements(Submodel submodel) {

return copy;
}

private static Submodel createTestSubmodel() {
String newSubmodelIdShort = "newSubmodelIdShort";
String newSubmodelId = "newSubmodelId";
Identifier newSubmodelIdentifier = new Identifier(IdentifierType.IRDI, newSubmodelId);

Submodel newSubmodel = new Submodel(newSubmodelIdShort, newSubmodelIdentifier);

newSubmodel.addSubmodelElement(new SubmodelElementCollection("smeColl"));
newSubmodel.addSubmodelElement(new Property("prop", false));

return newSubmodel;
}

}

0 comments on commit ebf6efa

Please sign in to comment.