Example usage for org.springframework.restdocs.operation Operation getAttributes

List of usage examples for org.springframework.restdocs.operation Operation getAttributes

Introduction

In this page you can find the example usage for org.springframework.restdocs.operation Operation getAttributes.

Prototype

Map<String, Object> getAttributes();

Source Link

Document

Returns a Map of attributes associated with the operation.

Usage

From source file:capital.scalable.restdocs.OperationAttributeHelper.java

public static String getAuthorization(Operation operation) {
    return (String) operation.getAttributes().get(AuthorizationSnippet.class.getName());
}

From source file:capital.scalable.restdocs.OperationAttributeHelper.java

public static ObjectMapper getObjectMapper(Operation operation) {
    return (ObjectMapper) operation.getAttributes().get(ObjectMapper.class.getName());
}

From source file:capital.scalable.restdocs.OperationAttributeHelper.java

public static JavadocReader getJavadocReader(Operation operation) {
    return (JavadocReader) operation.getAttributes().get(JavadocReader.class.getName());
}

From source file:capital.scalable.restdocs.OperationAttributeHelper.java

public static List<Snippet> getDefaultSnippets(Operation operation) {
    return (List<Snippet>) operation.getAttributes().get(ATTRIBUTE_NAME_DEFAULT_SNIPPETS);
}

From source file:capital.scalable.restdocs.OperationAttributeHelper.java

public static ConstraintReader getConstraintReader(Operation operation) {
    return (ConstraintReader) operation.getAttributes().get(ConstraintReader.class.getName());
}

From source file:capital.scalable.restdocs.OperationAttributeHelper.java

public static HandlerMethod getHandlerMethod(Operation operation) {
    Map<String, Object> attributes = operation.getAttributes();
    return (HandlerMethod) attributes.get(HandlerMethod.class.getName());
}

From source file:capital.scalable.restdocs.OperationAttributeHelper.java

public static String getRequestPattern(Operation operation) {
    Map<String, Object> attributes = operation.getAttributes();
    return (String) attributes.get(REQUEST_PATTERN);
}

From source file:capital.scalable.restdocs.OperationAttributeHelper.java

public static RestDocumentationContext getDocumentationContext(Operation operation) {
    return (RestDocumentationContext) operation.getAttributes().get(RestDocumentationContext.class.getName());
}

From source file:capital.scalable.restdocs.OperationAttributeHelper.java

public static TemplateFormat getTemplateFormat(Operation operation) {
    StandardWriterResolver writerResolver = (StandardWriterResolver) operation.getAttributes()
            .get(WriterResolver.class.getName());
    Field field = findField(StandardWriterResolver.class, "templateFormat");
    makeAccessible(field);// www  .j  av  a  2 s .  c  om
    return (TemplateFormat) getField(field, writerResolver);
}

From source file:io.spring.initializr.web.test.ResponseFieldSnippet.java

@Override
public void document(Operation operation) throws IOException {
    RestDocumentationContext context = (RestDocumentationContext) operation.getAttributes()
            .get(RestDocumentationContext.class.getName());
    WriterResolver writerResolver = (WriterResolver) operation.getAttributes()
            .get(WriterResolver.class.getName());
    try (Writer writer = writerResolver.resolve(operation.getName() + "/" + getSnippetName(), file, context)) {
        Map<String, Object> model = createModel(operation);
        model.putAll(getAttributes());//  w  w  w .j av  a2 s.  c o m
        TemplateEngine templateEngine = (TemplateEngine) operation.getAttributes()
                .get(TemplateEngine.class.getName());
        writer.append(templateEngine.compileTemplate(getSnippetName()).render(model));
    }
}