Removed attributes() from Request
Removes attributes() method from Request, as it exposes a mutable map.
This commit is contained in:
@@ -22,7 +22,6 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -94,11 +93,10 @@ public class DefaultRequestTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void attributes() throws Exception {
|
||||
Map<String, Object> attributes = new LinkedHashMap<>();
|
||||
when(mockExchange.getAttributes()).thenReturn(attributes);
|
||||
public void attribute() throws Exception {
|
||||
when(mockExchange.getAttribute("foo")).thenReturn(Optional.of("bar"));
|
||||
|
||||
assertEquals(attributes, defaultRequest.attributes());
|
||||
assertEquals(Optional.of("bar"), defaultRequest.attribute("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -103,11 +103,6 @@ public class MockRequest implements Request {
|
||||
return Optional.ofNullable((T) this.attributes.get(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> attributes() {
|
||||
return this.attributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryParams(String name) {
|
||||
return Collections.unmodifiableList(this.queryParams.get(name));
|
||||
|
||||
@@ -102,14 +102,6 @@ public class RequestWrapperTests {
|
||||
assertEquals(Optional.of(value), wrapper.attribute(name));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void attributes() throws Exception {
|
||||
Map<String, Object> attributes = Collections.singletonMap("foo", "bar");
|
||||
when(mockRequest.attributes()).thenReturn(attributes);
|
||||
|
||||
assertSame(attributes, wrapper.attributes());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void queryParam() throws Exception {
|
||||
String name = "foo";
|
||||
|
||||
Reference in New Issue
Block a user