3

I tried this simple unit test but got not what I expected:

@Test
  public void testReadPowerpoint() throws Exception {
    PowerPointSystem pps=new PowerPointSystem();
    pps.connect();
    SimpleNode slideShowNode =
 pps.moveTo("https://www.its.leeds.ac.uk/fileadmin/documents/alumni/Michele_Dix_Leeds_University_-_FINAL.PPTX");
    List<SimpleNode> slides = slideShowNode.out("slides")
        .collect(Collectors.toCollection(ArrayList::new));
    debug=true;
    if (debug)
      slides.forEach(slide -> slide.printNameValues(System.out));
    assertEquals(44, slides.size());
  }

Does not work - i get 0 slides instead of 44. Is this a bug or exists a workaround?

1 Answers1

3

My name is Wolfgang Fahl i am one of the committers of the SimpleGraph OpenSource Project.

I would consider this a bug/missing feature. The base question is what parameters moveTo should accept in the case of file/inputstream based modules. Powerpoint files can be read from any input inputstream with the Apache POI module. SimpleGraph needs a consistent way of handling the different cases of input and I think this is a valid discussion that should be done in the SimpleGraph dicussion group.

To fix your current issue I modified the code as a work around to make sure the Unit Tests runs and added your Unit Test to TestPowerPoint.

Current Workaround

The following is part of the Commit to fix your issue

/**
   * create a SlideShow
   * 
   * @param simpleGraph
   * @param nodeQuery
   * @throws Exception
   */
  public SlideShowNode(SimpleGraph simpleGraph, String pathOrUrl,
      String... keys) {
    super(simpleGraph, "slideshow", keys);
    InputStream is = null;
    try {
      try {
        URL url = new URL(pathOrUrl);
        is = url.openStream();
      } catch (MalformedURLException e1) {
        this.pathOrUl = pathOrUrl;
        pptFile = new File(pathOrUl);
        if (pptFile.canRead())
          is = new FileInputStream(pathOrUl);
      }
      if (is != null)
        slideshow = new XMLSlideShow(is);
      else
        slideshow = new XMLSlideShow();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    super.setVertexFromMap();
  }
Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186