@Test
 public void testGetFactoryService() {
   GridConnection<GridNode> connection = new LocalGridNodeConnection("test-id");
   GridNode gnode = connection.connect();
   KnowledgeBuilderFactoryService kbfService = gnode.get(KnowledgeBuilderFactoryService.class);
   assertNotNull(kbfService);
 }
 public static StatefulKnowledgeSession getStatefulKnowledgeSession(
     Grid grid, String nodeId, String sessionId, boolean forceRemote) {
   GridNode node = GridHelper.getGridNode(nodeId, grid, forceRemote);
   logger.error(
       "("
           + Thread.currentThread().getId()
           + ")"
           + Thread.currentThread().getName()
           + " ### SESSION 2 : Looking session = "
           + sessionId
           + " in node = "
           + nodeId
           + " - "
           + node);
   if (logger.isDebugEnabled()) {
     logger.debug(
         "("
             + Thread.currentThread().getId()
             + ")"
             + Thread.currentThread().getName()
             + " ### SESSION 2 : Looking session = "
             + sessionId
             + " in node = "
             + nodeId
             + " - "
             + node);
   }
   StatefulKnowledgeSession kSession = node.get(sessionId, StatefulKnowledgeSession.class);
   return kSession;
 }
  public static QueryResultsRemoteClient getQueryResultRemoteClient(
      Grid grid, String nodeId, String sessionId, String queryName, String remoteResultsId) {

    GridServiceDescription<GridNode> gsd = getGridServiceDescriptor(grid, nodeId);
    GridNode node = getGridNode(nodeId, grid, false);
    String reverseId = node.get(sessionId, String.class);
    return new QueryResultsRemoteClient(
        queryName, reverseId, remoteResultsId, gsd, grid.get(ConversationManager.class));
  }
  @Test
  public void testSetObject() {
    GridConnection<GridNode> connection = new LocalGridNodeConnection("test-id");
    GridNode gnode = connection.connect();

    KnowledgeBaseFactoryService kbfService = gnode.get(KnowledgeBaseFactoryService.class);
    KnowledgeBase kbase = kbfService.newKnowledgeBase();
    gnode.set("id1", kbase);
    assertSame(kbase, gnode.get("id1", KnowledgeBase.class));
  }
 public static KnowledgeAgent getKnowledgeAgentRemoteClient(
     Grid grid, String nodeId, String sessionId) {
   GridServiceDescription<GridNode> gsd = getGridServiceDescriptor(grid, nodeId);
   GridNode node = getGridNode(nodeId, grid, false);
   String reverseId = node.get(sessionId, String.class);
   if (logger.isDebugEnabled()) {
     logger.debug(
         " ### Grid Helper: Creating KnowledgeAgent Client for: reverseId: "
             + reverseId
             + " - session-id: "
             + sessionId);
   }
   return new KnowledgeAgentRemoteClient(reverseId, gsd, grid.get(ConversationManager.class));
 }