Search in sources :

Example 6 with WebSession

use of org.springframework.web.server.WebSession in project spring-session by spring-projects.

the class SpringSessionWebSessionStoreTests method createSessionWhenGetAttributesAndContainsKeyAndNotFoundThenFalse.

@Test
public void createSessionWhenGetAttributesAndContainsKeyAndNotFoundThenFalse() {
    WebSession createdWebSession = this.webSessionStore.createWebSession().block();
    Map<String, Object> attributes = createdWebSession.getAttributes();
    assertThat(attributes.containsKey("a")).isFalse();
}
Also used : WebSession(org.springframework.web.server.WebSession) Test(org.junit.Test)

Example 7 with WebSession

use of org.springframework.web.server.WebSession in project spring-session by spring-projects.

the class SpringSessionWebSessionStoreTests method createSessionWhenGetAttributesAndPutThenDelegatesToCreateSession.

@Test
public void createSessionWhenGetAttributesAndPutThenDelegatesToCreateSession() {
    WebSession createdWebSession = this.webSessionStore.createWebSession().block();
    Map<String, Object> attributes = createdWebSession.getAttributes();
    attributes.put("a", "b");
    verify(this.createSession).setAttribute("a", "b");
}
Also used : WebSession(org.springframework.web.server.WebSession) Test(org.junit.Test)

Example 8 with WebSession

use of org.springframework.web.server.WebSession in project spring-session by spring-projects.

the class SpringSessionWebSessionStoreTests method createSessionWhenGetAttributesAndPutAllThenDelegatesToCreateSession.

@Test
public void createSessionWhenGetAttributesAndPutAllThenDelegatesToCreateSession() {
    WebSession createdWebSession = this.webSessionStore.createWebSession().block();
    Map<String, Object> attributes = createdWebSession.getAttributes();
    attributes.putAll(Collections.singletonMap("a", "b"));
    verify(this.createSession).setAttribute("a", "b");
}
Also used : WebSession(org.springframework.web.server.WebSession) Test(org.junit.Test)

Example 9 with WebSession

use of org.springframework.web.server.WebSession in project spring-session by spring-projects.

the class SpringSessionWebSessionStoreTests method createSessionWhenGetAttributesAndIsEmptyThenDelegatesToCreateSession.

@Test
public void createSessionWhenGetAttributesAndIsEmptyThenDelegatesToCreateSession() {
    WebSession createdWebSession = this.webSessionStore.createWebSession().block();
    Map<String, Object> attributes = createdWebSession.getAttributes();
    assertThat(attributes.isEmpty()).isTrue();
    given(this.createSession.getAttributeNames()).willReturn(Collections.singleton("a"));
    assertThat(attributes.isEmpty()).isFalse();
}
Also used : WebSession(org.springframework.web.server.WebSession) Test(org.junit.Test)

Example 10 with WebSession

use of org.springframework.web.server.WebSession in project spring-session by spring-projects.

the class SpringSessionWebSessionStoreTests method createSessionWhenGetAttributesAndRemoveThenDelegatesToCreateSession.

@Test
public void createSessionWhenGetAttributesAndRemoveThenDelegatesToCreateSession() {
    WebSession createdWebSession = this.webSessionStore.createWebSession().block();
    Map<String, Object> attributes = createdWebSession.getAttributes();
    attributes.remove("a");
    verify(this.createSession).removeAttribute("a");
}
Also used : WebSession(org.springframework.web.server.WebSession) Test(org.junit.Test)

Aggregations

WebSession (org.springframework.web.server.WebSession)53 Test (org.junit.Test)24 Test (org.junit.jupiter.api.Test)24 Method (java.lang.reflect.Method)3 TestBean (org.springframework.beans.testfixture.beans.TestBean)3 GetMapping (org.springframework.web.bind.annotation.GetMapping)3 HandlerMethod (org.springframework.web.method.HandlerMethod)3 SyncInvocableHandlerMethod (org.springframework.web.reactive.result.method.SyncInvocableHandlerMethod)3 ServerWebExchange (org.springframework.web.server.ServerWebExchange)3 Mono (reactor.core.publisher.Mono)3 Instant (java.time.Instant)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)2 BDDMockito.given (org.mockito.BDDMockito.given)2 Mockito.mock (org.mockito.Mockito.mock)2 Mockito.spy (org.mockito.Mockito.spy)2 Mockito.times (org.mockito.Mockito.times)2 Mockito.verify (org.mockito.Mockito.verify)2