Skip to content

Commit b98c9b0

Browse files
committed
QueueOverrideChannel test.
1 parent 72b43a7 commit b98c9b0

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/*
2+
* (c) Copyright 2021 Palantir Technologies Inc. All rights reserved.
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+
* http://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 com.palantir.dialogue.core;
18+
19+
import static org.assertj.core.api.Assertions.assertThat;
20+
import static org.mockito.Mockito.verify;
21+
import static org.mockito.Mockito.verifyNoMoreInteractions;
22+
23+
import com.palantir.dialogue.Channel;
24+
import com.palantir.dialogue.Request;
25+
import com.palantir.dialogue.TestEndpoint;
26+
import org.junit.jupiter.api.AfterEach;
27+
import org.junit.jupiter.api.BeforeEach;
28+
import org.junit.jupiter.api.Test;
29+
import org.junit.jupiter.api.extension.ExtendWith;
30+
import org.mockito.Mock;
31+
import org.mockito.junit.jupiter.MockitoExtension;
32+
33+
@ExtendWith(MockitoExtension.class)
34+
public final class QueueOverrideChannelTest {
35+
36+
@Mock
37+
private Channel defaultDelegate;
38+
39+
@Mock
40+
private Channel override;
41+
42+
private Channel queueOverrideChannel;
43+
44+
@BeforeEach
45+
public void beforeEach() {
46+
queueOverrideChannel = new QueueOverrideChannel(defaultDelegate);
47+
}
48+
49+
@AfterEach
50+
public void afterEach() {
51+
verifyNoMoreInteractions(defaultDelegate, override);
52+
}
53+
54+
@Test
55+
public void routesToDefault() {
56+
Request request = Request.builder().build();
57+
assertThat(queueOverrideChannel.execute(TestEndpoint.GET, request)).isNull();
58+
verify(defaultDelegate).execute(TestEndpoint.GET, request);
59+
}
60+
61+
@Test
62+
public void routesToOverride() {
63+
Request request = Request.builder().build();
64+
QueueAttachments.setQueueOverride(request, override);
65+
assertThat(queueOverrideChannel.execute(TestEndpoint.GET, request)).isNull();
66+
verify(override).execute(TestEndpoint.GET, request);
67+
}
68+
}

0 commit comments

Comments
 (0)