@Test public void testChangeSelection() throws Exception { selector.init(path, "ksessionThatHasBeenRemovedFromKModuleXML"); reset(view); selector.onKBaseSelected("kbase2"); verify(view).setSelected("kbase2", "ksession2"); }
@Test public void testSetKBaseAndKSession() throws Exception { selector.init(path, "ksession2"); ArgumentCaptor<List> listArgumentCaptor = ArgumentCaptor.forClass(List.class); verify(view).setKSessions(listArgumentCaptor.capture()); List ksessionNamesList = listArgumentCaptor.getValue(); assertEquals(2, ksessionNamesList.size()); verify(view).setSelected("kbase2", "ksession2"); }
@Test public void testKBaseAndKSessionNotPreviouslySet() throws Exception { selector.init(path, null); verify(view).addKBase("kbase1"); ArgumentCaptor<List> listArgumentCaptor = ArgumentCaptor.forClass(List.class); verify(view).setKSessions(listArgumentCaptor.capture()); List ksessionNamesList = listArgumentCaptor.getValue(); assertEquals(1, ksessionNamesList.size()); verify(view).setSelected("kbase1", "ksession1"); }
@Test public void testEmpty() throws Exception { // No kbases or ksessions defined in the kmodule.xml when(kModuleService.load(kmodulePath)).thenReturn(new KModuleModel()); selector.init(path, null); verify(view).addKBase("defaultKieBase"); ArgumentCaptor<List> listArgumentCaptor = ArgumentCaptor.forClass(List.class); verify(view).setKSessions(listArgumentCaptor.capture()); verify(view).setSelected(eq("defaultKieBase"), eq("defaultKieSession")); List ksessionNamesList = listArgumentCaptor.getValue(); assertEquals(1, ksessionNamesList.size()); assertEquals("defaultKieSession", ksessionNamesList.iterator().next()); }
@Test public void testKSessionDefinedInScenarioNoLongerExistsAndKModuleIsEmpty() throws Exception { // No kbases or ksessions defined in the kmodule.xml when(kModuleService.load(kmodulePath)).thenReturn(new KModuleModel()); selector.init(path, "ksessionThatHasBeenRemovedFromKModuleXML"); verify(view).addKBase("defaultKieBase"); verify(view).addKBase("---"); ArgumentCaptor<List> listArgumentCaptor = ArgumentCaptor.forClass(List.class); verify(view).setKSessions(listArgumentCaptor.capture()); verify(view).setSelected(eq("---"), eq("ksessionThatHasBeenRemovedFromKModuleXML")); verify(view).showWarningSelectedKSessionDoesNotExist(); List ksessionNamesList = listArgumentCaptor.getValue(); assertEquals(1, ksessionNamesList.size()); assertEquals("ksessionThatHasBeenRemovedFromKModuleXML", ksessionNamesList.get(0)); }
@Test public void testKSessionDefinedInScenarioNoLongerExists() throws Exception { selector.init(path, "ksessionThatHasBeenRemovedFromKModuleXML"); verify(view).addKBase("kbase1"); verify(view).addKBase("kbase2"); verify(view).addKBase("kbase3"); verify(view).addKBase("---"); ArgumentCaptor<List> listArgumentCaptor = ArgumentCaptor.forClass(List.class); verify(view).setKSessions(listArgumentCaptor.capture()); verify(view).setSelected(eq("---"), eq("ksessionThatHasBeenRemovedFromKModuleXML")); verify(view).showWarningSelectedKSessionDoesNotExist(); List ksessionNamesList = listArgumentCaptor.getValue(); assertEquals(1, ksessionNamesList.size()); assertEquals("ksessionThatHasBeenRemovedFromKModuleXML", ksessionNamesList.get(0)); }