Skip to content

Commit 628ec27

Browse files
committed
#728 - Polishing.
Improving some JavaDoc. Adding issue references to tests. Updating copyright notice.
1 parent df0d2f2 commit 628ec27

13 files changed

+104
-19
lines changed

src/main/java/org/springframework/hateoas/config/mvc/HypermediaWebMvcConfigurer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import java.util.Arrays;
2424
import java.util.Collection;
25+
import java.util.Collections;
2526
import java.util.List;
2627

2728
import org.springframework.beans.BeansException;
@@ -104,7 +105,7 @@ public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
104105
if (this.hypermediaTypes.contains(HypermediaType.HAL_FORMS)) {
105106

106107
converters.add(0, new TypeConstrainedMappingJackson2HttpMessageConverter(
107-
ResourceSupport.class, Arrays.asList(HAL_FORMS_JSON),
108+
ResourceSupport.class, Collections.singletonList(HAL_FORMS_JSON),
108109
createHalFormsObjectMapper(this.mapper, this.curieProvider, this.relProvider, linkRelationMessageSource,
109110
this.halFormsConfiguration)));
110111
}
@@ -113,14 +114,14 @@ public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
113114
if (this.hypermediaTypes.contains(HypermediaType.COLLECTION_JSON)) {
114115

115116
converters.add(0, new TypeConstrainedMappingJackson2HttpMessageConverter(
116-
ResourceSupport.class, Arrays.asList(COLLECTION_JSON),
117+
ResourceSupport.class, Collections.singletonList(COLLECTION_JSON),
117118
createCollectionJsonObjectMapper(this.mapper, linkRelationMessageSource)));
118119
}
119120

120121
if (this.hypermediaTypes.contains(HypermediaType.UBER)) {
121122

122123
converters.add(0, new TypeConstrainedMappingJackson2HttpMessageConverter(
123-
ResourceSupport.class, Arrays.asList(UBER_JSON), createUberObjectMapper(this.mapper)));
124+
ResourceSupport.class, Collections.singletonList(UBER_JSON), createUberObjectMapper(this.mapper)));
124125
}
125126
}
126127
}

src/main/java/org/springframework/hateoas/core/DummyInvocationUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 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.

src/main/java/org/springframework/hateoas/core/JsonPathLinkDiscoverer.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 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.
@@ -79,8 +79,6 @@ public class JsonPathLinkDiscoverer implements LinkDiscoverer {
7979
public JsonPathLinkDiscoverer(String pathTemplate, MediaType mediaType, MediaType... others) {
8080

8181
Assert.hasText(pathTemplate, "Path template must not be null!");
82-
// Assert.isTrue(StringUtils.countOccurrencesOf(pathTemplate, "%s") == 1,
83-
// "Path template must contain a single placeholder!");
8482
Assert.notNull(mediaType, "Primary MediaType must not be null!");
8583
Assert.notNull(others, "Other MediaTypes must not be null!");
8684

src/main/java/org/springframework/hateoas/core/WebHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import org.springframework.web.util.UriTemplate;
4747

4848
/**
49-
* Utility for taking a a method invocation and extracting a {@link ControllerLinkBuilder}.
49+
* Utility for taking a method invocation and extracting a {@link ControllerLinkBuilder}.
5050
*
5151
* @author Greg Turnquist
5252
*/

src/main/java/org/springframework/hateoas/mvc/JacksonSerializers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017 the original author or authors.
2+
* Copyright 2019 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.

src/test/java/org/springframework/hateoas/config/mvc/HypermediaRestTemplateBeanPostProcessorTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,16 @@
3535
import org.springframework.web.client.RestTemplate;
3636

3737
/**
38+
*
39+
* Tests the registration of media types by the {@link HypermediaRestTemplateBeanPostProcessor}.
40+
*
3841
* @author Greg Turnquist
3942
*/
4043
public class HypermediaRestTemplateBeanPostProcessorTest {
4144

45+
/**
46+
* @see #728
47+
*/
4248
@Test
4349
public void shouldRegisterJustHal() {
4450

@@ -53,6 +59,9 @@ public void shouldRegisterJustHal() {
5359
});
5460
}
5561

62+
/**
63+
* @see #728
64+
*/
5665
@Test
5766
public void shouldRegisterHalAndCollectionJsonMessageConverters() {
5867

@@ -68,6 +77,9 @@ public void shouldRegisterHalAndCollectionJsonMessageConverters() {
6877
});
6978
}
7079

80+
/**
81+
* @see #728
82+
*/
7183
@Test
7284
public void shouldRegisterHypermediaMessageConverters() {
7385

src/test/java/org/springframework/hateoas/config/reactive/HypermediaWebClientBeanPostProcessorTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import org.springframework.web.reactive.function.client.WebClient;
4242

4343
/**
44+
* Tests registration of proper decoders by the {@link HypermediaWebClientBeanPostProcessor}.
4445
* @author Greg Turnquist
4546
*/
4647
public class HypermediaWebClientBeanPostProcessorTest {
@@ -74,6 +75,9 @@ public void tearDown() throws IOException {
7475
}
7576
}
7677

78+
/**
79+
* @see #728
80+
*/
7781
@Test
7882
public void shouldHandleRootHalDocument() {
7983

@@ -96,6 +100,9 @@ public void shouldHandleRootHalDocument() {
96100
});
97101
}
98102

103+
/**
104+
* @see #728
105+
*/
99106
@Test
100107
public void shouldHandleNavigatingToAResourceObject() {
101108

src/test/java/org/springframework/hateoas/config/reactive/HypermediaWebFluxConfigurerTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ void setUp(Class<?> context) {
7575
.build();
7676
}
7777

78+
/**
79+
* @see #728
80+
*/
7881
@Test
7982
public void registeringHalShouldServeHal() {
8083

@@ -85,6 +88,9 @@ public void registeringHalShouldServeHal() {
8588
verifySingleItemResourceServesHypermedia(MediaTypes.HAL_JSON, MediaTypes.HAL_JSON_UTF8);
8689
}
8790

91+
/**
92+
* @see #728
93+
*/
8894
@Test
8995
public void registeringHalFormsShouldServeHalForms() {
9096

@@ -95,6 +101,9 @@ public void registeringHalFormsShouldServeHalForms() {
95101
verifySingleItemResourceServesHypermedia(MediaTypes.HAL_FORMS_JSON);
96102
}
97103

104+
/**
105+
* @see #728
106+
*/
98107
@Test
99108
public void registeringCollectionJsonShouldServerCollectionJson() {
100109

@@ -105,6 +114,9 @@ public void registeringCollectionJsonShouldServerCollectionJson() {
105114
verifySingleItemResourceServesHypermedia(MediaTypes.COLLECTION_JSON);
106115
}
107116

117+
/**
118+
* @see #728
119+
*/
108120
@Test
109121
public void registeringUberShouldServerUber() {
110122

@@ -115,6 +127,9 @@ public void registeringUberShouldServerUber() {
115127
verifySingleItemResourceServesHypermedia(MediaTypes.UBER_JSON);
116128
}
117129

130+
/**
131+
* @see #728
132+
*/
118133
@Test
119134
public void registeringHalAndHalFormsShouldServerHalAndHalForms() {
120135

@@ -129,6 +144,9 @@ public void registeringHalAndHalFormsShouldServerHalAndHalForms() {
129144
verifySingleItemResourceServesHypermedia(MediaTypes.HAL_FORMS_JSON);
130145
}
131146

147+
/**
148+
* @see #728
149+
*/
132150
@Test
133151
public void registeringHalAndCollectionJsonShouldServerHalAndCollectionJson() {
134152

@@ -147,6 +165,9 @@ public void registeringHalAndCollectionJsonShouldServerHalAndCollectionJson() {
147165
verifySingleItemResourceServesHypermedia(MediaTypes.COLLECTION_JSON);
148166
}
149167

168+
/**
169+
* @see #728
170+
*/
150171
@Test
151172
public void registeringAllHypermediaTypesShouldServerThemAll() {
152173

@@ -169,6 +190,9 @@ public void registeringAllHypermediaTypesShouldServerThemAll() {
169190
verifySingleItemResourceServesHypermedia(MediaTypes.UBER_JSON);
170191
}
171192

193+
/**
194+
* @see #728
195+
*/
172196
@Test
173197
public void callingForUnregisteredMediaTypeShouldFail() {
174198

@@ -184,6 +208,9 @@ public void callingForUnregisteredMediaTypeShouldFail() {
184208
.verifyComplete();
185209
}
186210

211+
/**
212+
* @see #728
213+
*/
187214
@Test
188215
public void reactorTypesShouldWork() {
189216

src/test/java/org/springframework/hateoas/core/ControllerEntityLinksUnitTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616
package org.springframework.hateoas.core;
1717

18+
import static java.util.Collections.*;
1819
import static org.assertj.core.api.Assertions.*;
19-
import static org.mockito.ArgumentMatchers.any;
20-
import static org.mockito.ArgumentMatchers.eq;
20+
import static org.mockito.ArgumentMatchers.*;
2121
import static org.mockito.Mockito.*;
2222
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.*;
2323

@@ -49,7 +49,7 @@ public class ControllerEntityLinksUnitTest extends TestUtils {
4949
public void rejectsUnannotatedController() {
5050

5151
assertThatExceptionOfType(IllegalArgumentException.class) //
52-
.isThrownBy(() -> new ControllerEntityLinks(Arrays.asList(InvalidController.class), linkBuilderFactory)) //
52+
.isThrownBy(() -> new ControllerEntityLinks(singletonList(InvalidController.class), linkBuilderFactory)) //
5353
.withMessageContaining(InvalidController.class.getName());
5454
}
5555

@@ -63,14 +63,14 @@ public void rejectsNullControllerList() {
6363
public void rejectsNullLinkBuilderFactory() {
6464

6565
assertThatExceptionOfType(IllegalArgumentException.class) //
66-
.isThrownBy(() -> new ControllerEntityLinks(Arrays.asList(SampleController.class), null));
66+
.isThrownBy(() -> new ControllerEntityLinks(singletonList(SampleController.class), null));
6767
}
6868

6969
@Test
7070
public void registersControllerForEntity() {
7171

7272
when(linkBuilderFactory.linkTo(SampleController.class, new Object[0])).thenReturn(linkTo(SampleController.class));
73-
EntityLinks links = new ControllerEntityLinks(Arrays.asList(SampleController.class), linkBuilderFactory);
73+
EntityLinks links = new ControllerEntityLinks(singletonList(SampleController.class), linkBuilderFactory);
7474

7575
assertThat(links.supports(Person.class)).isTrue();
7676
assertThat(links.linkFor(Person.class)).isNotNull();
@@ -85,7 +85,7 @@ public void returnsLinkBuilderForParameterizedController() {
8585
when(linkBuilderFactory.linkTo(eq(ControllerWithParameters.class), (Object[]) any())) //
8686
.thenReturn(linkTo(ControllerWithParameters.class, "1"));
8787

88-
ControllerEntityLinks links = new ControllerEntityLinks(Arrays.asList(ControllerWithParameters.class),
88+
ControllerEntityLinks links = new ControllerEntityLinks(singletonList(ControllerWithParameters.class),
8989
linkBuilderFactory);
9090
LinkBuilder builder = links.linkFor(Order.class, "1");
9191

src/test/java/org/springframework/hateoas/reactive/HypermediaWebFilterTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public void setUp() {
6161
.build();
6262
}
6363

64+
/**
65+
* @see #728
66+
*/
6467
@Test
6568
public void webFilterShouldEmbedExchangeIntoContext() {
6669

src/test/java/org/springframework/hateoas/reactive/ReactiveLinkBuilderTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public class ReactiveLinkBuilderTest {
4949
@Mock ServerWebExchange exchange;
5050
@Mock ServerHttpRequest request;
5151

52+
/**
53+
* @see #728
54+
*/
5255
@Test
5356
public void linkAtSameLevelAsExplicitServerExchangeShouldWork() throws URISyntaxException {
5457

@@ -63,6 +66,9 @@ public void linkAtSameLevelAsExplicitServerExchangeShouldWork() throws URISyntax
6366
assertThat(link.getHref()).isEqualTo("http://localhost:8080/api");
6467
}
6568

69+
/**
70+
* @see #728
71+
*/
6672
@Test
6773
public void linkAtSameLevelAsContextProvidedServerExchangeShouldWork() throws URISyntaxException {
6874

@@ -85,6 +91,9 @@ public void linkAtSameLevelAsContextProvidedServerExchangeShouldWork() throws UR
8591
.verifyComplete();
8692
}
8793

94+
/**
95+
* @see #728
96+
*/
8897
@Test
8998
public void shallowLinkFromDeepExplicitServerExchangeShouldWork() throws URISyntaxException {
9099

@@ -99,6 +108,9 @@ public void shallowLinkFromDeepExplicitServerExchangeShouldWork() throws URISynt
99108
assertThat(link.getHref()).isEqualTo("http://localhost:8080/api");
100109
}
101110

111+
/**
112+
* @see #728
113+
*/
102114
@Test
103115
public void shallowLinkFromDeepContextProvidedServerExchangeShouldWork() throws URISyntaxException {
104116

@@ -121,6 +133,9 @@ public void shallowLinkFromDeepContextProvidedServerExchangeShouldWork() throws
121133
.verifyComplete();
122134
}
123135

136+
/**
137+
* @see #728
138+
*/
124139
@Test
125140
public void deepLinkFromShallowExplicitServerExchangeShouldWork() throws URISyntaxException {
126141

@@ -135,6 +150,9 @@ public void deepLinkFromShallowExplicitServerExchangeShouldWork() throws URISynt
135150
assertThat(link.getHref()).isEqualTo("http://localhost:8080/api/employees");
136151
}
137152

153+
/**
154+
* @see #728
155+
*/
138156
@Test
139157
public void deepLinkFromShallowContextProvidedServerExchangeShouldWork() throws URISyntaxException {
140158

@@ -157,6 +175,9 @@ public void deepLinkFromShallowContextProvidedServerExchangeShouldWork() throws
157175
.verifyComplete();
158176
}
159177

178+
/**
179+
* @see #728
180+
*/
160181
@Test
161182
public void linkToRouteWithNoMappingShouldWork() throws URISyntaxException {
162183

@@ -179,6 +200,9 @@ public void linkToRouteWithNoMappingShouldWork() throws URISyntaxException {
179200
.verifyComplete();
180201
}
181202

203+
/**
204+
* @see #728
205+
*/
182206
@Test
183207
public void linkToRouteWithNoExchangeInTheContextShouldFallbackToRelativeUris() throws URISyntaxException {
184208

@@ -195,6 +219,9 @@ public void linkToRouteWithNoExchangeInTheContextShouldFallbackToRelativeUris()
195219
.verifyComplete();
196220
}
197221

222+
/**
223+
* @see #728
224+
*/
198225
@Test
199226
public void linkToRouteWithExplictExchangeBeingNullShouldFallbackToRelativeUris() throws URISyntaxException {
200227

0 commit comments

Comments
 (0)