100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Made it possible to subscribe for AssetAttribute event with an specific attribute
Michael Rademakerf91327868094
diff --git a/manager/src/main/java/org/openremote/manager/gateway/GatewayConnector.java b/manager/src/main/java/org/openremote/manager/gateway/GatewayConnector.javaindex e768449ed..8b62ed576 100644--- a/manager/src/main/java/org/openremote/manager/gateway/GatewayConnector.java+++ b/manager/src/main/java/org/openremote/manager/gateway/GatewayConnector.java@@ -26,7 +26,6 @@ import org.openremote.manager.concurrent.ManagerExecutorService;import org.openremote.model.asset.*;import org.openremote.model.asset.agent.ConnectionStatus;import org.openremote.model.attribute.AttributeEvent;-import org.openremote.model.event.shared.EventSubscription;import org.openremote.model.event.shared.SharedEvent;import org.openremote.model.query.AssetQuery;import org.openremote.model.value.Values;diff --git a/manager/src/main/java/org/openremote/manager/mqtt/EventInterceptHandler.java b/manager/src/main/java/org/openremote/manager/mqtt/EventInterceptHandler.javaindex 9052aaf6a..fef411676 100644--- a/manager/src/main/java/org/openremote/manager/mqtt/EventInterceptHandler.java+++ b/manager/src/main/java/org/openremote/manager/mqtt/EventInterceptHandler.java@@ -33,8 +33,11 @@ import org.openremote.container.web.ConnectionConstants;import org.openremote.manager.event.ClientEventService;import org.openremote.manager.security.ManagerKeycloakIdentityProvider;import org.openremote.model.Constants;+import org.openremote.model.asset.Asset;import org.openremote.model.asset.AssetFilter;+import org.openremote.model.attribute.Attribute;import org.openremote.model.attribute.AttributeEvent;+import org.openremote.model.attribute.AttributeRef;import org.openremote.model.event.shared.CancelEventSubscription;import org.openremote.model.event.shared.EventSubscription;import org.openremote.model.event.shared.RenewEventSubscriptions;@@ -126,20 +129,37 @@ public class EventInterceptHandler extends AbstractInterceptHandler {if (connection != null) {String[] topicParts = interceptSubscribeMessage.getTopicFilter().split(TOPIC_SEPARATOR);String assetId = topicParts[1];- String subscriptionId = connection.assetSubscriptions.get(assetId);+ AttributeRef attributeRef = null;+ if (topicParts.length == 3) { //attribute specific+ attributeRef = new AttributeRef(assetId, topicParts[2]);+ }+ String subscriptionId;+ if (attributeRef == null) {+ subscriptionId = connection.assetSubscriptions.remove(assetId);+ } else {+ subscriptionId = connection.assetAttributeSubscriptions.remove(attributeRef);+ }if (subscriptionId != null) { //renew subscriptionRenewEventSubscriptions renewEventSubscriptions = new RenewEventSubscriptions(new String[]{subscriptionId});Map<String, Object> headers = prepareHeaders(connection);messageBrokerService.getProducerTemplate().sendBodyAndHeaders(ClientEventService.CLIENT_EVENT_QUEUE, renewEventSubscriptions, headers);} else {+ AssetFilter<AttributeEvent> attributeAssetFilter = new AssetFilter<AttributeEvent>().setRealm(connection.realm).setAssetIds(assetId);EventSubscription<AttributeEvent> subscription = new EventSubscription<>(AttributeEvent.class,- new AssetFilter<AttributeEvent>().setRealm(connection.realm).setAssetIds(assetId),+ attributeAssetFilter,String.valueOf(connection.getNextSubscriptionId()));++ if (attributeRef == null) { //attribute specific+ connection.assetSubscriptions.put(assetId, subscription.getSubscriptionId());+ } else {+ attributeAssetFilter.setAttributeNames(attributeRef.getAttributeName());+ connection.assetAttributeSubscriptions.put(attributeRef, subscription.getSubscriptionId());+ }+Map<String, Object> headers = prepareHeaders(connection);messageBrokerService.getProducerTemplate().sendBodyAndHeaders(ClientEventService.CLIENT_EVENT_QUEUE, subscription, headers);- connection.assetSubscriptions.put(assetId, subscription.getSubscriptionId());}} else {throw new IllegalStateException("Connection with clientId " + interceptSubscribeMessage.getClientID() + " not found.");@@ -152,7 +172,12 @@ public class EventInterceptHandler extends AbstractInterceptHandler {if (connection != null) {String[] topicParts = interceptUnsubscribeMessage.getTopicFilter().split(TOPIC_SEPARATOR);String assetId = topicParts[1];- String subscriptionId = connection.assetSubscriptions.remove(assetId);+ String subscriptionId;+ if (topicParts.length == 3) { //attribute specific+ subscriptionId = connection.assetAttributeSubscriptions.remove(new AttributeRef(assetId, topicParts[2]));+ } else {+ subscriptionId = connection.assetSubscriptions.remove(assetId);+ }if (subscriptionId != null) {Map<String, Object> headers = prepareHeaders(connection);CancelEventSubscription<AttributeEvent> cancelEventSubscription = new CancelEventSubscription<>(AttributeEvent.class, subscriptionId);@@ -167,13 +192,26 @@ public class EventInterceptHandler extends AbstractInterceptHandler {if (connection != null) {String[] topicParts = msg.getTopicName().split(TOPIC_SEPARATOR);String assetId = topicParts[1];- if (connection.assetSubscriptions.containsKey(assetId)) {- String payloadContent = msg.getPayload().toString(Charset.defaultCharset());- Values.parse(payloadContent).flatMap(Values::getObject).ifPresent(objectValue -> {+ AttributeRef attributeRef = null;+ if (topicParts.length == 3) { //attribute specific+ attributeRef = new AttributeRef(assetId, topicParts[2]);+ }+ if (attributeRef == null) {+ if (connection.assetSubscriptions.containsKey(assetId)) {+ String payloadContent = msg.getPayload().toString(Charset.defaultCharset());+ Values.parse(payloadContent).flatMap(Values::getObject).ifPresent(objectValue -> {+ Map<String, Object> headers = prepareHeaders(connection);+ AttributeEvent attributeEvent = new AttributeEvent(assetId, objectValue.keys()[0], objectValue.get(objectValue.keys()[0]).orElse(null));+ messageBrokerService.getProducerTemplate().sendBodyAndHeaders(ClientEventService.CLIENT_EVENT_QUEUE, attributeEvent, headers);+ });+ }+ } else {+ if (connection.assetAttributeSubscriptions.containsKey(attributeRef)) {+ String payloadContent = msg.getPayload().toString(Charset.defaultCharset());Map<String, Object> headers = prepareHeaders(connection);- AttributeEvent attributeEvent = new AttributeEvent(assetId, objectValue.keys()[0], objectValue.get(objectValue.keys()[0]).orElse(null));+ AttributeEvent attributeEvent = new AttributeEvent(assetId, attributeRef.getAttributeName(), Values.create(payloadContent));messageBrokerService.getProducerTemplate().sendBodyAndHeaders(ClientEventService.CLIENT_EVENT_QUEUE, attributeEvent, headers);- });+ }}}}diff --git a/manager/src/main/java/org/openremote/manager/mqtt/KeycloakAuthorizatorPolicy.java b/manager/src/main/java/org/openremote/manager/mqtt/KeycloakAuthorizatorPolicy.javaindex 7b29f32d5..f64b1247e 100644--- a/manager/src/main/java/org/openremote/manager/mqtt/KeycloakAuthorizatorPolicy.java+++ b/manager/src/main/java/org/openremote/manager/mqtt/KeycloakAuthorizatorPolicy.java@@ -1,6 +1,7 @@package org.openremote.manager.mqtt;import io.moquette.broker.security.IAuthorizatorPolicy;+import io.moquette.broker.subscriptions.Token;import io.moquette.broker.subscriptions.Topic;import org.keycloak.adapters.rotation.AdapterTokenVerifier;import org.keycloak.common.VerificationException;@@ -19,11 +20,14 @@ import org.openremote.model.security.ClientRole;import java.nio.charset.StandardCharsets;import java.util.Arrays;+import java.util.Collections;import java.util.Map;import java.util.logging.Level;import java.util.logging.Logger;+import java.util.stream.Collectors;import static org.openremote.manager.mqtt.MqttBrokerService.ASSETS_TOPIC;+import static org.openremote.manager.mqtt.MqttBrokerService.TOPIC_SEPARATOR;import static org.openremote.model.Constants.KEYCLOAK_CLIENT_ID;public class KeycloakAuthorizatorPolicy implements IAuthorizatorPolicy {@@ -64,13 +68,13 @@ public class KeycloakAuthorizatorPolicy implements IAuthorizatorPolicy {return false;}- if (topic.isEmpty() || topic.getTokens().size() != 2) {- LOG.info("Topic may not be empty and should have the following format: assets/{assetId}");+ if (topic.isEmpty() || topic.getTokens().size() < 2) {+ LOG.info("Topic may not be empty and should have the following format: assets/{assetId}(optional: /{attributeName})");return false;}if (!topic.headToken().toString().equals(ASSETS_TOPIC)) {- LOG.info("Topic should have the following format: assets/{assetId}");+ LOG.info("Topic should have the following format: assets/{assetId}(optional: /{attributeName})");return false;}@@ -97,10 +101,15 @@ public class KeycloakAuthorizatorPolicy implements IAuthorizatorPolicy {if (Arrays.asList(roles).contains(ClientRole.WRITE_ASSETS)) { //writereturn identityProvider.canSubscribeWith(authContext, new TenantFilter(connection.realm), roles);} else { // read- String assetId = topic.getTokens().get(1).toString();+ String[] topicParts = topic.getTokens().stream().map(Token::toString).toArray(String[]::new);+ String assetId = topicParts[1];+ AssetFilter<AttributeEvent> attributeAssetFilter = new AssetFilter<AttributeEvent>().setRealm(connection.realm).setAssetIds(assetId);+ if (topicParts.length == 3) { //attribute specific+ attributeAssetFilter.setAttributeNames(topicParts[2]);+ }EventSubscription<AttributeEvent> subscription = new EventSubscription<>(AttributeEvent.class,- new AssetFilter<AttributeEvent>().setRealm(connection.realm).setAssetIds(assetId)+ attributeAssetFilter);return clientEventService.authorizeEventSubscription(authContext, subscription);}diff --git a/manager/src/main/java/org/openremote/manager/mqtt/MqttBrokerService.java b/manager/src/main/java/org/openremote/manager/mqtt/MqttBrokerService.javaindex 3d6a76c0a..024f9bf50 100644--- a/manager/src/main/java/org/openremote/manager/mqtt/MqttBrokerService.java+++ b/manager/src/main/java/org/openremote/manager/mqtt/MqttBrokerService.java@@ -19,6 +19,7 @@*/package org.openremote.manager.mqtt;+import com.fasterxml.jackson.core.JsonProcessingException;import io.moquette.BrokerConstants;import io.moquette.broker.Server;import io.moquette.broker.config.MemoryConfig;@@ -36,10 +37,12 @@ import org.openremote.manager.security.ManagerKeycloakIdentityProvider;import org.openremote.model.attribute.AttributeEvent;import org.openremote.model.event.TriggeredEventSubscription;import org.openremote.model.value.ObjectValue;+import org.openremote.model.value.Value;import org.openremote.model.value.Values;import java.nio.charset.Charset;import java.util.*;+import java.util.logging.Level;import java.util.logging.Logger;import static org.openremote.container.util.MapAccess.getInteger;@@ -107,12 +110,20 @@ public class MqttBrokerService implements ContainerService {.process(exchange -> {String sessionKey = getSessionKey(exchange);@SuppressWarnings("unchecked")- TriggeredEventSubscription<AttributeEvent> triggeredEventSubscription = (TriggeredEventSubscription<AttributeEvent>)exchange.getIn().getBody(TriggeredEventSubscription.class);+ TriggeredEventSubscription<AttributeEvent> triggeredEventSubscription = (TriggeredEventSubscription<AttributeEvent>) exchange.getIn().getBody(TriggeredEventSubscription.class);triggeredEventSubscription.getEvents()- .forEach(event -> sendAttributeEvent(sessionKey, event));+ .forEach(event -> {+ MqttConnection mqttConnection = mqttConnectionMap.get(sessionKey);+ if (mqttConnection != null) {+ if (mqttConnection.assetSubscriptions.containsKey(event.getEntityId())) {+ sendAttributeEvent(sessionKey, event);+ } else if (mqttConnection.assetAttributeSubscriptions.containsKey(event.getAttributeRef())) {+ sendAttributeValue(sessionKey, event);+ }+ }+ });}).end();-}});}@@ -135,13 +146,27 @@ public class MqttBrokerService implements ContainerService {}public void sendAttributeEvent(String clientId, AttributeEvent attributeEvent) {- ObjectValue payloadContent = Values.createObject();- payloadContent.put(attributeEvent.getAttributeName(), attributeEvent.getValue().orElse(null));- ByteBuf payload = Unpooled.copiedBuffer(payloadContent.toJson(), Charset.defaultCharset());+ try {+ ByteBuf payload = Unpooled.copiedBuffer(Container.JSON.writeValueAsString(attributeEvent), Charset.defaultCharset());++ MqttPublishMessage publishMessage = MqttMessageBuilders.publish()+ .qos(MqttQoS.AT_MOST_ONCE)+ .topicName(ASSETS_TOPIC + TOPIC_SEPARATOR + attributeEvent.getEntityId())+ .payload(payload)+ .build();++ mqttBroker.internalPublish(publishMessage, clientId);+ } catch (JsonProcessingException e) {+ LOG.log(Level.WARNING, "Couldn't send AttributeEvent to MQTT client", e);+ }+ }++ public void sendAttributeValue(String clientId, AttributeEvent attributeEvent) {+ ByteBuf payload = Unpooled.copiedBuffer(attributeEvent.getValue().map(Value::toString).orElse(""), Charset.defaultCharset());MqttPublishMessage publishMessage = MqttMessageBuilders.publish().qos(MqttQoS.AT_MOST_ONCE)- .topicName(ASSETS_TOPIC + TOPIC_SEPARATOR + attributeEvent.getEntityId())+ .topicName(ASSETS_TOPIC + TOPIC_SEPARATOR + attributeEvent.getEntityId() + TOPIC_SEPARATOR + attributeEvent.getAttributeName()).payload(payload).build();diff --git a/manager/src/main/java/org/openremote/manager/mqtt/MqttConnection.java b/manager/src/main/java/org/openremote/manager/mqtt/MqttConnection.javaindex e6ef1c51a..8041ff2a3 100644--- a/manager/src/main/java/org/openremote/manager/mqtt/MqttConnection.java+++ b/manager/src/main/java/org/openremote/manager/mqtt/MqttConnection.java@@ -1,5 +1,7 @@package org.openremote.manager.mqtt;+import org.openremote.model.attribute.AttributeRef;+import java.util.HashMap;import java.util.Map;@@ -7,29 +9,31 @@ import static org.openremote.manager.mqtt.KeycloakAuthenticator.MQTT_CLIENT_ID_Spublic class MqttConnection {- protected final String realm;- protected final String clientId;- protected final String username;- protected final byte[] password;- protected final Map<String, String> assetSubscriptions;- protected String accessToken;- protected int subscriptionId;+ protected final String realm;+ protected final String clientId;+ protected final String username;+ protected final byte[] password;+ protected final Map<String, String> assetSubscriptions;+ protected final Map<AttributeRef, String> assetAttributeSubscriptions;+ protected String accessToken;+ protected int subscriptionId;- public MqttConnection(String clientId, String username, byte[] password) {- int indexSplit = clientId.indexOf(MQTT_CLIENT_ID_SEPARATOR);- if (indexSplit > 0) {- realm = clientId.substring(0, indexSplit);- } else {- realm = clientId;- }- this.clientId = clientId;- this.username = username;- this.password = password;- this.assetSubscriptions = new HashMap<>();- this.subscriptionId = 0;+ public MqttConnection(String clientId, String username, byte[] password) {+ int indexSplit = clientId.indexOf(MQTT_CLIENT_ID_SEPARATOR);+ if (indexSplit > 0) {+ realm = clientId.substring(0, indexSplit);+ } else {+ realm = clientId;}+ this.clientId = clientId;+ this.username = username;+ this.password = password;+ this.assetSubscriptions = new HashMap<>();+ this.assetAttributeSubscriptions = new HashMap<>();+ this.subscriptionId = 0;+ }- public int getNextSubscriptionId() {- return ++subscriptionId;- }+ public int getNextSubscriptionId() {+ return ++subscriptionId;+ }}diff --git a/model/src/main/java/org/openremote/model/asset/AssetEvent.java b/model/src/main/java/org/openremote/model/asset/AssetEvent.javaindex 30173888e..1f162fd4b 100644--- a/model/src/main/java/org/openremote/model/asset/AssetEvent.java+++ b/model/src/main/java/org/openremote/model/asset/AssetEvent.java@@ -67,6 +67,11 @@ public class AssetEvent extends SharedEvent implements AssetInfo {return asset.parentId;}+ @Override+ public String[] getAttributeNames() {+ return updatedProperties;+ }+public Cause getCause() {return cause;}diff --git a/model/src/main/java/org/openremote/model/asset/AssetFilter.java b/model/src/main/java/org/openremote/model/asset/AssetFilter.javaindex 87b55c292..c99c40257 100644--- a/model/src/main/java/org/openremote/model/asset/AssetFilter.java+++ b/model/src/main/java/org/openremote/model/asset/AssetFilter.java@@ -25,6 +25,7 @@ import org.openremote.model.event.shared.SharedEvent;import org.openremote.model.util.TextUtil;import java.util.Arrays;+import java.util.List;public class AssetFilter<T extends SharedEvent & AssetInfo> extends EventFilter<T> {@@ -33,6 +34,7 @@ public class AssetFilter<T extends SharedEvent & AssetInfo> extends EventFilter<protected String[] assetIds;protected String realm;protected String[] parentIds;+ protected String[] attributeNames;public AssetFilter() {}@@ -45,7 +47,7 @@ public class AssetFilter<T extends SharedEvent & AssetInfo> extends EventFilter<return assetIds;}- public AssetFilter<T> setAssetIds(String...assetIds) {+ public AssetFilter<T> setAssetIds(String... assetIds) {this.assetIds = assetIds;return this;}@@ -63,11 +65,20 @@ public class AssetFilter<T extends SharedEvent & AssetInfo> extends EventFilter<return parentIds;}- public AssetFilter<T> setParentIds(String...parentIds) {+ public AssetFilter<T> setParentIds(String... parentIds) {this.parentIds = parentIds;return this;}+ public String[] getAttributeNames() {+ return attributeNames;+ }++ public AssetFilter<T> setAttributeNames(String... attributeNames) {+ this.attributeNames = attributeNames;+ return this;+ }+@Overridepublic String getFilterType() {return FILTER_TYPE;@@ -94,6 +105,11 @@ public class AssetFilter<T extends SharedEvent & AssetInfo> extends EventFilter<}}+ if (attributeNames != null && attributeNames.length > 0) {+ List<String> eventAttributeNames = Arrays.asList(event.getAttributeNames());+ return Arrays.stream(attributeNames).anyMatch(eventAttributeNames::contains);+ }+return true;}@@ -103,6 +119,7 @@ public class AssetFilter<T extends SharedEvent & AssetInfo> extends EventFilter<"assetIds='" + (assetIds != null ? Arrays.toString(assetIds) : "") + '\'' +", parentIds='" + (parentIds != null ? Arrays.toString(parentIds) : "") + '\'' +", realm='" + realm + '\'' ++ ", attributeNames='" + (attributeNames != null ? Arrays.toString(attributeNames) : "") + '\'' +'}';}}diff --git a/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java b/model/src/main/java/org/openremote/model/attribute/AttributeEvent.javaindex cb017b417..8f63476ca 100644--- a/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java+++ b/model/src/main/java/org/openremote/model/attribute/AttributeEvent.java@@ -144,6 +144,11 @@ public class AttributeEvent extends SharedEvent implements AssetInfo {return this;}+ @Override+ public String[] getAttributeNames() {+ return new String[]{getAttributeRef().getAttributeName()};+ }+public String getAttributeName() {return getAttributeRef().getAttributeName();}diff --git a/model/src/main/java/org/openremote/model/event/shared/AssetInfo.java b/model/src/main/java/org/openremote/model/event/shared/AssetInfo.javaindex 5ebdb9f9b..9b5581f18 100644--- a/model/src/main/java/org/openremote/model/event/shared/AssetInfo.java+++ b/model/src/main/java/org/openremote/model/event/shared/AssetInfo.java@@ -26,4 +26,6 @@ public interface AssetInfo {String getRealm();String getParentId();++ String[] getAttributeNames();}diff --git a/test/src/test/groovy/org/openremote/test/mqtt/MqttTest.groovy b/test/src/test/groovy/org/openremote/test/mqtt/MqttTest.groovyindex 5b101a9cb..e78d76457 100644--- a/test/src/test/groovy/org/openremote/test/mqtt/MqttTest.groovy+++ b/test/src/test/groovy/org/openremote/test/mqtt/MqttTest.groovy@@ -25,12 +25,18 @@ class MqttTest extends Specification implements ManagerContainerTrait {given: "the container environment is started"def mqttBrokerServiceAttributeEventCalls = 0+ def mqttBrokerServiceAttributeValueCalls = 0def spyMqttBrokerService = Spy(MqttBrokerService) {sendAttributeEvent(_ as String, _ as AttributeEvent) >> {clientId, attributeEvent ->mqttBrokerServiceAttributeEventCalls++callRealMethod()}+ sendAttributeValue(_ as String, _ as AttributeEvent) >> {+ clientId, attributeEvent ->+ mqttBrokerServiceAttributeValueCalls+++ callRealMethod()+ }}def conditions = new PollingConditions(timeout: 10, delay: 1)@@ -193,7 +199,7 @@ class MqttTest extends Specification implements ManagerContainerTrait {def attributeEvent = new AttributeEvent(managerDemoSetup.apartment1HallwayId, "motionSensor", Values.create(50))assetProcessingService.sendAttributeEvent(attributeEvent)- then: "A publish message should be sent"+ then: "A publish event message should be sent"conditions.eventually {assert mqttBrokerServiceAttributeEventCalls == 1}@@ -202,7 +208,7 @@ class MqttTest extends Specification implements ManagerContainerTrait {attributeEvent = new AttributeEvent(managerDemoSetup.apartment1HallwayId, "presenceDetected", Values.create(true))assetProcessingService.sendAttributeEvent(attributeEvent)- then: "A second publish message should be sent"+ then: "A second publish event message should be sent"conditions.eventually {assert mqttBrokerServiceAttributeEventCalls == 2}@@ -271,11 +277,45 @@ class MqttTest extends Specification implements ManagerContainerTrait {attributeEvent = new AttributeEvent(managerDemoSetup.apartment1HallwayId, "presenceDetected", Values.create(false))assetProcessingService.sendAttributeEvent(attributeEvent)- then: "No publish message should be sent"+ then: "No publish event message should be sent"conditions.eventually {assert mqttBrokerServiceAttributeEventCalls == 3}+ when: "a mqtt client subscribes to an asset attribute"+ topic = "assets/" + managerDemoSetup.apartment1HallwayId + "/motionSensor"+ remainingLength = 4 + topic.size() + 1 //plus one for the QoS byte++ client+ // SUBSCRIBE+ .write(0x82) // MQTT Control Packet type(8) with QoS level 1+ .write(remainingLength.byteValue()) // Remaining Length+ .write(0x00, 0x10) // MessageId++ // Payload+ .write(0x00, topic.size().byteValue()) // Topic Length+ .write(topic) // Topic+ .write(0x01) // QoS level 1+ .flush()++ and: "that attribute changed"+ attributeEvent = new AttributeEvent(managerDemoSetup.apartment1HallwayId, "motionSensor", Values.create(30))+ assetProcessingService.sendAttributeEvent(attributeEvent)++ then: "A publish value message should be sent"+ conditions.eventually {+ assert mqttBrokerServiceAttributeValueCalls == 1+ }++ when: "Another asset attribute changed without any subscriptions on that attribute"+ attributeEvent = new AttributeEvent(managerDemoSetup.apartment1HallwayId, "presenceDetected", Values.create(true))+ assetProcessingService.sendAttributeEvent(attributeEvent)++ then: "No publish value message should be sent"+ conditions.eventually {+ assert mqttBrokerServiceAttributeValueCalls == 1+ }+cleanup: "the server should be stopped"stopContainer(container)}