diff --git a/pom.xml b/pom.xml
index cd224349..8b0ca392 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.symphonyoss.symphony
messageml
- 0.10.1
+ 0.10.2
MessageML Utils
https://github.com/finos/messageml-utils
A set of utilities for parsing, processing and rendering of MessageML messages
diff --git a/src/main/java/org/symphonyoss/symphony/messageml/MessageMLParser.java b/src/main/java/org/symphonyoss/symphony/messageml/MessageMLParser.java
index 1243d2b9..46c6495f 100644
--- a/src/main/java/org/symphonyoss/symphony/messageml/MessageMLParser.java
+++ b/src/main/java/org/symphonyoss/symphony/messageml/MessageMLParser.java
@@ -17,6 +17,7 @@
import org.apache.commons.lang3.tuple.Pair;
import org.symphonyoss.symphony.messageml.bi.BiContext;
import org.symphonyoss.symphony.messageml.bi.BiFields;
+import org.symphonyoss.symphony.messageml.bi.BiItem;
import org.symphonyoss.symphony.messageml.elements.Bold;
import org.symphonyoss.symphony.messageml.elements.BulletList;
import org.symphonyoss.symphony.messageml.elements.Button;
@@ -89,6 +90,7 @@
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -214,6 +216,7 @@ private void parseEntityJson(String entityJson) throws InvalidInputException {
} else {
throw new InvalidInputException("Error parsing EntityJSON: provided content is not a JSON object");
}
+ addCustomEntitiesToBiContext(jsonNode);
} catch (JsonProcessingException e) {
throw new InvalidInputException("Error parsing EntityJSON: " + e.getMessage());
}
@@ -222,6 +225,19 @@ private void parseEntityJson(String entityJson) throws InvalidInputException {
}
}
+ /**
+ * For each custom entity found in the entityJson payload we:
+ * - create a BiItem containing the type of entity found
+ * - increase the total count of entities found in the message
+ */
+ private void addCustomEntitiesToBiContext(JsonNode entityNode) {
+ entityNode.findValues(Entity.TYPE_FIELD).forEach(entityType -> {
+ biContext.updateItemCount(BiFields.ENTITIES.getValue());
+ biContext.addItem(new BiItem(BiFields.ENTITY.getValue(),
+ Collections.singletonMap(BiFields.ENTITY_TYPE.getValue(), entityType.asText())));
+ });
+ }
+
/**
* Retrieve a JSON representation of entity data (EntityJSON).
*/
diff --git a/src/test/java/org/symphonyoss/symphony/messageml/MessageMLContextTest.java b/src/test/java/org/symphonyoss/symphony/messageml/MessageMLContextTest.java
index 85702426..019c480a 100644
--- a/src/test/java/org/symphonyoss/symphony/messageml/MessageMLContextTest.java
+++ b/src/test/java/org/symphonyoss/symphony/messageml/MessageMLContextTest.java
@@ -518,7 +518,7 @@ public void testGetBiContextFromMessageMLWithStyles() throws Exception {
List expectedBiItems = getExpectedBiItems();
List biItems = context.getBiContext().getItems();
- assertEquals(biItems.size(), expectedBiItems.size());
+ assertEquals(expectedBiItems.size(), biItems.size());
assertTrue(biItems.containsAll(expectedBiItems));
assertTrue(expectedBiItems.containsAll(biItems));
}
@@ -535,7 +535,7 @@ private List getExpectedBiItems() {
biItems.add(
new BiItem(BiFields.MENTIONS.getValue(), Collections.singletonMap(BiFields.COUNT.getValue(), 1)));
biItems.add(new BiItem(BiFields.CARD.getValue(), Collections.singletonMap(BiFields.COUNT.getValue(), 1)));
- biItems.add(new BiItem(BiFields.ENTITIES.getValue(), Collections.singletonMap(BiFields.COUNT.getValue(), 1)));
+ biItems.add(new BiItem(BiFields.ENTITIES.getValue(), Collections.singletonMap(BiFields.COUNT.getValue(), 10)));
biItems.add(
new BiItem(BiFields.STYLES_CUSTOM.getValue(), Collections.singletonMap(BiFields.COUNT.getValue(), 1)));
biItems.add(new BiItem(BiFields.STYLES_CLASS_OTHER.getValue(),
@@ -549,6 +549,24 @@ private List getExpectedBiItems() {
Collections.singletonMap(BiFields.COUNT.getValue(), 2984)));
biItems.add(new BiItem(BiFields.ENTITY.getValue(),
Collections.singletonMap(BiFields.ENTITY_TYPE.getValue(), "com.symphony.user.mention")));
+ biItems.add(new BiItem(BiFields.ENTITY.getValue(),
+ Collections.singletonMap(BiFields.ENTITY_TYPE.getValue(), "com.symphony.integration.jira.event.v2.state")));
+ biItems.add(new BiItem(BiFields.ENTITY.getValue(),
+ Collections.singletonMap(BiFields.ENTITY_TYPE.getValue(), "com.symphony.integration.user")));
+ biItems.add(new BiItem(BiFields.ENTITY.getValue(),
+ Collections.singletonMap(BiFields.ENTITY_TYPE.getValue(), "com.symphony.integration.jira.label")));
+ biItems.add(new BiItem(BiFields.ENTITY.getValue(),
+ Collections.singletonMap(BiFields.ENTITY_TYPE.getValue(), "com.symphony.integration.jira.issue")));
+ biItems.add(new BiItem(BiFields.ENTITY.getValue(),
+ Collections.singletonMap(BiFields.ENTITY_TYPE.getValue(), "com.symphony.integration.icon")));
+ biItems.add(new BiItem(BiFields.ENTITY.getValue(),
+ Collections.singletonMap(BiFields.ENTITY_TYPE.getValue(), "com.symphony.integration.jira.priority")));
+ biItems.add(new BiItem(BiFields.ENTITY.getValue(),
+ Collections.singletonMap(BiFields.ENTITY_TYPE.getValue(), "com.symphony.integration.user")));
+ biItems.add(new BiItem(BiFields.ENTITY.getValue(),
+ Collections.singletonMap(BiFields.ENTITY_TYPE.getValue(), "com.symphony.integration.jira.issueType")));
+ biItems.add(new BiItem(BiFields.ENTITY.getValue(),
+ Collections.singletonMap(BiFields.ENTITY_TYPE.getValue(), "com.symphony.integration.jira.label")));
return biItems;
}