Skip to content

Commit 7dbbe64

Browse files
author
Micha Kiener
committed
SPR-6416, tests
1 parent 8aac395 commit 7dbbe64

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

org.springframework.context/src/test/java/org/springframework/conversation/BasicConversationTests.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public void testRootConversationFailure() {
110110
Conversation conversation = manager.beginConversation(false, JoinMode.ROOT);
111111
assertNotNull(conversation);
112112
assertFalse(conversation.isTemporary());
113+
assertFalse(conversation.isSwitched());
113114
assertSame(conversation, manager.getCurrentConversation());
114115

115116
try {
@@ -167,6 +168,7 @@ public void testNestedConversationEndingFailure() {
167168

168169
Conversation nestedConversation = manager.beginConversation(false, JoinMode.NESTED);
169170
assertNotNull(nestedConversation);
171+
assertFalse(nestedConversation.isSwitched());
170172
assertNotSame(conversation, nestedConversation);
171173
assertTrue(nestedConversation.isNested());
172174
assertTrue(((MutableConversation) conversation).isParent());
@@ -202,6 +204,7 @@ public void testIsolatedConversation() {
202204

203205
Conversation nestedConversation = manager.beginConversation(false, JoinMode.ISOLATED);
204206
assertNotNull(nestedConversation);
207+
assertFalse(nestedConversation.isSwitched());
205208
assertSame(nestedConversation, manager.getCurrentConversation());
206209
assertNotSame(conversation, nestedConversation);
207210
assertTrue(nestedConversation.isNested());
@@ -226,6 +229,7 @@ public void testJoinedConversation() {
226229
Conversation conversation = manager.beginConversation(false, JoinMode.ROOT);
227230
assertNotNull(conversation);
228231
assertFalse(conversation.isTemporary());
232+
assertFalse(conversation.isSwitched());
229233
assertSame(conversation, manager.getCurrentConversation());
230234
assertFalse(conversation.isNested());
231235
assertFalse(((MutableConversation) conversation).isParent());
@@ -235,6 +239,7 @@ public void testJoinedConversation() {
235239

236240
Conversation joinedConversation = manager.beginConversation(false, JoinMode.JOINED);
237241
assertNotNull(joinedConversation);
242+
assertFalse(joinedConversation.isSwitched());
238243
assertSame(joinedConversation, manager.getCurrentConversation());
239244
assertSame(conversation, joinedConversation);
240245
assertFalse(joinedConversation.isNested());
@@ -259,6 +264,7 @@ public void testSwitchedConversation() {
259264
Conversation conversation = manager.beginConversation(false, JoinMode.SWITCHED);
260265
assertNotNull(conversation);
261266
assertFalse(conversation.isTemporary());
267+
assertTrue(conversation.isSwitched());
262268
assertSame(conversation, manager.getCurrentConversation());
263269
assertFalse(conversation.isNested());
264270
assertFalse(((MutableConversation) conversation).isParent());
@@ -268,6 +274,7 @@ public void testSwitchedConversation() {
268274

269275
Conversation switchedConversation = manager.beginConversation(false, JoinMode.SWITCHED);
270276
assertNotNull(switchedConversation);
277+
assertTrue(conversation.isSwitched());
271278
assertSame(switchedConversation, manager.getCurrentConversation());
272279
assertNotSame(conversation, switchedConversation);
273280
assertFalse(switchedConversation.isNested());
@@ -277,6 +284,7 @@ public void testSwitchedConversation() {
277284
assertNotSame(bean, bean2);
278285

279286
manager.switchConversation(conversation.getId());
287+
assertSame(conversation, manager.getCurrentConversation());
280288
assertSame(bean, context.getBean("testBean"));
281289

282290
manager.switchConversation(switchedConversation.getId());
@@ -305,7 +313,30 @@ public void testSwitchedConversationEnding() {
305313
manager.switchConversation(switchedConversation.getId());
306314

307315
switchedConversation.end(ConversationEndingType.SUCCESS);
316+
assertNull(manager.getCurrentConversation());
308317
conversation.end(ConversationEndingType.SUCCESS);
318+
assertNull(manager.getCurrentConversation());
319+
320+
assertTrue(conversation.isEnded());
321+
assertTrue(switchedConversation.isEnded());
322+
assertNull(resolver.getCurrentConversationId());
323+
assertNull(manager.getCurrentConversation());
324+
}
325+
326+
@Test
327+
public void testImplicitConversationEnding() {
328+
Conversation conversation = manager.beginConversation(false, JoinMode.ROOT);
329+
assertNotNull(conversation);
330+
assertSame(conversation, manager.getCurrentConversation());
331+
332+
Conversation switchedConversation = manager.beginConversation(false, JoinMode.SWITCHED);
333+
assertNotNull(switchedConversation);
334+
assertSame(switchedConversation, manager.getCurrentConversation());
335+
assertNotSame(conversation, switchedConversation);
336+
assertTrue(conversation.isEnded());
337+
338+
switchedConversation.end(ConversationEndingType.SUCCESS);
339+
assertNull(manager.getCurrentConversation());
309340

310341
assertTrue(conversation.isEnded());
311342
assertTrue(switchedConversation.isEnded());

0 commit comments

Comments
 (0)