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
Asset Listener test now passing
Rich Turner762d05012a8b
diff --git a/manager/server/src/main/java/org/openremote/manager/server/assets/AbstractContextBrokerResourceImpl.java b/manager/server/src/main/java/org/openremote/manager/server/assets/AbstractContextBrokerResourceImpl.javaindex 9717b55a5..cc5f0c18f 100644--- a/manager/server/src/main/java/org/openremote/manager/server/assets/AbstractContextBrokerResourceImpl.java+++ b/manager/server/src/main/java/org/openremote/manager/server/assets/AbstractContextBrokerResourceImpl.java@@ -51,11 +51,11 @@ public abstract class AbstractContextBrokerResourceImpl implements RegistrationPMap<Attribute, AssetProvider> providerInfo = providerEntry != null ? providerEntry.getValue() : null;if (providerInfo != null) {- // If any attributes are already registered with another provider then don't proceed+ // If any attrs are already registered with another provider then don't proceedStream<AssetProvider> providers = attributes.stream().filter(providerInfo::containsKey).map(providerInfo::get).distinct();if (providers.count() > 0 && providers.anyMatch(p -> p != provider)) {- LOG.info("Request failed because one or more attributes already registered with another provider");+ LOG.info("Request failed because one or more attrs already registered with another provider");return false;}@@ -64,7 +64,7 @@ public abstract class AbstractContextBrokerResourceImpl implements RegistrationPproviderInfo = new HashMap<>();}- // Register all asset attributes with the Context Broker (updates or creates registration)+ // Register all asset attrs with the Context Broker (updates or creates registration)updateRegistration(assetType, assetId, regAttributes);for (Attribute attr : attributes) {@@ -98,10 +98,10 @@ public abstract class AbstractContextBrokerResourceImpl implements RegistrationPreturn;}- // Split attributes into those to be removed and those to remain+ // Split attrs into those to be removed and those to remainMap<Boolean, List<Map.Entry<Attribute, AssetProvider>>> splitAttributes = providerInfo.entrySet().stream().collect(Collectors.partitioningBy(es -> es.getValue() == provider));- // Remove obsolete attributes+ // Remove obsolete attrssplitAttributes.get(true).forEach(es -> providerInfo.remove(es.getKey()));// Update context provider registrationdiff --git a/manager/server/src/main/java/org/openremote/manager/server/assets/AssetsResourceImpl.java b/manager/server/src/main/java/org/openremote/manager/server/assets/AssetsResourceImpl.javaindex 631f9299d..43a4356e2 100644--- a/manager/server/src/main/java/org/openremote/manager/server/assets/AssetsResourceImpl.java+++ b/manager/server/src/main/java/org/openremote/manager/server/assets/AssetsResourceImpl.java@@ -23,6 +23,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;import com.fasterxml.jackson.databind.ObjectMapper;import elemental.json.Json;import elemental.json.JsonObject;+import elemental.json.JsonValue;import org.openremote.container.Container;import org.openremote.container.web.WebResource;import org.openremote.container.web.WebService;@@ -30,6 +31,8 @@ import org.openremote.manager.shared.Consumer;import org.openremote.manager.shared.assets.AssetsResource;import org.openremote.manager.shared.http.RequestParams;import org.openremote.manager.shared.ngsi.Entity;+import org.openremote.manager.shared.ngsi.KeyValueEntity;+import org.openremote.manager.shared.ngsi.NotificationFormat;import org.openremote.manager.shared.ngsi.params.*;import org.openremote.manager.shared.ngsi.SubscribeRequestV2;@@ -100,10 +103,34 @@ public class AssetsResourceImpl extends WebResource implements AssetsResource, S}@Override- public void subscriberCallback(Entity[] entities) {+ public synchronized void subscriberCallback(NotificationFormat format, JsonObject notification) {// We get here when Orion detects a change to a currently subscribed entity// TODO: Notify the listeners interested in this asset-+ switch(format) {+ case NORMALIZED:+ Entity[] entities = Entity.from(notification.getArray("data"));+ String id = notification.getString("subscriptionId");+ Map.Entry<Consumer<Entity[]>, SubscribeRequestV2> subscriber = subscribers.entrySet()+ .stream()+ .filter(es -> es.getValue().getId().equals(id))+ .findFirst()+ .orElse(null);++ if (subscriber != null) {+ subscriber.getKey().accept(entities);+ }++ break;+ case KEYVALUES:+ // TODO: Implement KeyValue Notification Support+ KeyValueEntity[] entities2 = KeyValueEntity.from(notification.getArray("data"));+ throw new RuntimeException("Unsupported notification format");+ case VALUES:+ // TODO: Implement Value Notification Support+ throw new RuntimeException("Unsupported notification format");+ default:+ throw new RuntimeException("Unsupported notification format");+ }}protected Response checkSuccessResponse(Response response) {@@ -115,7 +142,7 @@ public class AssetsResourceImpl extends WebResource implements AssetsResource, S}/**- * You must strip out id and type attributes of an entity if it's a PATCH or POST.+ * You must strip out id and type attrs of an entity if it's a PATCH or POST.* Why doesn't the NGSI server just ignore those fields? FU, that's why.*/protected JsonObject fixForUpdate(JsonObject original) {@@ -147,16 +174,16 @@ public class AssetsResourceImpl extends WebResource implements AssetsResource, SstoredSubscription.setSubject(subscription);storedSubscription.setExpires(createNewExpiryDate());- try {- String str = mapper.writeValueAsString(storedSubscription);- System.out.print(str);- } catch (JsonProcessingException e) {- e.printStackTrace();- }+// try {+// String str = mapper.writeValueAsString(storedSubscription);+// System.out.print(str);+// } catch (JsonProcessingException e) {+// e.printStackTrace();+// }Response response = assetsService.getContextBroker().createSubscription(storedSubscription);- if (response.getStatus() == 204) {+ if (response.getStatus() == 201) {String locationHeader = response.getHeaderString("Location");String id = locationHeader.split("/")[3];storedSubscription.setId(id);diff --git a/manager/server/src/main/java/org/openremote/manager/server/assets/ContextBrokerV1ResourceImpl.java b/manager/server/src/main/java/org/openremote/manager/server/assets/ContextBrokerV1ResourceImpl.javaindex 2ace5f48e..5ff491930 100644--- a/manager/server/src/main/java/org/openremote/manager/server/assets/ContextBrokerV1ResourceImpl.java+++ b/manager/server/src/main/java/org/openremote/manager/server/assets/ContextBrokerV1ResourceImpl.java@@ -128,7 +128,7 @@ public class ContextBrokerV1ResourceImpl extends AbstractContextBrokerResourceImif (providerInfo != null) {if (attributesAndValues == null || attributesAndValues.isEmpty()) {- // Get all attribute providers for these attributes+ // Get all attribute providers for these attrsattributeProviders = providerInfo.entrySet().stream()@@ -170,7 +170,7 @@ public class ContextBrokerV1ResourceImpl extends AbstractContextBrokerResourceIm.anyMatch(attr -> attr.getName().equalsIgnoreCase(attrVal.getVal1()))).map(attrValue -> new Attribute(attrValue.getVal1(), null, Json.create(attrValue.getVal2()))).collect(Collectors.toList());- // Call set attributes on provider+ // Call set attrs on provideres.getKey().setAssetAttributeValues(entityQuery.getId(), attrs);return attrs.stream();@@ -185,7 +185,7 @@ public class ContextBrokerV1ResourceImpl extends AbstractContextBrokerResourceIm}if (attributes.isEmpty()) {- LOG.info("Asset provider returned no attributes when asked for the value of one or more attributes");+ LOG.info("Asset provider returned no attrs when asked for the value of one or more attrs");return null;}@@ -217,9 +217,9 @@ public class ContextBrokerV1ResourceImpl extends AbstractContextBrokerResourceIm// Just remove this entity from the registrationexistingReg.getEntities().remove(entity);} else {- // Check if attributes all match if so there is nothing to do otherwise+ // Check if attrs all match if so there is nothing to do otherwise// We have to remove from this registration and either add to another- // or create a new one to match these attributes+ // or create a new one to match these attrsboolean allMatch = attributes.stream().allMatch(attr -> existingReg.getAttributes()diff --git a/manager/server/src/main/java/org/openremote/manager/server/assets/ContextBrokerV2ResourceImpl.java b/manager/server/src/main/java/org/openremote/manager/server/assets/ContextBrokerV2ResourceImpl.javaindex 10c024f3b..00bb05678 100644--- a/manager/server/src/main/java/org/openremote/manager/server/assets/ContextBrokerV2ResourceImpl.java+++ b/manager/server/src/main/java/org/openremote/manager/server/assets/ContextBrokerV2ResourceImpl.java@@ -280,7 +280,7 @@ public class ContextBrokerV2ResourceImpl extends AbstractContextBrokerResourceIm.collect(Collectors.toList());if (attributes.isEmpty()) {- LOG.info("Asset provider returned no attributes when asked for the value of one or more attributes");+ LOG.info("Asset provider returned no attrs when asked for the value of one or more attrs");return null;}@@ -317,9 +317,9 @@ public class ContextBrokerV2ResourceImpl extends AbstractContextBrokerResourceIm// Just remove this entity from the registrationexistingReg.getSubject().getEntities().remove(entity);} else {- // Check if attributes all match if so there is nothing to do otherwise+ // Check if attrs all match if so there is nothing to do otherwise// We have to remove from this registration and either add to another- // or create a new one to match these attributes+ // or create a new one to match these attrsboolean allMatch = attributes.stream().allMatch(attr -> existingReg.getSubject().getAttributes()diff --git a/manager/shared/src/main/java/org/openremote/manager/shared/assets/AssetsResource.java b/manager/shared/src/main/java/org/openremote/manager/shared/assets/AssetsResource.javaindex 1ca338de3..2a891902f 100644--- a/manager/shared/src/main/java/org/openremote/manager/shared/assets/AssetsResource.java+++ b/manager/shared/src/main/java/org/openremote/manager/shared/assets/AssetsResource.java@@ -21,16 +21,19 @@ package org.openremote.manager.shared.assets;import elemental.json.JsonArray;import elemental.json.JsonObject;+import elemental.json.JsonValue;import jsinterop.annotations.JsType;import org.openremote.manager.shared.http.PATCH;import org.openremote.manager.shared.http.RequestParams;import org.openremote.manager.shared.http.SuccessStatusCode;import org.openremote.manager.shared.ngsi.Entity;+import org.openremote.manager.shared.ngsi.NotificationFormat;import org.openremote.manager.shared.ngsi.params.EntityListParams;import org.openremote.manager.shared.ngsi.params.EntityParams;import javax.annotation.security.RolesAllowed;import javax.ws.rs.*;+import javax.ws.rs.core.Response;import static javax.ws.rs.core.MediaType.APPLICATION_JSON;@@ -84,5 +87,6 @@ public interface AssetsResource {@POST@Path("subscriber")@Consumes(APPLICATION_JSON)- void subscriberCallback(Entity[] entities);+ void subscriberCallback(@HeaderParam("Ngsiv2-AttrsFormat") NotificationFormat format, JsonObject notification);+}diff --git a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/ContextDiscovery.java b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/ContextDiscovery.javaindex 3888a55a6..05fd8cddf 100644--- a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/ContextDiscovery.java+++ b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/ContextDiscovery.java@@ -34,7 +34,7 @@ public class ContextDiscovery {this.entities = entities;}- public ContextDiscovery(@JsonProperty("entities") List<ContextEntity> entities, @JsonProperty("attributes") List<ContextAttribute> attributes) {+ public ContextDiscovery(@JsonProperty("entities") List<ContextEntity> entities, @JsonProperty("attrs") List<ContextAttribute> attributes) {this.entities = entities;this.attributes = attributes;}diff --git a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/ContextElement.java b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/ContextElement.javaindex 3287818e4..27707eb69 100644--- a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/ContextElement.java+++ b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/ContextElement.java@@ -28,7 +28,7 @@ public class ContextElement extends ContextEntity {@JsonIncludeprotected List<Attribute> attributes;- public ContextElement(@JsonProperty("type") String type, @JsonProperty("id") String id, @JsonProperty("pattern") boolean pattern, @JsonProperty("attributes") List<Attribute> attributes) {+ public ContextElement(@JsonProperty("type") String type, @JsonProperty("id") String id, @JsonProperty("pattern") boolean pattern, @JsonProperty("attrs") List<Attribute> attributes) {super(type, id, pattern);this.attributes = attributes;}diff --git a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/EntityAttributeListV1.java b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/EntityAttributeListV1.javaindex 5cd9a2a46..645ad92e2 100644--- a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/EntityAttributeListV1.java+++ b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/EntityAttributeListV1.java@@ -32,7 +32,7 @@ public class EntityAttributeListV1 {@JsonProperty(value = "providingApplication")protected String providerUri;- public EntityAttributeListV1(@JsonProperty("entities") List<ContextEntity> entities, @JsonProperty("attributes") List<ContextAttribute> attributes, @JsonProperty("providingApplication") String providerUri) {+ public EntityAttributeListV1(@JsonProperty("entities") List<ContextEntity> entities, @JsonProperty("attrs") List<ContextAttribute> attributes, @JsonProperty("providingApplication") String providerUri) {this.entities = entities;this.attributes = attributes;this.providerUri = providerUri;diff --git a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/EntityAttributeListV2.java b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/EntityAttributeListV2.javaindex 3aa8e3f0c..293d42fb8 100644--- a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/EntityAttributeListV2.java+++ b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/EntityAttributeListV2.java@@ -32,7 +32,7 @@ public class EntityAttributeListV2 {protected List<ContextAttribute> attributes;- public EntityAttributeListV2(@JsonProperty("entities") List<ContextEntity> entities, @JsonProperty("attributes") List<ContextAttribute> attributes) {+ public EntityAttributeListV2(@JsonProperty("entities") List<ContextEntity> entities, @JsonProperty("attrs") List<ContextAttribute> attributes) {this.entities = entities;this.attributes = attributes;}diff --git a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/EntityAttributeQuery.java b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/EntityAttributeQuery.javaindex 896f3ff81..1d213bd97 100644--- a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/EntityAttributeQuery.java+++ b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/EntityAttributeQuery.java@@ -30,7 +30,7 @@ public class EntityAttributeQuery {@JsonInclude(JsonInclude.Include.NON_NULL)protected List<String> attributes;- public EntityAttributeQuery(@JsonProperty("entities")List<ContextEntity> entities, @JsonProperty("attributes")List<String> attributes) {+ public EntityAttributeQuery(@JsonProperty("entities")List<ContextEntity> entities, @JsonProperty("attrs")List<String> attributes) {this.entities = entities;this.attributes = attributes;}diff --git a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/Notification.java b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/Notification.javanew file mode 100644index 000000000..6cfe5de58--- /dev/null+++ b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/Notification.java@@ -0,0 +1,43 @@+/*+ * Copyright 2016, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program 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 Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.manager.shared.ngsi;++import com.fasterxml.jackson.annotation.JsonInclude;+import com.fasterxml.jackson.annotation.JsonProperty;++public class Notification<T extends AbstractAttribute> {+ @JsonInclude+ protected String subscriptionId;+ @JsonInclude+ protected AbstractEntity<T> data;++ public Notification(@JsonProperty String subscriptionId, @JsonProperty AbstractEntity<T> data) {+ this.subscriptionId = subscriptionId;+ this.data = data;+ }++ public String getSubscriptionId() {+ return subscriptionId;+ }++ public AbstractEntity<T> getData() {+ return data;+ }+}diff --git a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/NotificationFormat.java b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/NotificationFormat.javanew file mode 100644index 000000000..ac7d3612b--- /dev/null+++ b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/NotificationFormat.java@@ -0,0 +1,35 @@+/*+ * Copyright 2016, OpenRemote Inc.+ *+ * See the CONTRIBUTORS.txt file in the distribution for a+ * full listing of individual contributors.+ *+ * This program is free software: you can redistribute it and/or modify+ * it under the terms of the GNU Affero General Public License as+ * published by the Free Software Foundation, either version 3 of the+ * License, or (at your option) any later version.+ *+ * This program 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 Affero General Public License for more details.+ *+ * You should have received a copy of the GNU Affero General Public License+ * along with this program. If not, see <http://www.gnu.org/licenses/>.+ */+package org.openremote.manager.shared.ngsi;++import com.fasterxml.jackson.annotation.JsonCreator;++public enum NotificationFormat {+ NORMALIZED,+ KEYVALUES,+ VALUES;++ @JsonCreator+ public static NotificationFormat fromString(String key) {+ return key == null+ ? null+ : NotificationFormat.valueOf(key.toUpperCase());+ }+}diff --git a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/params/Condition.java b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/params/Condition.javaindex 94b3d04a9..d5693018b 100644--- a/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/params/Condition.java+++ b/manager/shared/src/main/java/org/openremote/manager/shared/ngsi/params/Condition.java@@ -19,28 +19,59 @@*/package org.openremote.manager.shared.ngsi.params;-import com.fasterxml.jackson.annotation.JsonIgnore;import com.fasterxml.jackson.annotation.JsonInclude;import com.fasterxml.jackson.annotation.JsonProperty;+import com.fasterxml.jackson.core.JsonGenerator;+import com.fasterxml.jackson.databind.SerializerProvider;+import com.fasterxml.jackson.databind.annotation.JsonSerialize;+import com.fasterxml.jackson.databind.ser.std.StdSerializer;import org.openremote.manager.shared.ngsi.simplequery.Query;+import java.io.IOException;import java.util.ArrayList;-import java.util.Arrays;import java.util.List;+@JsonSerialize(using = Condition.ConditionSerialiser.class)public class Condition {- @JsonIgnore- protected List<String> attributes;+ public static class ConditionSerialiser extends StdSerializer<Condition> {+ public ConditionSerialiser() {+ this(null);+ }++ public ConditionSerialiser(Class<Condition> t) {+ super(t);+ }++ @Override+ public void serialize(Condition value, JsonGenerator gen, SerializerProvider provider) throws IOException {+ gen.writeStartObject();+ if (value.query != null) {+ gen.writeObjectFieldStart("expression");+ gen.writeObject(value.query);+ gen.writeEndObject();+ }+ gen.writeArrayFieldStart("attrs");+ for(String attr : value.attrs) {+ gen.writeString(attr);+ }+ gen.writeEndArray();+ gen.writeEndObject();+ }+ }++ // Unfortunately Jackson doesn't honour the always include for empty list (bug in Jackson https://github.com/FasterXML/jackson-databind/issues/1327)+ @JsonInclude(JsonInclude.Include.ALWAYS)+ protected List<String> attrs;@JsonProperty("expression")@JsonInclude(JsonInclude.Include.NON_NULL)protected Query query;public Condition() {- attributes = new ArrayList<>();+ attrs = new ArrayList<>();}public Condition(List<String> attributes) {- this.attributes = attributes;+ this.attrs = attributes;}public Condition(Query query) {@@ -48,24 +79,23 @@ public class Condition {}public Condition(List<String> attributes, Query query) {- this.attributes = attributes;+ this.attrs = attributes;this.query = query;}public List<String> getAttributes() {- return attributes;+ return attrs;}public Query getQuery() {return query;}- @JsonProperty("attrs")- @JsonInclude(JsonInclude.Include.ALWAYS)- protected String[] getAttributesArr() { return attributes == null ? new String[0] : attributes.toArray(new String[0]); }- @JsonProperty("attrs")- protected void setAttributesArr(String[] attributes) {- this.attributes = Arrays.asList(attributes);- }+// protected String[] getAttributesArr() { return attrs == null ? new String[0] : attrs.toArray(new String[0]); }+//+// @JsonProperty("attrs")+// protected void setAttributesArr(String[] attrs) {+// this.attrs = Arrays.asList(attrs);+// }}diff --git a/test/src/test/groovy/org/openremote/test/assets/AssetsServiceTest.groovy b/test/src/test/groovy/org/openremote/test/assets/AssetsServiceTest.groovyindex 43761e524..a79e9ca66 100644--- a/test/src/test/groovy/org/openremote/test/assets/AssetsServiceTest.groovy+++ b/test/src/test/groovy/org/openremote/test/assets/AssetsServiceTest.groovy@@ -55,7 +55,7 @@ class AssetsServiceTest extends Specification implements ContainerTrait {and: "the assets service is retrieved"def assetsService = container.getService(AssetsService.class);- when: "a mock asset provider with fake attributes is created"+ when: "a mock asset provider with fake attrs is created"def fakeAttributes = [new Attribute("temperature", AttributeType.FLOAT, Json.create(10.1)),new Attribute("speed", AttributeType.INTEGER, Json.create(50))@@ -138,7 +138,7 @@ class AssetsServiceTest extends Specification implements ContainerTrait {and: "the assets service is retrieved"def assetsService = container.getService(AssetsService.class);- when: "a mock asset provider with fake attributes is created"+ when: "a mock asset provider with fake attrs is created"def fakeAttributes = [new Attribute("temperature", AttributeType.FLOAT, Json.create(10.1)),new Attribute("speed", AttributeType.INTEGER, Json.create(50))@@ -277,12 +277,18 @@ class AssetsServiceTest extends Specification implements ContainerTrait {subscription.setEntities([new BasicEntityParams("Car.*", true)]);- subscription.setCondition(new Condition(["test"]))def result = assetsService.registerAssetListener(listener, subscription);then: "the mock listener is registered"result == true;+ and: "the mock listener should have been notified"+ def conditions = new PollingConditions(timeout: 10)++ conditions.eventually {+ assert receivedEntities.size() == 1;+ }+when: "the car speed is modified"def speed = car.getAttribute("speed");speed.setValue(Json.create(0))@@ -293,10 +299,8 @@ class AssetsServiceTest extends Specification implements ContainerTrait {assetsResource.patchEntityAttributes(null, car.getId(), carPatch);then: "the mock listener should have been notified"- def conditions = new PollingConditions(timeout: 10)-conditions.eventually {- assert receivedEntities.size() == 1;+ assert receivedEntities.size() == 2;}when: "the mock listener is unregistered"@@ -312,7 +316,7 @@ class AssetsServiceTest extends Specification implements ContainerTrait {then: "the mock listener should not have been notified"Thread.sleep(5000);- receivedEntities.size() == 1;+ receivedEntities.size() == 2;cleanup: "ensure mock listener is unregistered"if (assetsService != null)