Package com.eviware.soapui.impl.rest

Examples of com.eviware.soapui.impl.rest.RestMethod


            for (Object obj : types) {
                ResourceTypeDocument.ResourceType type = resolveResource(obj.toString());
                if (type != null) {
                    for (Method method : type.getMethodList()) {
                        method = resolveMethod(method);
                        RestMethod restMethod = initMethod(newResource, method);

                        for (Param param : type.getParamList()) {
                            param = resolveParameter(param);
                            if (param != null) {
                                String nm = param.getName();
                                RestParamProperty prop = restMethod.hasProperty(nm) ? restMethod.getProperty(nm)
                                        : restMethod.addProperty(nm);

                                initParam(param, prop);
                            }
                        }
                    }
View Full Code Here


                name = orgName + "-" + cnt;
            }
        }

        // add to resource
        RestMethod restMethod = newResource.addNewMethod(name);
        restMethod.setMethod(RestRequestInterface.HttpMethod.valueOf(method.getName()));

        if (method.getRequest() != null) {
            for (Param param : method.getRequest().getParamList()) {
                param = resolveParameter(param);
                if (param != null) {
                    RestParamProperty p = restMethod.addProperty(param.getName());
                    initParam(param, p);
                }
            }

            for (Representation representation : method.getRequest().getRepresentationList()) {
                representation = resolveRepresentation(representation);
                addRepresentationFromConfig(restMethod, representation, RestRepresentation.Type.REQUEST, null);
            }
        }

        for (Response response : method.getResponseList()) {
            for (Representation representation : response.getRepresentationList()) {
                addRepresentation(response, restMethod, representation);
            }
            if (!isWADL11) {
                NodeList children = response.getDomNode().getChildNodes();
                for (int i = 0; i < children.getLength(); i++) {
                    Node n = children.item(i);
                    if ("fault".equals(n.getNodeName())) {
                        String content = XmlUtils.serialize(n, false);
                        try {
                            Map<Object, Object> map = new HashMap<Object, Object>();
                            XmlCursor cursor = response.newCursor();
                            cursor.getAllNamespaces(map);
                            cursor.dispose();
                            XmlOptions options = new XmlOptions();
                            options.setLoadAdditionalNamespaces(map);
                            // XmlObject obj = XmlObject.Factory.parse(
                            // content.replaceFirst( "<(([a-z]+:)?)fault ",
                            // "<$1representation " ), options );
                            XmlObject obj = XmlUtils.createXmlObject(
                                    content.replaceFirst("<(([a-z]+:)?)fault ", "<$1representation "), options);
                            RepresentationDocument representation = (RepresentationDocument) obj
                                    .changeType(RepresentationDocument.type);
                            addRepresentation(response, restMethod, representation.getRepresentation());
                        } catch (XmlException e) {
                        }
                    }
                }
            }
        }

        restMethod.addNewRequest("Request 1");
        return restMethod;
    }
View Full Code Here

                    return null;
                }
                getRequestStepConfig().setService(restResource.getInterface().getName());
                getRequestStepConfig().setResourcePath(restResource.getFullPath());
            }
            RestMethod method = RestRequestConverter.getMethod(getResource(), getRequestStepConfig().getRestRequest()
                    .selectAttribute(null, "method").newCursor().getTextValue(), getRequestStepConfig().getRestRequest()
                    .getName());
            restRequestStepConfig.setMethodName(method.getName());
            return method;
        } else if (getResource() == null) {
            restResource = RestRequestConverter.resolveResource(this);
            if (restResource == null) {
                return null;
            }
            getRequestStepConfig().setService(restResource.getInterface().getName());
            getRequestStepConfig().setResourcePath(restResource.getFullPath());

            RestMethod m = (RestMethod) getWsdlModelItemByName(getResource().getRestMethodList(), getRequestStepConfig()
                    .getMethodName());
            if (m == null) {
                String mn = null;
                while (mn == null) {
                    mn = UISupport.prompt("Select method in REST Resource [" + restResource.getName() + "]",
View Full Code Here

    public void setRestMethod(RestMethod method) {
        if (restMethod == method) {
            return;
        }

        RestMethod oldMethod = restMethod;
        restMethod = method;

        getRequestStepConfig().setService(method.getInterface().getName());
        getRequestStepConfig().setResourcePath(method.getResource().getFullPath());
        getRequestStepConfig().setMethodName(method.getName());

        // new resource?
        RestResource res = findRestResource();
        if (res != getResource()) {
            restResource.removePropertyChangeListener(this);
            restResource.getService().removeInterfaceListener(interfaceListener);
            restResource.getService().removePropertyChangeListener(this);

            restResource = res;

            restResource.getService().addInterfaceListener(interfaceListener);
            restResource.getService().addPropertyChangeListener(this);
            restResource.addPropertyChangeListener(this);
        }

        if (oldMethod != null) {
            oldMethod.removePropertyChangeListener(this);
        }

        restMethod.addPropertyChangeListener(this);
        getTestRequest().setRestMethod(restMethod);
    }
View Full Code Here

            context.addPathToResolve(this, "Missing REST Method in Project",
                    getRequestStepConfig().getService() + "/" + getRequestStepConfig().getMethodName()).addResolvers(
                    new RemoveTestStepResolver(this), new ImportInterfaceResolver(this) {
                        @Override
                        protected boolean update() {
                            RestMethod restMethod = findRestMethod();
                            if (restMethod == null) {
                                return false;
                            }

                            setRestMethod(restMethod);
                            initRestTestRequest();
                            setDisabled(false);
                            return true;
                        }

                    }, new ChangeRestMethodResolver(this) {
                        @Override
                        public boolean update() {
                            RestMethod restMethod = getSelectedRestMethod();
                            if (restMethod == null) {
                                return false;
                            }

                            setRestMethod(restMethod);
View Full Code Here

        RestParamsTable paramsTable = new RestParamsTable(params, false, paramsTableModel, ParamLocation.METHOD, true, false);

        dialog.getFormField(Form.PARAMSTABLE).setProperty("component", paramsTable);

        if (dialog.show()) {
            RestMethod method = resource.addNewMethod(dialog.getValue(Form.RESOURCENAME));
            method.setMethod(RestRequestInterface.HttpMethod.valueOf(dialog.getValue(Form.METHOD)));
            paramsTable.extractParams(method.getParams(), ParamLocation.METHOD);
            method.addPropertyChangeListener(paramsTableModel);
            UISupport.select(method);

            if (dialog.getBooleanValue(Form.CREATEREQUEST)) {
                createRequest(method, method.getParams());
            }
        }
    }
View Full Code Here

            setEndpoint(fullPath);
        }
    }

    public void setRestMethod(RestMethod restMethod) {
        RestMethod old = this.getRestMethod();

        if (old != null) {
            old.getResource().removePropertyChangeListener(this);
        }

        super.setRestMethod(restMethod);

        restMethod.getResource().addPropertyChangeListener(this);
View Full Code Here

        assertThat(restMockService.getPath(), is("myPath"));
    }

    @Test
    public void shouldAddOperationToMockServiceAction() throws SoapUIException {
        RestMethod restMethod = mock(RestMethod.class);
        when(restMethod.getRequestAt(0)).thenReturn(restRequest);
        when(restMethod.getMethod()).thenReturn(RestRequestInterface.HttpMethod.GET);

        RestResource restResource = mock(RestResource.class);
        when(restResource.getRestMethodCount()).thenReturn(1);
        when(restResource.getFullPath()).thenReturn("/full/path");
        List<RestMethod> restMethodList = new ArrayList<RestMethod>();
View Full Code Here

        assertThat(mockAction.getMethod(), is(method));
        assertThat(mockAction.getResourcePath(), is(path));
    }

    private void addMethod(RestResource one, HttpMethod method) {
        RestMethod restMethod = one.addNewMethod(method.name());
        restMethod.setMethod(method);
    }
View Full Code Here

        RestResource resource = mock(RestResource.class);
        RestParamsPropertyHolder resourceParams = mock(XmlBeansRestParamsTestPropertyHolder.class);
        when(resource.getParams()).thenReturn(resourceParams);
        when(restRequest.getResource()).thenReturn(resource);

        RestMethod restMethod = mock(RestMethod.class);
        RestParamsPropertyHolder methodParams = mock(XmlBeansRestParamsTestPropertyHolder.class);
        when(restMethod.getParams()).thenReturn(methodParams);
        when(restRequest.getRestMethod()).thenReturn(restMethod);

        when(params.getModelItem()).thenReturn(restRequest);

    }
View Full Code Here

TOP

Related Classes of com.eviware.soapui.impl.rest.RestMethod

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.