List of usage examples for org.springframework.web.context.request NativeWebRequest getParameterValues
@Nullable String[] getParameterValues(String paramName);
From source file:net.kaczmarzyk.spring.data.jpa.web.AndSpecificationResolverTest.java
@Test public void skipsMissingInnerSpec() throws Exception { MethodParameter param = MethodParameter.forMethodOrConstructor(testMethod("testMethod"), 0); NativeWebRequest req = mock(NativeWebRequest.class); when(req.getParameterValues("path1")).thenReturn(new String[] { "value1" }); Specification<?> result = resolver.resolveArgument(param, null, req, null); assertThat(result).isEqualTo(new Conjunction<>(new Like<>("path1", "value1"))); }
From source file:net.kaczmarzyk.spring.data.jpa.web.OrSpecificationResolverTest.java
@Test public void skipsMissingInnerSpec() throws Exception { MethodParameter param = MethodParameter.forMethodOrConstructor(testMethod("testMethod"), 0); NativeWebRequest req = mock(NativeWebRequest.class); when(req.getParameterValues("path1")).thenReturn(new String[] { "value1" }); Specification<?> result = resolver.resolveArgument(param, null, req, null); assertThat(result).isEqualTo(new Disjunction<>(new Like<>("path1", "value1"))); }
From source file:net.kaczmarzyk.spring.data.jpa.web.AndSpecificationResolverTest.java
@Test public void resolvesWrapperOfInnerSpecs() throws Exception { MethodParameter param = MethodParameter.forMethodOrConstructor(testMethod("testMethod"), 0); NativeWebRequest req = mock(NativeWebRequest.class); when(req.getParameterValues("path1")).thenReturn(new String[] { "value1" }); when(req.getParameterValues("path2")).thenReturn(new String[] { "value2" }); Specification<?> result = resolver.resolveArgument(param, null, req, null); assertThat(result)/*from w w w . jav a 2 s.c om*/ .isEqualTo(new Conjunction<>(new Like<>("path1", "value1"), new Like<>("path2", "value2"))); }
From source file:net.kaczmarzyk.spring.data.jpa.web.OrSpecificationResolverTest.java
@Test public void resolvesWrapperOfInnerSpecs() throws Exception { MethodParameter param = MethodParameter.forMethodOrConstructor(testMethod("testMethod"), 0); NativeWebRequest req = mock(NativeWebRequest.class); when(req.getParameterValues("path1")).thenReturn(new String[] { "value1" }); when(req.getParameterValues("path2")).thenReturn(new String[] { "value2" }); Specification<?> result = resolver.resolveArgument(param, null, req, null); assertThat(result)//from ww w .j av a 2 s. com .isEqualTo(new Disjunction<>(new Like<>("path1", "value1"), new Like<>("path2", "value2"))); }
From source file:net.kaczmarzyk.spring.data.jpa.web.ConjunctionSpecificationResolverTest.java
@Test public void resolvesWrapperOfOrs() throws Exception { MethodParameter param = MethodParameter.forMethodOrConstructor(testMethod("testMethod"), 0); NativeWebRequest req = mock(NativeWebRequest.class); when(req.getParameterValues("path1")).thenReturn(new String[] { "value1" }); when(req.getParameterValues("path2")).thenReturn(new String[] { "value2" }); when(req.getParameterValues("path3")).thenReturn(new String[] { "value3" }); when(req.getParameterValues("path4")).thenReturn(new String[] { "value4" }); Specification<?> result = resolver.resolveArgument(param, null, req, null); Specification<Object> or1 = new Disjunction<>(new Like<>("path1", "value1"), new Like<>("path2", "value2")); Specification<Object> or2 = new Disjunction<>(new Like<>("path3", "value3"), new Like<>("path4", "value4")); assertThat(result).isEqualTo(new net.kaczmarzyk.spring.data.jpa.domain.Conjunction<>(or1, or2)); }
From source file:net.kaczmarzyk.spring.data.jpa.web.ConjunctionSpecificationResolverTest.java
@Test public void resolvesWrapperOfSimpleSpecsAndOrs() throws Exception { MethodParameter param = MethodParameter.forMethodOrConstructor(testMethod("testMethod2"), 0); NativeWebRequest req = mock(NativeWebRequest.class); when(req.getParameterValues("path1")).thenReturn(new String[] { "value1" }); when(req.getParameterValues("path2")).thenReturn(new String[] { "value2" }); when(req.getParameterValues("path3")).thenReturn(new String[] { "value3" }); when(req.getParameterValues("path4")).thenReturn(new String[] { "value4" }); Specification<?> result = resolver.resolveArgument(param, null, req, null); Specification<Object> or = new Disjunction<>(new Like<>("path3", "value3"), new Like<>("path4", "value4")); assertThat(result).isEqualTo(new net.kaczmarzyk.spring.data.jpa.domain.Conjunction<>(or, new Like<>("path1", "value1"), new Like<>("path2", "value2"))); }
From source file:net.kaczmarzyk.spring.data.jpa.web.SimpleSpecificationResolverOnTypeMismatchTest.java
@Test public void doesNotWrapWithEmptyResultSpecWhenSpecificationDoesntRequireDataConversion() throws Exception { MethodParameter param = MethodParameter .forMethodOrConstructor(testMethod("testMethodWithSpecWithoutDataConversion"), 0); NativeWebRequest req = mock(NativeWebRequest.class); when(req.getParameterValues("thePath")).thenReturn(new String[] { "theValue" }); Specification<?> resolved = resolver.resolveArgument(param, null, req, null); assertThat(resolved).isNotInstanceOf(EmptyResultOnTypeMismatch.class) .isInstanceOf(SpecWithoutDataConversion.class); }
From source file:net.kaczmarzyk.spring.data.jpa.web.SimpleSpecificationResolverOnTypeMismatchTest.java
@Test public void usesEmptyResultSpecWrapperWhenSpecified() throws Exception { MethodParameter param = MethodParameter .forMethodOrConstructor(testMethod("testMethodWithOnTypeMismatchConfig"), 0); NativeWebRequest req = mock(NativeWebRequest.class); when(req.getParameterValues("thePath")).thenReturn(new String[] { "theValue" }); Specification<?> resolved = resolver.resolveArgument(param, null, req, null); assertThat(resolved).isInstanceOf(EmptyResultOnTypeMismatch.class); assertThat(((EmptyResultOnTypeMismatch<?>) resolved).getWrappedSpec()) .isEqualTo(new Equal<>("thePath", new String[] { "theValue" }, defaultConverter)); }
From source file:com.wiiyaya.framework.consumer.support.easyui.EasyuiSortHandlerMethodArgumentResolver.java
@Override public Sort resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) { String[] sortParameter = webRequest.getParameterValues(EASYUI_SORT_PARAMETER); String[] orderParameter = webRequest.getParameterValues(EASYUI_ORDER_PARAMETER); if (sortParameter != null && sortParameter.length != 0) { return prepareSort(sortParameter[0], orderParameter); } else {//from w ww . jav a 2s . co m return null; } }
From source file:net.kaczmarzyk.spring.data.jpa.web.DisjunctionSpecificationResolverTest.java
@Test public void resolvesWrapperOfSimpleSpecsAndAnds() throws Exception { MethodParameter param = MethodParameter.forMethodOrConstructor(testMethod("testMethod2"), 0); NativeWebRequest req = mock(NativeWebRequest.class); when(req.getParameterValues("path1")).thenReturn(new String[] { "value1" }); when(req.getParameterValues("path2")).thenReturn(new String[] { "value2" }); when(req.getParameterValues("path3")).thenReturn(new String[] { "value3" }); when(req.getParameterValues("path4")).thenReturn(new String[] { "value4" }); Specification<?> result = resolver.resolveArgument(param, null, req, null); Specification<Object> and = new Conjunction<>(new Like<>("path3", "value3"), new Like<>("path4", "value4")); assertThat(result).isEqualTo(new net.kaczmarzyk.spring.data.jpa.domain.Disjunction<>(and, new Like<>("path1", "value1"), new Like<>("path2", "value2"))); }