#340 - Polishing.
Used IDE to migrate several Java 6 constructors to Java 8.
This commit is contained in:
committed by
Oliver Gierke
parent
092ceb987f
commit
b81b1a4e45
@@ -66,7 +66,7 @@ public class Jackson2PagedResourcesIntegrationTest {
|
||||
user.lastname = "Matthews";
|
||||
|
||||
PageMetadata metadata = new PagedResources.PageMetadata(1, 0, 2);
|
||||
PagedResources<User> resources = new PagedResources<User>(Collections.singleton(user), metadata);
|
||||
PagedResources<User> resources = new PagedResources<>(Collections.singleton(user), metadata);
|
||||
|
||||
Method method = Sample.class.getMethod("someMethod");
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
@@ -27,7 +27,7 @@ public class Jackson2ResourceIntegrationTest extends AbstractJackson2Marshalling
|
||||
person.firstname = "Dave";
|
||||
person.lastname = "Matthews";
|
||||
|
||||
Resource<Person> resource = new Resource<Person>(person);
|
||||
Resource<Person> resource = new Resource<>(person);
|
||||
resource.add(new Link("localhost"));
|
||||
|
||||
assertThat(write(resource)).isEqualTo(REFERENCE);
|
||||
|
||||
@@ -57,7 +57,7 @@ public class PagedResourcesMarshallingTest {
|
||||
marshaller = context.createMarshaller();
|
||||
unmarshaller = context.createUnmarshaller();
|
||||
|
||||
pagedResources = new PagedResources<Inner>(new ArrayList<Inner>(), null);
|
||||
pagedResources = new PagedResources<>(new ArrayList<>(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,14 +73,10 @@ public class PagedResourcesMarshallingTest {
|
||||
|
||||
private static String readFile(org.springframework.core.io.Resource resource) throws IOException {
|
||||
|
||||
FileInputStream stream = new FileInputStream(resource.getFile());
|
||||
|
||||
try {
|
||||
try (FileInputStream stream = new FileInputStream(resource.getFile())) {
|
||||
FileChannel fc = stream.getChannel();
|
||||
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
|
||||
return Charset.defaultCharset().decode(bb).toString();
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PagedResourcesUnitTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
resources = new PagedResources<Object>(Collections.emptyList(), metadata);
|
||||
resources = new PagedResources<>(Collections.emptyList(), metadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ResourceIntegrationTest extends AbstractJackson2MarshallingIntegrat
|
||||
person.firstname = "Dave";
|
||||
person.lastname = "Matthews";
|
||||
|
||||
Resource<Person> resource = new Resource<Person>(person);
|
||||
Resource<Person> resource = new Resource<>(person);
|
||||
resource.add(new Link("localhost"));
|
||||
|
||||
assertThat(write(resource)).isEqualTo(REFERENCE);
|
||||
|
||||
@@ -31,15 +31,15 @@ public class ResourceUnitTest {
|
||||
@Test
|
||||
public void equalsForSelfReference() {
|
||||
|
||||
Resource<String> resource = new Resource<String>("foo");
|
||||
Resource<String> resource = new Resource<>("foo");
|
||||
assertThat(resource).isEqualTo(resource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsWithEqualContent() {
|
||||
|
||||
Resource<String> left = new Resource<String>("foo");
|
||||
Resource<String> right = new Resource<String>("foo");
|
||||
Resource<String> left = new Resource<>("foo");
|
||||
Resource<String> right = new Resource<>("foo");
|
||||
|
||||
assertThat(left).isEqualTo(right);
|
||||
assertThat(right).isEqualTo(left);
|
||||
@@ -48,8 +48,8 @@ public class ResourceUnitTest {
|
||||
@Test
|
||||
public void notEqualForDifferentContent() {
|
||||
|
||||
Resource<String> left = new Resource<String>("foo");
|
||||
Resource<String> right = new Resource<String>("bar");
|
||||
Resource<String> left = new Resource<>("foo");
|
||||
Resource<String> right = new Resource<>("bar");
|
||||
|
||||
assertThat(left).isNotEqualTo(right);
|
||||
assertThat(right).isNotEqualTo(left);
|
||||
@@ -58,8 +58,8 @@ public class ResourceUnitTest {
|
||||
@Test
|
||||
public void notEqualForDifferentLinks() {
|
||||
|
||||
Resource<String> left = new Resource<String>("foo");
|
||||
Resource<String> right = new Resource<String>("foo");
|
||||
Resource<String> left = new Resource<>("foo");
|
||||
Resource<String> right = new Resource<>("foo");
|
||||
right.add(new Link("localhost"));
|
||||
|
||||
assertThat(left).isNotEqualTo(right);
|
||||
|
||||
@@ -29,21 +29,21 @@ import org.junit.Test;
|
||||
*/
|
||||
public class ResourcesUnitTest {
|
||||
|
||||
Set<Resource<String>> foo = Collections.singleton(new Resource<String>("foo"));
|
||||
Set<Resource<String>> bar = Collections.singleton(new Resource<String>("bar"));
|
||||
Set<Resource<String>> foo = Collections.singleton(new Resource<>("foo"));
|
||||
Set<Resource<String>> bar = Collections.singleton(new Resource<>("bar"));
|
||||
|
||||
@Test
|
||||
public void equalsForSelfReference() {
|
||||
|
||||
Resources<Resource<String>> resource = new Resources<Resource<String>>(foo);
|
||||
Resources<Resource<String>> resource = new Resources<>(foo);
|
||||
assertThat(resource).isEqualTo(resource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsWithEqualContent() {
|
||||
|
||||
Resources<Resource<String>> left = new Resources<Resource<String>>(foo);
|
||||
Resources<Resource<String>> right = new Resources<Resource<String>>(foo);
|
||||
Resources<Resource<String>> left = new Resources<>(foo);
|
||||
Resources<Resource<String>> right = new Resources<>(foo);
|
||||
|
||||
assertThat(left).isEqualTo(right);
|
||||
assertThat(right).isEqualTo(left);
|
||||
@@ -52,8 +52,8 @@ public class ResourcesUnitTest {
|
||||
@Test
|
||||
public void notEqualForDifferentContent() {
|
||||
|
||||
Resources<Resource<String>> left = new Resources<Resource<String>>(foo);
|
||||
Resources<Resource<String>> right = new Resources<Resource<String>>(bar);
|
||||
Resources<Resource<String>> left = new Resources<>(foo);
|
||||
Resources<Resource<String>> right = new Resources<>(bar);
|
||||
|
||||
assertThat(left).isNotEqualTo(right);
|
||||
assertThat(right).isNotEqualTo(left);
|
||||
@@ -62,8 +62,8 @@ public class ResourcesUnitTest {
|
||||
@Test
|
||||
public void notEqualForDifferentLinks() {
|
||||
|
||||
Resources<Resource<String>> left = new Resources<Resource<String>>(foo);
|
||||
Resources<Resource<String>> right = new Resources<Resource<String>>(bar);
|
||||
Resources<Resource<String>> left = new Resources<>(foo);
|
||||
Resources<Resource<String>> right = new Resources<>(bar);
|
||||
right.add(new Link("localhost"));
|
||||
|
||||
assertThat(left).isNotEqualTo(right);
|
||||
|
||||
@@ -133,7 +133,7 @@ public class UriTemplateUnitTest {
|
||||
@Test
|
||||
public void expandsMultipleRequestParameters() {
|
||||
|
||||
Map<String, Object> parameters = new HashMap<String, Object>();
|
||||
Map<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("bar", "myBar");
|
||||
parameters.put("fooBar", "myFooBar");
|
||||
|
||||
@@ -150,7 +150,7 @@ public class UriTemplateUnitTest {
|
||||
public void rejectsMissingRequiredPathVariable() {
|
||||
|
||||
UriTemplate template = new UriTemplate("/foo/{bar}");
|
||||
template.expand(Collections.<String, Object> emptyMap());
|
||||
template.expand(Collections.emptyMap());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -200,7 +200,7 @@ public class UriTemplateUnitTest {
|
||||
UriTemplate source = new UriTemplate("/{foo}/bar{?page}");
|
||||
List<TemplateVariable> toAdd = Arrays.asList(new TemplateVariable("bar", VariableType.REQUEST_PARAM));
|
||||
|
||||
List<TemplateVariable> expected = new ArrayList<TemplateVariable>();
|
||||
List<TemplateVariable> expected = new ArrayList<>();
|
||||
expected.addAll(source.getVariables());
|
||||
expected.addAll(toAdd);
|
||||
|
||||
|
||||
@@ -122,14 +122,10 @@ public class VndErrorsMarshallingTest {
|
||||
|
||||
private static String readFile(org.springframework.core.io.Resource resource) throws IOException {
|
||||
|
||||
FileInputStream stream = new FileInputStream(resource.getFile());
|
||||
|
||||
try {
|
||||
try (FileInputStream stream = new FileInputStream(resource.getFile())) {
|
||||
FileChannel fc = stream.getChannel();
|
||||
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
|
||||
return Charset.defaultCharset().decode(bb).toString();
|
||||
} finally {
|
||||
stream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class HopUnitTest {
|
||||
Hop hop = Hop.rel("rel").withParameter("key", "value").withParameters(Collections.singletonMap("foo", "bar"));
|
||||
|
||||
assertThat(hop.getParameters()).hasSize(1) //
|
||||
.containsEntry("foo", (Object) "bar");
|
||||
.containsEntry("foo", "bar");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +99,7 @@ public class HopUnitTest {
|
||||
|
||||
Hop hop = Hop.rel("rel").withParameter("key", "value");
|
||||
|
||||
Map<String, Object> result = hop.getMergedParameters(Collections.singletonMap("key", (Object) "global"));
|
||||
Map<String, Object> result = hop.getMergedParameters(Collections.singletonMap("key", "global"));
|
||||
|
||||
assertThat(result).hasSize(1) //
|
||||
.containsEntry("key", "value");
|
||||
|
||||
@@ -52,7 +52,7 @@ public class Server implements Closeable {
|
||||
private final ObjectMapper mapper;
|
||||
private final RelProvider relProvider;
|
||||
|
||||
private final MultiValueMap<Link, Link> baseResources = new LinkedMultiValueMap<Link, Link>();
|
||||
private final MultiValueMap<Link, Link> baseResources = new LinkedMultiValueMap<>();
|
||||
private final ResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||
|
||||
public Server() {
|
||||
@@ -187,13 +187,13 @@ public class Server implements Closeable {
|
||||
|
||||
public void finishMocking() {
|
||||
|
||||
Resources<String> resources = new Resources<String>(Collections.<String> emptyList());
|
||||
Resources<String> resources = new Resources<>(Collections.emptyList());
|
||||
|
||||
for (Link link : baseResources.keySet()) {
|
||||
|
||||
resources.add(link);
|
||||
|
||||
Resources<String> nested = new Resources<String>(Collections.<String> emptyList());
|
||||
Resources<String> nested = new Resources<>(Collections.emptyList());
|
||||
nested.add(baseResources.get(link));
|
||||
|
||||
register(link.getHref(), nested);
|
||||
|
||||
@@ -91,7 +91,7 @@ public class TraversonTest {
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void rejectsEmptyMediaTypes() {
|
||||
new Traverson(baseUri, new MediaType[0]);
|
||||
new Traverson(baseUri);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,7 +187,7 @@ public class TraversonTest {
|
||||
CountingInterceptor interceptor = new CountingInterceptor();
|
||||
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
restTemplate.setInterceptors(Arrays.<ClientHttpRequestInterceptor> asList(interceptor));
|
||||
restTemplate.setInterceptors(Arrays.asList(interceptor));
|
||||
|
||||
this.traverson = new Traverson(baseUri, MediaTypes.HAL_JSON);
|
||||
this.traverson.setRestOperations(restTemplate);
|
||||
@@ -266,7 +266,7 @@ public class TraversonTest {
|
||||
public void returnsDefaultMessageConverters() {
|
||||
|
||||
List<HttpMessageConverter<?>> converters = Traverson
|
||||
.getDefaultMessageConverters(Collections.<MediaType> emptyList());
|
||||
.getDefaultMessageConverters(Collections.emptyList());
|
||||
|
||||
assertThat(converters).hasSize(1);
|
||||
assertThat(converters.get(0)).isInstanceOf(StringHttpMessageConverter.class);
|
||||
@@ -346,7 +346,7 @@ public class TraversonTest {
|
||||
|
||||
this.traverson = new Traverson(URI.create(server.rootResource() + "/springagram"), MediaTypes.HAL_JSON);
|
||||
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("projection", "thisShouldGetOverwrittenByLocalHop");
|
||||
|
||||
ParameterizedTypeReference<Resource<Item>> resourceParameterizedTypeReference = new ParameterizedTypeReference<Resource<Item>>() {};
|
||||
@@ -382,11 +382,11 @@ public class TraversonTest {
|
||||
|
||||
private void setUpActors() {
|
||||
|
||||
Resource<Actor> actor = new Resource<Actor>(new Actor("Keanu Reaves"));
|
||||
Resource<Actor> actor = new Resource<>(new Actor("Keanu Reaves"));
|
||||
String actorUri = server.mockResourceFor(actor);
|
||||
|
||||
Movie movie = new Movie("The Matrix");
|
||||
Resource<Movie> resource = new Resource<Movie>(movie);
|
||||
Resource<Movie> resource = new Resource<>(movie);
|
||||
resource.add(new Link(actorUri, "actor"));
|
||||
|
||||
server.mockResourceFor(resource);
|
||||
@@ -403,7 +403,7 @@ public class TraversonTest {
|
||||
this.intercepted++;
|
||||
return execution.execute(request, body);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static class GitHubLinkDiscoverer extends JsonPathLinkDiscoverer {
|
||||
|
||||
|
||||
@@ -144,9 +144,7 @@ public class EnableHypermediaSupportIntegrationTest {
|
||||
.getField(processor, "messageConverters");
|
||||
|
||||
assertThat(converters.get(0)).isInstanceOfSatisfying(TypeConstrainedMappingJackson2HttpMessageConverter.class,
|
||||
it -> {
|
||||
assertThat(it.getSupportedMediaTypes()).contains(MediaTypes.HAL_JSON, MediaTypes.HAL_JSON_UTF8);
|
||||
});
|
||||
it -> assertThat(it.getSupportedMediaTypes()).contains(MediaTypes.HAL_JSON, MediaTypes.HAL_JSON_UTF8));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ public class ControllerEntityLinksFactoryBeanUnitTest {
|
||||
ControllerEntityLinksFactoryBean builder = new ControllerEntityLinksFactoryBean();
|
||||
|
||||
assertThatExceptionOfType(IllegalStateException.class) //
|
||||
.isThrownBy(() -> builder.afterPropertiesSet()) //
|
||||
.isThrownBy(builder::afterPropertiesSet) //
|
||||
.withMessageContaining("Annotation");
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class DelegatingEntityLinksUnitTest extends TestUtils {
|
||||
@Test
|
||||
public void throwsExceptionForUnsupportedClass() {
|
||||
|
||||
EntityLinks links = new DelegatingEntityLinks(SimplePluginRegistry.<Class<?>, EntityLinks> create());
|
||||
EntityLinks links = new DelegatingEntityLinks(SimplePluginRegistry.create());
|
||||
|
||||
assertThatExceptionOfType(IllegalArgumentException.class) //
|
||||
.isThrownBy(() -> links.linkFor(String.class)) //
|
||||
|
||||
@@ -170,7 +170,7 @@ public class DefaultCurieProviderUnitTest {
|
||||
|
||||
private static Map<String, UriTemplate> getCuries() {
|
||||
|
||||
Map<String, UriTemplate> curies = new HashMap<String, UriTemplate>(2);
|
||||
Map<String, UriTemplate> curies = new HashMap<>(2);
|
||||
curies.put("foo", new UriTemplate("/foo/{rel}"));
|
||||
curies.put("bar", new UriTemplate("/bar/{rel}"));
|
||||
|
||||
|
||||
@@ -160,11 +160,11 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
|
||||
@Test
|
||||
public void rendersSimpleResourcesAsEmbedded() throws Exception {
|
||||
|
||||
List<String> content = new ArrayList<String>();
|
||||
List<String> content = new ArrayList<>();
|
||||
content.add("first");
|
||||
content.add("second");
|
||||
|
||||
Resources<String> resources = new Resources<String>(content);
|
||||
Resources<String> resources = new Resources<>(content);
|
||||
resources.add(new Link("localhost"));
|
||||
|
||||
assertThat(write(resources)).isEqualTo(SIMPLE_EMBEDDED_RESOURCE_REFERENCE);
|
||||
@@ -173,11 +173,11 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
|
||||
@Test
|
||||
public void deserializesSimpleResourcesAsEmbedded() throws Exception {
|
||||
|
||||
List<String> content = new ArrayList<String>();
|
||||
List<String> content = new ArrayList<>();
|
||||
content.add("first");
|
||||
content.add("second");
|
||||
|
||||
Resources<String> expected = new Resources<String>(content);
|
||||
Resources<String> expected = new Resources<>(content);
|
||||
expected.add(new Link("localhost"));
|
||||
|
||||
Resources<String> result = mapper.readValue(SIMPLE_EMBEDDED_RESOURCE_REFERENCE,
|
||||
@@ -190,10 +190,10 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
|
||||
@Test
|
||||
public void rendersSingleResourceResourcesAsEmbedded() throws Exception {
|
||||
|
||||
List<Resource<SimplePojo>> content = new ArrayList<Resource<SimplePojo>>();
|
||||
content.add(new Resource<SimplePojo>(new SimplePojo("test1", 1), new Link("localhost")));
|
||||
List<Resource<SimplePojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimplePojo("test1", 1), new Link("localhost")));
|
||||
|
||||
Resources<Resource<SimplePojo>> resources = new Resources<Resource<SimplePojo>>(content);
|
||||
Resources<Resource<SimplePojo>> resources = new Resources<>(content);
|
||||
resources.add(new Link("localhost"));
|
||||
|
||||
assertThat(write(resources)).isEqualTo(SINGLE_EMBEDDED_RESOURCE_REFERENCE);
|
||||
@@ -202,10 +202,10 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
|
||||
@Test
|
||||
public void deserializesSingleResourceResourcesAsEmbedded() throws Exception {
|
||||
|
||||
List<Resource<SimplePojo>> content = new ArrayList<Resource<SimplePojo>>();
|
||||
content.add(new Resource<SimplePojo>(new SimplePojo("test1", 1), new Link("localhost")));
|
||||
List<Resource<SimplePojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimplePojo("test1", 1), new Link("localhost")));
|
||||
|
||||
Resources<Resource<SimplePojo>> expected = new Resources<Resource<SimplePojo>>(content);
|
||||
Resources<Resource<SimplePojo>> expected = new Resources<>(content);
|
||||
expected.add(new Link("localhost"));
|
||||
|
||||
Resources<Resource<SimplePojo>> result = mapper.readValue(SINGLE_EMBEDDED_RESOURCE_REFERENCE,
|
||||
@@ -244,10 +244,10 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
|
||||
@Test
|
||||
public void serializesAnnotatedResourceResourcesAsEmbedded() throws Exception {
|
||||
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<Resource<SimpleAnnotatedPojo>>();
|
||||
content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
|
||||
Resources<Resource<SimpleAnnotatedPojo>> resources = new Resources<Resource<SimpleAnnotatedPojo>>(content);
|
||||
Resources<Resource<SimpleAnnotatedPojo>> resources = new Resources<>(content);
|
||||
resources.add(new Link("localhost"));
|
||||
|
||||
assertThat(write(resources)).isEqualTo(ANNOTATED_EMBEDDED_RESOURCE_REFERENCE);
|
||||
@@ -259,10 +259,10 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
|
||||
@Test
|
||||
public void deserializesAnnotatedResourceResourcesAsEmbedded() throws Exception {
|
||||
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<Resource<SimpleAnnotatedPojo>>();
|
||||
content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
|
||||
Resources<Resource<SimpleAnnotatedPojo>> expected = new Resources<Resource<SimpleAnnotatedPojo>>(content);
|
||||
Resources<Resource<SimpleAnnotatedPojo>> expected = new Resources<>(content);
|
||||
expected.add(new Link("localhost"));
|
||||
|
||||
Resources<Resource<SimpleAnnotatedPojo>> result = mapper.readValue(ANNOTATED_EMBEDDED_RESOURCE_REFERENCE,
|
||||
@@ -319,8 +319,8 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
|
||||
@Test
|
||||
public void rendersCuriesCorrectly() throws Exception {
|
||||
|
||||
Resources<Object> resources = new Resources<Object>(Collections.emptySet(), new Link("foo"),
|
||||
new Link("bar", "myrel"));
|
||||
Resources<Object> resources = new Resources<>(Collections.emptySet(), new Link("foo"),
|
||||
new Link("bar", "myrel"));
|
||||
|
||||
assertThat(getCuriedObjectMapper().writeValueAsString(resources)).isEqualTo(CURIED_DOCUMENT);
|
||||
}
|
||||
@@ -331,7 +331,7 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
|
||||
@Test
|
||||
public void doesNotRenderCuriesIfNoLinkIsPresent() throws Exception {
|
||||
|
||||
Resources<Object> resources = new Resources<Object>(Collections.emptySet());
|
||||
Resources<Object> resources = new Resources<>(Collections.emptySet());
|
||||
assertThat(getCuriedObjectMapper().writeValueAsString(resources)).isEqualTo(EMPTY_DOCUMENT);
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
|
||||
@Test
|
||||
public void doesNotRenderCuriesIfNoCurieLinkIsPresent() throws Exception {
|
||||
|
||||
Resources<Object> resources = new Resources<Object>(Collections.emptySet());
|
||||
Resources<Object> resources = new Resources<>(Collections.emptySet());
|
||||
resources.add(new Link("foo"));
|
||||
|
||||
assertThat(getCuriedObjectMapper().writeValueAsString(resources)).isEqualTo(SINGLE_NON_CURIE_LINK);
|
||||
@@ -365,7 +365,7 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
|
||||
@Test
|
||||
public void rendersMultipleCuries() throws Exception {
|
||||
|
||||
Resources<Object> resources = new Resources<Object>(Collections.emptySet());
|
||||
Resources<Object> resources = new Resources<>(Collections.emptySet());
|
||||
resources.add(new Link("foo", "myrel"));
|
||||
|
||||
CurieProvider provider = new DefaultCurieProvider("default", new UriTemplate("/doc{?rel}")) {
|
||||
@@ -386,10 +386,10 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
|
||||
|
||||
EmbeddedWrappers wrappers = new EmbeddedWrappers(false);
|
||||
|
||||
List<Object> values = new ArrayList<Object>();
|
||||
List<Object> values = new ArrayList<>();
|
||||
values.add(wrappers.emptyCollectionOf(SimpleAnnotatedPojo.class));
|
||||
|
||||
Resources<Object> resources = new Resources<Object>(values);
|
||||
Resources<Object> resources = new Resources<>(values);
|
||||
|
||||
assertThat(write(resources)).isEqualTo("{\"_embedded\":{\"pojos\":[]}}");
|
||||
}
|
||||
@@ -439,29 +439,29 @@ public class Jackson2HalIntegrationTest extends AbstractJackson2MarshallingInteg
|
||||
|
||||
private static Resources<Resource<SimpleAnnotatedPojo>> setupAnnotatedPagedResources() {
|
||||
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<Resource<SimpleAnnotatedPojo>>();
|
||||
content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test2", 2), new Link("localhost")));
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
content.add(new Resource<>(new SimpleAnnotatedPojo("test2", 2), new Link("localhost")));
|
||||
|
||||
return new PagedResources<Resource<SimpleAnnotatedPojo>>(content, new PageMetadata(2, 0, 4), PAGINATION_LINKS);
|
||||
return new PagedResources<>(content, new PageMetadata(2, 0, 4), PAGINATION_LINKS);
|
||||
}
|
||||
|
||||
private static Resources<Resource<SimpleAnnotatedPojo>> setupAnnotatedResources() {
|
||||
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<Resource<SimpleAnnotatedPojo>>();
|
||||
content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test2", 2), new Link("localhost")));
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
content.add(new Resource<>(new SimpleAnnotatedPojo("test2", 2), new Link("localhost")));
|
||||
|
||||
return new Resources<Resource<SimpleAnnotatedPojo>>(content);
|
||||
return new Resources<>(content);
|
||||
}
|
||||
|
||||
private static Resources<Resource<SimplePojo>> setupResources() {
|
||||
|
||||
List<Resource<SimplePojo>> content = new ArrayList<Resource<SimplePojo>>();
|
||||
content.add(new Resource<SimplePojo>(new SimplePojo("test1", 1), new Link("localhost")));
|
||||
content.add(new Resource<SimplePojo>(new SimplePojo("test2", 2), new Link("localhost")));
|
||||
List<Resource<SimplePojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimplePojo("test1", 1), new Link("localhost")));
|
||||
content.add(new Resource<>(new SimplePojo("test2", 2), new Link("localhost")));
|
||||
|
||||
return new Resources<Resource<SimplePojo>>(content);
|
||||
return new Resources<>(content);
|
||||
}
|
||||
|
||||
private static ObjectMapper getCuriedObjectMapper() {
|
||||
|
||||
@@ -109,7 +109,7 @@ public class HalFormsValidationIntegrationTest {
|
||||
@RestController
|
||||
static class BadController {
|
||||
|
||||
private final static Map<Integer, Employee> EMPLOYEES = new TreeMap<Integer, Employee>();
|
||||
private final static Map<Integer, Employee> EMPLOYEES = new TreeMap<>();
|
||||
|
||||
static {
|
||||
EMPLOYEES.put(0, new Employee("Frodo Baggins", "ring bearer"));
|
||||
@@ -120,7 +120,7 @@ public class HalFormsValidationIntegrationTest {
|
||||
public Resources<Resource<Employee>> all() {
|
||||
|
||||
// Create a list of Resource<Employee>'s to return
|
||||
List<Resource<Employee>> employees = new ArrayList<Resource<Employee>>();
|
||||
List<Resource<Employee>> employees = new ArrayList<>();
|
||||
|
||||
// Fetch each Resource<Employee> using the controller's findOne method.
|
||||
for (int i = 0; i < EMPLOYEES.size(); i++) {
|
||||
@@ -132,7 +132,7 @@ public class HalFormsValidationIntegrationTest {
|
||||
.andAffordance(afford(methodOn(BadController.class).updateEmployee(null, 0)));
|
||||
|
||||
// Return the collection of employee resources along with the composite affordance
|
||||
return new Resources<Resource<Employee>>(employees, selfLink);
|
||||
return new Resources<>(employees, selfLink);
|
||||
}
|
||||
|
||||
@GetMapping("/employees/{id}")
|
||||
@@ -146,8 +146,8 @@ public class HalFormsValidationIntegrationTest {
|
||||
.andAffordance(afford(methodOn(BadController.class).newEmployee(null)));
|
||||
|
||||
// Return the affordance + a link back to the entire collection resource.
|
||||
return new Resource<Employee>(EMPLOYEES.get(id), findOneLink.andAffordances(employeesLink.getAffordances()),
|
||||
employeesLink);
|
||||
return new Resource<>(EMPLOYEES.get(id), findOneLink.andAffordances(employeesLink.getAffordances()),
|
||||
employeesLink);
|
||||
}
|
||||
|
||||
@PostMapping("/employees")
|
||||
|
||||
@@ -127,7 +127,7 @@ public class HalFormsWebMvcIntegrationTest {
|
||||
@RestController
|
||||
static class EmployeeController {
|
||||
|
||||
private final static Map<Integer, Employee> EMPLOYEES = new TreeMap<Integer, Employee>();
|
||||
private final static Map<Integer, Employee> EMPLOYEES = new TreeMap<>();
|
||||
|
||||
static {
|
||||
EMPLOYEES.put(0, new Employee("Frodo Baggins", "ring bearer"));
|
||||
@@ -138,7 +138,7 @@ public class HalFormsWebMvcIntegrationTest {
|
||||
public Resources<Resource<Employee>> all() {
|
||||
|
||||
// Create a list of Resource<Employee>'s to return
|
||||
List<Resource<Employee>> employees = new ArrayList<Resource<Employee>>();
|
||||
List<Resource<Employee>> employees = new ArrayList<>();
|
||||
|
||||
// Fetch each Resource<Employee> using the controller's findOne method.
|
||||
for (int i = 0; i < EMPLOYEES.size(); i++) {
|
||||
@@ -150,7 +150,7 @@ public class HalFormsWebMvcIntegrationTest {
|
||||
.andAffordance(afford(methodOn(EmployeeController.class).newEmployee(null)));
|
||||
|
||||
// Return the collection of employee resources along with the composite affordance
|
||||
return new Resources<Resource<Employee>>(employees, selfLink);
|
||||
return new Resources<>(employees, selfLink);
|
||||
}
|
||||
|
||||
@GetMapping("/employees/{id}")
|
||||
@@ -163,10 +163,10 @@ public class HalFormsWebMvcIntegrationTest {
|
||||
Link employeesLink = linkTo(methodOn(EmployeeController.class).all()).withRel("employees");
|
||||
|
||||
// Return the affordance + a link back to the entire collection resource.
|
||||
return new Resource<Employee>(EMPLOYEES.get(id),
|
||||
findOneLink.andAffordance(afford(methodOn(EmployeeController.class).updateEmployee(null, id))) //
|
||||
.andAffordance(afford(methodOn(EmployeeController.class).partiallyUpdateEmployee(null, id))),
|
||||
employeesLink);
|
||||
return new Resource<>(EMPLOYEES.get(id),
|
||||
findOneLink.andAffordance(afford(methodOn(EmployeeController.class).updateEmployee(null, id))) //
|
||||
.andAffordance(afford(methodOn(EmployeeController.class).partiallyUpdateEmployee(null, id))),
|
||||
employeesLink);
|
||||
}
|
||||
|
||||
@PostMapping("/employees")
|
||||
|
||||
@@ -116,7 +116,7 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
@Test
|
||||
public void rendersResource() throws Exception {
|
||||
|
||||
Resource<SimplePojo> resource = new Resource<SimplePojo>(new SimplePojo("test1", 1), new Link("localhost"));
|
||||
Resource<SimplePojo> resource = new Resource<>(new SimplePojo("test1", 1), new Link("localhost"));
|
||||
|
||||
assertThat(write(resource),
|
||||
is(MappingUtils.read(new ClassPathResource("simple-resource-unwrapped.json", getClass()))));
|
||||
@@ -125,7 +125,7 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
@Test
|
||||
public void deserializesResource() throws IOException {
|
||||
|
||||
Resource<SimplePojo> expected = new Resource<SimplePojo>(new SimplePojo("test1", 1), new Link("localhost"));
|
||||
Resource<SimplePojo> expected = new Resource<>(new SimplePojo("test1", 1), new Link("localhost"));
|
||||
|
||||
Resource<SimplePojo> result = mapper.readValue(
|
||||
MappingUtils.read(new ClassPathResource("simple-resource-unwrapped.json", getClass())),
|
||||
@@ -137,11 +137,11 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
@Test
|
||||
public void rendersSimpleResourcesAsEmbedded() throws Exception {
|
||||
|
||||
List<String> content = new ArrayList<String>();
|
||||
List<String> content = new ArrayList<>();
|
||||
content.add("first");
|
||||
content.add("second");
|
||||
|
||||
Resources<String> resources = new Resources<String>(content);
|
||||
Resources<String> resources = new Resources<>(content);
|
||||
resources.add(new Link("localhost"));
|
||||
|
||||
assertThat(write(resources),
|
||||
@@ -151,11 +151,11 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
@Test
|
||||
public void deserializesSimpleResourcesAsEmbedded() throws Exception {
|
||||
|
||||
List<String> content = new ArrayList<String>();
|
||||
List<String> content = new ArrayList<>();
|
||||
content.add("first");
|
||||
content.add("second");
|
||||
|
||||
Resources<String> expected = new Resources<String>(content);
|
||||
Resources<String> expected = new Resources<>(content);
|
||||
expected.add(new Link("localhost"));
|
||||
|
||||
Resources<String> result = mapper.readValue(
|
||||
@@ -169,10 +169,10 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
@Test
|
||||
public void rendersSingleResourceResourcesAsEmbedded() throws Exception {
|
||||
|
||||
List<Resource<SimplePojo>> content = new ArrayList<Resource<SimplePojo>>();
|
||||
content.add(new Resource<SimplePojo>(new SimplePojo("test1", 1), new Link("localhost")));
|
||||
List<Resource<SimplePojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimplePojo("test1", 1), new Link("localhost")));
|
||||
|
||||
Resources<Resource<SimplePojo>> resources = new Resources<Resource<SimplePojo>>(content);
|
||||
Resources<Resource<SimplePojo>> resources = new Resources<>(content);
|
||||
resources.add(new Link("localhost"));
|
||||
|
||||
assertThat(write(resources),
|
||||
@@ -182,10 +182,10 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
@Test
|
||||
public void deserializesSingleResourceResourcesAsEmbedded() throws Exception {
|
||||
|
||||
List<Resource<SimplePojo>> content = new ArrayList<Resource<SimplePojo>>();
|
||||
content.add(new Resource<SimplePojo>(new SimplePojo("test1", 1), new Link("localhost")));
|
||||
List<Resource<SimplePojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimplePojo("test1", 1), new Link("localhost")));
|
||||
|
||||
Resources<Resource<SimplePojo>> expected = new Resources<Resource<SimplePojo>>(content);
|
||||
Resources<Resource<SimplePojo>> expected = new Resources<>(content);
|
||||
expected.add(new Link("localhost"));
|
||||
|
||||
Resources<Resource<SimplePojo>> result = mapper.readValue(
|
||||
@@ -223,10 +223,10 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
@Test
|
||||
public void serializesAnnotatedResourceResourcesAsEmbedded() throws Exception {
|
||||
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<Resource<SimpleAnnotatedPojo>>();
|
||||
content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
|
||||
Resources<Resource<SimpleAnnotatedPojo>> resources = new Resources<Resource<SimpleAnnotatedPojo>>(content);
|
||||
Resources<Resource<SimpleAnnotatedPojo>> resources = new Resources<>(content);
|
||||
resources.add(new Link("localhost"));
|
||||
|
||||
assertThat(write(resources),
|
||||
@@ -236,10 +236,10 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
@Test
|
||||
public void deserializesAnnotatedResourceResourcesAsEmbedded() throws Exception {
|
||||
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<Resource<SimpleAnnotatedPojo>>();
|
||||
content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
|
||||
Resources<Resource<SimpleAnnotatedPojo>> expected = new Resources<Resource<SimpleAnnotatedPojo>>(content);
|
||||
Resources<Resource<SimpleAnnotatedPojo>> expected = new Resources<>(content);
|
||||
expected.add(new Link("localhost"));
|
||||
|
||||
Resources<Resource<SimpleAnnotatedPojo>> result = mapper.readValue(
|
||||
@@ -286,8 +286,8 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
@Test
|
||||
public void rendersCuriesCorrectly() throws Exception {
|
||||
|
||||
Resources<Object> resources = new Resources<Object>(Collections.emptySet(), new Link("foo"),
|
||||
new Link("bar", "myrel"));
|
||||
Resources<Object> resources = new Resources<>(Collections.emptySet(), new Link("foo"),
|
||||
new Link("bar", "myrel"));
|
||||
|
||||
assertThat(getCuriedObjectMapper().writeValueAsString(resources),
|
||||
is(MappingUtils.read(new ClassPathResource("curied-document.json", getClass()))));
|
||||
@@ -296,7 +296,7 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
@Test
|
||||
public void doesNotRenderCuriesIfNoLinkIsPresent() throws Exception {
|
||||
|
||||
Resources<Object> resources = new Resources<Object>(Collections.emptySet());
|
||||
Resources<Object> resources = new Resources<>(Collections.emptySet());
|
||||
assertThat(getCuriedObjectMapper().writeValueAsString(resources),
|
||||
is(MappingUtils.read(new ClassPathResource("empty-document.json", getClass()))));
|
||||
}
|
||||
@@ -304,7 +304,7 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
@Test
|
||||
public void doesNotRenderCuriesIfNoCurieLinkIsPresent() throws Exception {
|
||||
|
||||
Resources<Object> resources = new Resources<Object>(Collections.emptySet());
|
||||
Resources<Object> resources = new Resources<>(Collections.emptySet());
|
||||
resources.add(new Link("foo"));
|
||||
|
||||
assertThat(getCuriedObjectMapper().writeValueAsString(resources),
|
||||
@@ -323,7 +323,7 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
@Test
|
||||
public void rendersMultipleCuries() throws Exception {
|
||||
|
||||
Resources<Object> resources = new Resources<Object>(Collections.emptySet());
|
||||
Resources<Object> resources = new Resources<>(Collections.emptySet());
|
||||
resources.add(new Link("foo", "myrel"));
|
||||
|
||||
CurieProvider provider = new DefaultCurieProvider("default", new UriTemplate("/doc{?rel}")) {
|
||||
@@ -342,10 +342,10 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
|
||||
EmbeddedWrappers wrappers = new EmbeddedWrappers(false);
|
||||
|
||||
List<Object> values = new ArrayList<Object>();
|
||||
List<Object> values = new ArrayList<>();
|
||||
values.add(wrappers.emptyCollectionOf(SimpleAnnotatedPojo.class));
|
||||
|
||||
Resources<Object> resources = new Resources<Object>(values);
|
||||
Resources<Object> resources = new Resources<>(values);
|
||||
|
||||
assertThat(write(resources), is(MappingUtils.read(new ClassPathResource("empty-embedded-pojos.json", getClass()))));
|
||||
}
|
||||
@@ -378,30 +378,30 @@ public class Jackson2HalFormsIntegrationTest extends AbstractJackson2Marshalling
|
||||
|
||||
private static Resources<Resource<SimplePojo>> setupResources() {
|
||||
|
||||
List<Resource<SimplePojo>> content = new ArrayList<Resource<SimplePojo>>();
|
||||
content.add(new Resource<SimplePojo>(new SimplePojo("test1", 1), new Link("localhost")));
|
||||
content.add(new Resource<SimplePojo>(new SimplePojo("test2", 2), new Link("localhost")));
|
||||
List<Resource<SimplePojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimplePojo("test1", 1), new Link("localhost")));
|
||||
content.add(new Resource<>(new SimplePojo("test2", 2), new Link("localhost")));
|
||||
|
||||
return new Resources<Resource<SimplePojo>>(content);
|
||||
return new Resources<>(content);
|
||||
}
|
||||
|
||||
private static Resources<Resource<SimpleAnnotatedPojo>> setupAnnotatedResources() {
|
||||
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<Resource<SimpleAnnotatedPojo>>();
|
||||
content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test2", 2), new Link("localhost")));
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
content.add(new Resource<>(new SimpleAnnotatedPojo("test2", 2), new Link("localhost")));
|
||||
|
||||
return new Resources<Resource<SimpleAnnotatedPojo>>(content);
|
||||
return new Resources<>(content);
|
||||
}
|
||||
|
||||
private static Resources<Resource<SimpleAnnotatedPojo>> setupAnnotatedPagedResources() {
|
||||
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<Resource<SimpleAnnotatedPojo>>();
|
||||
content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
content.add(new Resource<SimpleAnnotatedPojo>(new SimpleAnnotatedPojo("test2", 2), new Link("localhost")));
|
||||
List<Resource<SimpleAnnotatedPojo>> content = new ArrayList<>();
|
||||
content.add(new Resource<>(new SimpleAnnotatedPojo("test1", 1), new Link("localhost")));
|
||||
content.add(new Resource<>(new SimpleAnnotatedPojo("test2", 2), new Link("localhost")));
|
||||
|
||||
return new PagedResources<Resource<SimpleAnnotatedPojo>>(content, new PagedResources.PageMetadata(2, 0, 4),
|
||||
PAGINATION_LINKS);
|
||||
return new PagedResources<>(content, new PagedResources.PageMetadata(2, 0, 4),
|
||||
PAGINATION_LINKS);
|
||||
}
|
||||
|
||||
private static ObjectMapper getCuriedObjectMapper() {
|
||||
|
||||
@@ -131,7 +131,7 @@ public class ControllerLinkBuilderFactoryUnitTest extends TestUtils {
|
||||
@Test
|
||||
public void createsLinkToControllerMethodWithMapRequestParam() {
|
||||
|
||||
Map<String, String> queryParams = new LinkedHashMap<String, String>();
|
||||
Map<String, String> queryParams = new LinkedHashMap<>();
|
||||
queryParams.put("firstKey", "firstValue");
|
||||
queryParams.put("secondKey", "secondValue");
|
||||
|
||||
@@ -148,7 +148,7 @@ public class ControllerLinkBuilderFactoryUnitTest extends TestUtils {
|
||||
@Test
|
||||
public void createsLinkToControllerMethodWithMultiValueMapRequestParam() {
|
||||
|
||||
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
|
||||
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||
queryParams.put("key1", Arrays.asList("value1a", "value1b"));
|
||||
queryParams.put("key2", Arrays.asList("value2a", "value2b"));
|
||||
|
||||
@@ -173,7 +173,7 @@ public class ControllerLinkBuilderFactoryUnitTest extends TestUtils {
|
||||
assertThat(link.getHref()).endsWith("/people/17/addresses");
|
||||
}
|
||||
|
||||
static interface SampleController {
|
||||
interface SampleController {
|
||||
|
||||
@RequestMapping("/sample/{id}")
|
||||
HttpEntity<?> sampleMethod(@PathVariable("id") Long id, SpecialType parameter);
|
||||
|
||||
@@ -561,7 +561,7 @@ public class ControllerLinkBuilderUnitTest extends TestUtils {
|
||||
@Test
|
||||
public void considersEmptyOptionalMethodParameterOptional() {
|
||||
|
||||
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithJdk8Optional(Optional.<Integer> empty()))
|
||||
Link link = linkTo(methodOn(ControllerWithMethods.class).methodWithJdk8Optional(Optional.empty()))
|
||||
.withSelfRel();
|
||||
|
||||
assertThat(link.isTemplated()).isTrue();
|
||||
|
||||
@@ -53,12 +53,12 @@ public class DummyInvocationUtilsUnitTest extends TestUtils {
|
||||
|
||||
@RequestMapping("/{id}/foo")
|
||||
HttpEntity<Void> someMethod(@PathVariable("id") Long id) {
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping("/{otherName}/bar")
|
||||
HttpEntity<Void> someOtherMethod(@PathVariable(name = "otherName") Long id) {
|
||||
return new ResponseEntity<Void>(HttpStatus.OK);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ public class HeaderLinksResponseEntityUnitTest {
|
||||
static final Object CONTENT = new Object();
|
||||
static final Link LINK = new Link("href", "rel");
|
||||
|
||||
Resource<Object> resource = new Resource<Object>(CONTENT, LINK);
|
||||
ResponseEntity<Resource<Object>> entity = new ResponseEntity<Resource<Object>>(resource, HttpStatus.OK);
|
||||
Resource<Object> resource = new Resource<>(CONTENT, LINK);
|
||||
ResponseEntity<Resource<Object>> entity = new ResponseEntity<>(resource, HttpStatus.OK);
|
||||
|
||||
@Test
|
||||
public void movesRootResourceLinksToHeader() {
|
||||
@@ -58,7 +58,7 @@ public class HeaderLinksResponseEntityUnitTest {
|
||||
@Test
|
||||
public void defaultStatusCodeToOkForHttpEntities() {
|
||||
|
||||
HttpEntity<Resource<Object>> entity = new HttpEntity<Resource<Object>>(resource);
|
||||
HttpEntity<Resource<Object>> entity = new HttpEntity<>(resource);
|
||||
ResponseEntity<Resource<Object>> wrappedEntity = HeaderLinksResponseEntity.wrap(entity);
|
||||
|
||||
assertThat(wrappedEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
|
||||
@@ -60,39 +60,34 @@ import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ResourceProcessorHandlerMethodReturnValueHandlerUnitTest {
|
||||
|
||||
static final Resource<String> FOO = new Resource<String>("foo");
|
||||
static final Resources<Resource<String>> FOOS = new Resources<Resource<String>>(Collections.singletonList(FOO));
|
||||
static final PagedResources<Resource<String>> FOO_PAGE = new PagedResources<Resource<String>>(
|
||||
Collections.singleton(FOO), new PageMetadata(1, 0, 10));
|
||||
static final Resource<String> FOO = new Resource<>("foo");
|
||||
static final Resources<Resource<String>> FOOS = new Resources<>(Collections.singletonList(FOO));
|
||||
static final PagedResources<Resource<String>> FOO_PAGE = new PagedResources<>(
|
||||
Collections.singleton(FOO), new PageMetadata(1, 0, 10));
|
||||
static final StringResource FOO_RES = new StringResource("foo");
|
||||
static final HttpEntity<Resource<String>> FOO_ENTITY = new HttpEntity<Resource<String>>(FOO);
|
||||
static final ResponseEntity<Resource<String>> FOO_RESP_ENTITY = new ResponseEntity<Resource<String>>(FOO,
|
||||
HttpStatus.OK);
|
||||
static final HttpEntity<StringResource> FOO_RES_ENTITY = new HttpEntity<StringResource>(FOO_RES);
|
||||
static final Resource<String> BAR = new Resource<String>("bar");
|
||||
static final Resources<Resource<String>> BARS = new Resources<Resource<String>>(Collections.singletonList(BAR));
|
||||
static final HttpEntity<Resource<String>> FOO_ENTITY = new HttpEntity<>(FOO);
|
||||
static final ResponseEntity<Resource<String>> FOO_RESP_ENTITY = new ResponseEntity<>(FOO,
|
||||
HttpStatus.OK);
|
||||
static final HttpEntity<StringResource> FOO_RES_ENTITY = new HttpEntity<>(FOO_RES);
|
||||
static final Resource<String> BAR = new Resource<>("bar");
|
||||
static final Resources<Resource<String>> BARS = new Resources<>(Collections.singletonList(BAR));
|
||||
static final StringResource BAR_RES = new StringResource("bar");
|
||||
static final HttpEntity<Resource<String>> BAR_ENTITY = new HttpEntity<Resource<String>>(BAR);
|
||||
static final ResponseEntity<Resource<String>> BAR_RESP_ENTITY = new ResponseEntity<Resource<String>>(BAR,
|
||||
HttpStatus.OK);
|
||||
static final HttpEntity<StringResource> BAR_RES_ENTITY = new HttpEntity<StringResource>(BAR_RES);
|
||||
static final Resource<Long> LONG_10 = new Resource<Long>(10L);
|
||||
static final Resource<Long> LONG_20 = new Resource<Long>(20L);
|
||||
static final HttpEntity<Resource<String>> BAR_ENTITY = new HttpEntity<>(BAR);
|
||||
static final ResponseEntity<Resource<String>> BAR_RESP_ENTITY = new ResponseEntity<>(BAR,
|
||||
HttpStatus.OK);
|
||||
static final HttpEntity<StringResource> BAR_RES_ENTITY = new HttpEntity<>(BAR_RES);
|
||||
static final Resource<Long> LONG_10 = new Resource<>(10L);
|
||||
static final Resource<Long> LONG_20 = new Resource<>(20L);
|
||||
static final LongResource LONG_10_RES = new LongResource(10L);
|
||||
static final LongResource LONG_20_RES = new LongResource(20L);
|
||||
static final HttpEntity<Resource<Long>> LONG_10_ENTITY = new HttpEntity<Resource<Long>>(LONG_10);
|
||||
static final HttpEntity<LongResource> LONG_10_RES_ENTITY = new HttpEntity<LongResource>(LONG_10_RES);
|
||||
static final HttpEntity<Resource<Long>> LONG_20_ENTITY = new HttpEntity<Resource<Long>>(LONG_20);
|
||||
static final HttpEntity<LongResource> LONG_20_RES_ENTITY = new HttpEntity<LongResource>(LONG_20_RES);
|
||||
static final Map<String, MethodParameter> METHOD_PARAMS = new HashMap<String, MethodParameter>();
|
||||
static final HttpEntity<Resource<Long>> LONG_10_ENTITY = new HttpEntity<>(LONG_10);
|
||||
static final HttpEntity<LongResource> LONG_10_RES_ENTITY = new HttpEntity<>(LONG_10_RES);
|
||||
static final HttpEntity<Resource<Long>> LONG_20_ENTITY = new HttpEntity<>(LONG_20);
|
||||
static final HttpEntity<LongResource> LONG_20_RES_ENTITY = new HttpEntity<>(LONG_20_RES);
|
||||
static final Map<String, MethodParameter> METHOD_PARAMS = new HashMap<>();
|
||||
|
||||
static {
|
||||
doWithMethods(Controller.class, new MethodCallback() {
|
||||
@Override
|
||||
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
|
||||
METHOD_PARAMS.put(method.getName(), new MethodParameter(method, -1));
|
||||
}
|
||||
});
|
||||
doWithMethods(Controller.class, method -> METHOD_PARAMS.put(method.getName(), new MethodParameter(method, -1)));
|
||||
}
|
||||
|
||||
@Mock HandlerMethodReturnValueHandler delegate;
|
||||
@@ -100,7 +95,7 @@ public class ResourceProcessorHandlerMethodReturnValueHandlerUnitTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
resourceProcessors = new ArrayList<ResourceProcessor<?>>();
|
||||
resourceProcessors = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,12 +247,12 @@ public class ResourceProcessorHandlerMethodReturnValueHandlerUnitTest {
|
||||
*/
|
||||
@Test
|
||||
public void usesHeaderLinksResponseEntityIfConfigured() throws Exception {
|
||||
usesHeaderLinksResponseEntityIfConfigured(it -> ResponseEntity.ok(it));
|
||||
usesHeaderLinksResponseEntityIfConfigured(ResponseEntity::ok);
|
||||
}
|
||||
|
||||
private void usesHeaderLinksResponseEntityIfConfigured(Function<Object, Object> mapper) throws Exception {
|
||||
|
||||
Resource<String> resource = new Resource<String>("foo", new Link("href", "rel"));
|
||||
Resource<String> resource = new Resource<>("foo", new Link("href", "rel"));
|
||||
MethodParameter parameter = METHOD_PARAMS.get("resource");
|
||||
|
||||
ResourceProcessorHandlerMethodReturnValueHandler handler = new ResourceProcessorHandlerMethodReturnValueHandler(
|
||||
@@ -287,8 +282,8 @@ public class ResourceProcessorHandlerMethodReturnValueHandlerUnitTest {
|
||||
public void doesNotInvokeAProcessorForASpecializedType() throws Exception {
|
||||
|
||||
EmbeddedWrappers wrappers = new EmbeddedWrappers(false);
|
||||
Resources<Object> value = new Resources<Object>(
|
||||
Collections.<Object> singleton(wrappers.emptyCollectionOf(Object.class)));
|
||||
Resources<Object> value = new Resources<>(
|
||||
Collections.singleton(wrappers.emptyCollectionOf(Object.class)));
|
||||
ResourcesProcessorWrapper wrapper = new ResourcesProcessorWrapper(new SpecialResourcesProcessor());
|
||||
|
||||
ResolvableType type = ResolvableType.forMethodReturnType(Controller.class.getMethod("resourcesOfObject"));
|
||||
@@ -392,7 +387,7 @@ public class ResourceProcessorHandlerMethodReturnValueHandlerUnitTest {
|
||||
}
|
||||
}
|
||||
|
||||
static interface Controller {
|
||||
interface Controller {
|
||||
|
||||
Resources<Resource<String>> resources();
|
||||
|
||||
@@ -439,13 +434,13 @@ public class ResourceProcessorHandlerMethodReturnValueHandlerUnitTest {
|
||||
}
|
||||
}
|
||||
|
||||
static class PagedStringResources extends PagedResources<Resource<String>> {};
|
||||
static class PagedStringResources extends PagedResources<Resource<String>> {}
|
||||
|
||||
static class Sample {
|
||||
|
||||
}
|
||||
|
||||
static interface SampleProjection {
|
||||
interface SampleProjection {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user