Skip to content
Snippets Groups Projects
Commit c4727b6a authored by Sebastien's avatar Sebastien
Browse files

restore unit test of dot generation of cat sentence

parent fd9796a9
Branches
Tags
No related merge requests found
......@@ -16,39 +16,14 @@ public class CatSentenceWithExpectedDotChecker extends SentenceWithExpectedDotCh
"[/S]\n";
private static final String CAT_DOT = "digraph G {\n" +
"digraph G {\n" +
"1 [\n" +
"label=\"eat(agt>living_thing,icl>consume(icl>do),ins>thing,obj>concrete_thing)\\n.@entry.@pl.@present.@progress\"\n" +
"shape=\"box\"\n" +
"fontname=\"courb\"\n" +
"];\n" +
"2 [\n" +
"label=\"cat(icl>feline(icl>thing)):01\\n.@def.@entry\"\n" +
"shape=\"box\"\n" +
"fontname=\"courb\"\n" +
"];\n" +
"3 [\n" +
"label=\"black(icl>adj)\"\n" +
"shape=\"box\"\n" +
"fontname=\"courb\"\n" +
"];\n" +
"4 [\n" +
"label=\"cat(icl>feline(icl>thing)):02\\n.@def.@entry\"\n" +
"shape=\"box\"\n" +
"fontname=\"courb\"\n" +
"];\n" +
"5 [\n" +
"label=\"white(icl>adj)\"\n" +
"shape=\"box\"\n" +
"fontname=\"courb\"\n" +
"];\n" +
"subgraph cluster_01{\n" +
" color = black;\n" +
" label = \":01\"2 -> 3 [label=\"mod\" ];\n" +
"2 -> 4 [label=\"and\" ];\n" +
"4 -> 5 [label=\"mod\" ]\n" +
"}\n" +
"1 -> 2 [label=\"agt\" lhead=\"cluster_01\"];\n" +
"graph [fontname=\"courier\", compound=\"true\"];\n" +
"1 [ label=\"cat(icl>feline(icl>thing)):01\\n.@def.@entry\" shape=\"box\" fontname=\"courb\" ];\n" +
"2 [ label=\"black(icl>adj)\\n\" shape=\"box\" ];\n" +
"3 [ label=\"cat(icl>feline(icl>thing)):02\\n.@def.@entry\" shape=\"box\" fontname=\"courb\" ];\n" +
"4 [ label=\"white(icl>adj)\\n\" shape=\"box\" ];\n" +
"5 [ label=\"eat(agt>living_thing,icl>consume(icl>do),ins>thing,obj>concrete_thing)\\n.@entry.@pl.@present.@progress\" shape=\"box\" fontname=\"courb\" ];" +
" subgraph cluster_01{ color = black; label = \":01\"1 -> 2 [label=\"mod\" ]; 1 -> 3 [label=\"and\" ]; 3 -> 4 [label=\"mod\" ]; }\n" +
"5 -> 1 [label=\"agt\" lhead=\"cluster_01\"];\n" +
"}\n";
public CatSentenceWithExpectedDotChecker() {
......
package unl;
import org.junit.jupiter.api.Assertions;
public abstract class SentenceWithExpectedDotChecker {
private String unlSentence;
private String expectedDotContent;
private String currentDotContent;
public SentenceWithExpectedDotChecker(String unlSentence, String expectedDotContent) {
if ((null == unlSentence) || (null == expectedDotContent)) {
throw new IllegalArgumentException();
}
this.unlSentence = unlSentence;
this.expectedDotContent = expectedDotContent;
}
public String getUnlSentence() {
return this.unlSentence;
}
......@@ -29,15 +39,7 @@ public abstract class SentenceWithExpectedDotChecker {
this.currentDotContent = null == currentDotContent ? "" : currentDotContent;
}
public boolean checkDotContentIsEqual(){
return this.expectedDotContent.equals(this.currentDotContent);
}
public SentenceWithExpectedDotChecker(String unlSentence, String expectedDotContent) {
if ((null == unlSentence) || (null == expectedDotContent)) {
throw new IllegalArgumentException();
}
this.unlSentence = unlSentence;
this.expectedDotContent = expectedDotContent;
public void assetSameAsExpected() {
Assertions.assertEquals(this.expectedDotContent.replaceAll("\\s+", " "), this.currentDotContent.replaceAll("\\s+", " "));
}
}
package unl.print.dotFile;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestReporter;
import org.junit.jupiter.api.io.TempDir;
......@@ -37,7 +36,6 @@ class DotFileBuilderTest {
}
@Test
@Disabled("a refaire pour resultat attendu")
public void dotFileBuilderShouldCreateDotFileCatWithoutException(TestReporter testReporter) {
this.testReporter = testReporter;
Path dotPAth = SharedTempDir.resolve("cat.dot");
......@@ -78,7 +76,7 @@ class DotFileBuilderTest {
});
Assertions.assertTrue(() -> outFile.get().length() != 0);
Assertions.assertDoesNotThrow(() -> sentenceChecker.setCurrentDotContent(Files.readString(filePath, StandardCharsets.UTF_8)));
Assertions.assertTrue(sentenceChecker::checkDotContentIsEqual);
sentenceChecker.assetSameAsExpected();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment