Search in sources :

Example 1 with KModuleModel

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

the class KnowledgeBasesPresenterTest method testSetup.

@Test
public void testSetup() {
    final ProjectScreenModel model = mock(ProjectScreenModel.class);
    when(model.getKModule()).thenReturn(spy(new KModuleModel()));
    when(model.getKModule().getKBases()).thenReturn(emptyMap());
    knowledgeBasesPresenter.setup(model).catch_(i -> {
        Assert.fail("Promise should've been resolved!");
        return promises.resolve();
    });
    verify(view).init(eq(knowledgeBasesPresenter));
    verify(knowledgeBaseListPresenter).setup(any(), any(), any());
}
Also used : ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Test(org.junit.Test)

Example 2 with KModuleModel

use of org.kie.workbench.common.services.shared.kmodule.KModuleModel 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());
}
Also used : KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Test(org.junit.Test)

Example 3 with KModuleModel

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

the class ProjectScreenModelLoaderTest method testKModule.

@Test
public void testKModule() throws Exception {
    final KModuleModel kModuleModel = new KModuleModel();
    when(kModuleService.load(kmoduleXMLPath)).thenReturn(kModuleModel);
    final Metadata metadata = new Metadata();
    when(metadataService.getMetadata(kmoduleXMLPath)).thenReturn(metadata);
    ProjectScreenModel model = loader.load(pathToPom);
    assertEquals(kmoduleXMLPath, model.getPathToKModule());
    assertEquals(kModuleModel, model.getKModule());
    assertEquals(metadata, model.getKModuleMetaData());
}
Also used : Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectScreenModel(org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Test(org.junit.Test)

Example 4 with KModuleModel

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

the class ProjectScreenModelTest method testHashCode.

@Test
public void testHashCode() {
    final ProjectScreenModel model = new ProjectScreenModel();
    model.setPOM(new POM("test", "test", "url", new GAV("groupID", "artifactID", "version")));
    final MavenRepository repository = new MavenRepository();
    repository.setId("guvnor-m2-repo");
    repository.setName("Guvnor M2 Repo");
    repository.setUrl("http://localhost/maven2/");
    model.getPOM().addRepository(repository);
    model.setPOMMetaData(new Metadata());
    model.setKModule(new KModuleModel());
    model.setKModuleMetaData(new Metadata());
    model.setProjectTagsMetaData(new Metadata());
    model.setProjectImports(new ProjectImports());
    model.setProjectImportsMetaData(new Metadata());
    final int hashCode1 = model.hashCode();
    assertTrue(hashCode1 <= Integer.MAX_VALUE);
    assertTrue(hashCode1 >= Integer.MIN_VALUE);
    model.getProjectImports().getImports().addImport(new Import("java.lang.List"));
    final int hashCode2 = model.hashCode();
    assertTrue(hashCode2 <= Integer.MAX_VALUE);
    assertTrue(hashCode2 >= Integer.MIN_VALUE);
    assertNotEquals(hashCode1, hashCode2);
}
Also used : Import(org.kie.soup.project.datamodel.imports.Import) MavenRepository(org.guvnor.common.services.project.model.MavenRepository) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) ProjectImports(org.guvnor.common.services.project.model.ProjectImports) GAV(org.guvnor.common.services.project.model.GAV) POM(org.guvnor.common.services.project.model.POM) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Test(org.junit.Test)

Example 5 with KModuleModel

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

the class KSessionSelectorTest method setUp.

@Before
public void setUp() throws Exception {
    kieModule = spy(new KieModule());
    when(kieModule.getKModuleXMLPath()).thenReturn(kmodulePath);
    kModule = new KModuleModel();
    kModule.getKBases().put("kbase1", getKBase("kbase1", "ksession1"));
    kModule.getKBases().put("kbase2", getKBase("kbase2", "ksession2", "ksession3"));
    kModule.getKBases().put("kbase3", getKBase("kbase3"));
    view = mock(KSessionSelectorView.class);
    when(kieModuleService.resolveModule(path)).thenReturn(kieModule);
    when(kModuleService.load(kmodulePath)).thenReturn(kModule);
    selector = new KSessionSelector(view, new CallerMock<>(kieModuleService), new CallerMock<>(kModuleService));
}
Also used : KieModule(org.kie.workbench.common.services.shared.project.KieModule) CallerMock(org.uberfire.mocks.CallerMock) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Before(org.junit.Before)

Aggregations

KModuleModel (org.kie.workbench.common.services.shared.kmodule.KModuleModel)16 Test (org.junit.Test)13 KBaseModel (org.kie.workbench.common.services.shared.kmodule.KBaseModel)6 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)4 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)4 List (java.util.List)2 GAV (org.guvnor.common.services.project.model.GAV)2 MavenRepository (org.guvnor.common.services.project.model.MavenRepository)2 POM (org.guvnor.common.services.project.model.POM)2 ProjectImports (org.guvnor.common.services.project.model.ProjectImports)2 Import (org.kie.soup.project.datamodel.imports.Import)2 KSessionModel (org.kie.workbench.common.services.shared.kmodule.KSessionModel)2 HierarchicalStreamReader (com.thoughtworks.xstream.io.HierarchicalStreamReader)1 AbstractXStreamConverter (org.drools.core.util.AbstractXStreamConverter)1 MavenRepositoryMetadata (org.guvnor.common.services.project.model.MavenRepositoryMetadata)1 Before (org.junit.Before)1 ConsoleLogger (org.kie.workbench.common.services.shared.kmodule.ConsoleLogger)1 FileLogger (org.kie.workbench.common.services.shared.kmodule.FileLogger)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 Path (org.uberfire.backend.vfs.Path)1