@Test public void testOperationFailureOfExecution() throws Exception { IWsdlModelRoot wsdlModelRoot = getWSDLModelRoot(WSDL_FILE_PATH, WSDL_FILE); IDescription description = wsdlModelRoot.getDescription(); IXSDModelRoot xsdModelRoot = getXSDModelRoot(XSD_FILE_PATH, XSD_FILE); IType type = xsdModelRoot.getSchema().getType(true, "Element1UN"); IOperation firstOperation = description.getAllInterfaces().iterator().next().getAllOperations().iterator().next(); assertEquals( Status.OK_STATUS, wsdlModelRoot .getEnv() .execute(new AddInParameterCommand(wsdlModelRoot, firstOperation, PARAMETER_NAME))); IParameter parameter = firstOperation.getInputParameter(PARAMETER_NAME).get(0); SetParameterTypeCommand setParameterTypeCommand = new SetParameterTypeCommand(parameter, type); IStatus status = wsdlModelRoot.getEnv().execute(setParameterTypeCommand); assertEquals(Status.ERROR, status.getSeverity()); }
@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); }
/** * 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; }
@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; }