-
Notifications
You must be signed in to change notification settings - Fork 13
Fix expanders for multiple modules #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tobianas
wants to merge
6
commits into
PANTHEONtech:main
Choose a base branch
from
Tobianas:17.xFixv3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
08a4b65
Improve testing for multiple json-tree modules
Tobianas f7fdccb
Improve testing for JsTree format
Tobianas b803309
Fix multiple bodies in JsTree output
Tobianas ae7c552
Adjust the expected JsTree output
Tobianas 88b0fbe
Fix expanders for multiple modules
Tobianas a32a092
Adjust the expected JsTree output
Tobianas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div> <b> module name <NAME_REVISION>, namespace <NAMESPACE>, prefix <PREFIX> </b></div><div> | ||
<button type="button" id="expander" class="btn btn-danger">Expand All</button> | ||
<button type="button" id="collapser" class="btn btn-info">Collapse All</button> | ||
<table id="basic" class="table table-bordered table-striped simple-tree-table"> | ||
<th> element </th> | ||
<th> schema </th> | ||
<th> type </th> | ||
<th> flag </th> | ||
<th> status </th> | ||
<th> path </th> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,8 +9,10 @@ | |
|
||
import static io.lighty.yang.validator.Main.startLyv; | ||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
import io.lighty.yang.validator.FormatTest; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
@@ -69,6 +71,34 @@ public void runDeviationTest() throws Exception { | |
runJsTreeTest("moduleDeviation.html"); | ||
} | ||
|
||
@Test | ||
public void testMultipleFiles() throws IOException { | ||
final String module1 = Paths.get(yangPath + "/[email protected]").toString(); | ||
final String module2 = Paths.get(yangPath + "/[email protected]").toString(); | ||
builder.setYangModules(List.of(module1, module2)); | ||
final List<FormatPlugin> formats = new ArrayList<>(); | ||
formats.add(new JsTree()); | ||
formatter = new Format(formats); | ||
builder.setFormat("jstree"); | ||
final var configuration = builder.build(); | ||
startLyv(configuration, formatter); | ||
final Path outLog = Paths.get(outPath).resolve("out.log"); | ||
String fileCreated = Files.readString(outLog); | ||
final String compareWith = Files.readString(outLog.resolveSibling("compare").resolve("multipleModules.html")); | ||
|
||
//assert that file contains the first module | ||
assertTrue(fileCreated.contains("<b> module name ietf-connection-oriented-oam@2019-04-16, " | ||
+ "namespace urn:ietf:params:xml:ns:yang:ietf-connection-oriented-oam, prefix co-oam </b>")); | ||
//assert that file contains the second module | ||
assertTrue(fileCreated.contains("<b> module name ietf-routing@2018-03-13, " | ||
+ "namespace urn:ietf:params:xml:ns:yang:ietf-routing, prefix rt </b>")); | ||
//assert that there is only one <body> tag | ||
final int bodyTagCount = fileCreated.split("<body>").length - 1; | ||
assertEquals(1, bodyTagCount); | ||
//assert that outputs match | ||
assertEquals(fileCreated.replaceAll("\\s+", ""), compareWith.replaceAll("\\s+", "")); | ||
} | ||
|
||
private void runJsTreeTest(final String comapreWithFileName) throws Exception { | ||
final Path outLog = Paths.get(outPath).resolve("out.log"); | ||
final String fileCreated = Files.readString(outLog); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,17 @@ | |
*/ | ||
package io.lighty.yang.validator.formats; | ||
|
||
import static io.lighty.yang.validator.Main.startLyv; | ||
|
||
import io.lighty.yang.validator.FormatTest; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
public class JsonTreeTest extends FormatTest { | ||
|
||
|
@@ -55,6 +59,34 @@ public void runDeviationTest() throws Exception { | |
runJsonTreeTest("ModuleDeviation.json"); | ||
} | ||
|
||
@Test | ||
public void testMultipleFiles() throws IOException { | ||
final var module1 = Paths.get(yangPath + "/[email protected]").toString(); | ||
final var module2 = Paths.get(yangPath + "/[email protected]").toString(); | ||
builder.setYangModules(List.of(module1, module2)); | ||
final List<FormatPlugin> formats = new ArrayList<>(); | ||
Tobianas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
formats.add(new JsonTree()); | ||
formatter = new Format(formats); | ||
builder.setFormat("json-tree"); | ||
final var configuration = builder.build(); | ||
startLyv(configuration, formatter); | ||
final var outLog = Paths.get(outPath).resolve("out.log"); | ||
final String fileCreated = Files.readString(outLog).substring(Files.readString(outLog).indexOf("{")); | ||
final String compareWith = Files.readString(outLog.resolveSibling("compare").resolve("multipleModules.json")); | ||
final String compareModel1 = Files.readString( | ||
outLog.resolveSibling("compare").resolve("connectionOrientedOam.json")) | ||
.replaceFirst("\\{\\s+\"parsed-models\": \\[\\s+\\{\n", "") | ||
.replaceFirst("]\n\\s*}$", "").replaceAll("\\n\\s*", ""); | ||
final String compareModel2 = Files.readString( | ||
outLog.resolveSibling("compare").resolve("routing.json")) | ||
.replaceFirst("\\{\\s+\"parsed-models\": \\[\\s+\\{\n", "") | ||
.replaceFirst("]\n\\s*}$", "").replaceAll("\\n\\s*", ""); | ||
|
||
Assert.assertEquals(fileCreated.replaceAll("\\s+", ""), compareWith.replaceAll("\\s+", "")); | ||
Assert.assertTrue(fileCreated.replaceAll("\\s+", "").contains(compareModel1.replaceAll("\\s+", ""))); | ||
Assert.assertTrue(fileCreated.replaceAll("\\s+", "").contains(compareModel2.replaceAll("\\s+", ""))); | ||
} | ||
|
||
private void runJsonTreeTest(final String comapreWithFileName) throws Exception { | ||
final Path outLog = Paths.get(outPath).resolve("out.log"); | ||
final String fileCreated = Files.readString(outLog); | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.