本文整理汇总了Java中org.raml.model.parameter.Header类的典型用法代码示例。如果您正苦于以下问题:Java Header类的具体用法?Java Header怎么用?Java Header使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Header类属于org.raml.model.parameter包,在下文中一共展示了Header类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldReturnErrorsForBrokenSecuritySpecifications
import org.raml.model.parameter.Header; //导入依赖的package包/类
@Test
public void shouldReturnErrorsForBrokenSecuritySpecifications() {
org.mockserver.model.Header authorizationHeader = new org.mockserver.model.Header(HttpHeaders.AUTHORIZATION, "Basic 1234", "wrong");
Parameter tokenParameter = new Parameter("token", "123456", "i_am_text");
when(expectation.getRequestHeader(HttpHeaders.AUTHORIZATION)).thenReturn(Optional.of(authorizationHeader));
when(expectation.getQueryParameter("token")).thenReturn(Optional.of(tokenParameter));
ValidationErrors errors = new RequestSecurityValidator(expectation).validate();
assertThat(errors.isInError()).isTrue();
assertThat(errors.getMessages())
.hasSize(4)
.contains(
"[ security ] [ header ] [ basic ] Only one value allowed for security parameters but multiple found.",
"[ security ] [ header ] [ basic ] Value of [ wrong ] does not meet API requirements.",
"[ security ] [ query ] [ query-token ] Only one value allowed for security parameters but multiple found.",
"[ security ] [ query ] [ query-token ] Value of [ i_am_text ] does not meet API requirements."
);
}
示例2: addHeaders
import org.raml.model.parameter.Header; //导入依赖的package包/类
private void addHeaders(Action action, DCMethod method)
{
// first add common headers, based on mediaType
method.getHeaderParams().addAll(headerParams);
Map<String, Header> headers = action.getHeaders();
for (String headerName : headers.keySet())
{
Header header = headers.get(headerName);
HeaderParam param = new HeaderParam();
// for some strange reason, the header param names are suffixed with "-header". so we remove it
String name = headerName.endsWith("-header") ? headerName.substring(0,headerName.length()-7) : headerName;
param.setName(name);
if (header.getDefaultValue()!=null)
{
param.setValue(header.getDefaultValue());
}
method.addHeaderParam(param);
}
}
示例3: convertHeader
import org.raml.model.parameter.Header; //导入依赖的package包/类
public HeaderParameter convertHeader(Header source) {
if (source == null) {
return null;
}
HeaderParameter target = new HeaderParameter();
target.setExample(convertExample(source.getExample()));
target.setDescription(convertDescription(source.getDescription()));
target.setName(convertName(source.getDisplayName()));
target.setPattern(convertPattern(source.getPattern()));
target.setDefaultValue(convertDefaultValue(source.getDefaultValue()));
target.setMaximum(source.getMaximum());
target.setMinimum(source.getMinimum());
target.setEnumeration(source.getEnumeration());
target.setMaxLength(source.getMaxLength());
target.setMinLength(source.getMinLength());
target.setRepeat(source.isRepeat());
target.setRequired(source.isRequired());
target.setType(convertParameterType(source.getType()));
return target;
}
示例4: testConvertResponse
import org.raml.model.parameter.Header; //导入依赖的package包/类
@Test
public void testConvertResponse() {
Response source = new Response();
source.setDescription("responseDescription");
Map<String, Header> headers = new HashMap<>();
headers.put("testHeader", new Header());
Map<String, MimeType> body = new HashMap<>();
body.put("testBody", new MimeType());
source.setHeaders(headers);
source.setBody(body);
ch.alv.components.web.api.config.Response result = converter.convertResponse(source);
assertEquals(source.getDescription(), result.getDescription());
assertEquals(source.getBody().size(), result.getBody().size());
assertEquals(source.getHeaders().size(), result.getHeaders().size());
assertNull(converter.convertResponse(null));
}
示例5: exampleResponse
import org.raml.model.parameter.Header; //导入依赖的package包/类
@Override
public EndpointRoute exampleResponse(HttpResponseStatus status, String description, String headerName, String example, String headerDescription) {
Response response = new Response();
response.setDescription(description);
exampleResponses.put(status.code(), response);
if (headerName != null) {
Header header = new Header();
header.setDescription(headerDescription);
header.setExample(example);
Map<String, Header> headers = new HashMap<>();
headers.put(headerName, header);
response.setHeaders(headers);
}
return this;
}
示例6: apply
import org.raml.model.parameter.Header; //导入依赖的package包/类
@Override
public void apply(Header header, ResourceClassBuilder resourceClassBuilder) {
resourceClassBuilder.getApiClass()
.withMethod(new AddHeaderMethod(header, header.getDisplayName(),
resourceClassBuilder.getReq(),
resourceClassBuilder.getApiClass()));
resourceClassBuilder.getDefaultsMethod().forParamDefaults(header.getDisplayName(), header);
}
示例7: basicAuthorizationHeaders
import org.raml.model.parameter.Header; //导入依赖的package包/类
private Map<String, Header> basicAuthorizationHeaders() {
Map<String, Header> headers = new HashMap<>();
Header header = new Header();
header.setRequired(true);
header.setRepeat(false);
header.setType(ParamType.STRING);
header.setPattern("Basic (.+)");
headers.put(HttpHeaders.AUTHORIZATION, header);
return headers;
}
示例8: getMandatoryHeaders
import org.raml.model.parameter.Header; //导入依赖的package包/类
public Map<String, String> getMandatoryHeaders() {
Map<String, Header> oHeaders=getAction().getHeaders();
Map<String, String> oReturn=new HashMap<String, String>();
for(Map.Entry<String, Header> oHeader:oHeaders.entrySet()) {
if(oHeader.getValue().isRequired()) {
String oValue=Resolver.getValueParam(oHeader.getValue(), oHeader.getKey(),"[Mandatory Header]");
oReturn.put(oHeader.getKey(),oValue);
}
}
return oReturn;
}
示例9: convertHeaders
import org.raml.model.parameter.Header; //导入依赖的package包/类
public List<HeaderParameter> convertHeaders(Map<String, Header> source) {
List<HeaderParameter> list = new ArrayList<>();
if (source.isEmpty()) {
return list;
}
for (String key : source.keySet()) {
list.add(convertHeader(source.get(key)));
}
return list;
}
示例10: testConvertHeaders
import org.raml.model.parameter.Header; //导入依赖的package包/类
@Test
public void testConvertHeaders() {
Map<String, Header> sourceHeaders = new HashMap<>();
sourceHeaders.put("testHeader", new Header());
List<HeaderParameter> result = converter.convertHeaders(sourceHeaders);
assertEquals(1, result.size());
}
示例11: testConvertHeader
import org.raml.model.parameter.Header; //导入依赖的package包/类
@Test
public void testConvertHeader() {
Header source = new Header();
source.setDisplayName("testHeader");
source.setExample("testHeaderExample");
source.setPattern("testHeaderPattern");
source.setType(ParamType.INTEGER);
source.setDefaultValue("testHeaderDefaultValue");
List<String> enums = new ArrayList<>();
enums.add("testValue");
source.setEnumeration(enums);
source.setMaximum(new BigDecimal("5"));
source.setMinimum(new BigDecimal("1"));
source.setMinLength(3);
source.setMaxLength(9);
source.setRepeat(true);
source.setRequired(true);
HeaderParameter result = converter.convertHeader(source);
assertEquals(source.getDisplayName(), result.getName());
assertEquals(source.getExample(), result.getExample());
assertEquals(source.getPattern(), result.getPattern());
assertEquals(ParameterType.INTEGER, result.getType());
assertEquals(source.getDefaultValue(), result.getDefaultValue());
assertEquals(source.getEnumeration(), result.getEnumeration());
assertEquals(source.getMaximum(), result.getMaximum());
assertEquals(source.getMinimum(), result.getMinimum());
assertEquals(source.getMinLength(), result.getMinLength());
assertEquals(source.getMaxLength(), result.getMaxLength());
assertEquals(source.isRepeat(), result.isRepeat());
assertEquals(source.isRequired(), result.isRequired());
assertNull(converter.convertHeader(null));
}
示例12: AddHeaderMethod
import org.raml.model.parameter.Header; //导入依赖的package包/类
public AddHeaderMethod(Header header, String name, ReqSpecField req, ApiResourceClass apiClass) {
this.header = header;
this.name = name;
this.req = req;
this.apiClass = apiClass;
}
示例13: HeaderDefinition
import org.raml.model.parameter.Header; //导入依赖的package包/类
public HeaderDefinition(String name, String javaType, PatternDefinition pattern, Header uriParameter) {
super(name, javaType, pattern, uriParameter);
}
示例14: RJP08V1RamlHeader
import org.raml.model.parameter.Header; //导入依赖的package包/类
public RJP08V1RamlHeader(Header header) {
this.header = header;
}
示例15: createRamlHeader
import org.raml.model.parameter.Header; //导入依赖的package包/类
@Override
public RamlHeader createRamlHeader(Object header) {
return new RJP08V1RamlHeader((Header)header);
}