use of org.xwiki.uiextension.internal.WikiUIExtensionParameters in project xwiki-platform by xwiki.
the class WikiUIExtensionParametersTest method getParametersWithAnEqualSignInAValue.
@Test
public void getParametersWithAnEqualSignInAValue() throws Exception {
when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("xwiki"));
when(velocityEngine.evaluate(any(VelocityContext.class), any(StringWriter.class), eq("id:key"), eq("value"))).thenReturn(true);
WikiUIExtensionParameters parameters = new WikiUIExtensionParameters("id", "key=value", componentManager);
// Since the StringWriter is created within the method, the value is "" and not "value".
Assert.assertEquals("", parameters.get().get("key"));
}
use of org.xwiki.uiextension.internal.WikiUIExtensionParameters in project xwiki-platform by xwiki.
the class WikiUIExtensionParametersTest method getParametersFromDifferentRequests.
@Test
public void getParametersFromDifferentRequests() throws Exception {
when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("wiki1"));
when(velocityEngine.evaluate(any(VelocityContext.class), any(StringWriter.class), eq("id:key"), eq("value"))).thenReturn(true);
WikiUIExtensionParameters parameters = new WikiUIExtensionParameters("id", "key=value", componentManager);
ExecutionContext ec1 = mock(ExecutionContext.class, "ec1");
ExecutionContext ec2 = mock(ExecutionContext.class, "ec2");
when(execution.getContext()).thenReturn(ec1).thenReturn(ec2);
// It should fail silently
Assert.assertEquals("", parameters.get().get("key"));
Assert.assertEquals("", parameters.get().get("key"));
// Verify the velocity evaluation has been done for both wikis.
verify(velocityEngine, times(2)).evaluate(any(VelocityContext.class), any(StringWriter.class), eq("id:key"), eq("value"));
}
use of org.xwiki.uiextension.internal.WikiUIExtensionParameters in project xwiki-platform by xwiki.
the class WikiUIExtensionParametersTest method getParametersWithAnEmptyParametersProperty.
@Test
public void getParametersWithAnEmptyParametersProperty() throws Exception {
when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("xwiki"));
WikiUIExtensionParameters parameters = new WikiUIExtensionParameters("id", "", componentManager);
Assert.assertEquals(MapUtils.EMPTY_MAP, parameters.get());
}
use of org.xwiki.uiextension.internal.WikiUIExtensionParameters in project xwiki-platform by xwiki.
the class WikiUIExtensionParametersTest method getParametersFromTheSameRequestButForDifferentWikis.
@Test
public void getParametersFromTheSameRequestButForDifferentWikis() throws Exception {
when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("wiki1")).thenReturn(new WikiReference("wiki2"));
when(velocityEngine.evaluate(any(VelocityContext.class), any(StringWriter.class), eq("id:key"), eq("value"))).thenReturn(true);
WikiUIExtensionParameters parameters = new WikiUIExtensionParameters("id", "key=value", componentManager);
// It should fail silently
Assert.assertEquals("", parameters.get().get("key"));
Assert.assertEquals("", parameters.get().get("key"));
// Verify the velocity evaluation has been done for both wikis.
verify(velocityEngine, times(2)).evaluate(any(VelocityContext.class), any(StringWriter.class), eq("id:key"), eq("value"));
}
use of org.xwiki.uiextension.internal.WikiUIExtensionParameters in project xwiki-platform by xwiki.
the class WikiUIExtensionParametersTest method getParametersFromTheSameRequestAndForTheSameWiki.
@Test
public void getParametersFromTheSameRequestAndForTheSameWiki() throws Exception {
when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("xwiki"));
when(velocityEngine.evaluate(any(VelocityContext.class), any(StringWriter.class), eq("id:key"), eq("value"))).thenReturn(true);
WikiUIExtensionParameters parameters = new WikiUIExtensionParameters("id", "key=value", componentManager);
// It should fail silently
Assert.assertEquals("", parameters.get().get("key"));
Assert.assertEquals("", parameters.get().get("key"));
// Verify the evaluate is done only once
verify(velocityEngine).evaluate(any(VelocityContext.class), any(StringWriter.class), eq("id:key"), eq("value"));
}
Aggregations