Search in sources :

Example 71 with Import

use of org.kie.soup.project.datamodel.imports.Import in project kie-wb-common by kiegroup.

the class ImportsWidgetPresenterTest method testOnImportAdded.

@Test
public void testOnImportAdded() {
    final Imports imports = new Imports();
    imports.addImport(new Import("Internal1"));
    presenter.setContent(dmo, imports, false);
    presenter.onAddImport(new Import("NewImport1"));
    assertEquals(2, imports.getImports().size());
    assertContains("Internal1", imports.getImports());
    assertContains("NewImport1", imports.getImports());
    verify(importAddedEvent, times(1)).fire(importAddedEventCaptor.capture());
    assertEquals("NewImport1", importAddedEventCaptor.getValue().getImport().getType());
    verify(view, times(2)).updateRenderedColumns();
}
Also used : Import(org.kie.soup.project.datamodel.imports.Import) Imports(org.kie.soup.project.datamodel.imports.Imports) Test(org.junit.Test)

Example 72 with Import

use of org.kie.soup.project.datamodel.imports.Import in project kie-wb-common by kiegroup.

the class ImportsWidgetPresenterTest method testOnImportRemovedExternal.

@Test
public void testOnImportRemovedExternal() {
    final Imports imports = new Imports();
    imports.addImport(new Import("org.pkg1.External1"));
    presenter.setContent(dmo, imports, false);
    presenter.onRemoveImport(new Import("org.pkg1.External1"));
    verify(view, times(2)).updateRenderedColumns();
    assertEquals(0, imports.getImports().size());
    assertContains("org.pkg1.External1", presenter.getExternalFactTypes());
}
Also used : Import(org.kie.soup.project.datamodel.imports.Import) Imports(org.kie.soup.project.datamodel.imports.Imports) Test(org.junit.Test)

Example 73 with Import

use of org.kie.soup.project.datamodel.imports.Import in project kie-wb-common by kiegroup.

the class ImportsWidgetPresenterTest method testSetContentWithExternalImport.

@Test
public void testSetContentWithExternalImport() {
    final Imports imports = new Imports();
    imports.addImport(new Import("org.pkg1.External1"));
    presenter.setContent(dmo, imports, false);
    verify(view, times(1)).setContent(internalFactTypesCaptor.capture(), externalFactTypesCaptor.capture(), importsFactTypesCaptor.capture(), eq(false));
    assertEquals(3, internalFactTypesCaptor.getValue().size());
    assertContains("Internal1", internalFactTypesCaptor.getValue());
    assertContains("Internal2", internalFactTypesCaptor.getValue());
    assertContains("Internal3", internalFactTypesCaptor.getValue());
    assertEquals(2, externalFactTypesCaptor.getValue().size());
    assertContains("org.pkg1.External2", externalFactTypesCaptor.getValue());
    assertContains("org.pkg1.External3", externalFactTypesCaptor.getValue());
    assertEquals(1, importsFactTypesCaptor.getValue().size());
    assertContains("org.pkg1.External1", importsFactTypesCaptor.getValue());
    assertEquals(1, imports.getImports().size());
    assertContains("org.pkg1.External1", imports.getImports());
}
Also used : Import(org.kie.soup.project.datamodel.imports.Import) Imports(org.kie.soup.project.datamodel.imports.Imports) Test(org.junit.Test)

Example 74 with Import

use of org.kie.soup.project.datamodel.imports.Import in project kie-wb-common by kiegroup.

the class ImportsWidgetPresenterTest method testSetContentRemovesOldImportsOnImportAdded.

@Test
public void testSetContentRemovesOldImportsOnImportAdded() {
    when(dmo.getInternalFactTypes()).thenReturn(new String[] { "a" });
    when(dmo.getExternalFactTypes()).thenReturn(new String[] { "b" });
    final Imports imports = new Imports();
    imports.addImport(new Import("c"));
    presenter.setContent(dmo, imports, false);
    when(dmo.getInternalFactTypes()).thenReturn(new String[] { "A" });
    when(dmo.getExternalFactTypes()).thenReturn(new String[] { "B" });
    final Imports importsNew = new Imports();
    importsNew.addImport(new Import("C"));
    presenter.setContent(dmo, importsNew, false);
    verify(view, times(2)).updateRenderedColumns();
    assertEquals(1, presenter.getInternalFactTypes().size());
    assertEquals("A", presenter.getInternalFactTypes().get(0).getType());
    assertEquals(1, presenter.getExternalFactTypes().size());
    assertEquals("B", presenter.getExternalFactTypes().get(0).getType());
    assertEquals(1, presenter.getModelFactTypes().size());
    assertEquals("C", presenter.getModelFactTypes().get(0).getType());
}
Also used : Import(org.kie.soup.project.datamodel.imports.Import) Imports(org.kie.soup.project.datamodel.imports.Imports) Test(org.junit.Test)

Example 75 with Import

use of org.kie.soup.project.datamodel.imports.Import in project kie-wb-common by kiegroup.

the class ImportsWidgetPresenterTest method setup.

@Before
public void setup() {
    this.presenter = new ImportsWidgetPresenter(view);
    imports.getImports().addImport(new Import("import1"));
    imports.getImports().addImport(new Import("import2"));
}
Also used : Import(org.kie.soup.project.datamodel.imports.Import) Before(org.junit.Before)

Aggregations

Import (org.kie.soup.project.datamodel.imports.Import)103 Test (org.junit.Test)79 Imports (org.kie.soup.project.datamodel.imports.Imports)26 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)25 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)14 ArrayList (java.util.ArrayList)12 Path (org.uberfire.java.nio.file.Path)12 Query (org.apache.lucene.search.Query)11 FactData (org.drools.workbench.models.testscenarios.shared.FactData)11 VerifyFact (org.drools.workbench.models.testscenarios.shared.VerifyFact)11 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)11 SingleTermQueryBuilder (org.kie.workbench.common.services.refactoring.backend.server.query.builder.SingleTermQueryBuilder)11 VerifyField (org.drools.workbench.models.testscenarios.shared.VerifyField)10 FieldData (org.drools.workbench.models.testscenarios.shared.FieldData)9 KieSession (org.kie.api.runtime.KieSession)9 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)9 ValueReferenceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm)9 Path (org.uberfire.backend.vfs.Path)9 ProjectImports (org.guvnor.common.services.project.model.ProjectImports)8 Analyzer (org.drools.verifier.core.main.Analyzer)7