Search in sources :

Example 6 with SlideShow

use of org.apache.poi.hslf.usermodel.SlideShow in project ddf by codice.

the class MetricsEndpointTest method testGetMetricsDataAsPpt.

@Test
public void testGetMetricsDataAsPpt() throws Exception {
    // Create RRD file that Metrics Endpoint will detect
    // 15 minutes in seconds
    int dateOffset = 900;
    createRrdFile(dateOffset);
    UriInfo uriInfo = createUriInfo();
    // Get the metrics data from the endpoint
    MetricsEndpoint endpoint = getEndpoint();
    endpoint.setMetricsDir(TEST_DIR);
    Response response = endpoint.getMetricsData("uptime", "ppt", null, null, Integer.toString(dateOffset), "my label", "my title", uriInfo);
    cleanupRrd();
    InputStream is = (InputStream) response.getEntity();
    assertThat(is, not(nullValue()));
    SlideShow ppt = new SlideShow(is);
    Slide[] slides = ppt.getSlides();
    assertThat(slides.length, equalTo(1));
}
Also used : Response(javax.ws.rs.core.Response) Slide(org.apache.poi.hslf.model.Slide) InputStream(java.io.InputStream) SlideShow(org.apache.poi.hslf.usermodel.SlideShow) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Example 7 with SlideShow

use of org.apache.poi.hslf.usermodel.SlideShow in project ddf by codice.

the class MetricsEndpointTest method testGetMetricsReportAsPpt.

@Test
public void testGetMetricsReportAsPpt() throws Exception {
    // Create RRD file that Metrics Endpoint will detect
    // 15 minutes in seconds
    int dateOffset = 900;
    createRrdFile(dateOffset, "uptime");
    UriInfo uriInfo = createUriInfo();
    // Get the metrics data from the endpoint
    MetricsEndpoint endpoint = getEndpoint();
    endpoint.setMetricsDir(TEST_DIR);
    Response response = endpoint.getMetricsReport("ppt", null, null, Integer.toString(dateOffset), null, uriInfo);
    cleanupRrd();
    MultivaluedMap<String, Object> headers = response.getHeaders();
    assertTrue(headers.getFirst("Content-Disposition").toString().contains("attachment; filename="));
    InputStream is = (InputStream) response.getEntity();
    assertThat(is, not(nullValue()));
    SlideShow ppt = new SlideShow(is);
    Slide[] slides = ppt.getSlides();
    assertThat(slides.length, equalTo(1));
}
Also used : Response(javax.ws.rs.core.Response) Slide(org.apache.poi.hslf.model.Slide) InputStream(java.io.InputStream) SlideShow(org.apache.poi.hslf.usermodel.SlideShow) JSONObject(org.json.simple.JSONObject) Matchers.anyString(org.mockito.Matchers.anyString) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test)

Aggregations

SlideShow (org.apache.poi.hslf.usermodel.SlideShow)7 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 InputStream (java.io.InputStream)5 Slide (org.apache.poi.hslf.model.Slide)5 Test (org.junit.Test)5 MetricsRetriever (ddf.metrics.reporting.internal.MetricsRetriever)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 OutputStream (java.io.OutputStream)3 Response (javax.ws.rs.core.Response)2 UriInfo (javax.ws.rs.core.UriInfo)2 ArrayList (java.util.ArrayList)1 JSONObject (org.json.simple.JSONObject)1 Matchers.anyString (org.mockito.Matchers.anyString)1