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


Java Resource类代码示例

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


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

示例1: buildPathForMethod

import org.raml.v2.api.model.v08.resources.Resource; //导入依赖的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

示例2: getResources

import org.raml.v2.api.model.v08.resources.Resource; //导入依赖的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

示例3: V08_RamlResourceModel

import org.raml.v2.api.model.v08.resources.Resource; //导入依赖的package包/类
public V08_RamlResourceModel(Resource resource, List<RamlSecurityModel> securitySchemes) {
    this.resource = resource;
    this.securitySchemes = securitySchemes;
}
 
开发者ID:ozwolf-software,项目名称:dropwizard-raml-view,代码行数:5,代码来源:V08_RamlResourceModel.java

示例4: addStubIfHaveExamples

import org.raml.v2.api.model.v08.resources.Resource; //导入依赖的package包/类
void addStubIfHaveExamples(Resource resource) {
    logger.debug("Processing resource {} ", resource.displayName());

    List<Method> methods = resource.methods();

    methods.forEach(this::addStubIfHaveExamples);

    resource.resources().forEach(this::addStubIfHaveExamples);

}
 
开发者ID:arielsegura,项目名称:raml-java-mock-server,代码行数:11,代码来源:RamlMockServer.java


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