use of org.kie.workbench.common.services.shared.kmodule.ConsoleLogger in project kie-wb-common by kiegroup.
the class KSessionConverter method marshal.
public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) {
KSessionModel kSession = (KSessionModel) value;
writer.addAttribute("name", kSession.getName());
writer.addAttribute("type", kSession.getType());
writer.addAttribute("default", Boolean.toString(kSession.isDefault()));
if (kSession.getClockType() != null) {
writer.addAttribute("clockType", kSession.getClockType().getClockTypeAsString());
}
if (kSession.getScope() != null) {
writer.addAttribute("scope", kSession.getScope().toString());
}
writeObjectList(writer, context, "workItemHandlers", "workItemHandler", kSession.getWorkItemHandelerModels());
if (kSession.getLogger() instanceof ConsoleLogger) {
writeObject(writer, context, "consoleLogger", kSession.getLogger());
} else if (kSession.getLogger() instanceof FileLogger) {
writeObject(writer, context, "fileLogger", kSession.getLogger());
}
if (!kSession.getListeners().isEmpty()) {
writer.startNode("listeners");
for (ListenerModel listener : kSession.getListeners()) {
writeObject(writer, context, listener.getKind().toString(), listener);
}
writer.endNode();
}
}
use of org.kie.workbench.common.services.shared.kmodule.ConsoleLogger in project kie-wb-common by kiegroup.
the class KModuleContentHandlerTest method testConsoleLogger.
@Test
public void testConsoleLogger() throws Exception {
final KModuleContentHandler kModuleContentHandler = new KModuleContentHandler();
final KModuleModel model = kModuleContentHandler.toModel(readResource("consoleLoggerKModule.xml"));
assertNotNull(model);
assertEquals(1, model.getKBases().size());
final KBaseModel kBaseModel = model.getKBases().get("org.kie.example2");
assertNotNull(kBaseModel);
assertEquals(1, kBaseModel.getKSessions().size());
final KSessionModel kSessionModel = kBaseModel.getKSessions().get(0);
assertEquals("ksession2", kSessionModel.getName());
assertEquals("stateless", kSessionModel.getType());
assertFalse(kSessionModel.isDefault());
assertEquals(ClockTypeOption.PSEUDO, kSessionModel.getClockType());
assertTrue(kSessionModel.getLogger() instanceof ConsoleLogger);
final String xml = kModuleContentHandler.toString(model);
assertTrue(xml.contains("<kbase name=\"org.kie.example2\" default=\"false\" eventProcessingMode=\"stream\" equalsBehavior=\"identity\">"));
assertTrue(xml.contains("<ksession name=\"ksession2\" type=\"stateless\" default=\"false\" clockType=\"pseudo\">"));
assertTrue(xml.contains("<consoleLogger/>"));
}
Aggregations