diff --git a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingTest.java b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingTest.java index 95ea83761f..0008751ba7 100644 --- a/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingTest.java +++ b/zeppelin-zengine/src/test/java/org/apache/zeppelin/interpreter/InterpreterSettingTest.java @@ -166,4 +166,42 @@ public class InterpreterSettingTest { interpreterSetting.closeAndRemoveInterpreterGroup("note2", "user1"); assertEquals(0, interpreterSetting.getAllInterpreterGroups().size()); } + + @Test + public void perNoteIsolatedModeCloseAndRemoveInterpreterGroupTest() { + InterpreterOption interpreterOption = new InterpreterOption(); + interpreterOption.setPerNote(InterpreterOption.ISOLATED); + InterpreterSetting interpreterSetting = new InterpreterSetting("", "", "", new ArrayList(), new Properties(), new ArrayList(), interpreterOption, "", null); + + interpreterSetting.setInterpreterGroupFactory(new InterpreterGroupFactory() { + @Override + public InterpreterGroup createInterpreterGroup(String interpreterGroupId, + InterpreterOption option) { + return new InterpreterGroup(interpreterGroupId); + } + }); + + Interpreter mockInterpreter1 = mock(RemoteInterpreter.class); + List interpreterList1 = new ArrayList<>(); + interpreterList1.add(mockInterpreter1); + InterpreterGroup interpreterGroup = interpreterSetting.getInterpreterGroup("user1", "note1"); + interpreterGroup.put(interpreterSetting.getInterpreterSessionKey("user1", "note1"), interpreterList1); + + Interpreter mockInterpreter2 = mock(RemoteInterpreter.class); + List interpreterList2 = new ArrayList<>(); + interpreterList2.add(mockInterpreter2); + interpreterGroup = interpreterSetting.getInterpreterGroup("user1", "note2"); + interpreterGroup.put(interpreterSetting.getInterpreterSessionKey("user1", "note2"), interpreterList2); + + assertEquals(2, interpreterSetting.getAllInterpreterGroups().size()); + assertEquals(1, interpreterSetting.getInterpreterGroup("user1", "note1").size()); + assertEquals(1, interpreterSetting.getInterpreterGroup("user1", "note2").size()); + + interpreterSetting.closeAndRemoveInterpreterGroup("note1", "user1"); + assertEquals(1, interpreterSetting.getInterpreterGroup("user1","note2").size()); + assertEquals(1, interpreterSetting.getAllInterpreterGroups().size()); + + interpreterSetting.closeAndRemoveInterpreterGroup("note2", "user1"); + assertEquals(0, interpreterSetting.getAllInterpreterGroups().size()); + } }