Rebound Java Client

Client library for rebound mock server

Лицензия

Лицензия

Категории

Категории

Java Языки программирования CLI Взаимодействие с пользователем
Группа

Группа

io.pileworx
Идентификатор

Идентификатор

rebound-client-java
Последняя версия

Последняя версия

0.2.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

Rebound Java Client
Client library for rebound mock server
Ссылка на сайт

Ссылка на сайт

https://github.com/pileworx/rebound-client-java
Система контроля версий

Система контроля версий

https://github.com/pileworx/rebound-client-java

Скачать rebound-client-java

Как подключить последнюю версию

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

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
com.konghq : unirest-java jar 3.7.02
com.fasterxml.jackson.core : jackson-databind jar 2.9.8
com.fasterxml.jackson.core : jackson-annotations jar 2.9.8

test (4)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.mockito : mockito-core jar 2.23.0
org.hamcrest : hamcrest-core jar 1.3
org.hamcrest : hamcrest-library jar 1.3

Модули Проекта

Данный проект не имеет модулей.

rebound-client-java

A convenience library for working with rebound in the jvm.

Build Status Codacy Badge Codacy Badge

Please visit rebound for details on the rebound mock server and it's API.

Usage

Include the dependency in your build:

<dependency>
  <groupId>io.pileworx</groupId>
  <artifactId>rebound-client-java</artifactId>
  <version>0.2.0</version>
</dependency>

API

Create an instance of the client

String reboundHost = "http://localhost:8585";
ReboundRestClient client = ReboundRestClient.create(reboundHost);

Mocking

Defining a mock:

Mock mock = new DefineMock().with(m -> {
            m.scenario = "Test Scenario";
            m.when = new DefineRequest().with(req -> {
                req.method = Method.GET;
                req.path = "/foo";
                req.query = "foo=bar&bar=baz";
                req.headers = Header.of​("Accept", "application/hal+json");
                req.body = "{\"foo\":\"bar\"}";
            }).build();
            m.then = List.of(
                    new DefineResponse().with(resp1 -> {
                        resp1.status = 200;
                        resp1.headers = Header.of​("Content-Type", "application/json");
                        resp1.body = "[#foreach($i in [1..5]){\"propertyName\":\"this is my value\"} #if($foreach.count != 5), #end #end]";
                    }).build(),
                    new DefineResponse().with(resp2 -> {
                        resp2.status = 200;
                        resp2.headers = Header.of​("Content-Type", "application/json");
                        resp2.bodyFromFile = Paths.get("./src/test/java/io/pileworx/rebound/client/velocity.vm");
                        resp2.values = Map.of("myValue", "this is my value");
                    }).build()
            );
        }).build();

If one response is supplied, it will be returned on every matching request. If a list is supplied, they will return in order. After the last response is returned following requests will result in error. Response Body support velocity templates. They can be defined inline or from a vm file. For more info please see Velocity. For more info on each of the properties, please see the rebound documentation at rebound.

Then you can add the mock to the server:

Status status = client.createMock(mock);

Teardown

In your teardown, you can reset the mock server like this.

Status status = client.clearMocks();
io.pileworx

pileworx

Версии библиотеки

Версия
0.2.1
0.2.0