@Override
  protected void assertPostUndoState(IStatus undoStatus, IXSDModelRoot modelRoot) {
    ISchema mySchema = modelRoot.getSchema();

    int numberOfImports = 0;
    for (XSDSchemaContent content : mySchema.getComponent().getContents()) {
      if (content instanceof XSDImport
          && ((XSDImport) content).getNamespace().equals("http://example.com/MySchema1")) {
        numberOfImports++;
      }
    }
    assertEquals(1, numberOfImports);
  }
  IXSDModelRoot getXSDModelRoot(XSDSchema xsdSchema, IAdaptable adaptable) {
    if (adaptable != null) {
      ISchema schema = (ISchema) adaptable.getAdapter(ISchema.class);
      xsdSchema = schema == null ? xsdSchema : schema.getComponent();
    }

    clearEmptyKeys(xsdModelRootPool.keySet());
    Resource schemaResource = xsdSchema.eResource();
    final ModelRootObjectKey key = new ModelRootObjectKey(schemaResource, xsdSchema, adaptable);
    WeakReference<IXSDModelRoot> weakXSDModelRoot = xsdModelRootPool.get(key);
    IXSDModelRoot xsdModelRoot = weakXSDModelRoot == null ? null : weakXSDModelRoot.get();
    if (xsdModelRoot == null) {
      xsdModelRoot = new XSDModelRoot(xsdSchema, adaptable);
      xsdModelRootPool.put(key, new WeakReference<IXSDModelRoot>(xsdModelRoot));
    }
    return xsdModelRoot;
  }
  @Override
  protected AbstractNotificationOperation getOperation(IXSDModelRoot modelRoot) throws Exception {
    ISchema mySchema = modelRoot.getSchema();

    int numberOfImports = 0;
    for (XSDSchemaContent content : mySchema.getComponent().getContents()) {
      if (content instanceof XSDImport
          && ((XSDImport) content).getNamespace().equals("http://example.com/MySchema1")) {
        numberOfImports++;
      }
    }
    assertEquals(1, numberOfImports);

    ISchema mySchema1_2 = this.getXSDModelRoot(mySchema1_2File).getSchema();
    AbstractType sch2Element1 = (AbstractType) mySchema1_2.getType(true, "Sch2Element1");

    ImportSchemaCommand command =
        new ImportSchemaCommand(
            (IXSDModelRoot) mySchema.getModelRoot(), (Schema) mySchema, sch2Element1);
    return command;
  }
  @Override
  protected AbstractNotificationOperation getNextOperation(final IWsdlModelRoot modelRoot)
      throws Exception {
    if (inlineNSCommand == null) {
      final ISchema containingSchema = findSingleSchema(modelRoot, "http://namespace1");
      final Collection<ISchema> allReferredSchemas = containingSchema.getAllReferredSchemas();
      ISchema schemaToInline = null;
      for (final ISchema iSchema : allReferredSchemas) {
        if (XSD1_NS.equals(iSchema.getNamespace())) {
          schemaToInline = iSchema;
          break;
        }
      }
      inlineNSCommand = new InlineNamespaceCompositeCommand(modelRoot, schemaToInline);
      return inlineNSCommand;
    }
    if (setTypeCommand == null) {
      final IElement attribute =
          getStructureType3(modelRoot).getElements("Attribute2").iterator().next();

      final ISchema schema2 = findSingleSchema(modelRoot, "http://namespace3");
      final IType typeToBeSet = schema2.getType(false, "SimpleType2");
      setTypeCommand = new SetElementTypeCommand(attribute, typeToBeSet);
      return setTypeCommand;
    }
    return null;
  }
  /**
   * Checks modelObject.getModelRoot() referred schemas, do match modelObject's XSDSchema
   *
   * @param modelObject which is supposed to be from referred schema.
   * @return referred ISchema, or null
   */
  public static ISchema getReferredSchema(final IModelObject modelObject) {
    if (modelObject == null || !(modelObject.getModelRoot() instanceof IXSDModelRoot)) {
      return null;
    }

    final IXSDModelRoot xsdModelRoot = (IXSDModelRoot) modelObject.getModelRoot();
    final ISchema schema = xsdModelRoot.getSchema();

    // get referred XSDSchema
    EObject referredXSDSchema = modelObject.getComponent();
    while (referredXSDSchema != null && !(referredXSDSchema instanceof XSDSchema)) {
      referredXSDSchema = referredXSDSchema.eContainer();
    }

    if (referredXSDSchema != null) {
      for (final ISchema referredSchema : schema.getAllReferredSchemas()) {
        if (referredXSDSchema.equals(referredSchema.getComponent())) {
          return referredSchema;
        }
      }
    }
    return null;
  }
 // custom for this test. When ever it is first initiated :)
 private IStructureType getStructureType3(final IWsdlModelRoot modelRoot) {
   final ISchema schema = findSingleSchema(modelRoot, "http://namespace1");
   return (StructureType) schema.getType(false, "StructureType3");
 }