Esempio n. 1
0
 /**
  * Utility function to create a collaboration.
  *
  * @return a new collaboration
  * @param namespace the back-up namespace to put the collaboration in
  */
 protected static Object createCollaboration(Object namespace) {
   Object target = TargetManager.getInstance().getModelTarget();
   if (Model.getFacade().isAUMLElement(target)
       && Model.getModelManagementHelper().isReadOnly(target)) {
     target = namespace;
   }
   Object collaboration = null;
   if (Model.getFacade().isAOperation(target)) {
     Object ns = Model.getFacade().getNamespace(Model.getFacade().getOwner(target));
     collaboration = Model.getCollaborationsFactory().buildCollaboration(ns, target);
   } else if (Model.getFacade().isAClassifier(target)) {
     Object ns = Model.getFacade().getNamespace(target);
     collaboration = Model.getCollaborationsFactory().buildCollaboration(ns, target);
   } else {
     collaboration = Model.getCollaborationsFactory().createCollaboration();
     if (Model.getFacade().isANamespace(target)) {
       /* TODO: Not all namespaces are useful here - any WFRs? */
       namespace = target;
     } else {
       if (Model.getFacade().isAModelElement(target)) {
         Object ns = Model.getFacade().getNamespace(target);
         if (Model.getFacade().isANamespace(ns)) {
           namespace = ns;
         }
       }
     }
     Model.getCoreHelper().setNamespace(collaboration, namespace);
     Model.getCoreHelper().setName(collaboration, "unattachedCollaboration");
   }
   return collaboration;
 }
  /** Test the name of the ClassifierRole. */
  public void testClassifierRoleName() {
    Object cr;

    cr = Model.getCollaborationsFactory().createClassifierRole();
    checkNameClassifierRole(cr, clro01, "roname");
    checkNameClassifierRole(cr, clro02, "roname2");

    cr = Model.getCollaborationsFactory().createClassifierRole();
    checkNameClassifierRole(cr, clro03, "roname");
  }
 /*
  * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#fillModel()
  */
 protected Object[] fillModel() {
   Object[] messages = new Object[10];
   for (int i = 0; i < messages.length; i++) {
     messages[i] = Model.getCollaborationsFactory().createMessage();
     Model.getCollaborationsHelper().addMessage(getElem(), messages[i]);
   }
   return messages;
 }
 /*
  * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#fillModel()
  */
 protected Object[] fillModel() {
   Object[] inter = new Object[NO_OF_ELEMENTS];
   for (int i = 0; i < NO_OF_ELEMENTS; i++) {
     inter[i] = Model.getCollaborationsFactory().createInteraction();
     Model.getCollaborationsHelper().setContext(inter[i], getElem());
   }
   return inter;
 }
  /** Test if help is correctly provided. */
  public void testGetHelp() {
    Object cr;
    cr = Model.getCollaborationsFactory().createClassifierRole();

    ClassifierRoleNotationUml notation = new ClassifierRoleNotationUml(cr);
    String help = notation.getParsingHelp();
    assertTrue("No help at all given", help.length() > 0);
    assertTrue("Parsing help not conform for translation", help.startsWith("parsing."));
  }
  /** Test if parsing a ClassifierRole throws exceptions. */
  public void testClassifierRoleThrows() {
    Object cr;

    cr = Model.getCollaborationsFactory().createClassifierRole();
    checkThrowsClassifierRole(cr, nclro01, true, false, false);
    checkThrowsClassifierRole(cr, nclro02, true, false, false);
    checkThrowsClassifierRole(cr, nclro03, true, false, false);
    checkThrowsClassifierRole(cr, nclro04, true, false, false);
  }
  /** Test the Base of the ClassifierRole. */
  public void testClassifierRoleBases() {
    Object cr;
    String[] res1 = {
      "int",
    };
    String[] res2 = {
      "int", "double",
    };
    String[] res3 = {
      "float", "long",
    };

    cr = Model.getCollaborationsFactory().createClassifierRole();
    checkBases(cr, clro01, res1);
    checkBases(cr, clro02, res2);
    checkBases(cr, clro03, res3);

    cr = Model.getCollaborationsFactory().createClassifierRole();
    checkBases(cr, clro03, res3);
  }
 /*
  * @see org.tigris.gef.graph.GraphFactory#makeNode()
  */
 public Object makeNode() {
   Object node = null;
   Editor ce = Globals.curEditor();
   GraphModel gm = ce.getGraphModel();
   if (gm instanceof CollabDiagramGraphModel) {
     Object collaboration = ((CollabDiagramGraphModel) gm).getHomeModel();
     node = Model.getCollaborationsFactory().buildClassifierRole(collaboration);
   } else {
     throw new IllegalStateException("Graphmodel is not a " + "collaboration diagram graph model");
   }
   return node;
 }
 /*
  * @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildElement()
  */
 protected void buildElement() {
   setElem(Model.getCollaborationsFactory().createInteraction());
 }
 /** @see org.argouml.uml.ui.AbstractUMLModelElementListModel2Test#buildElement() */
 protected void buildElement() {
   setElem(Model.getCollaborationsFactory().createClassifierRole());
 }