Skip to content

Commit

Permalink
Add a test case for empty defaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-sergiichuk committed Mar 4, 2021
1 parent 01329f8 commit d931ee7
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
package io.spine.web.given;

import com.google.common.collect.ImmutableMap;
import com.google.common.io.CharStreams;
import com.google.common.net.MediaType;
import com.google.common.testing.NullPointerTester;
import org.junit.jupiter.api.DisplayName;
Expand All @@ -49,9 +50,11 @@ void notTolerateNull() {

@Test
@DisplayName("return set values")
@SuppressWarnings("JdkObsolete") // we're force to follow the contract
@SuppressWarnings("JdkObsolete")
// we're force to follow the contract
void returnSetValues() throws IOException {
String text = "some text";
String uri = "/perform/action";
MediaType type = MediaType.PLAIN_TEXT_UTF_8;
String headerName = "custom";
String headerValue = "header";
Expand All @@ -61,6 +64,7 @@ void returnSetValues() throws IOException {
.withContent(text)
.withType(type)
.withHeaders(headers)
.withUri(uri)
.build();
assertThat(request.getContentLength())
.isEqualTo(text.length());
Expand All @@ -79,6 +83,22 @@ void returnSetValues() throws IOException {
assertThat(request.getReader()
.readLine())
.isEqualTo(text);
assertThat(request.getRequestURI())
.isEqualTo(uri);
}

@Test
@DisplayName("create empty request")
void empty() throws IOException {
KnownRequest request = KnownRequest.empty();
assertThat(request.getContentLength())
.isEqualTo(0);
assertThat(request.getContentLengthLong())
.isEqualTo(0);
assertThat(request.getContentType())
.isEqualTo(MediaType.ANY_TYPE.toString());
assertThat(CharStreams.toString(request.getReader()))
.isEmpty();
assertThat(request.getRequestURI())
.isEmpty();
}
Expand Down

0 comments on commit d931ee7

Please sign in to comment.