Skip to content

Commit 8966907

Browse files
committed
DATAREST-1250 - Polishing.
Added unit test to verify new behavior and prevent regressions. Fixed author capitalization.
1 parent d0283bf commit 8966907

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

Diff for: spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/ResourceMetadataHandlerMethodArgumentResolver.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*
3636
* @author Jon Brisbin
3737
* @author Oliver Gierke
38-
* @author jiacheng Yang
38+
* @author Jiacheng Yang
3939
*/
4040
public class ResourceMetadataHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver {
4141

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.rest.webmvc.config;
17+
18+
import static org.assertj.core.api.Assertions.*;
19+
import static org.mockito.Mockito.*;
20+
21+
import org.junit.Test;
22+
import org.springframework.core.MethodParameter;
23+
import org.springframework.data.repository.support.Repositories;
24+
import org.springframework.data.rest.core.mapping.ResourceMappings;
25+
import org.springframework.data.rest.core.mapping.ResourceMetadata;
26+
import org.springframework.data.rest.webmvc.BaseUri;
27+
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
28+
29+
/**
30+
* Unit tests for {@link ResourceMetadataHandlerMethodArgumentResolver}.
31+
*
32+
* @author Oliver Gierke
33+
*/
34+
public class ResourceMetadataHandlerMethodArgumentResolverUnitTests {
35+
36+
@Test // DATAREST-1250
37+
public void supportsResourceMetadataParameterType() {
38+
39+
HandlerMethodArgumentResolver resolver = new ResourceMetadataHandlerMethodArgumentResolver(mock(Repositories.class),
40+
mock(ResourceMappings.class), BaseUri.NONE);
41+
42+
MethodParameter parameter = mock(MethodParameter.class);
43+
doReturn(ResourceMetadata.class).when(parameter).getParameterType();
44+
45+
assertThat(resolver.supportsParameter(parameter)).isTrue();
46+
}
47+
}

0 commit comments

Comments
 (0)