示例#1
0
 /** Test of draw method, of class EventsTreeAdapter. */
 @Test
 public void testDraw() {
   int width = 500, height = 500;
   //        Map<String, Object> edge2 = new HashMap<String, Object> ();
   //        edge2.put(mxConstants.STYLE_EXIT_X, "0.5");
   //        edge2.put(mxConstants.STYLE_EXIT_Y, "1");
   System.out.println("draw");
   mxGraphComponent mxGraphComponent1 = new mxGraphComponent(new mxGraph());
   mxGraphComponent1.setBounds(0, 0, width, height);
   expect(drawPanel.getComponents()).andReturn(new Component[] {mxGraphComponent1}).anyTimes();
   replay(drawPanel);
   //        expect(tree.getEvents()).andReturn(new HashMap<Integer, Event>()).anyTimes();
   //        expect(tree.getEdges()).andReturn(new HashMap<Integer, Edge>()).anyTimes();
   //        replay(tree);
   instance.draw(drawPanel);
   eventTreeUtil = new EventTreeUtil(drawPanel);
   assertNotNull(eventTreeUtil.getCellByID("" + 2));
   assertNotNull(eventTreeUtil.getCellByID("E" + 0));
   assertTrue(eventTreeUtil.getCellByID("" + 2).getGeometry().getWidth() == (double) (width / 2));
   //        mxCellState targetState =
   // mxGraphComponent1.getGraph().getView().getState(eventTreeUtil.getCellByID("final"));
   //        mxCellState edgeState =
   // mxGraphComponent1.getGraph().getView().getState(eventTreeUtil.getCellByID("E"+0));
   //        edgeState.setStyle(edge2);
   //        mxConnectionConstraint connectionConstraint =
   // mxGraphComponent1.getGraph().getConnectionConstraint(edgeState, targetState, false);
   //        assertTrue(connectionConstraint.getPoint().equals(new mxPoint(0.5, 0.5)));
   instance.draw(drawPanel);
   assertNotNull(eventTreeUtil.getCellByID("" + 3));
   assertNotNull(eventTreeUtil.getCellByID("E" + 1));
   assertNotNull(eventTreeUtil.getCellByID("E" + 2));
   assertTrue(eventTreeUtil.getCellByID("" + 2).getGeometry().getWidth() == (double) (width / 3));
 }
示例#2
0
 /** Test of removeEdge method, of class EventsTreeAdapter. */
 @Test(expected = NullPointerException.class)
 public void testRemoveEdge() {
   int width = 500, height = 500;
   System.out.println("removeEdge");
   mxGraphComponent mxGraphComponent1 = new mxGraphComponent(new mxGraph());
   mxGraphComponent1.setBounds(0, 0, width, height);
   expect(drawPanel.getComponents()).andReturn(new Component[] {mxGraphComponent1}).anyTimes();
   replay(drawPanel);
   instance.draw(drawPanel);
   instance.draw(drawPanel);
   instance.draw(drawPanel);
   eventTreeUtil = new EventTreeUtil(drawPanel);
   instance.removeEdge(eventTreeUtil.getCellByID("E" + 2));
   try {
     assertNull(eventTreeUtil.getCellByID("E" + 2));
     fail("Nie usunieto 2.");
   } catch (NullPointerException exception) {
     try {
       assertNull(eventTreeUtil.getCellByID("E" + 5));
       fail("Nie usunieto 5.");
     } catch (NullPointerException ex) {
       assertNull(eventTreeUtil.getCellByID("E" + 6));
     }
   }
 }
示例#3
0
 /** Test of removeVertex method, of class EventsTreeAdapter. */
 public void testRemoveVertex() {
   int width = 500, height = 500;
   System.out.println("removeVertex");
   mxGraphComponent mxGraphComponent1 = new mxGraphComponent(new mxGraph());
   mxGraphComponent1.setBounds(0, 0, width, height);
   expect(drawPanel.getComponents()).andReturn(new Component[] {mxGraphComponent1}).anyTimes();
   replay(drawPanel);
   instance.draw(drawPanel);
   instance.draw(drawPanel);
   instance.draw(drawPanel);
   instance.removeVertex(eventTreeUtil.getCellByID("" + 3));
   String str = checkIfAllGettersThrowNull("" + 3, "" + 4);
   //        assertNull(eventTreeUtil.getCellByID(""+3));
   //        assertNull(eventTreeUtil.getCellByID(""+4));
   if (str != null) {
     fail(str);
   }
   assertNull(str);
 }