当前位置: 首页>>代码示例>>Java>>正文


Java Method类代码示例

本文整理汇总了Java中org.raml.v2.api.model.v08.methods.Method的典型用法代码示例。如果您正苦于以下问题:Java Method类的具体用法?Java Method怎么用?Java Method使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Method类属于org.raml.v2.api.model.v08.methods包,在下文中一共展示了Method类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addStubIfHaveExamples

import org.raml.v2.api.model.v08.methods.Method; //导入依赖的package包/类
void addStubIfHaveExamples(final Method method) {
    Optional<ResourceMap> resourceMapOptional = requestMapping.getResource(method.resource().resourcePath());
    method.responses()
            .stream()
            .filter(response -> {
                // if the response represents an error (i.e. 404)
                // and the uri parameters are not overwritten
                // ignore the response so it does not overrides 'ok' responses like 200
                Integer statusCode = Integer.valueOf(response.code().value());

                boolean anError = isStatusCodeAnError(statusCode);
                if(resourceMapOptional.isPresent()){
                    ResourceMap resourceMap = resourceMapOptional.get();
                    if(anError){
                        return resourceMap.getStatusCode(statusCode).isPresent();
                    } else {
                        return true;
                    }
                } else {
                    return !anError;
                }
            })
            .forEach(response -> addStubIfHaveExamples(method, response));
}
 
开发者ID:arielsegura,项目名称:raml-java-mock-server,代码行数:25,代码来源:RamlMockServer.java

示例2: mappingBuilder

import org.raml.v2.api.model.v08.methods.Method; //导入依赖的package包/类
MappingBuilder mappingBuilder(Method method, String example, String code, String contentType){
    Integer status = Integer.valueOf(code);
    String urlRegex = buildPathForMethod(status, method);

    MappingBuilder request = WireMock.request(method.method().toUpperCase(), urlPathMatching(urlRegex));
    request.willReturn(aResponse()
            .withBody(example)
            .withHeader("Content-Type", contentType)
            .withStatus(status));
    return request;
}
 
开发者ID:arielsegura,项目名称:raml-java-mock-server,代码行数:12,代码来源:RamlMockServer.java

示例3: buildPathForMethod

import org.raml.v2.api.model.v08.methods.Method; //导入依赖的package包/类
String buildPathForMethod(Integer statusCode, Method method) {
    Resource resource = method.resource();
    Preconditions.checkArgument(resource != null, "Resource for method {} cannot be null. ", method.method());
    String resourcePath = resource.resourcePath();
    String urlRegex = getPathAsRegex(resourcePath);

    Optional<ResourceMap> anyStubWithSamePath = requestMapping.getResource(resourcePath);

    if(anyStubWithSamePath.isPresent()){
        // this path already exists. There should be UriParameters to use for this status code.
        Optional<ResourceMap> resourceMapOptional = requestMapping.getResource(resourcePath);
        if(resourceMapOptional.isPresent()) {
            ResourceMap resourceMap = resourceMapOptional.get();
            Optional<UriParameter[]> uriParametersOptional = resourceMap.getStatusCode(statusCode);
            if (uriParametersOptional.isPresent()) {
                UriParameter[] uriParameters = uriParametersOptional.get();

                for(UriParameter uriParameter : uriParameters){
                    resourcePath = resourcePath.replace(format("{%s}", uriParameter.getKey()), uriParameter.getValue());
                }

                return getPathAsRegex(resourcePath);
            }
        }
    }
    return urlRegex;
}
 
开发者ID:arielsegura,项目名称:raml-java-mock-server,代码行数:28,代码来源:RamlMockServer.java

示例4: getResources

import org.raml.v2.api.model.v08.methods.Method; //导入依赖的package包/类
public void getResources(final List<Resource> resources, final List<RestResourceDto> result,
                         final String path, boolean generateResponse) {
    if(resources.isEmpty()){
        return;
    }

    for(Resource resource : resources){
        String uri = path + resource.relativeUri().value();

        List<Method> methods = resource.methods();
        if(!methods.isEmpty()){
            RestResourceDto restResource = new RestResourceDto();
            restResource.setName(uri);
            restResource.setUri(uri);
            result.add(restResource);

            for(Method method : methods){
                HttpMethod httpMethod = HttpMethod.getValue(method.method());
                if(httpMethod == null){
                    LOGGER.error("The REST method '" + method.method() + "' is not supported.");
                    continue;
                }

                RestMethodDto restMethod = new RestMethodDto();
                restMethod.setName(httpMethod.name());
                restMethod.setStatus(RestMethodStatus.MOCKED);
                restMethod.setResponseStrategy(RestResponseStrategy.RANDOM);
                restMethod.setHttpMethod(httpMethod);

                if(generateResponse){
                    final Collection<RestMockResponseDto> mockResponses = createMockResponses(method.responses());
                    restMethod.getMockResponses().addAll(mockResponses);
                }

                restResource.getMethods().add(restMethod);
            }

        }

        getResources(resource.resources(), result, uri, generateResponse);
    }
}
 
开发者ID:castlemock,项目名称:castlemock,代码行数:43,代码来源:RAML08Parser.java

示例5: V08_RamlMethodModel

import org.raml.v2.api.model.v08.methods.Method; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions")
public V08_RamlMethodModel(Method method, List<RamlSecurityModel> securitySchemes) {
    this.method = method;
    this.securitySchemes = securitySchemes;
}
 
开发者ID:ozwolf-software,项目名称:dropwizard-raml-view,代码行数:6,代码来源:V08_RamlMethodModel.java


注:本文中的org.raml.v2.api.model.v08.methods.Method类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。