Package de.hpi.eworld.core

Examples of de.hpi.eworld.core.ModelManager


      return;
   
    DatabaseAccess dba = DatabaseAccess.getInstance();
    dba.checkSettings();
   
    ModelManager mm = ModelManager.getInstance();
    ModelManagerMockUp mmm = ModelManagerMockUp.getInstance();
   
    mm.clearModel();
   
    ArrayList<ModelElement> testCase = TestCaseUtil.createSampleTestcase();
    for(ModelElement m : testCase) {
      mm.addModelElement(m);
      // save test case structural information for later use
      mmm.addModelElement(m);
    }
    // save and load again from the DB
    dba.save();
    dba.load();
   
    Collection<ModelElement> loadedModelElements = mm.getAllModelElements();
    ModelManagerMockUp mmmCompare = ModelManagerMockUp.getInstance();
    for(ModelElement m : loadedModelElements) {
      mmmCompare.addModelElement(m);
    }
   
View Full Code Here


   
  private Collection<ModelElement> databaseSaveLoadGeneric(ModelElement testElement) {
    DatabaseAccess dba = DatabaseAccess.getInstance();
    dba.checkSettings();
   
    ModelManager mm = ModelManager.getInstance();
    mm.clearModel();
    mm.addModelElement(testElement);
   
    // save and load again from the DB
    dba.save();
    dba.load();
   
    Collection<ModelElement> loadedModelElements = mm.getAllModelElements();
    return loadedModelElements;
  }
View Full Code Here

    gridLayout.addWidget(vehicleTypeCombo, 3, 1, 1, 1, AlignmentFlag.AlignRight);

    QLabel timeLabel = new QLabel("Dep.-Time:");
    timeSpin = new QSpinBox();
    timeSpin.setValue(0);
    ModelManager mm = ModelManager.getInstance();
    timeSpin.setMinimum(mm.getSimulationStartTime());
    timeSpin.setMaximum(mm.getSimulationEndTime());

    gridLayout.addWidget(timeLabel, 4, 0, 1, 1, AlignmentFlag.AlignLeft);
    gridLayout.addWidget(timeSpin, 4, 1, 1, 1, AlignmentFlag.AlignRight);

    QPushButton okButton = new QPushButton("OK");
View Full Code Here

  /**
   * takes all elements of the ModelManager and sorts them in the appropriate list
   * (currently edges, nodes, trafficLights)
   */
  private void fillModelElementLists(){
    final ModelManager modelManager = ModelManager.getInstance();
    modelElements = modelManager.getAllModelElements();
    for (final ModelElement modelElement : modelElements) {
      if (modelElement instanceof EdgeModel) {
        edges.add((EdgeModel) modelElement);
      } else if (modelElement instanceof NodeModel) {
        nodes.add((NodeModel) modelElement);
View Full Code Here

  /**
   * Manually creates a custom model that contains at least one instance of each existing
   * model element. This test case is then later used in actual tests.
   */
  private void initTestCase() {
    ModelManager mm = ModelManager.getInstance();
    mm.clearModel();
    mm.setSimulationStartTime(0);
    mm.setSimulationEndTime(5000);
   
    allModelElements = TestCaseUtil.createSampleTestcase();
   
    for(ModelElement e : allModelElements) {
      mm.addModelElement(e);
    }
  }
View Full Code Here

   * This method checks if all model elements that were created actaully exist in the model
   */
  @Test
  public void testModelContent() {
    initTestCase();
    ModelManager mm = ModelManager.getInstance();
    Collection<ModelElement> mmAllModelElements = mm.getAllModelElements();
    Assert.assertEquals(allModelElements.size(), mmAllModelElements.size());
    for(ModelElement e : allModelElements) {
      Assert.assertEquals(true, mmAllModelElements.contains(e));
    }
  }
View Full Code Here

   * This test checks that it is impossible to add a model element that already exists in the model
   */
  @Test
  public void testAddRefused() {
    initTestCase();
    ModelManager mm = ModelManager.getInstance();
    for(ModelElement e : allModelElements) {
      Assert.assertEquals(false, mm.addModelElement(e));
    }
  }
View Full Code Here

   * number of model elements
   */
  @Test
  public void testSaveLoad() {
    initTestCase();
    ModelManager mm = ModelManager.getInstance();
    PersistenceManager.getInstance().saveToFile(DIR_SAVE + "out.ewd");
    mm.clearModel();
    Assert.assertEquals(0,mm.getAllModelElements().size());
   
    mm.clearModel();
   
    PersistenceManager.getInstance().loadFromFile(DIR_SAVE + "out.ewd");
    compareModels(allModelElements, mm.getAllModelElements());
  }
View Full Code Here

   */
  @Ignore // test takes forever, ignore it for now
  @Test
  public void testSaveLoad_Imported() {
    Osm2Model converter = new Osm2Model();
    ModelManager mm = ModelManager.getInstance();
    ModelManagerMockUp mmmu = ModelManagerMockUp.getInstance();
    mm.addObserver(mmmu);
    mm.notifyObservers(new ObserverNotification(NotificationType.elementAdded));
    try {
      converter.parseFile(new FileInputStream("./resources/rostock.osm"));
    }
    catch (Exception xcp) {
      xcp.printStackTrace();
    }
    mm.deleteObserver(mmmu);
    PersistenceManager.getInstance().saveToFile(DIR_SAVE + "out.ewd");
    mm.clearModel();
    Assert.assertEquals(0,mm.getAllModelElements().size());

    PersistenceManager.getInstance().loadFromFile(DIR_SAVE + "out.ewd");
    compareModels(mmmu.getModelElements(), mm.getAllModelElements());
  }
View Full Code Here

   * the simulationstatistic plugin
   */
  @Test
  public void testInternalIDs(){
    initTestCase();
    ModelManager mm = ModelManager.getInstance();
   
    // map all edges of the current map to their ids
    Map<String, EdgeModel> edges = new HashMap<String, EdgeModel>();
    for (ModelElement element : allModelElements) {
      //for all ways
      if (element instanceof WayModel) {
        WayModel way = (WayModel) element;
        //store all edges
        for (EdgeModel edge: way.getBackwardEdges()){
          edges.put(edge.getInternalID(), edge);
        }
        for (EdgeModel edge: way.getForwardEdges()){
          edges.put(edge.getInternalID(), edge);
        }
      }
    }
   
    //check if internal ids are the same
    for (ModelElement element : mm.getAllModelElements()){
      //for all ways
      if (element instanceof WayModel) {
        WayModel way = (WayModel) element;
        //store all edges
        for (EdgeModel edge: way.getBackwardEdges()){
          Assert.assertEquals(
              edge.getId(),
              edges.get(edge.getInternalID()).getId());
        }
        for (EdgeModel edge: way.getForwardEdges()){
          Assert.assertEquals(
              edge.getId(),
              edges.get(edge.getInternalID()).getId());
        }
      }
    }
   
    PersistenceManager.getInstance().saveToFile(DIR_SAVE + "out.ewd");
    mm.clearModel();
    Assert.assertEquals(0,mm.getAllModelElements().size());
   
    mm.clearModel();
   
    PersistenceManager.getInstance().loadFromFile(DIR_SAVE + "out.ewd");
   
    //check again if internal ids are the same
    for (ModelElement element : mm.getAllModelElements()){
      //for all ways
      if (element instanceof WayModel) {
        WayModel way = (WayModel) element;
        //store all edges
        for (EdgeModel edge: way.getBackwardEdges()){
View Full Code Here

TOP

Related Classes of de.hpi.eworld.core.ModelManager

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.