docuss

A library to test with describing document for controller layer

License

License

Categories

Categories

Net
GroupId

GroupId

net.moznion
ArtifactId

ArtifactId

docuss
Last Version

Last Version

0.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

docuss
A library to test with describing document for controller layer
Project URL

Project URL

https://github.com/moznion/docuss
Source Code Management

Source Code Management

https://github.com/moznion/docuss

Download docuss

How to add to project

<!-- https://jarcasting.com/artifacts/net.moznion/docuss/ -->
<dependency>
    <groupId>net.moznion</groupId>
    <artifactId>docuss</artifactId>
    <version>0.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/net.moznion/docuss/
implementation 'net.moznion:docuss:0.2.1'
// https://jarcasting.com/artifacts/net.moznion/docuss/
implementation ("net.moznion:docuss:0.2.1")
'net.moznion:docuss:jar:0.2.1'
<dependency org="net.moznion" name="docuss" rev="0.2.1">
  <artifact name="docuss" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.moznion', module='docuss', version='0.2.1')
)
libraryDependencies += "net.moznion" % "docuss" % "0.2.1"
[net.moznion/docuss "0.2.1"]

Dependencies

compile (4)

Group / Artifact Type Version
org.apache.httpcomponents : httpclient jar 4.5.2
com.fasterxml.jackson.core : jackson-core jar 2.8.1
com.fasterxml.jackson.dataformat : jackson-dataformat-yaml jar 2.8.1
com.fasterxml.jackson.core : jackson-databind jar 2.8.1

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.14.8

test (4)

Group / Artifact Type Version
junit : junit jar 4.12
me.geso : servlettester-jetty jar 0.1.0
com.google.code.findbugs : findbugs jar 3.0.0
net.moznion : capture-output-stream jar 1.0.0

Project Modules

There are no modules declared in this project.

Docuss Build Status javadoc.io

A library to test with describing document for controller layer.

Synopsis

final Docuss<HttpEntity, HttpResponse> docuss = new Docuss<>(new YAMLFormatterGenerator(),
                                                             new StandardOutPresenter(),
                                                             new ApacheHttpclient());
docuss.shouldGet(uri, resp -> {
    assertEquals(200, resp.getStatusLine().getStatusCode());
}); // <= tests and outputs request/response information

Description

This library provides methods to test HTTP request and response of your application easily; and output the request/response information automatically.

Methods receive "a URI of request" and "a lambda to inspect response". These methods send a request to the specified URI with HTTP method that corresponds to each method. And the response of the request is passed to given lambda as a parameter. We must write code into lambda to test the response.

When testing is finished successfully, it outputs contents of request and response as arbitrary format. For example, it outputs as follows hen the code that is shown on Synopsis is given.

---
request:
  method: "GET"
  protocol: "HTTP/1.1"
  path: "/foo/bar"
  headers: []
  body: null
  queryParams: {}
response:
  protocol: "HTTP/1.1"
  statusCode: 200
  headers:
  - "Date: Sat, 30 Jul 2016 15:36:35 GMT"
  - "Content-Length: 28"
  - "Server: Jetty(9.2.2.v20140723)"
  body: "{\"msg\": \"Hey\",\n\"value\": 100}"

Show the way to control format below.

Formatter generator

DocussFormatterGenerator is an Interface that defines a method to get a formatter generator for results (results = DocussDocument). The class that implements this interface must provide a formatter generator. Generated formatter is applied to the results to format it.

It means, you can modify the format of output by writing your own formatter generator.

Presenter

DocussPresenter is an Interface that defines a method to output the results.

If you want to change the way (or destination) of output, please implement this interface on your own class.

HTTP client

DocussHttpClient is an Interface that defines methods to handle the operations of HTTP layer.

This library doesn't depend on any specific HTTP client implementations. So if you want to use this library with any HTTP client, please implement this interface on your own class with the HTTP client.

More information

Please refer to javadoc.

javadoc.io

See Also

This library is inspired by autodoc.

Author

moznion ([email protected])

License

The MIT License (MIT)
Copyright © 2016 moznion, http://moznion.net/ <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Versions

Version
0.2.1
0.2.0
0.1.0
0.0.2
0.0.1