Search in sources :

Example 6 with KModuleModel

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

the class ProjectScreenModelTests 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 7 with KModuleModel

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

the class ProjectScreenModelSaverTest method testKModuleSave.

@Test
public void testKModuleSave() throws Exception {
    final ProjectScreenModel model = new ProjectScreenModel();
    final KModuleModel kModule = new KModuleModel();
    model.setKModule(kModule);
    final Path pathToKModule = mock(Path.class);
    model.setPathToKModule(pathToKModule);
    final Metadata metadata = new Metadata();
    model.setKModuleMetaData(metadata);
    saver.save(pathToPom, model, DeploymentMode.FORCED, "message kmodule");
    verify(kModuleService).save(eq(pathToKModule), eq(kModule), eq(metadata), eq("message kmodule"));
}
Also used : Path(org.uberfire.backend.vfs.Path) 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 8 with KModuleModel

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

the class KSessionSelectorTest method testEmpty.

@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());
}
Also used : List(java.util.List) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Test(org.junit.Test)

Example 9 with KModuleModel

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

the class KSessionSelectorTest method testKSessionDefinedInScenarioNoLongerExistsAndKModuleIsEmpty.

@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));
}
Also used : List(java.util.List) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel) Test(org.junit.Test)

Example 10 with KModuleModel

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

the class KModuleConverter method marshal.

public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
    KModuleModel kModule = (KModuleModel) value;
    // https://issues.jboss.org/browse/DROOLS-1023 introduced "version-less" XSDs
    writer.addAttribute("xmlns", "http://www.drools.org/xsd/kmodule");
    writer.addAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    for (KBaseModel kBaseModule : kModule.getKBases().values()) {
        writeObject(writer, context, "kbase", kBaseModule);
    }
}
Also used : KBaseModel(org.kie.workbench.common.services.shared.kmodule.KBaseModel) KModuleModel(org.kie.workbench.common.services.shared.kmodule.KModuleModel)

Aggregations

KModuleModel (org.kie.workbench.common.services.shared.kmodule.KModuleModel)12 Test (org.junit.Test)9 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)3 ProjectScreenModel (org.kie.workbench.common.screens.projecteditor.model.ProjectScreenModel)3 KBaseModel (org.kie.workbench.common.services.shared.kmodule.KBaseModel)3 List (java.util.List)2 HierarchicalStreamReader (com.thoughtworks.xstream.io.HierarchicalStreamReader)1 AbstractXStreamConverter (org.drools.core.util.AbstractXStreamConverter)1 GAV (org.guvnor.common.services.project.model.GAV)1 MavenRepository (org.guvnor.common.services.project.model.MavenRepository)1 POM (org.guvnor.common.services.project.model.POM)1 ProjectImports (org.guvnor.common.services.project.model.ProjectImports)1 Before (org.junit.Before)1 Import (org.kie.soup.project.datamodel.imports.Import)1 KieModule (org.kie.workbench.common.services.shared.project.KieModule)1 Path (org.uberfire.backend.vfs.Path)1 CallerMock (org.uberfire.mocks.CallerMock)1