How-To test model-api
client code without a model-server
If you want to test code that processes model-api
instances, you can do this in-process without a running model-server.
Use the following pattern to set up your test fixture containing model-api
instances:
val branch = ModelFacade.toLocalBranch(ModelFacade.newLocalTree())
branch.runWrite {
val root = branch.getRootNode()
val someRootNode = root.addNewChild(null, C_SomeConcept.untyped()).typed<N_SomeConcept>()
someRootNode.member.addNew(-1, C_OtherConcept).apply {
name = "some test property value"
}
}
All classes of the pattern C_*
and N_*
are generated using the model-api-gen
.