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