-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
155 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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
47 changes: 47 additions & 0 deletions
47
cli/src/test/java/com/mrv/yangtools/codegen/main/Issue57.java
This file contains 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,47 @@ | ||
package com.mrv.yangtools.codegen.main; | ||
|
||
import io.swagger.models.Swagger; | ||
import io.swagger.parser.SwaggerParser; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.kohsuke.args4j.CmdLineParser; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public class Issue57 { | ||
|
||
@Test | ||
public void test() throws Exception { | ||
|
||
String path = Paths.get(Issue57.class.getResource("/bug_57/").toURI()).toAbsolutePath().toString(); | ||
|
||
List<String> args = Stream.of( | ||
"-yang-dir", | ||
path | ||
).collect(Collectors.toList()); | ||
|
||
Main main = new Main(); | ||
CmdLineParser parser = new CmdLineParser(main); | ||
parser.parseArgument(args); | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
main.out = baos; | ||
main.init(); | ||
main.generate(); | ||
|
||
Swagger swagger = new SwaggerParser().parse(new String(baos.toByteArray(), StandardCharsets.UTF_8)); | ||
|
||
Set<String> result = swagger.getDefinitions().keySet().stream() | ||
.filter(s -> s.endsWith("Input")) | ||
.collect(Collectors.toSet()); | ||
Set<String> expected = Stream.of("objects.createobject.Input", "objects.updateobject.Input") | ||
.collect(Collectors.toSet()); | ||
Assert.assertEquals(expected, result); | ||
|
||
} | ||
} |
This file contains 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,36 @@ | ||
module objects { | ||
|
||
yang-version "1.1"; | ||
namespace "urn:objects"; | ||
prefix "obje"; | ||
|
||
grouping id_1 { | ||
leaf id_1 { | ||
type "string"; | ||
} | ||
} | ||
|
||
grouping id_2 { | ||
leaf id_2 { | ||
type "string"; | ||
} | ||
} | ||
|
||
rpc create-object { | ||
input { | ||
uses id_1; | ||
uses id_2; | ||
} | ||
output { | ||
} | ||
} | ||
|
||
rpc update-object { | ||
input { | ||
uses id_1; | ||
uses id_2; | ||
} | ||
output { | ||
} | ||
} | ||
} |
This file contains 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
22 changes: 22 additions & 0 deletions
22
swagger-generator/src/test/java/com/mrv/yangtools/codegen/issues/Issue57.java
This file contains 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,22 @@ | ||
package com.mrv.yangtools.codegen.issues; | ||
|
||
import com.mrv.yangtools.codegen.AbstractItTest; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public class Issue57 extends AbstractItTest { | ||
@Test | ||
public void testIssue57() { | ||
swaggerFor(p -> p.getParent().getFileName().toString().equals("bug_57")); | ||
Set<String> result = swagger.getDefinitions().keySet().stream() | ||
.filter(s -> s.endsWith("Input")) | ||
.collect(Collectors.toSet()); | ||
Set<String> expected = Stream.of("objects.createobject.Input", "objects.updateobject.Input") | ||
.collect(Collectors.toSet()); | ||
Assert.assertEquals(expected, result); | ||
} | ||
} |
This file contains 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,36 @@ | ||
module objects { | ||
|
||
yang-version "1.1"; | ||
namespace "urn:objects"; | ||
prefix "obje"; | ||
|
||
grouping id_1 { | ||
leaf id_1 { | ||
type "string"; | ||
} | ||
} | ||
|
||
grouping id_2 { | ||
leaf id_2 { | ||
type "string"; | ||
} | ||
} | ||
|
||
rpc create-object { | ||
input { | ||
uses id_1; | ||
uses id_2; | ||
} | ||
output { | ||
} | ||
} | ||
|
||
rpc update-object { | ||
input { | ||
uses id_1; | ||
uses id_2; | ||
} | ||
output { | ||
} | ||
} | ||
} |