TransactionTokenRequestDataValueProcessor extends
                                                       RequestDataValueProcessorAdaptor { @Override public Map<String, String> getExtraHiddenFields( HttpServletRequest request) { TransactionToken nextToken = (TransactionToken) request.getAttribute( TransactionTokenInterceptor.NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME); if (nextToken != null) { Map<String, String> map = new HashMap<String, String>(2); map.put(TransactionTokenInterceptor.TOKEN_REQUEST_PARAMETER, nextToken.getTokenString()); return map; } return null; }  @Override Map<String, String> getExtraHiddenFields(
            HttpServletRequest request);  }
@Test public void testGetExtraHiddenFields01() { TransactionTokenRequestDataValueProcessor processor = new TransactionTokenRequestDataValueProcessor(); HttpServletRequest request = mock(HttpServletRequest.class); when((TransactionToken) request.getAttribute( TransactionTokenInterceptor.NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME)) .thenReturn(null); Map<String, String> result = processor.getExtraHiddenFields(request); assertThat(result, nullValue()); }
@Test public void testGetExtraHiddenFields02() { TransactionTokenRequestDataValueProcessor processor = new TransactionTokenRequestDataValueProcessor(); HttpServletRequest request = mock(HttpServletRequest.class); TransactionToken token = new TransactionToken("tokenName", "tokenkey", "tokenValue"); when((TransactionToken) request.getAttribute( TransactionTokenInterceptor.NEXT_TOKEN_REQUEST_ATTRIBUTE_NAME)) .thenReturn(token); Map<String, String> result = processor.getExtraHiddenFields(request); Map<String, String> expected = new HashMap<String, String>(); expected.put("_TRANSACTION_TOKEN", token.getTokenString()); assertThat(result, is(expected)); }