コード例 #1
0
  /**
   * Tests common to all file types.
   *
   * @param file project file
   */
  private void testEmbeddedObjects(ProjectFile file) {
    Task task = file.getTaskByID(Integer.valueOf(1));
    assertEquals("Task 1", task.getName());
    String notes = task.getNotes();
    assertNotNull(notes);
    List<List<RTFEmbeddedObject>> list = RTFEmbeddedObject.getEmbeddedObjects(notes);
    assertNull(list);

    task = file.getTaskByID(Integer.valueOf(2));
    assertEquals("Task 2", task.getName());
    notes = task.getNotes();
    assertNotNull(notes);
    list = RTFEmbeddedObject.getEmbeddedObjects(notes);
    assertNotNull(list);
    assertEquals(1, list.size());
    List<RTFEmbeddedObject> objectList = list.get(0);
    assertEquals(4, objectList.size());
    assertEquals("Package", new String(objectList.get(0).getData(), 0, 7));
    assertEquals("METAFILEPICT", new String(objectList.get(2).getData(), 0, 12));

    task = file.getTaskByID(Integer.valueOf(3));
    assertEquals("Task 3", task.getName());
    notes = task.getNotes();
    assertNotNull(notes);
    list = RTFEmbeddedObject.getEmbeddedObjects(notes);
    assertNotNull(list);
    assertEquals(1, list.size());
    objectList = list.get(0);
    assertEquals(4, objectList.size());
    assertEquals("Package", new String(objectList.get(0).getData(), 0, 7));
    assertEquals("METAFILEPICT", new String(objectList.get(2).getData(), 0, 12));

    task = file.getTaskByID(Integer.valueOf(4));
    assertEquals("Task 4", task.getName());
    notes = task.getNotes();
    assertNotNull(notes);
    list = RTFEmbeddedObject.getEmbeddedObjects(notes);
    assertNotNull(list);
    assertEquals(1, list.size());
    objectList = list.get(0);
    assertEquals(4, objectList.size());
    assertEquals("Package", new String(objectList.get(0).getData(), 0, 7));
    assertEquals("METAFILEPICT", new String(objectList.get(2).getData(), 0, 12));

    task = file.getTaskByID(Integer.valueOf(5));
    assertEquals("Task 5", task.getName());
    notes = task.getNotes();
    assertNotNull(notes);
    list = RTFEmbeddedObject.getEmbeddedObjects(notes);
    assertNotNull(list);
    assertEquals(1, list.size());
    objectList = list.get(0);
    assertEquals(4, objectList.size());
    assertEquals("Package", new String(objectList.get(0).getData(), 0, 7));
    assertEquals("METAFILEPICT", new String(objectList.get(2).getData(), 0, 12));

    task = file.getTaskByID(Integer.valueOf(6));
    assertEquals("Task 6", task.getName());
    notes = task.getNotes();
    assertNotNull(notes);
    list = RTFEmbeddedObject.getEmbeddedObjects(notes);
    assertNotNull(list);
    assertEquals(2, list.size());
    objectList = list.get(0);
    assertEquals(4, objectList.size());
    assertEquals("Package", new String(objectList.get(0).getData(), 0, 7));
    assertEquals("METAFILEPICT", new String(objectList.get(2).getData(), 0, 12));
    objectList = list.get(1);
    assertEquals(4, objectList.size());
    assertEquals("Package", new String(objectList.get(0).getData(), 0, 7));
    assertEquals("METAFILEPICT", new String(objectList.get(2).getData(), 0, 12));

    task = file.getTaskByID(Integer.valueOf(7));
    assertEquals("Task 7", task.getName());
    notes = task.getNotes();
    assertNotNull(notes);
    list = RTFEmbeddedObject.getEmbeddedObjects(notes);
    assertNotNull(list);
    assertEquals(2, list.size());
    objectList = list.get(0);
    assertEquals(4, objectList.size());
    assertEquals("Package", new String(objectList.get(0).getData(), 0, 7));
    assertEquals("METAFILEPICT", new String(objectList.get(2).getData(), 0, 12));
    objectList = list.get(1);
    assertEquals(4, objectList.size());
    assertEquals("Package", new String(objectList.get(0).getData(), 0, 7));
    assertEquals("METAFILEPICT", new String(objectList.get(2).getData(), 0, 12));
  }
コード例 #2
0
ファイル: SlackTest.java プロジェクト: tmyroadctfig/mpxj
  /**
   * Exercise slack duration functionality.
   *
   * @throws Exception
   */
  public void testSlack() throws Exception {
    ProjectFile mpp = new MPPReader().read(m_basedir + "/slack9.mpp");
    Task task = mpp.getTaskByID(Integer.valueOf(1));
    assertEquals("Task 1", task.getName());
    assertEquals(Duration.getInstance(8, TimeUnit.HOURS), task.getDuration());
    assertEquals(Duration.getInstance(40, TimeUnit.HOURS), task.getStartSlack());
    assertEquals(Duration.getInstance(40, TimeUnit.HOURS), task.getFinishSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.HOURS), task.getFreeSlack());
    assertEquals(Duration.getInstance(40, TimeUnit.HOURS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(2));
    assertEquals("Task 2", task.getName());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(3));
    assertEquals("Task 3", task.getName());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(10, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(10, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(10, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(4));
    assertEquals("Task 4", task.getName());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(5));
    assertEquals("Milestone 1", task.getName());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(6));
    assertEquals("Task 5", task.getName());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(-1, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(-1, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(-1, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(7));
    assertEquals("Task 6", task.getName());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(-1, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(-1, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(-1, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(8));
    assertEquals("Task 7", task.getName());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(-1, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(-1, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(-1, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(9));
    assertEquals("Task 8", task.getName());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(4, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(4, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(4, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(4, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(10));
    assertEquals("Milestone 2", task.getName());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(-1, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(-1, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(11));
    assertEquals("Task 9", task.getName());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(12));
    assertEquals("Task 10", task.getName());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(13));
    assertEquals("Task 11", task.getName());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(14));
    assertEquals("Task 12", task.getName());
    assertEquals(Duration.getInstance(5, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(6, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(6, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(6, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(6, TimeUnit.DAYS), task.getTotalSlack());

    task = mpp.getTaskByID(Integer.valueOf(15));
    assertEquals("Milestone 3", task.getName());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getDuration());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getStartSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFinishSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getFreeSlack());
    assertEquals(Duration.getInstance(0, TimeUnit.DAYS), task.getTotalSlack());
  }