Package de.hpi.eworld.model.db.data

Examples of de.hpi.eworld.model.db.data.NodeModel


   */
  @Test
  public void testEdgeCreation() {
    //////////// test constructor EdgeModel(fromNode, toNode) ////////////
    //initialize constructor parameters
    NodeModel fromNode = TestCaseUtil.createTestNode();
    NodeModel toNode = TestCaseUtil.createTestNode();
    //construct edge
    EdgeModel edge = TestCaseUtil.createTestEdge(fromNode, toNode);
    Assert.assertEquals(fromNode, edge.getFromNode());
    Assert.assertEquals(toNode, edge.getToNode());
    Assert.assertTrue(fromNode.getUsedBy().contains(edge));
    Assert.assertTrue(toNode.getUsedBy().contains(edge));
   
    //////////// test constructor EdgeModel(fromNode, toNode, parentWay, priority, maxSpeed) ////////////
    //initialize constructor parameters
    WayModel parentWay = new WayModel("test");
    //construct edge
    edge = new EdgeModel(fromNode, toNode, parentWay, 1, 100);
    Assert.assertEquals(fromNode, edge.getFromNode());
    Assert.assertEquals(toNode, edge.getToNode());
    Assert.assertTrue(fromNode.getUsedBy().contains(edge));
    Assert.assertTrue(toNode.getUsedBy().contains(edge));
    Assert.assertEquals(1, edge.getPriority());
    Assert.assertEquals(parentWay, edge.getParentWay());
    Assert.assertEquals(100, edge.getMaxspeed());
  }
View Full Code Here


   * @return The created node.
   */
  public static NodeModel createTestNode() {
    double lat = (100 * Math.random() % 1);
    double longitude = (100 * Math.random() % 1);
    NodeModel resultNode = new NodeModel(lat, longitude);
    return resultNode;
  }
View Full Code Here

  /**
   * Creates an edge with a random global position.
   * @return The created edge.
   */
  public static EdgeModel createTestEdge() {
    NodeModel n1 = createTestNode();
    NodeModel n2 = createTestNode();

    return createTestEdge(n1, n2);
  }
View Full Code Here

  public static ArrayList<ModelElement> createSampleTestcase() {
    ArrayList<ModelElement> allModelElements = new ArrayList<ModelElement>();

    // create nodes
    NodeModel[] n = new NodeModel[16];
    n[0] = new NodeModel(3.0, 0.0);
    n[1] = new NodeModel(1.0, 1.0);
    n[2] = new NodeModel(2.0, 1.0);
    n[3] = new NodeModel(3.0, 1.0);
    n[4] = new NodeModel(4.0, 1.0);
    n[5] = new NodeModel(4.0, 2.0);
    n[6] = new NodeModel(5.0, 2.0);
    n[7] = new NodeModel(1.0, 3.0);
    n[8] = new NodeModel(2.0, 3.0);
    n[9] = new NodeModel(3.0, 3.0);
    n[10] = new NodeModel(4.0, 3.0);
    n[11] = new NodeModel(2.0, 4.0);
    n[12] = new NodeModel(3.0, 4.0);
    n[13] = new NodeModel(4.0, 4.0);
    n[14] = new NodeModel(5.0, 4.0);
    n[15] = new NodeModel(3.0, 5.0);

    // create ways
    WayModel[] w = new WayModel[25];
    for (int i = 0; i < w.length; i++) {
      w[i] = new WayModel("Road " + i);
    }

    // create traffic lights
    TrafficLightModel[] tl = new TrafficLightModel[2];
    NodeModel[] tln = new NodeModel[2];
    tln[0] = new NodeModel(2.0, 2.0);
    tln[1] = new NodeModel(3.0, 2.0);
    tl[0] = new TrafficLightModel(tln[0]);
    tl[1] = new TrafficLightModel(tln[1]);

    // create street network
    EdgeModel[] e = new EdgeModel[50];
View Full Code Here

   * Tests initialization and methods of
   * de.hpi.eworld.model.db.data.event.EdgeLocation
   */
  @Test
  public void testEdgeLocation () {
    NodeModel fromNode = new NodeModel(2.3, 45,6);
    NodeModel toNode = new NodeModel(45.22, 78.899);
   
    EdgeModel e = new EdgeModel("testModelID", fromNode, toNode);
    EdgeLocationModel el1 = new EdgeLocationModel(e, -12.3, -55.67);
    EdgeLocationModel el2 = new EdgeLocationModel(e, 12.3, 55.67);
   
View Full Code Here

   
   
    ///////////////////////////////////
    // set up EdgeLocation
   
    NodeModel fromNode = new NodeModel(2.3, 45,6);
    NodeModel toNode = new NodeModel(45.22, 78.899);
   
    EdgeModel e = new EdgeModel("testModelID", fromNode, toNode);
    EdgeLocationModel el1 = new EdgeLocationModel(e, -12.3, -55.67);
    EdgeLocationModel el2 = new EdgeLocationModel(e, 12.3, 55.67);
   
View Full Code Here

    Assert.assertNotNull(timeline);
  }
 
  @Test
  public void testSetEvent() {
    NodeModel from = new NodeModel(0, 0);
    NodeModel to = new NodeModel(1, 1);
    EdgeModel e = new EdgeModel("testModelID", from, to);
    EdgeLocationModel edgeLocation = new EdgeLocationModel(e, 0, 0);
    RoadEventModel roadEvent = new RoadEventModel(RoadEventModel.Type.Accident, edgeLocation);
    timeline.getTimeline().setEvent(roadEvent);
    Assert.assertTrue(timeline.getTimeline().getCurrentEvent() == roadEvent);
View Full Code Here

   * createViewItem with it to check if the correct ViewModel element
   * is created from it
   */ 
  @Test
  public void testNodeItem() {
    NodeModel node = new NodeModel(0, 0);
    AbstractView<Observable> viewObject = AbstractViewFactory.createView(node);
    Assert.assertNotNull(viewObject);
    Assert.assertTrue(viewObject instanceof AbstractView<?>);   
    Assert.assertSame(node, viewObject.getModelElement());
  }
View Full Code Here

  }
  
  @Test
  public void testWayItem() {
    WayModel way = new WayModel("Way");
    NodeModel from = new NodeModel(0, 0);
    NodeModel to = new NodeModel(1, 1);
    EdgeModel e = new EdgeModel("testModelID", from, to);
    way.addForwardEdge(e);
    AbstractView<Observable> viewObject = AbstractViewFactory.createView(way);
    Assert.assertNotNull(viewObject);
    Assert.assertTrue(viewObject instanceof AbstractView<?>);
View Full Code Here

    Assert.assertSame(poi, viewObject.getModelElement());
  }

  @Test
  public void testTrafficLightItem() {
    NodeModel nodeModel = new NodeModel(0,0);
    TrafficLightModel trafficLight = new TrafficLightModel(nodeModel);
    AbstractView<Observable> viewObject = AbstractViewFactory.createView(trafficLight);
    Assert.assertNotNull(viewObject);
    Assert.assertTrue(viewObject instanceof AbstractView<?>);
//    trafficLightView trafficLightItem = (TrafficLightView) viewObject;
View Full Code Here

TOP

Related Classes of de.hpi.eworld.model.db.data.NodeModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.