Skip to content

Commit 61fe2fd

Browse files
author
Mathias Düsterhöft
committed
Apply review hints.
1 parent abfe42f commit 61fe2fd

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/ContentTypeHandlerFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-restdocs-core/src/main/java/org/springframework/restdocs/payload/FieldTypeResolver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
* payloads.
2424
*
2525
* @author Mathias Düsterhöft
26+
* @since 2.0.3
2627
*/
2728
public interface FieldTypeResolver {
2829

@@ -32,7 +33,7 @@ public interface FieldTypeResolver {
3233
* @param contentType the content type of the payload
3334
* @return the {@link FieldTypeResolver}
3435
*/
35-
static FieldTypeResolver create(byte[] content, MediaType contentType) {
36+
static FieldTypeResolver forContent(byte[] content, MediaType contentType) {
3637
return ContentTypeHandlerFactory.create(content, contentType)
3738
.getFieldTypeResolver();
3839
}

spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/FieldTypeResolverTests.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2016 the original author or authors.
2+
* Copyright 2014-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,12 +16,13 @@
1616

1717
package org.springframework.restdocs.payload;
1818

19+
import org.junit.Rule;
1920
import org.junit.Test;
21+
import org.junit.rules.ExpectedException;
2022

2123
import org.springframework.http.MediaType;
2224

2325
import static org.assertj.core.api.Assertions.assertThat;
24-
import static org.assertj.core.api.Assertions.assertThatThrownBy;
2526

2627
/**
2728
* Tests for {@link FieldTypeResolver}.
@@ -30,22 +31,25 @@
3031
*/
3132
public class FieldTypeResolverTests {
3233

34+
@Rule
35+
public ExpectedException thrownException = ExpectedException.none();
36+
3337
@Test
3438
public void returnJsonFieldTypeResolver() {
35-
assertThat(FieldTypeResolver.create("{\"field\": \"value\"}".getBytes(),
39+
assertThat(FieldTypeResolver.forContent("{\"field\": \"value\"}".getBytes(),
3640
MediaType.APPLICATION_JSON)).isInstanceOf(JsonFieldTypeResolver.class);
3741
}
3842

3943
@Test
4044
public void returnXmlContentHandler() {
41-
assertThat(FieldTypeResolver.create("<a><b>5</b></a>".getBytes(),
45+
assertThat(FieldTypeResolver.forContent("<a><b>5</b></a>".getBytes(),
4246
MediaType.APPLICATION_XML)).isInstanceOf(XmlContentHandler.class);
4347
}
4448

4549
@Test
4650
public void throwOnInvalidContent() {
47-
assertThatThrownBy(() -> FieldTypeResolver.create("some".getBytes(),
48-
MediaType.APPLICATION_XML)).isInstanceOf(PayloadHandlingException.class);
51+
this.thrownException.expect(PayloadHandlingException.class);
52+
FieldTypeResolver.forContent("some".getBytes(), MediaType.APPLICATION_XML);
4953
}
5054

5155
}

0 commit comments

Comments
 (0)