Skip to content

Commit

Permalink
XWIKI-22702: Provide parentType information in EntityReference
Browse files Browse the repository at this point in the history
  * Minor improvment
  • Loading branch information
surli committed Dec 3, 2024
1 parent c5b9c60 commit a5f4f86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;

Expand Down Expand Up @@ -325,7 +326,7 @@ private void setParentTypeParameter(Serializable value)
if (value instanceof EntityType entityType) {
parentType = entityType;
} else {
parentType = EntityType.valueOf(value.toString());
parentType = EntityType.valueOf(value.toString().toUpperCase(Locale.ROOT));
}
if (getType().getAllowedParents().contains(parentType)) {
this.parameters.put(PARENT_TYPE_PARAMETER, parentType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,5 +673,10 @@ void getParentType()
exception = assertThrows(IllegalArgumentException.class, () ->
new EntityReference(SPACE_NAME, EntityType.SPACE, parametersMap2));
assertEquals("No enum constant org.xwiki.model.EntityType.42", exception.getMessage());

// custom type lowercase
spaceReference = new EntityReference(SPACE_NAME, EntityType.SPACE,
Map.of(EntityReference.PARENT_TYPE_PARAMETER, "space"));
assertEquals(EntityType.SPACE, spaceReference.getParentType());
}
}

0 comments on commit a5f4f86

Please sign in to comment.