DefaultWorldpaySessionService implements WorldpaySessionService { @Override public String getAndRemoveThreeDSecureCookie() { final String attribute = sessionService.getAttribute(THREED_SECURE_COOKIE_KEY); sessionService.removeAttribute(THREED_SECURE_COOKIE_KEY); return attribute; } DefaultWorldpaySessionService(final SessionService sessionService); @Override void setSessionAttributesFor3DSecure(final DirectAuthoriseServiceResponse authoriseServiceResponse, final WorldpayAdditionalInfoData worldpayAdditionalInfoData); @Override String getAndRemoveThreeDSecureCookie(); @Override String getAndRemoveAdditionalDataSessionId(); @Override ChallengeWindowSizeEnum getWindowSizeChallengeFromSession();  }
@Test public void testGetAndRemoveThreeDSecureCookie() { when(sessionServiceMock.getAttribute(THREED_SECURE_COOKIE_KEY)).thenReturn(THREED_SECURE_COOKIE_VALUE); doNothing().when(sessionServiceMock).removeAttribute(THREED_SECURE_COOKIE_KEY); final String response = testObj.getAndRemoveThreeDSecureCookie(); verify(sessionServiceMock).getAttribute(THREED_SECURE_COOKIE_KEY); Assert.assertEquals(THREED_SECURE_COOKIE_VALUE, response); }