Code example for ServletWebRequest

0
 
public class DeviceWebArgumentResolverTest { 
	 
	private DeviceWebArgumentResolver resolver = new DeviceWebArgumentResolver(); 
 
	private ServletWebRequest request = new ServletWebRequest(new MockHttpServletRequest()); 
 
	private Device device = new StubDevice(); 
	 
	@Test 
	public void resolve() throws Exception { 
		request.setAttribute(DeviceUtils.CURRENT_DEVICE_ATTRIBUTE, device, WebRequest.SCOPE_REQUEST); 
		MethodParameter parameter = new MethodParameter(getClass().getMethod("handlerMethod", Device.class), 0); 
		Object resolved = resolver.resolveArgument(parameter, request); 
		assertSame(device, resolved); 
	} 
 
	@Test 
	public void unresolved() throws Exception { 
		request.setAttribute(DeviceUtils.CURRENT_DEVICE_ATTRIBUTE, device, WebRequest.SCOPE_REQUEST);