@Test
public void testWrite() throws IOException {

  final KnowledgeBaseWriter writer = TacKbp2017KBWriter.create();
  final Assertion assertion1 = TypeAssertion.of(eventNode0, Symbol.from("CONFLICT.ATTACK"));
  final Assertion assertion2 = EventMentionAssertion.of(
      eventNode0, "dummy\tmention", Symbol.from("actual"), DUMMY);
  final Assertion assertion3 = TypeAssertion.of(stringNode0, Symbol.from("STRING"));
  final Assertion assertion4 = NormalizedMentionAssertion.of(
      stringNode0, "XXXX-XX-XX", DUMMY);
  final KnowledgeBase kb = KnowledgeBase.builder()
      .runId(Symbol.from("dummy_runID"))
      .addNodes(eventNode0, stringNode0)
      .nameNode(eventNode0, nodeNames.get(eventNode0))
      .nameNode(stringNode0, nodeNames.get(stringNode0))
      .addAssertions(assertion4, assertion3, assertion2, assertion1)
      .putConfidence(assertion1, 0.9)
      .putConfidence(assertion3, 0.0000000000000000000000000000000001)
      .build();
  final String expectedOutput = "dummy_runID\n"
      + ":Event_000000\ttype\tCONFLICT.ATTACK\t0.900000\n"
      + ":Event_000000\tmention.actual\t\"dummy mention\"\tdocID:5-12\n"
      + ":String_000000\ttype\tSTRING\t0.000001\n"
      + ":String_000000\tnormalized_mention\t\"XXXX-XX-XX\"\tdocID:5-12";
  final File outputFile = File.createTempFile("kb-writer-test", ".tmp");
  writer.write(kb, new Random(0), Files.asCharSink(outputFile, Charsets.UTF_8));
  final String actualOutput = Joiner.on("\n").join(Files.readLines(outputFile, Charsets.UTF_8));
  outputFile.deleteOnExit();
  assertEquals(expectedOutput, actualOutput);
}