本文整理汇总了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));
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}