/**
   * Check expected selected elements.
   *
   * @param editor the editor
   * @param objectsNameToCheck object names to check
   * @param expectedSize expected size
   * @param semanticObjectName true if objectsNameToCheck contains object names of the semantic
   *     object at the root of selected elements
   */
  protected void checkExpectedElementsInSelection(
      DialectEditor editor,
      List<String> objectsNameToCheck,
      int expectedSize,
      boolean semanticObjectName) {
    List<DSemanticDecorator> selections =
        Lists.newArrayList(DialectUIManager.INSTANCE.getSelection(editor));

    assertEquals("Bad selection size, after tool execution.", expectedSize, selections.size());

    if (objectsNameToCheck != null) {
      for (int i = 0; i < objectsNameToCheck.size(); i++) {
        String objectNameToCheck = objectsNameToCheck.get(i);
        String selectionName = "";
        if (semanticObjectName) {
          EObject target = selections.get(i).getTarget();
          if (target != null) {
            selectionName = target.toString();
          }
        } else {
          selectionName = selections.get(i).toString();
        }
        assertTrue(
            "Bad selection after tool execution. Missing object :" + objectNameToCheck,
            selectionName.contains(objectNameToCheck));
      }
    }
  }