Java Code Examples for org.springframework.web.server.WebSession#getAttributes()

The following examples show how to use org.springframework.web.server.WebSession#getAttributes() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void createSessionWhenGetAttributesAndContainsKeyAndNotStringThenFalse() {
	WebSession createdWebSession = this.webSessionStore.createWebSession().block();

	Map<String, Object> attributes = createdWebSession.getAttributes();

	assertThat(attributes.containsKey(1L)).isFalse();
}
 
Example 2
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void createSessionWhenGetAttributesAndContainsKeyAndNotFoundThenFalse() {
	WebSession createdWebSession = this.webSessionStore.createWebSession().block();

	Map<String, Object> attributes = createdWebSession.getAttributes();

	assertThat(attributes.containsKey("a")).isFalse();
}
 
Example 3
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void createSessionWhenGetAttributesAndContainsKeyAndFoundThenTrue() {
	given(this.createSession.getAttributeNames()).willReturn(Collections.singleton("a"));
	WebSession createdWebSession = this.webSessionStore.createWebSession().block();

	Map<String, Object> attributes = createdWebSession.getAttributes();

	assertThat(attributes.containsKey("a")).isTrue();
}
 
Example 4
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void createSessionWhenGetAttributesAndPutThenDelegatesToCreateSession() {
	WebSession createdWebSession = this.webSessionStore.createWebSession().block();

	Map<String, Object> attributes = createdWebSession.getAttributes();
	attributes.put("a", "b");

	verify(this.createSession).setAttribute("a", "b");
}
 
Example 5
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void createSessionWhenGetAttributesAndPutNullThenDelegatesToCreateSession() {
	WebSession createdWebSession = this.webSessionStore.createWebSession().block();

	Map<String, Object> attributes = createdWebSession.getAttributes();
	attributes.put("a", null);

	verify(this.createSession).setAttribute("a", null);
}
 
Example 6
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void createSessionWhenGetAttributesAndRemoveThenDelegatesToCreateSession() {
	WebSession createdWebSession = this.webSessionStore.createWebSession().block();

	Map<String, Object> attributes = createdWebSession.getAttributes();
	attributes.remove("a");

	verify(this.createSession).removeAttribute("a");
}
 
Example 7
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
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");
}
 
Example 8
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void createSessionWhenGetAttributesAndClearThenDelegatesToCreateSession() {
	given(this.createSession.getAttributeNames()).willReturn(Collections.singleton("a"));
	WebSession createdWebSession = this.webSessionStore.createWebSession().block();

	Map<String, Object> attributes = createdWebSession.getAttributes();
	attributes.clear();

	verify(this.createSession).removeAttribute("a");
}
 
Example 9
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void createSessionWhenGetAttributesAndKeySetThenDelegatesToCreateSession() {
	given(this.createSession.getAttributeNames()).willReturn(Collections.singleton("a"));
	WebSession createdWebSession = this.webSessionStore.createWebSession().block();

	Map<String, Object> attributes = createdWebSession.getAttributes();

	assertThat(attributes.keySet()).containsExactly("a");
}
 
Example 10
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void createSessionWhenGetAttributesAndValuesThenDelegatesToCreateSession() {
	given(this.createSession.getAttributeNames()).willReturn(Collections.singleton("a"));
	given(this.createSession.getAttribute("a")).willReturn("b");
	WebSession createdWebSession = this.webSessionStore.createWebSession().block();

	Map<String, Object> attributes = createdWebSession.getAttributes();

	assertThat(attributes.values()).containsExactly("b");
}
 
Example 11
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void createSessionWhenGetAttributesAndEntrySetThenDelegatesToCreateSession() {
	String attrName = "attrName";
	given(this.createSession.getAttributeNames()).willReturn(Collections.singleton(attrName));
	String attrValue = "attrValue";
	given(this.createSession.getAttribute(attrName)).willReturn(attrValue);
	WebSession createdWebSession = this.webSessionStore.createWebSession().block();

	Map<String, Object> attributes = createdWebSession.getAttributes();
	Set<Map.Entry<String, Object>> entries = attributes.entrySet();

	assertThat(entries).containsExactly(new AbstractMap.SimpleEntry<>(attrName, attrValue));
}
 
Example 12
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 3 votes vote down vote up
@Test
void createSessionWhenGetAttributesAndSizeThenDelegatesToCreateSession() {
	WebSession createdWebSession = this.webSessionStore.createWebSession().block();

	Map<String, Object> attributes = createdWebSession.getAttributes();

	assertThat(attributes.size()).isEqualTo(0);

	given(this.createSession.getAttributeNames()).willReturn(Collections.singleton("a"));

	assertThat(attributes.size()).isEqualTo(1);
}
 
Example 13
Source File: SpringSessionWebSessionStoreTests.java    From spring-session with Apache License 2.0 3 votes vote down vote up
@Test
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();
}