API { public boolean destroySession() { Optional<Session> session = getSession(); if (!session.isPresent()) { return false; } currentSession = null; try { return sessionManager.destroySession(requestLookup.getRequest(), requestLookup.getResponse()); } catch (SessionManagementException e) { throw new PluginExecutionException( "Cannot destroy current session of request '" + requestLookup.getRequest() + "' using session manager '" + sessionManager.getClass().getName() + "'.", e); } } API(SessionManager sessionManager, Authorizer authorizer, RequestLookup requestLookup); RequestLookup getRequestLookup(); static Object callOSGiService(String serviceClassName, String serviceMethodName, Object... args); static Map<String, Object> getOSGiServices(String serviceClassName); static void callMicroService(); static void sendError(int status, String message); static void sendRedirect(String redirectUrl); Session createSession(User user); Optional<Session> getSession(); boolean hasPermission(Permission permission); boolean destroySession();  }
@Test public void testDestroySession() throws Exception { Configuration configuration = mock(Configuration.class); when(configuration.getSessionTimeout()).thenReturn(600L); HttpRequest request = mock(HttpRequest.class); when(request.getContextPath()).thenReturn("/test"); SessionManager sessionManager = createSessionManager(); mockGetSession(sessionManager); mockDestroySession(sessionManager); RequestLookup requestLookup = new RequestLookup("/test", request, null); API api = new API(sessionManager, null, requestLookup); Assert.assertEquals(api.destroySession(), true); }