@Test public void testBrandNewUser() throws ServletException, IOException { // Scenario: // User visits the website for the first time or has cleared all cookies given(cookieGenerator.getCookieName()).willReturn(""); filter.doFilterInternal(request, response, filterChain); // Expect to check cookies verify(request, times(1)).getCookies(); // Expect no userLocationData to be set verify(customerLocationFacade, never()).setUserLocationData(any(UserLocationData.class)); }
@Test public void testLoggedInUserWhoLogsOut() throws ServletException, IOException { // Scenario: // User selects a store location, logs in, then logs out to end the session // The user then decides to pickup another item given(cookieGenerator.getCookieName()).willReturn(COOKIE_NAME); filter.doFilterInternal(request, response, filterChain); // Expect to check cookies verify(request, times(1)).getCookies(); // Expect a userLocationData to be set verify(customerLocationFacade, times(1)).setUserLocationData(any(UserLocationData.class)); }