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);
}
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"));
}
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());
}
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));
}
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);
}
}
Aggregations