AgdistisWrapper { public String process(final String input) { List<Document> docs; try { docs = nif.parseNIF(input); } catch (Exception e) { return NifEverything.INPUT_NOT_PARSABLE; } List<Document> answerDocs = new ArrayList<>(); for (Document doc : docs) { Document answerDoc = new DocumentImpl(doc.getText()); List<Marking> resultMarkings = requestForStringAgdistis(createAgdistisString(doc)); nif.addAllMarkingsToDoc(answerDoc, resultMarkings); answerDocs.add(answerDoc); } return nif.writeNIF(answerDocs); }  @RequestMapping(method = RequestMethod.GET) String getAgdistis(); @RequestMapping(method = RequestMethod.POST) String postAgdistis(@RequestBody final String input); String process(final String input); List<Marking> requestForStringAgdistis(final String sentence); String createAgdistisString(final Document doc);  }
@Test public void testAgdistis() { String testDocNif = NifEverything.getInstance().writeNIF(testDoc); System.out.println(testDocNif); String q = testDoc.getText(); Document doc = new DocumentImpl(q); String namedEntity1 = "Barack Obama"; String namedEntity2 = "Michelle Obama"; NamedEntity obama = new NamedEntity(q.indexOf(namedEntity1), namedEntity1.length(), "http: NamedEntity michelle = new NamedEntity(q.indexOf(namedEntity2), namedEntity2.length(), "http: doc.addMarking(obama); doc.addMarking(michelle); String shouldBeNif = NifEverything.getInstance().writeNIF(doc); Assert.assertTrue("Should be: \n" + shouldBeNif + "\n but was\n" + testDocNif, shouldBeNif.equals(agdistis.process(testDocNif))); }
@Test public void emptyTest() { agdistis.process(null); agdistis.process(""); }