Added Test suite for testing of TypeProviderImpl. 45/11245/5
authorLukas Sedlak <lsedlak@cisco.com>
Fri, 5 Sep 2014 08:58:14 +0000 (10:58 +0200)
committerTony Tkacik <ttkacik@cisco.com>
Mon, 22 Sep 2014 14:12:41 +0000 (14:12 +0000)
commit0859da7c4d61a4f31d7783c37f4bca9faf18ae70
tree687ec0d1ddfe2b85622e8d9d6a9e3216298f2cf8
parent8651ca9446b4359920c5af900eb7dc13fc75d8f4
Added Test suite for testing of TypeProviderImpl.

Removed commented out blocks of code from TypeProviderImpl.
Fixed invalid typecast in getTypeDefaultConstruction(LeafSchemaNode, defaultValue) in else branch of BitsTypeDefinition processing. The parent value is of type ModuleImpl which cannot
be cast to SchemaNode as originaly was. Instead of we can extract QName direclty from parent value -> no need to typecast at all.

Fixed leafrefToDef method in TypeProviderImpl. This method will now process defaultValue from method parameter instead of parent node. Method leafrefToDef has been called only via getTypeDefaultConstruction(LeafSchemaNode, defaultValue) method where default value has been added implicitly. In case that user calls getTypeDefaultConstruction for leafref schema node
and specifies defaultValue as parameter and not in yang model the method will throw exception. Now behaviour of leafrefToDef depends only and only on parameter passed in getTypeDefaultConstruction.

Created TypeProviderTest which contains whole test suite for testing of TypeProviderImpl class.
TestIntegerTypeDefinition is mock implementation of IntegerTypeDefinition in order to testing null references returned by TypeDefinition object.

TypeProviderModel contains methods for provisiononing of YANG test models from test/resources folder.
Created Mock implementations of LeafrefTypeWithNullToStringInXpath, LeafrefTypeWithNullXpath, TestIntegerTypeDefinition and TestLeafSchemaNode designated
to increase branch coverage in tests and provide fail scenarios.

Change-Id: I5599c9b1e8f02a8553fab27c1771e32f88c38bc6
Signed-off-by: Lukas Sedlak <lsedlak@cisco.com>
12 files changed:
code-generator/binding-type-provider/pom.xml
code-generator/binding-type-provider/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java
code-generator/binding-type-provider/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/BaseYangTypesTest.java
code-generator/binding-type-provider/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/LeafrefTypeWithNullToStringInXpath.java [new file with mode: 0644]
code-generator/binding-type-provider/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/LeafrefTypeWithNullXpath.java [new file with mode: 0644]
code-generator/binding-type-provider/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/TestIntegerTypeDefinition.java [new file with mode: 0644]
code-generator/binding-type-provider/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/TestLeafSchemaNode.java [new file with mode: 0644]
code-generator/binding-type-provider/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderModel.java [new file with mode: 0644]
code-generator/binding-type-provider/src/test/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderTest.java [new file with mode: 0644]
code-generator/binding-type-provider/src/test/resources/base-yang-types.yang
code-generator/binding-type-provider/src/test/resources/test-type-provider-b.yang [new file with mode: 0644]
code-generator/binding-type-provider/src/test/resources/test-type-provider.yang [new file with mode: 0644]