LoadBProjectCommand extends AbstractCommand { @Override public void writeCommand(final IPrologTermOutput pto) { pto.openTerm(PROLOG_COMMAND_NAME); pto.printAtom(mainMachine.getAbsolutePath()); pto.openList(); printLoadTerm(pto); pto.closeList(); pto.closeTerm(); } LoadBProjectCommand(final RecursiveMachineLoader rml, File f); @Override void writeCommand(final IPrologTermOutput pto); @Override void processResult(final ISimplifiedROMap<String, PrologTerm> bindings); NodeIdAssignment getNodeIdMapping();  }
@Test public void testWriteCommand() throws URISyntaxException, IOException { URL resource = this.getClass().getResource("/de/prob/testmachines/b/scheduler.mch"); assertNotNull(resource); File f = new File(resource.toURI()); StructuredPrologOutput prologTermOutput = new StructuredPrologOutput(); ClassicalBFactory factory = new ClassicalBFactory(null); BParser bparser = new BParser(); Start ast = factory.parseFile(f, bparser); RecursiveMachineLoader rml = factory.parseAllMachines(ast, f.getParent(), f, bparser.getContentProvider(), bparser); LoadBProjectCommand command = new LoadBProjectCommand(rml, f); command.writeCommand(prologTermOutput); prologTermOutput.fullstop().flush(); Collection<PrologTerm> sentences = prologTermOutput.getSentences(); PrologTerm next = sentences.iterator().next(); assertNotNull(next); assertTrue(next instanceof CompoundPrologTerm); CompoundPrologTerm t = (CompoundPrologTerm) next; assertEquals("load_classical_b_from_list_of_facts", t.getFunctor()); assertEquals(2, t.getArity()); PrologTerm argument = t.getArgument(2); assertTrue(argument.isList()); }