DocumentTranslationCLI implements Action { @Override public Object execute() throws Exception { validateOutputLocation(outputDirectory); final SemanticTranslator translator = getTranslatorForType(type != null ? type : FilenameUtils.getExtension(documentFile.getName())); ontologyIriString = ontologyIriString != null ? ontologyIriString : String.format("urn: final IRI ontologyIri = valueFactory.createIRI(ontologyIriString); final ExtractedOntology ontology = ormFactoryRegistry.createNew(ontologyIri, modelFactory.createModel(), ExtractedOntology.class); final Model results = translator.translate(Paths.get(documentFile.toURI()), ontology); final File outputFile = File.createTempFile(ontologyIri.getLocalName(), ".zip", outputDirectory); try (ZipOutputStream os = new ZipOutputStream(new FileOutputStream(outputFile))) { final ZipEntry ontologyEntry = new ZipEntry("ontology.ttl"); os.putNextEntry(ontologyEntry); writeData(ontology.getModel(), os); ZipEntry dataEntry = new ZipEntry("data.ttl"); os.putNextEntry(dataEntry); writeData(results, os); } return null; }  @Override Object execute();  }
@Test public void testSuccessJson() throws Exception { setArguments(cli, "src/test/resources/test.json", "target/jsonTest", "urn: cli.execute(); }
@Test public void testRandomUUidOntologyUri() throws Exception { setArguments(cli, "src/test/resources/test.json", "target/randomUUidOnt", null, "json"); cli.execute(); }
@Test public void testSuccessXml() throws Exception { setArguments(cli, "src/test/resources/test.xml", "target/xmlTest", "urn: cli.execute(); }