### Question:
TokenRequestDataValueProcessing implements RequestDataValueProcessor { @Override public Map<String, String> getExtraHiddenFields(HttpServletRequest request) { return manager.getTokenMap(request); } TokenRequestDataValueProcessing(); String processAction(HttpServletRequest request, String action); @Override String processAction(HttpServletRequest request, String action, String httpMethod); @Override String processFormFieldValue(HttpServletRequest request, String name, String value, String type); @Override Map<String, String> getExtraHiddenFields(HttpServletRequest request); @Override String processUrl(HttpServletRequest request, String url);  }### Answer:
@Test public void セッションスコープに保存したトークンのhidden用パラメータが取得できる() throws Exception { TokenManager manager = new TokenManager(); manager.afterPropertiesSet(); manager.saveToken(request, Controllers.SCOPE_SESSION); TokenRequestDataValueProcessing t = new TokenRequestDataValueProcessing(); Field managerField = t.getClass().getDeclaredField("manager"); managerField.setAccessible(true); managerField.set(t, manager); Map<String, String> hiddenParameterMap = t.getExtraHiddenFields(request); assertThat(hiddenParameterMap.keySet(), hasItem(TokenManager.SESSION_TOKEN_PARAMETER_NAME)); assertThat(hiddenParameterMap.get(TokenManager.SESSION_TOKEN_PARAMETER_NAME), is(manager.getToken(request, Controllers.SCOPE_SESSION))); }
@Test public void セッションスコープに保存したトークンがリセットされhidden用パラメータが取得できない() throws Exception { TokenManager manager = new TokenManager(); manager.afterPropertiesSet(); manager.saveToken(request, Controllers.SCOPE_SESSION); manager.isTokenValid(request, Controllers.SCOPE_SESSION); TokenRequestDataValueProcessing t = new TokenRequestDataValueProcessing(); Field managerField = t.getClass().getDeclaredField("manager"); managerField.setAccessible(true); managerField.set(t, manager); Map<String, String> hiddenParameterMap = t.getExtraHiddenFields(request); assertThat(hiddenParameterMap, is(nullValue())); }