當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。