added map, list model types with tests

This commit is contained in:
Tony Tam
2014-09-27 09:13:26 -07:00
parent ba45641801
commit 530ebe1f7d
11 changed files with 184 additions and 66 deletions

View File

@@ -206,4 +206,37 @@ class JavaModelTest extends FlatSpec with Matchers {
vars.get(0).isContainer should equal (true)
vars.get(0).isNotContainer should be (null)
}
it should "convert an array model" in {
val model = new ArrayModel()
.description("an array model")
.items(new RefProperty("#/definitions/Children"))
val codegen = new JavaClientCodegen()
val cm = codegen.fromModel("sample", model)
cm.name should be ("sample")
cm.classname should be ("Sample")
cm.description should be ("an array model")
cm.vars.size should be (0)
cm.parent should be ("ArrayList<Children>")
cm.imports.size should be (3)
(cm.imports.asScala.toSet & Set("List", "ArrayList", "Children")).size should be (3)
}
it should "convert an map model" in {
val model = new ModelImpl()
.description("an map model")
.additionalProperties(new RefProperty("#/definitions/Children"))
val codegen = new JavaClientCodegen()
val cm = codegen.fromModel("sample", model)
cm.name should be ("sample")
cm.classname should be ("Sample")
cm.description should be ("an map model")
cm.vars.size should be (0)
cm.parent should be ("HashMap<String, Children>")
cm.imports.size should be (3)
(cm.imports.asScala.toSet & Set("Map", "HashMap", "Children")).size should be (3)
}
}