|
42 | 42 | import org.eclipse.basyx.submodel.metamodel.map.identifier.Identifier; |
43 | 43 | import org.eclipse.basyx.submodel.metamodel.map.submodelelement.SubmodelElementCollection; |
44 | 44 | import org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.Property; |
| 45 | +import org.eclipse.basyx.submodel.restapi.api.ISubmodelAPI; |
| 46 | +import org.eclipse.basyx.submodel.restapi.vab.VABSubmodelAPI; |
45 | 47 | import org.eclipse.basyx.testsuite.regression.extensions.shared.mqtt.MqttTestListener; |
46 | 48 | import org.eclipse.basyx.vab.coder.json.serialization.DefaultTypeFactory; |
47 | 49 | import org.eclipse.basyx.vab.coder.json.serialization.GSONTools; |
| 50 | +import org.eclipse.basyx.vab.modelprovider.generic.VABModelProvider; |
| 51 | +import org.eclipse.basyx.vab.modelprovider.map.VABMapHandler; |
48 | 52 | import org.eclipse.paho.client.mqttv3.MqttClient; |
49 | 53 | import org.eclipse.paho.client.mqttv3.MqttException; |
50 | 54 | import org.junit.After; |
|
62 | 66 | /** |
63 | 67 | * Tests events emitting with the MqttSubmodelAggregatorObserver |
64 | 68 | * |
65 | | - * @author fischer, jungjan, siebert |
| 69 | + * @author fischer, jungjan, siebert, mateusmolina |
66 | 70 | * |
67 | 71 | */ |
68 | 72 | public class TestMqttV2SubmodelAggregatorObserver { |
@@ -120,18 +124,24 @@ public void tearDown() { |
120 | 124 |
|
121 | 125 | @Test |
122 | 126 | public void testCreateSubmodel() { |
123 | | - String newSubmodelIdShort = "newSubmodelIdShort"; |
124 | | - String newSubmodelId = "newSubmodelId"; |
125 | | - Identifier newSubmodelIdentifier = new Identifier(IdentifierType.IRDI, newSubmodelId); |
126 | | - Submodel newSubmodel = new Submodel(newSubmodelIdShort, newSubmodelIdentifier); |
127 | | - newSubmodel.addSubmodelElement(new SubmodelElementCollection("smeColl")); |
128 | | - newSubmodel.addSubmodelElement(new Property("prop", false)); |
| 127 | + Submodel newSubmodel = createTestSubmodel(); |
129 | 128 | observedSubmodelAggregator.createSubmodel(newSubmodel); |
130 | 129 |
|
131 | 130 | assertEquals(removeSubmodelElements(newSubmodel), deserializePayload(listener.lastPayload)); |
132 | 131 | assertEquals(payloadFactory.createCreateSubmodelTopic(null, observedSubmodelAggregator.getAasServerId()), listener.lastTopic); |
133 | 132 | } |
134 | 133 |
|
| 134 | + @Test |
| 135 | + public void noEventExpectedWhenSubmodelIsCreatedViaAPI() { |
| 136 | + ISubmodelAPI smApi = new VABSubmodelAPI(new VABModelProvider(createTestSubmodel(), new VABMapHandler())); |
| 137 | + |
| 138 | + String lastPayload = listener.lastPayload; |
| 139 | + |
| 140 | + observedSubmodelAggregator.createSubmodel(smApi); |
| 141 | + |
| 142 | + assertEquals(lastPayload, listener.lastPayload); |
| 143 | + } |
| 144 | + |
135 | 145 | @Test |
136 | 146 | public void testUpdateSubmodel() { |
137 | 147 | submodel.setCategory("newCategory"); |
@@ -174,4 +184,18 @@ private Submodel removeSubmodelElements(Submodel submodel) { |
174 | 184 |
|
175 | 185 | return copy; |
176 | 186 | } |
| 187 | + |
| 188 | + private static Submodel createTestSubmodel() { |
| 189 | + String newSubmodelIdShort = "newSubmodelIdShort"; |
| 190 | + String newSubmodelId = "newSubmodelId"; |
| 191 | + Identifier newSubmodelIdentifier = new Identifier(IdentifierType.IRDI, newSubmodelId); |
| 192 | + |
| 193 | + Submodel newSubmodel = new Submodel(newSubmodelIdShort, newSubmodelIdentifier); |
| 194 | + |
| 195 | + newSubmodel.addSubmodelElement(new SubmodelElementCollection("smeColl")); |
| 196 | + newSubmodel.addSubmodelElement(new Property("prop", false)); |
| 197 | + |
| 198 | + return newSubmodel; |
| 199 | + } |
| 200 | + |
177 | 201 | } |
0 commit comments