Search in sources :

Example 1 with ChartMacroParameters

use of org.xwiki.rendering.macro.chart.ChartMacroParameters in project xwiki-platform by xwiki.

the class ImageIdTest method testGetIdWithSameParametersButDifferentInstances.

/**
 * Verify id are different even when using same parameters (but different instances of parameters).
 */
@Test
public void testGetIdWithSameParametersButDifferentInstances() {
    ChartMacroParameters parameters1 = new ChartMacroParameters();
    ChartMacroParameters parameters2 = new ChartMacroParameters();
    Assert.assertFalse(new ImageId(parameters1).getId().equals(new ImageId(parameters2).getId()));
}
Also used : ChartMacroParameters(org.xwiki.rendering.macro.chart.ChartMacroParameters) Test(org.junit.Test)

Example 2 with ChartMacroParameters

use of org.xwiki.rendering.macro.chart.ChartMacroParameters in project xwiki-platform by xwiki.

the class TemporaryChartImageWriterTest method getStorageLocation.

@Test
public void getStorageLocation() throws Exception {
    WikiReference currentWikiReference = new WikiReference("wiki");
    ModelContext modelContext = this.componentManager.getInstance(ModelContext.class);
    when(modelContext.getCurrentEntityReference()).thenReturn(currentWikiReference);
    Environment environment = this.componentManager.getInstance(Environment.class);
    when(environment.getTemporaryDirectory()).thenReturn(new File("/tmpdir"));
    File location = this.componentManager.getComponentUnderTest().getStorageLocation(new ImageId(new ChartMacroParameters()));
    Assert.assertTrue("Got: " + location.toString(), location.toString().matches("/tmpdir/temp/chart/wiki/space/page/.*\\.png"));
}
Also used : ModelContext(org.xwiki.model.ModelContext) ChartMacroParameters(org.xwiki.rendering.macro.chart.ChartMacroParameters) Environment(org.xwiki.environment.Environment) WikiReference(org.xwiki.model.reference.WikiReference) File(java.io.File) Test(org.junit.Test)

Example 3 with ChartMacroParameters

use of org.xwiki.rendering.macro.chart.ChartMacroParameters in project xwiki-platform by xwiki.

the class TemporaryChartImageWriterTest method getURL.

@Test
public void getURL() throws Exception {
    WikiReference currentWikiReference = new WikiReference("wiki");
    ModelContext modelContext = this.componentManager.getInstance(ModelContext.class);
    when(modelContext.getCurrentEntityReference()).thenReturn(currentWikiReference);
    DocumentAccessBridge dab = this.componentManager.getInstance(DocumentAccessBridge.class);
    when(dab.getDocumentURL(new DocumentReference("wiki", "space", "page"), "temp", null, null)).thenReturn("temp/Space/Page");
    String location = this.componentManager.getComponentUnderTest().getURL(new ImageId(new ChartMacroParameters()));
    Assert.assertTrue("Got: " + location, location.toString().matches("temp/Space/Page/chart/.*\\.png"));
}
Also used : ModelContext(org.xwiki.model.ModelContext) ChartMacroParameters(org.xwiki.rendering.macro.chart.ChartMacroParameters) DocumentAccessBridge(org.xwiki.bridge.DocumentAccessBridge) WikiReference(org.xwiki.model.reference.WikiReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 ChartMacroParameters (org.xwiki.rendering.macro.chart.ChartMacroParameters)3 ModelContext (org.xwiki.model.ModelContext)2 WikiReference (org.xwiki.model.reference.WikiReference)2 File (java.io.File)1 DocumentAccessBridge (org.xwiki.bridge.DocumentAccessBridge)1 Environment (org.xwiki.environment.Environment)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1