Skip to content

Commit 7e17a00

Browse files
Add RequestMatcherEntry
1 parent 53b8cff commit 7e17a00

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2002-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security.web.util.matcher;
18+
19+
/**
20+
* A rich object for associating a {@link RequestMatcher} to another object.
21+
*
22+
* @author Marcus Da Coregio
23+
* @since 5.7
24+
*/
25+
public class RequestMatcherEntry<T> {
26+
27+
private final RequestMatcher requestMatcher;
28+
29+
private final T entry;
30+
31+
public RequestMatcherEntry(RequestMatcher requestMatcher, T entry) {
32+
this.requestMatcher = requestMatcher;
33+
this.entry = entry;
34+
}
35+
36+
public RequestMatcher getRequestMatcher() {
37+
return this.requestMatcher;
38+
}
39+
40+
public T getEntry() {
41+
return this.entry;
42+
}
43+
44+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2002-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.security.web.util.matcher;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import static org.assertj.core.api.Assertions.assertThat;
22+
import static org.mockito.Mockito.mock;
23+
24+
class RequestMatcherEntryTests {
25+
26+
@Test
27+
void constructWhenGetRequestMatcherAndEntryThenSameRequestMatcherAndEntry() {
28+
RequestMatcher requestMatcher = mock(RequestMatcher.class);
29+
RequestMatcherEntry<String> entry = new RequestMatcherEntry<>(requestMatcher, "entry");
30+
assertThat(entry.getRequestMatcher()).isSameAs(requestMatcher);
31+
assertThat(entry.getEntry()).isEqualTo("entry");
32+
}
33+
34+
@Test
35+
void constructWhenNullValuesThenNullValues() {
36+
RequestMatcherEntry<String> entry = new RequestMatcherEntry<>(null, null);
37+
assertThat(entry.getRequestMatcher()).isNull();
38+
assertThat(entry.getEntry()).isNull();
39+
}
40+
41+
}

0 commit comments

Comments
 (0)