Search in sources :

Example 6 with WikiUIExtensionParameters

use of org.xwiki.uiextension.internal.WikiUIExtensionParameters in project xwiki-platform by xwiki.

the class WikiUIExtensionParametersTest method getParametersWhenVelocityFails.

@Test
public void getParametersWhenVelocityFails() throws Exception {
    when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("xwiki"));
    when(velocityEngine.evaluate(any(VelocityContext.class), any(StringWriter.class), eq("id:key"), eq("value"))).thenThrow(new XWikiVelocityException(""));
    WikiUIExtensionParameters parameters = new WikiUIExtensionParameters("id", "key=value", componentManager);
    // It should fail and put a warn in the logs
    Assert.assertEquals(null, parameters.get().get("key"));
    Assert.assertTrue(logRule.contains("Failed to evaluate UI extension data value, key [key], value [value]. Reason: []"));
}
Also used : XWikiVelocityException(org.xwiki.velocity.XWikiVelocityException) StringWriter(java.io.StringWriter) WikiUIExtensionParameters(org.xwiki.uiextension.internal.WikiUIExtensionParameters) VelocityContext(org.apache.velocity.VelocityContext) WikiReference(org.xwiki.model.reference.WikiReference) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 WikiReference (org.xwiki.model.reference.WikiReference)6 WikiUIExtensionParameters (org.xwiki.uiextension.internal.WikiUIExtensionParameters)6 StringWriter (java.io.StringWriter)5 VelocityContext (org.apache.velocity.VelocityContext)5 ExecutionContext (org.xwiki.context.ExecutionContext)1 XWikiVelocityException (org.xwiki.velocity.XWikiVelocityException)1