Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish spine-testutils-web #167

Merged
merged 12 commits into from
Mar 4, 2021
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ plugins {
}

extra["credentialsPropertyFile"] = PublishingRepos.cloudRepo.credentials
extra["projectsToPublish"] = listOf("web", "firebase-web")
extra["projectsToPublish"] = listOf("web", "firebase-web", "testutil-web")

allprojects {
apply {
Expand Down
2 changes: 1 addition & 1 deletion client-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spine-web",
"version": "1.7.2",
"version": "1.7.3",
"license": "Apache-2.0",
"description": "A JS client for interacting with Spine applications.",
"homepage": "https://spine.io",
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/js-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "client-js-tests",
"version": "1.7.2",
"version": "1.7.3",
"license": "Apache-2.0",
"description": "Tests of a `spine-web` JS library against the Spine-based application.",
"scripts": {
Expand Down
32 changes: 16 additions & 16 deletions license-report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# Dependencies of `io.spine:spine-client-js:1.7.2`
# Dependencies of `io.spine:spine-client-js:1.7.3`

## Runtime
1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2
Expand Down Expand Up @@ -367,10 +367,10 @@
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Feb 01 17:22:46 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Mar 04 13:36:38 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).


#NPM dependencies of `spine-web@1.7.2`
#NPM dependencies of `spine-web@1.7.3`

## `Production` dependencies:

Expand All @@ -389,7 +389,7 @@ This report was generated on **Mon Feb 01 17:22:46 EET 2021** using [Gradle-Lice
1. **rxjs@6.5.5**
* Licenses: Apache-2.0
* Repository: [https://github.com/reactivex/rxjs](https://github.com/reactivex/rxjs)
1. **spine-web@1.7.2**
1. **spine-web@1.7.3**
* Licenses: Apache-2.0
* Repository: [https://github.com/SpineEventEngine/web](https://github.com/SpineEventEngine/web)
1. **tslib@1.14.1**
Expand Down Expand Up @@ -2449,7 +2449,7 @@ This report was generated on **Mon Feb 01 17:22:46 EET 2021** using [Gradle-Lice
1. **spdx-satisfies@4.0.1**
* Licenses: MIT
* Repository: [https://github.com/kemitchell/spdx-satisfies.js](https://github.com/kemitchell/spdx-satisfies.js)
1. **spine-web@1.7.2**
1. **spine-web@1.7.3**
* Licenses: Apache-2.0
* Repository: [https://github.com/SpineEventEngine/web](https://github.com/SpineEventEngine/web)
1. **split-string@3.1.0**
Expand Down Expand Up @@ -2757,12 +2757,12 @@ This report was generated on **Mon Feb 01 17:22:46 EET 2021** using [Gradle-Lice
* Repository: [https://github.com/yargs/yargs](https://github.com/yargs/yargs)


This report was generated on **Mon Feb 01 2021 17:22:49 GMT+0200 (Eastern European Standard Time)** using [NPM License Checker](https://github.com/davglass/license-checker) library.
This report was generated on **Thu Mar 04 2021 13:36:42 GMT+0200 (Eastern European Standard Time)** using [NPM License Checker](https://github.com/davglass/license-checker) library.




# Dependencies of `io.spine.gcloud:spine-firebase-web:1.7.2`
# Dependencies of `io.spine.gcloud:spine-firebase-web:1.7.3`

## Runtime
1. **Group:** com.fasterxml.jackson.core **Name:** jackson-annotations **Version:** 2.9.10
Expand Down Expand Up @@ -3548,12 +3548,12 @@ This report was generated on **Mon Feb 01 2021 17:22:49 GMT+0200 (Eastern Europe
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Feb 01 17:22:57 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Mar 04 13:36:50 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-js-tests:1.7.2`
# Dependencies of `io.spine:spine-js-tests:1.7.3`

## Runtime
1. **Group:** com.google.code.findbugs **Name:** jsr305 **Version:** 3.0.2
Expand Down Expand Up @@ -3942,12 +3942,12 @@ This report was generated on **Mon Feb 01 17:22:57 EET 2021** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Feb 01 17:23:04 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Mar 04 13:37:42 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-test-app:1.7.2`
# Dependencies of `io.spine:spine-test-app:1.7.3`

## Runtime
1. **Group:** com.fasterxml.jackson.core **Name:** jackson-annotations **Version:** 2.9.10
Expand Down Expand Up @@ -5520,12 +5520,12 @@ This report was generated on **Mon Feb 01 17:23:04 EET 2021** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Feb 01 17:23:08 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Mar 04 13:37:48 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-testutil-web:1.7.2`
# Dependencies of `io.spine:spine-testutil-web:1.7.3`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -5983,12 +5983,12 @@ This report was generated on **Mon Feb 01 17:23:08 EET 2021** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Feb 01 17:23:09 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Mar 04 13:37:52 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).




# Dependencies of `io.spine:spine-web:1.7.2`
# Dependencies of `io.spine:spine-web:1.7.3`

## Runtime
1. **Group:** com.google.android **Name:** annotations **Version:** 4.1.1.4
Expand Down Expand Up @@ -6485,4 +6485,4 @@ This report was generated on **Mon Feb 01 17:23:09 EET 2021** using [Gradle-Lice
The dependencies distributed under several licenses, are used according their commercial-use-friendly license.


This report was generated on **Mon Feb 01 17:23:12 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
This report was generated on **Thu Mar 04 13:37:58 EET 2021** using [Gradle-License-Report plugin](https://github.com/jk1/Gradle-License-Report) by Evgeny Naumenko, licensed under [Apache 2.0 License](https://github.com/jk1/Gradle-License-Report/blob/master/LICENSE).
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ all modules and does not describe the project structure per-subproject.

<groupId>io.spine</groupId>
<artifactId>spine-web</artifactId>
<version>1.7.2</version>
<version>1.7.3</version>

<inceptionYear>2015</inceptionYear>

Expand Down
132 changes: 101 additions & 31 deletions testutil-web/src/main/java/io/spine/web/given/KnownRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,23 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.net.MediaType;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.Map;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterators.asEnumeration;
import static com.google.common.collect.Iterators.singletonIterator;
import static java.util.Collections.emptyIterator;

/**
* A mocked servlet request with pre-defined {@code content}, {@code type} and {@code headers}.
* A mocked servlet request with pre-defined content.
*
* @implNote The request is effectively immutable and does not pay attention to any
* modification attempts. Such a mocked implementation may be used for tests where
Expand All @@ -58,55 +60,49 @@ public final class KnownRequest implements MockedRequest {
private final ImmutableMap<String, String> headers;
private final byte[] content;
private final MediaType type;
private final String uri;

private KnownRequest(ImmutableMap<String, String> headers, byte[] content, MediaType type) {
this.headers = headers;
this.content = content;
this.type = type;
private KnownRequest(Builder builder) {
this.headers = builder.headers;
this.content = builder.content;
this.type = builder.type;
this.uri = builder.uri;
}

/**
* Creates a new mocked request with specified {@code content} and default
* {@linkplain MediaType#ANY_TYPE any} type.
* Creates an empty request.
*/
public static KnownRequest create(String content) {
checkNotNull(content);
return create(content, MediaType.ANY_TYPE);
public static KnownRequest empty() {
return newBuilder().build();
}

/**
* Creates a new mocked request with specified {@code content} and {@code type}.
* Creates a new request builder.
*/
public static KnownRequest create(String content, MediaType type) {
checkNotNull(content);
checkNotNull(type);
return create(content, type, contentTypeHeader(type));
public static Builder newBuilder() {
return new Builder();
}

/**
* Creates a new mocked request with specified {@code content}, {@code type}
* and {@code headers}.
* Creates a new mocked request with specified {@code content} and default
* {@linkplain MediaType#ANY_TYPE any} type.
*/
public static KnownRequest create(String content,
MediaType type,
ImmutableMap<String, String> headers) {
public static KnownRequest create(String content) {
checkNotNull(content);
checkNotNull(type);
checkNotNull(headers);
return create(content.getBytes(StandardCharsets.UTF_8), type, headers);
return create(content, MediaType.ANY_TYPE);
}

/**
* Creates a new mocked request with specified {@code content}, {@code type}
* and {@code headers}.
* Creates a new mocked request with specified {@code content} and {@code type}.
*/
public static KnownRequest create(byte[] content,
MediaType type,
ImmutableMap<String, String> headers) {
public static KnownRequest create(String content, MediaType type) {
checkNotNull(content);
checkNotNull(type);
checkNotNull(headers);
return new KnownRequest(headers, content, type);
return newBuilder()
.withContent(content)
.withType(type)
.withHeaders(contentTypeHeader(type))
.build();
}

private static ImmutableMap<String, String> contentTypeHeader(MediaType type) {
Expand Down Expand Up @@ -144,7 +140,7 @@ public long getContentLengthLong() {
}

@Override
public @Nullable String getContentType() {
public @NonNull String getContentType() {
return type.toString();
}

Expand All @@ -156,4 +152,78 @@ public BufferedReader getReader() {
)
);
}

@Override
public @NonNull String getRequestURI() {
return uri;
}

/**
* A builder for producing {@code KnownRequest} instances.
*/
public static class Builder {

private ImmutableMap<String, String> headers = ImmutableMap.of();
private MediaType type = MediaType.ANY_TYPE;
private byte[] content = "".getBytes(StandardCharsets.UTF_8);
private String uri = "";

/**
* Prevents instantiation outside of the class.
*
* @see #newBuilder()
*/
private Builder() {
}

/**
* Sets the request content.
*/
public Builder withContent(String content) {
checkNotNull(content);
this.content = content.getBytes(StandardCharsets.UTF_8);
return this;
}

/**
* Sets the request content bytes.
*/
public Builder withBinaryContent(byte[] content) {
checkNotNull(content);
this.content = content.clone();
return this;
}

/**
* Sets the request headers.
*/
public Builder withHeaders(Map<String, String> headers) {
checkNotNull(headers);
this.headers = ImmutableMap.copyOf(headers);
return this;
}

/**
* Sets the request media type.
*/
public Builder withType(MediaType type) {
this.type = checkNotNull(type);
return this;
}

/**
* Sets the request URI.
*/
public Builder withUri(String uri) {
this.uri = checkNotNull(uri);
return this;
}

/**
* Creates a request out of this builder.
*/
public KnownRequest build() {
return new KnownRequest(this);
}
}
}
Loading