use of org.kie.workbench.common.services.shared.kmodule.KBaseModel in project kie-wb-common by kiegroup.
the class KSessionSelector method initKBases.
private void initKBases(final String currentKSession) {
final ArrayList<String> kbaseNames = new ArrayList<>();
if (kmodule.getKBases().isEmpty()) {
addMockKBaseModel(DEFAULT_KIE_BASE, DEFAULT_KIE_SESSION);
kbaseNames.add(DEFAULT_KIE_BASE);
} else {
for (KBaseModel kBase : kmodule.getKBases().values()) {
kbaseNames.add(kBase.getName());
}
}
Collections.sort(kbaseNames, (first, other) -> first.compareToIgnoreCase(other));
if (isNotNullOrEmpty(currentKSession) && !kmoduleContainsCurrentKSession(currentKSession)) {
addMockKBaseModel(NON_EXISTING_KBASE, currentKSession);
kbaseNames.add(NON_EXISTING_KBASE);
view.showWarningSelectedKSessionDoesNotExist();
}
view.addKBases(kbaseNames.toArray(new String[kbaseNames.size()]));
}
use of org.kie.workbench.common.services.shared.kmodule.KBaseModel in project kie-wb-common by kiegroup.
the class KnowledgeBasesPresenterTest method testSave.
@Test
public void testSave() {
final KModuleModel kModuleModel = spy(new KModuleModel());
knowledgeBasesPresenter.kModuleModel = kModuleModel;
final Map<String, KBaseModel> kBasesMap = spy(new HashMap<>());
doReturn(kBasesMap).when(kModuleModel).getKBases();
knowledgeBasesPresenter.save("Test comment", null).catch_(i -> {
Assert.fail("Promise should've been resolved!");
return promises.resolve();
});
verify(kBasesMap).clear();
verify(kBasesMap).putAll(any());
}
use of org.kie.workbench.common.services.shared.kmodule.KBaseModel in project kie-wb-common by kiegroup.
the class KnowledgeBaseItemPresenterTest method testSignalAddedOrRemoved.
@Test
public void testSignalAddedOrRemoved() {
final KBaseModel kBaseModel = new KBaseModel();
final KnowledgeBasesPresenter parentPresenter = mock(KnowledgeBasesPresenter.class);
knowledgeBaseItemPresenter.kBaseModel = kBaseModel;
knowledgeBaseItemPresenter.parentPresenter = parentPresenter;
knowledgeBaseItemPresenter.signalAddedOrRemoved();
verify(parentPresenter).fireChangeEvent();
verify(view).setKnowledgeSessionsCount(eq(0));
}
use of org.kie.workbench.common.services.shared.kmodule.KBaseModel in project kie-wb-common by kiegroup.
the class KnowledgeBaseItemPresenterTest method testSetDefault.
@Test
public void testSetDefault() {
final KBaseModel kBaseModel = new KBaseModel();
kBaseModel.setDefault(false);
final KnowledgeBasesPresenter parentPresenter = mock(KnowledgeBasesPresenter.class);
knowledgeBaseItemPresenter.kBaseModel = kBaseModel;
knowledgeBaseItemPresenter.parentPresenter = parentPresenter;
knowledgeBaseItemPresenter.setDefault(true);
Assert.assertTrue(kBaseModel.isDefault());
verify(defaultKnowledgeBaseChangeEvent).fire(any());
verify(parentPresenter).fireChangeEvent();
}
use of org.kie.workbench.common.services.shared.kmodule.KBaseModel in project kie-wb-common by kiegroup.
the class KnowledgeSessionListItemPresenterTest method testOnDefaultKnowledgeSessionChangedWithAnotherKSessionModel.
@Test
public void testOnDefaultKnowledgeSessionChangedWithAnotherKSessionModel() {
final KBaseModel kBaseModel = new KBaseModel();
final KSessionModel kSessionModel = new KSessionModel();
kSessionModel.setDefault(true);
final KnowledgeSessionsModal parentPresenter = mock(KnowledgeSessionsModal.class);
doReturn(kBaseModel).when(parentPresenter).getObject();
knowledgeSessionListItemPresenter.parentPresenter = parentPresenter;
knowledgeSessionListItemPresenter.kSessionModel = kSessionModel;
final KSessionModel anotherKSessionModel = new KSessionModel();
anotherKSessionModel.setName("Distinguishing name");
knowledgeSessionListItemPresenter.onDefaultKnowledgeSessionChanged(new DefaultKnowledgeSessionChange(kBaseModel, anotherKSessionModel));
Assert.assertEquals(false, kSessionModel.isDefault());
}
Aggregations