Search in sources :

Example 1 with SingleValueItemObjectModel

use of org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel in project kie-wb-common by kiegroup.

the class IncludedKnowledgeBaseItemPresenterTest method testSetup.

@Test
public void testSetup() {
    includedKnowledgeBaseItemPresenter.setup(new SingleValueItemObjectModel("Name"), mock(KnowledgeBaseItemPresenter.class));
    verify(view).init(eq(includedKnowledgeBaseItemPresenter));
    verify(view).setName(eq("Name"));
}
Also used : SingleValueItemObjectModel(org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel) KnowledgeBaseItemPresenter(org.kie.workbench.common.screens.library.client.settings.sections.knowledgebases.item.KnowledgeBaseItemPresenter) Test(org.junit.Test)

Example 2 with SingleValueItemObjectModel

use of org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel in project kie-wb-common by kiegroup.

the class PackageItemPresenterTest method testSetup.

@Test
public void testSetup() {
    packageItemPresenter.setup(new SingleValueItemObjectModel("Name"), mock(KnowledgeBaseItemPresenter.class));
    verify(view).init(eq(packageItemPresenter));
    verify(view).setName(eq("Name"));
}
Also used : SingleValueItemObjectModel(org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel) KnowledgeBaseItemPresenter(org.kie.workbench.common.screens.library.client.settings.sections.knowledgebases.item.KnowledgeBaseItemPresenter) Test(org.junit.Test)

Example 3 with SingleValueItemObjectModel

use of org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel in project kie-wb-common by kiegroup.

the class ListPresenterTest method newPresenterForTest.

@Test
public void newPresenterForTest() {
    final IncludedKnowledgeBaseItemPresenter p1 = spy(new IncludedKnowledgeBaseItemPresenter(null));
    doReturn(p1).when(includedKnowledgeBaseItemPresenters).get();
    listPresenter.setup(mock(HTMLElement.class), new ArrayList<>(), (o, p) -> {
        assertEquals(new SingleValueItemObjectModel("foo"), o);
        assertEquals(p1, p);
    });
    listPresenter.newPresenterFor(new SingleValueItemObjectModel("foo"));
    verify(p1).setListPresenter(eq(listPresenter));
}
Also used : SingleValueItemObjectModel(org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel) HTMLElement(elemental2.dom.HTMLElement) IncludedKnowledgeBaseItemPresenter(org.kie.workbench.common.screens.library.client.settings.sections.knowledgebases.item.includedknowledgebases.IncludedKnowledgeBaseItemPresenter) Test(org.junit.Test)

Example 4 with SingleValueItemObjectModel

use of org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel in project kie-wb-common by kiegroup.

the class ListPresenterTest method addTest.

@Test
public void addTest() {
    doNothing().when(listPresenter).addToListElement(any());
    final List<SingleValueItemObjectModel> objs = new ArrayList<SingleValueItemObjectModel>();
    objs.add(new SingleValueItemObjectModel("foo"));
    objs.add(new SingleValueItemObjectModel("bar"));
    listPresenter.setup(mock(HTMLElement.class), objs, (a, b) -> {
    });
    listPresenter.add(new SingleValueItemObjectModel("dee"));
    verify(listPresenter).addToListElement(eq(new SingleValueItemObjectModel("dee")));
    assertEquals(Arrays.asList(new SingleValueItemObjectModel("foo"), new SingleValueItemObjectModel("bar"), new SingleValueItemObjectModel("dee")), listPresenter.getObjectsList());
}
Also used : SingleValueItemObjectModel(org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel) HTMLElement(elemental2.dom.HTMLElement) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with SingleValueItemObjectModel

use of org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel in project kie-wb-common by kiegroup.

the class ListPresenterTest method testSetupWithPresenters.

@Test
public void testSetupWithPresenters() {
    doNothing().when(listPresenter).addPresenter(any());
    final IncludedKnowledgeBaseItemPresenter p1 = mock(IncludedKnowledgeBaseItemPresenter.class);
    doReturn(new SingleValueItemObjectModel("foo")).when(p1).getObject();
    final IncludedKnowledgeBaseItemPresenter p2 = mock(IncludedKnowledgeBaseItemPresenter.class);
    doReturn(new SingleValueItemObjectModel("bar")).when(p2).getObject();
    final List<IncludedKnowledgeBaseItemPresenter> presenters = Arrays.asList(p1, p2);
    listPresenter.setupWithPresenters(mock(HTMLElement.class), presenters, (a, b) -> {
    });
    assertEquals(presenters, listPresenter.getPresenters());
    assertEquals(Arrays.asList(new SingleValueItemObjectModel("foo"), new SingleValueItemObjectModel("bar")), listPresenter.getObjectsList());
    verify(listPresenter, times(2)).addPresenter(any());
}
Also used : SingleValueItemObjectModel(org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel) HTMLElement(elemental2.dom.HTMLElement) IncludedKnowledgeBaseItemPresenter(org.kie.workbench.common.screens.library.client.settings.sections.knowledgebases.item.includedknowledgebases.IncludedKnowledgeBaseItemPresenter) Test(org.junit.Test)

Aggregations

SingleValueItemObjectModel (org.kie.workbench.common.services.shared.kmodule.SingleValueItemObjectModel)10 Test (org.junit.Test)6 HTMLElement (elemental2.dom.HTMLElement)4 KnowledgeBaseItemPresenter (org.kie.workbench.common.screens.library.client.settings.sections.knowledgebases.item.KnowledgeBaseItemPresenter)2 IncludedKnowledgeBaseItemPresenter (org.kie.workbench.common.screens.library.client.settings.sections.knowledgebases.item.includedknowledgebases.IncludedKnowledgeBaseItemPresenter)2 KBaseModel (org.kie.workbench.common.services.shared.kmodule.KBaseModel)2 KSessionModel (org.kie.workbench.common.services.shared.kmodule.KSessionModel)2 HierarchicalStreamReader (com.thoughtworks.xstream.io.HierarchicalStreamReader)1 ArrayList (java.util.ArrayList)1 AbstractXStreamConverter (org.drools.core.util.AbstractXStreamConverter)1