### Question:
SpringSecurityAdapterTokenStoreFactory implements AdapterTokenStoreFactory { @Override public AdapterTokenStore createAdapterTokenStore(KeycloakDeployment deployment, HttpServletRequest request, HttpServletResponse response) { Assert.notNull(deployment, "KeycloakDeployment is required"); if (deployment.getTokenStore() == TokenStore.COOKIE) { return new SpringSecurityCookieTokenStore(deployment, request, response); } return new SpringSecurityTokenStore(deployment, request); }  @Override AdapterTokenStore createAdapterTokenStore(KeycloakDeployment deployment, HttpServletRequest request, HttpServletResponse response);  }### Answer:
@Test public void testCreateAdapterTokenStore() throws Exception { when(deployment.getTokenStore()).thenReturn(TokenStore.SESSION); AdapterSessionStore store = factory.createAdapterTokenStore(deployment, request, response); assertTrue(store instanceof SpringSecurityTokenStore); }
@Test public void testCreateAdapterTokenStoreUsingCookies() throws Exception { when(deployment.getTokenStore()).thenReturn(TokenStore.COOKIE); AdapterSessionStore store = factory.createAdapterTokenStore(deployment, request, response); assertTrue(store instanceof SpringSecurityCookieTokenStore); }
@Test(expected = IllegalArgumentException.class) public void testCreateAdapterTokenStoreNullDeployment() throws Exception { factory.createAdapterTokenStore(null, request, response); }
@Test(expected = IllegalArgumentException.class) public void testCreateAdapterTokenStoreNullRequest() throws Exception { factory.createAdapterTokenStore(deployment, null, response); }
@Test public void testCreateAdapterTokenStoreNullResponse() throws Exception { when(deployment.getTokenStore()).thenReturn(TokenStore.SESSION); factory.createAdapterTokenStore(deployment, request, null); }
@Test(expected = IllegalArgumentException.class) public void testCreateAdapterTokenStoreNullResponseUsingCookies() throws Exception { when(deployment.getTokenStore()).thenReturn(TokenStore.COOKIE); factory.createAdapterTokenStore(deployment, request, null); }