Skip to content
Snippets Groups Projects
Commit 860786e9 authored by sebastien curt's avatar sebastien curt
Browse files

Highlighting of the bug by unit test

parent 3dc711cc
Branches
No related tags found
No related merge requests found
Pipeline #219 failed
Showing
with 523 additions and 19 deletions
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="RemoteRepositoriesConfiguration"> <component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="tetra_central" />
<option name="name" value="Tetras Central" />
<option name="url" value="file:////Users/scurt/.m2/tetrasArtifacts/repository" />
</remote-repository>
<remote-repository> <remote-repository>
<option name="id" value="tetra_central" /> <option name="id" value="tetra_central" />
<option name="name" value="Tetras Central" /> <option name="name" value="Tetras Central" />
<option name="url" value="file:////Users/scurt/.m2/tetrasArtifacts-unl" /> <option name="url" value="file:////Users/scurt/.m2/tetrasArtifacts-unl" />
</remote-repository> </remote-repository>
<remote-repository> <remote-repository>
<option name="id" value="central" /> <option name="id" value="tetra_central" />
<option name="name" value="Central Repository" /> <option name="name" value="Tetras Central" />
<option name="url" value="https://repo.maven.apache.org/maven2" /> <option name="url" value="file:///C:\Users\curts/.m2/tetrasArtifacts-unl" />
</remote-repository> </remote-repository>
<remote-repository> <remote-repository>
<option name="id" value="central" /> <option name="id" value="central" />
...@@ -19,7 +29,7 @@ ...@@ -19,7 +29,7 @@
<remote-repository> <remote-repository>
<option name="id" value="tetra_central" /> <option name="id" value="tetra_central" />
<option name="name" value="Tetras Central" /> <option name="name" value="Tetras Central" />
<option name="url" value="file:////Users/scurt/.m2/tetrasArtifacts/repository" /> <option name="url" value="file:///C:\Users\curts\.m2\tetrasArtifacts-unl" />
</remote-repository> </remote-repository>
<remote-repository> <remote-repository>
<option name="id" value="jboss.community" /> <option name="id" value="jboss.community" />
......
[D]
[S:00]
{org:en}
This document defines the functional requirements for ERTMS/ETCS (EUROPEAN RAIL TRAFFIC MANAGEMENT SYSTEM / EUROPEAN TRAIN CONTROL SYSTEM).
{/org}
{unl}
mod(document(icl>writing>thing),this(icl>determiner>adj,mod<concrete_thing))
aoj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,document(icl>writing>thing))
mod(requirement(icl>duty>thing).@def.@pl,functional(icl>adj,ant>nonfunctional))
obj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,requirement(icl>duty>thing).@def.@pl)
or(etcs,ertms)
pur(requirement(icl>duty>thing).@def.@pl,etcs)
mod:01(management(icl>action,agt>volitional_thing,obj>thing),traffic(icl>collection>thing))
mod(:03.@_hn-scope,management(icl>action,agt>volitional_thing,obj>thing))
or:03(european(icl>inhabitant>person).@entry,system(icl>group>thing):01.@entry)
mod:01(control(icl>power>thing),train(icl>public_transport>thing))
mod:01(system(icl>group>thing):02,control(icl>power>thing))
agt:02(rail(icl>complain>do,rsn>thing,agt>volitional_thing).@entry.@present,:01.@entry.@parenthesis)
rsn:02(rail(icl>complain>do,rsn>thing,agt>volitional_thing).@entry.@present,:01.@entry.@parenthesis)
shd(etcs,:02)
mod(train(icl>public_transport>thing),:03.@_hn-scope)
{/unl}
[/S]
[S:00]
{org:en}
The document primarily defines the operational requirements and therefore contains only a few technical terms.
{/org}
{unl}
aoj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,document(icl>writing>thing).@def)
man(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,primarily(icl>how,equ>mainly))
and(:01,define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present)
mod(requirement(icl>duty>thing).@def.@pl,operational(icl>adj,com>operation))
obj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,requirement(icl>duty>thing).@def.@pl)
man:01(contain(icl>be,equ>comprise,obj>abstract_thing,aoj>information,pur>abstract_thing).@entry.@present,therefore(icl>how))
man:01(term(icl>word>thing,mod>thing).@pl,only(icl>how,equ>recently))
qua:01(term(icl>word>thing,mod>thing).@pl,a_few(icl>adj,equ>some,qua<thing))
mod:01(term(icl>word>thing,mod>thing).@pl,technical(icl>adj,ant>nontechnical))
obj:01(contain(icl>be,equ>comprise,obj>abstract_thing,aoj>information,pur>abstract_thing).@entry.@present,term(icl>word>thing,mod>thing).@pl)
{/unl}
[/S]
[S:00]
{org:en}
For consistency reasons, all functional requirements not implemented in the SRS 2.3.0 have been removed from this version..
{/org}
{unl}
agt:01(reason(icl>persuade>do,agt>thing,gol>uw,rec>person).@entry.@present,consistency(icl>uniformity>thing,ant>inconsistency))
qua:02(requirement(icl>duty>thing).@pl,all(icl>quantity,ant>some,per>thing))
mod:02(requirement(icl>duty>thing).@pl,functional(icl>adj,ant>nonfunctional))
agt:02(implement(icl>employ>do,agt>thing,obj>thing).@past.@not,requirement(icl>duty>thing).@pl)
plc(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,srs.@def)
obj(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,"2.3".@topic)
mod("2.3".@topic,".0")
mod(version(icl>interpretation>abstract_thing,agt>thing,obj>uw),this(icl>determiner>adj,mod<concrete_thing))
plf(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,version(icl>interpretation>abstract_thing,agt>thing,obj>uw))
and(implement(icl>employ>do,agt>thing,obj>thing).@past.@not,:01)
rsn(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,:02)
{/unl}
[/S]
[/D]
\ No newline at end of file
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
</snapshots> </snapshots>
<id>tetra_central</id> <id>tetra_central</id>
<name>Tetras Central</name> <name>Tetras Central</name>
<url>file:///${user.home}/.m2/tetrasArtifacts-unl</url> <url>file:///${user.home}\.m2\tetrasArtifacts-unl</url>
</repository> </repository>
</repositories> </repositories>
......
...@@ -2,6 +2,7 @@ package fr.tetras_libre.unltools.Convert; ...@@ -2,6 +2,7 @@ package fr.tetras_libre.unltools.Convert;
import fr.tetras_libre.unltools.cqrs.CommandHandler; import fr.tetras_libre.unltools.cqrs.CommandHandler;
import fr.tetras_libre.unltools.cqrs.Result; import fr.tetras_libre.unltools.cqrs.Result;
import fr.tetras_libre.unltools.unl.GraphExportException;
import fr.tetras_libre.unltools.unl.GraphExporterFactory; import fr.tetras_libre.unltools.unl.GraphExporterFactory;
import java.io.IOException; import java.io.IOException;
...@@ -18,7 +19,9 @@ public class ExportUnlDocumentsHandler implements CommandHandler<ExportUnlDocume ...@@ -18,7 +19,9 @@ public class ExportUnlDocumentsHandler implements CommandHandler<ExportUnlDocume
try { try {
var graphExporter = factory.createGraphExporter(command.getWriter(), command.getExporterName()); var graphExporter = factory.createGraphExporter(command.getWriter(), command.getExporterName());
graphExporter.write(command.getGraphImporter().Import()); graphExporter.write(command.getGraphImporter().Import());
} catch (IOException e) { command.getWriter().flush();
command.getWriter().close();
} catch (IOException | GraphExportException e) {
return Result.Failure(String.format("Cannot export unl documents to format '%s'", command.getExporterName()), return Result.Failure(String.format("Cannot export unl documents to format '%s'", command.getExporterName()),
e); e);
} }
......
...@@ -81,6 +81,15 @@ public class Graph { ...@@ -81,6 +81,15 @@ public class Graph {
int i = 0; int i = 0;
GraphNode graphNode = null; GraphNode graphNode = null;
while ((i < this.nodes.size()) && (null == graphNode)) {
var node = this.nodes.get(i);
if(graphNumber.equals(node.getNodeId()) && node.isEntryNode()){
return node;
}
i++;
}
i=0;
while ((i < relations.size()) && (null == graphNode)) { while ((i < relations.size()) && (null == graphNode)) {
graphNode = getEntryNode(this.relations.get(i), graphNumber); graphNode = getEntryNode(this.relations.get(i), graphNumber);
i++; i++;
......
package fr.tetras_libre.unltools.unl;
public class GraphExportException extends Exception {
public GraphExportException() {
super();
}
public GraphExportException(String message) {
super(message);
}
public GraphExportException(String message, Throwable cause) {
super(message, cause);
}
public GraphExportException(Throwable cause) {
super(cause);
}
}
...@@ -4,5 +4,5 @@ import java.io.IOException; ...@@ -4,5 +4,5 @@ import java.io.IOException;
import java.util.List; import java.util.List;
public interface GraphExporter { public interface GraphExporter {
void write(List<UnlDocument> g) throws IOException; void write(List<UnlDocument> g) throws IOException, GraphExportException;
} }
...@@ -30,7 +30,7 @@ public class GraphRelationBuilder { ...@@ -30,7 +30,7 @@ public class GraphRelationBuilder {
public interface RequiredLeftNode { public interface RequiredLeftNode {
RequiredRightNode leftNode(Function<UniversalWordNodeBuilder.IRequiredUniversalWord, UniversalWordNodeBuilder.IBuild> f); RequiredRightNode leftNode(Function<UniversalWordNodeBuilder.IRequiredUniversalWord, UniversalWordNodeBuilder.IBuild> f);
IBuild rightSubGraphNode(Function<SubGraphReferenceNodeBuilder.IRequiredReferenceNumber, SubGraphReferenceNodeBuilder.IBuild> f); RequiredRightNode leftSubGraphNode(Function<SubGraphReferenceNodeBuilder.IRequiredReferenceNumber, SubGraphReferenceNodeBuilder.IBuild> f);
} }
public interface RequiredRightNode { public interface RequiredRightNode {
...@@ -69,8 +69,8 @@ public class GraphRelationBuilder { ...@@ -69,8 +69,8 @@ public class GraphRelationBuilder {
} }
@Override @Override
public IBuild rightSubGraphNode(Function<SubGraphReferenceNodeBuilder.IRequiredReferenceNumber, SubGraphReferenceNodeBuilder.IBuild> f) { public RequiredRightNode leftSubGraphNode(Function<SubGraphReferenceNodeBuilder.IRequiredReferenceNumber, SubGraphReferenceNodeBuilder.IBuild> f) {
instance.node2 = f.apply(SubGraphReferenceNodeBuilder.createBuilder()).buildSubGraphReferenceNode(); instance.node1 = f.apply(SubGraphReferenceNodeBuilder.createBuilder()).buildSubGraphReferenceNode();
return this; return this;
} }
...@@ -90,5 +90,11 @@ public class GraphRelationBuilder { ...@@ -90,5 +90,11 @@ public class GraphRelationBuilder {
instance.node2 = f.apply(UniversalWordNodeBuilder.createBuilder()).buildUniversalWordNode(); instance.node2 = f.apply(UniversalWordNodeBuilder.createBuilder()).buildUniversalWordNode();
return this; return this;
} }
@Override
public IBuild rightSubGraphNode(Function<SubGraphReferenceNodeBuilder.IRequiredReferenceNumber, SubGraphReferenceNodeBuilder.IBuild> f) {
instance.node2 = f.apply(SubGraphReferenceNodeBuilder.createBuilder()).buildSubGraphReferenceNode();
return this;
}
} }
} }
...@@ -23,11 +23,12 @@ public class DotFileGraphExporter implements GraphExporter { ...@@ -23,11 +23,12 @@ public class DotFileGraphExporter implements GraphExporter {
} }
private void write(Graph g) throws IOException { private void write(Graph g) throws IOException, GraphExportException {
try { try {
this.InternalWrite(g); this.InternalWrite(g);
} catch (NoEntryNodeException e) { } catch (NoEntryNodeException e) {
// TODO : to define what to do here // TODO : to define what to do here
throw new GraphExportException("Unable to export graph due to unknown node relation", e);
} }
} }
...@@ -190,7 +191,7 @@ public class DotFileGraphExporter implements GraphExporter { ...@@ -190,7 +191,7 @@ public class DotFileGraphExporter implements GraphExporter {
} }
@Override @Override
public void write(List<UnlDocument> documents) throws IOException { public void write(List<UnlDocument> documents) throws IOException, GraphExportException {
for (var document : documents) { for (var document : documents) {
for (var documentNode : document.getDocElements()) { for (var documentNode : document.getDocElements()) {
this.write(documentNode.getGraph()); this.write(documentNode.getGraph());
......
...@@ -22,8 +22,9 @@ public class UnlGraphImporterFromUnlParser implements GraphImporter { ...@@ -22,8 +22,9 @@ public class UnlGraphImporterFromUnlParser implements GraphImporter {
@Override @Override
public List<UnlDocument> Import() { public List<UnlDocument> Import() {
if (documents == null) { if (documents == null) {
var documentParser = new UnlParser(this.bufferedReader);
try { try {
documents = new UnlParser(this.bufferedReader).createUnlDocumentList(); documents = documentParser.createUnlDocumentList();
} catch (ParseException e) { } catch (ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -93,4 +93,64 @@ public class UnlSentences { ...@@ -93,4 +93,64 @@ public class UnlSentences {
"{/unl}\n" + "{/unl}\n" +
"[/S]\n" + "[/S]\n" +
"[/D]"; "[/D]";
public static final String Issue12 = "[D]\n" +
"[S:00]\n" +
"{org:en}\n" +
"This document defines the functional requirements for ERTMS/ETCS (EUROPEAN RAIL TRAFFIC MANAGEMENT SYSTEM / EUROPEAN TRAIN CONTROL SYSTEM).\n" +
"{/org}\n" +
"{unl}\n" +
"mod(document(icl>writing>thing),this(icl>determiner>adj,mod<concrete_thing))\n" +
"aoj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,document(icl>writing>thing))\n" +
"mod(requirement(icl>duty>thing).@def.@pl,functional(icl>adj,ant>nonfunctional))\n" +
"obj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,requirement(icl>duty>thing).@def.@pl)\n" +
"or(etcs,ertms)\n" +
"pur(requirement(icl>duty>thing).@def.@pl,etcs)\n" +
"mod:01(management(icl>action,agt>volitional_thing,obj>thing),traffic(icl>collection>thing))\n" +
"mod(:03.@_hn-scope,management(icl>action,agt>volitional_thing,obj>thing))\n" +
"or:03(european(icl>inhabitant>person).@entry,system(icl>group>thing):01.@entry)\n" +
"mod:01(control(icl>power>thing),train(icl>public_transport>thing))\n" +
"mod:01(system(icl>group>thing):02,control(icl>power>thing))\n" +
"agt:02(rail(icl>complain>do,rsn>thing,agt>volitional_thing).@entry.@present,:01.@entry.@parenthesis)\n" +
"rsn:02(rail(icl>complain>do,rsn>thing,agt>volitional_thing).@entry.@present,:01.@entry.@parenthesis)\n" +
"shd(etcs,:02)\n" +
"mod(train(icl>public_transport>thing),:03.@_hn-scope)\n" +
"{/unl}\n" +
"[/S]\n" +
// "[S:00]\n" +
// "{org:en}\n" +
// "The document primarily defines the operational requirements and therefore contains only a few technical terms.\n" +
// "{/org}\n" +
// "{unl}\n" +
// "aoj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,document(icl>writing>thing).@def)\n" +
// "man(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,primarily(icl>how,equ>mainly))\n" +
// "and(:01,define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present)\n" +
// "mod(requirement(icl>duty>thing).@def.@pl,operational(icl>adj,com>operation))\n" +
// "obj(define(icl>characterize>be,obj>uw,aoj>thing).@entry.@present,requirement(icl>duty>thing).@def.@pl)\n" +
// "man:01(contain(icl>be,equ>comprise,obj>abstract_thing,aoj>information,pur>abstract_thing).@entry.@present,therefore(icl>how))\n" +
// "man:01(term(icl>word>thing,mod>thing).@pl,only(icl>how,equ>recently))\n" +
// "qua:01(term(icl>word>thing,mod>thing).@pl,a_few(icl>adj,equ>some,qua<thing))\n" +
// "mod:01(term(icl>word>thing,mod>thing).@pl,technical(icl>adj,ant>nontechnical))\n" +
// "obj:01(contain(icl>be,equ>comprise,obj>abstract_thing,aoj>information,pur>abstract_thing).@entry.@present,term(icl>word>thing,mod>thing).@pl)\n" +
// "{/unl}\n" +
// "[/S]\n" +
// "[S:00]\n" +
// "{org:en}\n" +
// "For consistency reasons, all functional requirements not implemented in the SRS 2.3.0 have been removed from this version..\n" +
// "{/org}\n" +
// "{unl}\n" +
// "agt:01(reason(icl>persuade>do,agt>thing,gol>uw,rec>person).@entry.@present,consistency(icl>uniformity>thing,ant>inconsistency))\n" +
// "qua:02(requirement(icl>duty>thing).@pl,all(icl>quantity,ant>some,per>thing))\n" +
// "mod:02(requirement(icl>duty>thing).@pl,functional(icl>adj,ant>nonfunctional))\n" +
// "agt:02(implement(icl>employ>do,agt>thing,obj>thing).@past.@not,requirement(icl>duty>thing).@pl)\n" +
// "plc(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,srs.@def)\n" +
// "obj(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,\"2.3\".@topic)\n" +
// "mod(\"2.3\".@topic,\".0\")\n" +
// "mod(version(icl>interpretation>abstract_thing,agt>thing,obj>uw),this(icl>determiner>adj,mod<concrete_thing))\n" +
// "plf(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,version(icl>interpretation>abstract_thing,agt>thing,obj>uw))\n" +
// "and(implement(icl>employ>do,agt>thing,obj>thing).@past.@not,:01)\n" +
// "rsn(remove(icl>dismiss>do,plf>thing,agt>volitional_thing,obj>person).@entry.@present.@complete,:02)\n" +
// "{/unl}\n" +
// "[/S]\n" +
"[/D]";
} }
...@@ -30,6 +30,21 @@ class DotFileBuilderTest { ...@@ -30,6 +30,21 @@ class DotFileBuilderTest {
this.writeInFile(new AllUnl().getUnlDocuments(), new AllSetenceWithExpectedDotChecker()); this.writeInFile(new AllUnl().getUnlDocuments(), new AllSetenceWithExpectedDotChecker());
} }
@Test
public void Issue12shouldBeExportedInDotFormatWithoutException(){
// Startup
Writer strResult = new StringWriter();
DotFileGraphExporter dotFileBuilder = new DotFileGraphExporter(strResult);
// Test
Assertions.assertDoesNotThrow(() -> dotFileBuilder.write(new Issue12Unl().getUnlDocuments()));
// Teardown
Assertions.assertDoesNotThrow(strResult::flush);
Assertions.assertTrue(() -> strResult.toString().length() != 0);
Assertions.assertDoesNotThrow(strResult::close);
}
private void writeInFile(List<UnlDocument> unlDocuments, SentenceWithExpectedDotChecker sentenceChecker) { private void writeInFile(List<UnlDocument> unlDocuments, SentenceWithExpectedDotChecker sentenceChecker) {
// Startup // Startup
Writer strResult = new StringWriter(); Writer strResult = new StringWriter();
...@@ -39,11 +54,11 @@ class DotFileBuilderTest { ...@@ -39,11 +54,11 @@ class DotFileBuilderTest {
Assertions.assertDoesNotThrow(() -> dotFileBuilder.write(unlDocuments)); Assertions.assertDoesNotThrow(() -> dotFileBuilder.write(unlDocuments));
// Teardown // Teardown
Assertions.assertDoesNotThrow(() -> strResult.flush()); Assertions.assertDoesNotThrow(strResult::flush);
Assertions.assertTrue(() -> strResult.toString().length() != 0); Assertions.assertTrue(() -> strResult.toString().length() != 0);
Assertions.assertDoesNotThrow(() -> sentenceChecker.setCurrentDotContent(strResult.toString())); Assertions.assertDoesNotThrow(() -> sentenceChecker.setCurrentDotContent(strResult.toString()));
sentenceChecker.assetSameAsExpected(); sentenceChecker.assetSameAsExpected();
Assertions.assertDoesNotThrow(() -> strResult.close()); Assertions.assertDoesNotThrow(strResult::close);
} }
} }
\ No newline at end of file
package fr.tetras_libre.unltools.unl.parser;
import fr.tetras_libre.unltools.unl.Issue12Unl;
import fr.tetras_libre.unltools.unl.UnlDocument;
import fr.tetras_libre.unltools.unl.UnlSentences;
import java.util.List;
public class Issue12WithExpectedUnlDocumentsChecker extends SentenceWithExpectedUnlDocumentsChecker {
public Issue12WithExpectedUnlDocumentsChecker() {
super(UnlSentences.Issue12, new Issue12Unl().getUnlDocuments());
}
}
...@@ -16,11 +16,12 @@ class UnlParserTest { ...@@ -16,11 +16,12 @@ class UnlParserTest {
return Stream.of(new R1SentenceWithExpectedUnlDocumentsChecker(), return Stream.of(new R1SentenceWithExpectedUnlDocumentsChecker(),
new R2SentenceWithExpectedUnlDocumentsChecker(), new R2SentenceWithExpectedUnlDocumentsChecker(),
new CatsSentenceWithExpectedUnlDocumentsChecker(), new CatsSentenceWithExpectedUnlDocumentsChecker(),
new AllSentenceWithExpectedUnlDocumentsChecker()); new AllSentenceWithExpectedUnlDocumentsChecker(),
new Issue12WithExpectedUnlDocumentsChecker());
} }
@ParameterizedTest @ParameterizedTest
@ValueSource(strings = {UnlSentences.R1, UnlSentences.R2, UnlSentences.Cats, UnlSentences.All}) @ValueSource(strings = {UnlSentences.R1, UnlSentences.R2, UnlSentences.Cats, UnlSentences.All, UnlSentences.Issue12})
void unlParserShouldParseSimpleSentenceWithoutException(String input) { void unlParserShouldParseSimpleSentenceWithoutException(String input) {
UnlParserFactory unlFactory = new UnlParserFactoryFromString(input); UnlParserFactory unlFactory = new UnlParserFactoryFromString(input);
var wrapper = createAndCheckUnlParserValidity(unlFactory); var wrapper = createAndCheckUnlParserValidity(unlFactory);
......
...@@ -8,6 +8,7 @@ import fr.tetras_libre.unltools.unl.exporters.GraphExporterNames; ...@@ -8,6 +8,7 @@ import fr.tetras_libre.unltools.unl.exporters.GraphExporterNames;
import fr.tetras_libre.unltools.unl.parser.UnlGraphImporterFromUnlParser; import fr.tetras_libre.unltools.unl.parser.UnlGraphImporterFromUnlParser;
import picocli.CommandLine; import picocli.CommandLine;
import java.io.BufferedWriter;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
...@@ -43,9 +44,9 @@ public class Unl2Rdf { ...@@ -43,9 +44,9 @@ public class Unl2Rdf {
String extension = ToExtension(outType); String extension = ToExtension(outType);
String outfileName = options.getOutputFile() + extension; String outfileName = options.getOutputFile() + extension;
FileWriter fileWriter = new FileWriter(outfileName, false); FileWriter fileWriter = new FileWriter(outfileName, false);
var convertCommand = new ExportUnlDocuments(importer, GetExporterName(outType), fileWriter); var bufferedWriter = new BufferedWriter(fileWriter);
var convertCommand = new ExportUnlDocuments(importer, GetExporterName(outType), bufferedWriter);
handler.handle(convertCommand); handler.handle(convertCommand);
fileWriter.close();
System.out.println(String.format("Graph writen into file '%s'", outfileName)); System.out.println(String.format("Graph writen into file '%s'", outfileName));
} }
} }
......
...@@ -44,6 +44,12 @@ class Unl2RdfTest { ...@@ -44,6 +44,12 @@ class Unl2RdfTest {
Assertions.assertDoesNotThrow(() -> Unl2Rdf.main(new String[]{"--input-file", "../Examples/exemples_unl.txt", "--output-file", "exemples_unl", "--output-type", "rdf"})); Assertions.assertDoesNotThrow(() -> Unl2Rdf.main(new String[]{"--input-file", "../Examples/exemples_unl.txt", "--output-file", "exemples_unl", "--output-type", "rdf"}));
} }
@Tag("integration")
@Test
public void issue12ShouldBeConvertedToDotFile() {
Assertions.assertDoesNotThrow(() -> Unl2Rdf.main(new String[]{"--input-file", "../Examples/issue12.txt", "--output-file", "issue12", "--output-type", "dot"}));
}
static class TestMainShouldNotThrowOnPartialParameterArgumentProvider implements ArgumentsProvider { static class TestMainShouldNotThrowOnPartialParameterArgumentProvider implements ArgumentsProvider {
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment