import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import java.io.File;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
+import com.google.common.collect.ImmutableMap;
import java.util.Set;
+import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.opendaylight.mdsal.binding.yang.types.TypeProviderImpl;
+import org.opendaylight.mdsal.binding.yang.types.AbstractTypeProvider;
+import org.opendaylight.mdsal.binding.yang.types.CodegenTypeProvider;
import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class TypeProviderIntegrationTest {
- private final String PKG = "org.opendaylight.yang.gen.v1.urn.opendaylight.test.rev131008.";
- private static SchemaContext context;
- private TypeProviderImpl provider;
- private Module m;
+ private static final String PKG = "org.opendaylight.yang.gen.v1.urn.opendaylight.test.rev131008.";
+ private static SchemaContext CONTEXT;
+ private AbstractTypeProvider provider;
+ private Module module;
@BeforeClass
- public static void setup() throws Exception {
- File abstractTopology = new File(TypeProviderIntegrationTest.class.getResource("/type-provider/test.yang")
- .toURI());
- File ietfInetTypes = new File(TypeProviderIntegrationTest.class.getResource("/ietf/ietf-inet-types.yang")
- .toURI());
- context = YangParserTestUtils.parseYangSources(abstractTopology, ietfInetTypes);
- assertNotNull(context);
+ public static void setup() {
+ CONTEXT = YangParserTestUtils.parseYangResources(TypeProviderIntegrationTest.class, "/type-provider/test.yang",
+ "/ietf/ietf-inet-types.yang");
+ assertNotNull(CONTEXT);
+ }
+
+ @AfterClass
+ public static void teardown() {
+ CONTEXT = null;
}
@Before
- public void init() throws ParseException {
- provider = new TypeProviderImpl(context);
- m = context.findModuleByName("test", new SimpleDateFormat("yyyy-MM-dd").parse("2013-10-08"));
+ public void init() {
+ provider = new CodegenTypeProvider(CONTEXT, ImmutableMap.of());
+ module = CONTEXT.findModule("test", Revision.of("2013-10-08")).get();
}
@Test
- public void testGetTypeDefaultConstructionBinary() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-binary");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionBinary() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-binary");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new byte[] {77, 97, 110}", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-binary");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-binary");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyBinary(new byte[] {77, 97, 110})", actual);
}
@Test
- public void testGetTypeDefaultConstructionBits() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-bits");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionBits() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-bits");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "TestData.LeafBits(false, false, true)", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-bits");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-bits");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyBits(false, false, true)", actual);
}
@Test
- public void testGetTypeDefaultConstructionBoolean() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-boolean");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionBoolean() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-boolean");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Boolean.TRUE", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-boolean");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-boolean");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyBoolean(java.lang.Boolean.TRUE)", actual);
}
@Test
- public void testGetTypeDefaultConstructionDecimal() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-decimal64");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionDecimal() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-decimal64");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new java.math.BigDecimal(\"3.14\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-decimal64");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-decimal64");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyDecimal64(new java.math.BigDecimal(\"3.14\"))", actual);
}
@Test
- public void testGetTypeDefaultConstructionEmpty() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-empty");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionEmpty() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-empty");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Boolean.FALSE", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-empty");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-empty");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyEmpty(java.lang.Boolean.FALSE)", actual);
}
@Test
- public void testGetTypeDefaultConstructionEnumeration() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-enumeration");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionEnumeration() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-enumeration");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("org.opendaylight.yang.gen.v1.urn.opendaylight.test.rev131008.LeafEnumeration.Seven", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-enumeration");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-enumeration");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals(PKG + "MyEnumeration.Seven", actual);
}
@Test
- public void testGetTypeDefaultConstructionInt8() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-int8");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionInt8() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-int8");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Byte.valueOf(\"11\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-int8");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-int8");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyInt8(java.lang.Byte.valueOf(\"11\"))", actual);
}
@Test
- public void testGetTypeDefaultConstructionInt16() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-int16");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionInt16() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-int16");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Short.valueOf(\"111\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-int16");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-int16");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyInt16(java.lang.Short.valueOf(\"111\"))", actual);
}
@Test
- public void testGetTypeDefaultConstructionInt32() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-int32");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionInt32() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-int32");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Integer.valueOf(\"1111\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-int32");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-int32");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyInt32(java.lang.Integer.valueOf(\"1111\"))", actual);
}
@Test
- public void testGetTypeDefaultConstructionInt64() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-int64");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionInt64() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-int64");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("java.lang.Long.valueOf(\"11111\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-int64");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-int64");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyInt64(java.lang.Long.valueOf(\"11111\"))", actual);
}
@Test
- public void testGetTypeDefaultConstructionLeafref1() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-leafref");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionLeafref1() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-leafref");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new java.math.BigDecimal(\"1.234\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-leafref");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-leafref");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new java.math.BigDecimal(\"1.234\")", actual);
}
@Test
- public void testGetTypeDefaultConstructionLeafref2() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-leafref1");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionLeafref2() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-leafref1");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyBinary(new byte[] {77, 97, 110})", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-leafref1");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-leafref1");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyBinary(new byte[] {77, 97, 110})", actual);
}
@Test
- public void testGetTypeDefaultConstructionString() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-string");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionString() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-string");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("\"name\"", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-string");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-string");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
assertEquals("new " + PKG + "MyString(\"name\")", actual);
}
@Test
- public void testGetTypeDefaultConstructionUint8() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-uint8");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionUint8() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-uint8");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
- assertEquals("java.lang.Short.valueOf(\"11\")", actual);
+ assertEquals("org.opendaylight.yangtools.yang.common.Uint8.valueOf(\"11\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-uint8");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-uint8");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
- assertEquals("new " + PKG + "MyUint8(java.lang.Short.valueOf(\"11\"))", actual);
+ assertEquals("new " + PKG + "MyUint8(org.opendaylight.yangtools.yang.common.Uint8.valueOf(\"11\"))", actual);
}
@Test
- public void testGetTypeDefaultConstructionUint16() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-uint16");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionUint16() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-uint16");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
- assertEquals("java.lang.Integer.valueOf(\"111\")", actual);
+ assertEquals("org.opendaylight.yangtools.yang.common.Uint16.valueOf(\"111\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-uint16");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-uint16");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
- assertEquals("new " + PKG + "MyUint16(java.lang.Integer.valueOf(\"111\"))", actual);
+ assertEquals("new " + PKG + "MyUint16(org.opendaylight.yangtools.yang.common.Uint16.valueOf(\"111\"))", actual);
}
@Test
- public void testGetTypeDefaultConstructionUint32() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-uint32");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionUint32() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-uint32");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
- assertEquals("java.lang.Long.valueOf(\"1111\")", actual);
+ assertEquals("org.opendaylight.yangtools.yang.common.Uint32.valueOf(\"1111\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-uint32");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-uint32");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
- assertEquals("new " + PKG + "MyUint32(java.lang.Long.valueOf(\"1111\"))", actual);
+ assertEquals("new " + PKG + "MyUint32(org.opendaylight.yangtools.yang.common.Uint32.valueOf(\"1111\"))",
+ actual);
}
@Test
- public void testGetTypeDefaultConstructionUint64() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-uint64");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionUint64() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-uint64");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
- assertEquals("new java.math.BigInteger(\"11111\")", actual);
+ assertEquals("org.opendaylight.yangtools.yang.common.Uint64.valueOf(\"11111\")", actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-uint64");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-uint64");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
- assertEquals("new " + PKG + "MyUint64(new java.math.BigInteger(\"11111\"))", actual);
+ assertEquals("new " + PKG + "MyUint64(org.opendaylight.yangtools.yang.common.Uint64.valueOf(\"11111\"))",
+ actual);
}
@Test
- public void testGetTypeDefaultConstruction() throws ParseException {
- final QName leafNode = QName.create(m.getQNameModule(), "ip-leaf");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode);
+ public void testGetTypeDefaultConstruction() {
+ final QName leafNode = QName.create(module.getQNameModule(), "ip-leaf");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode).get();
String actual = provider.getTypeDefaultConstruction(leaf);
- String exp = "new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address(\"0.0.0.1\")";
+ String exp = "new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924."
+ + "Ipv4Address(\"0.0.0.1\")";
assertEquals(exp, actual);
}
@Test
- public void testGetTypeDefaultConstructionUnion() throws ParseException {
- final QName leafNode1 = QName.create(m.getQNameModule(), "leaf-union");
- LeafSchemaNode leaf = (LeafSchemaNode) m.getDataChildByName(leafNode1);
+ public void testGetTypeDefaultConstructionUnion() {
+ final QName leafNode1 = QName.create(module.getQNameModule(), "leaf-union");
+ LeafSchemaNode leaf = (LeafSchemaNode) module.findDataChildByName(leafNode1).get();
String actual = provider.getTypeDefaultConstruction(leaf);
String expected = "new " + PKG + "TestData.LeafUnion(\"111\".toCharArray())";
assertEquals(expected, actual);
- final QName leafNode2 = QName.create(m.getQNameModule(), "ext-union");
- leaf = (LeafSchemaNode) m.getDataChildByName(leafNode2);
+ final QName leafNode2 = QName.create(module.getQNameModule(), "ext-union");
+ leaf = (LeafSchemaNode) module.findDataChildByName(leafNode2).get();
actual = provider.getTypeDefaultConstruction(leaf);
expected = "new " + PKG + "MyUnion(\"111\".toCharArray())";
assertEquals(expected, actual);
}
@Test
- public void testGetTypeDefaultConstructionUnionNested() throws ParseException {
- final QName containerNode1 = QName.create(m.getQNameModule(), "c1");
- ContainerSchemaNode c1 = (ContainerSchemaNode) m.getDataChildByName(containerNode1);
- final QName containerNode2 = QName.create(m.getQNameModule(), "c2");
- ContainerSchemaNode c2 = (ContainerSchemaNode) c1.getDataChildByName(containerNode2);
- final QName containerNode3 = QName.create(m.getQNameModule(), "c3");
- ContainerSchemaNode c3 = (ContainerSchemaNode) c2.getDataChildByName(containerNode3);
- final QName leafNode = QName.create(m.getQNameModule(), "id");
- LeafSchemaNode leaf = (LeafSchemaNode) c3.getDataChildByName(leafNode);
+ public void testGetTypeDefaultConstructionUnionNested() {
+ final QName containerNode1 = QName.create(module.getQNameModule(), "c1");
+ ContainerSchemaNode c1 = (ContainerSchemaNode) module.findDataChildByName(containerNode1).get();
+ final QName containerNode2 = QName.create(module.getQNameModule(), "c2");
+ ContainerSchemaNode c2 = (ContainerSchemaNode) c1.findDataChildByName(containerNode2).get();
+ final QName containerNode3 = QName.create(module.getQNameModule(), "c3");
+ ContainerSchemaNode c3 = (ContainerSchemaNode) c2.findDataChildByName(containerNode3).get();
+ final QName leafNode = QName.create(module.getQNameModule(), "id");
+ LeafSchemaNode leaf = (LeafSchemaNode) c3.findDataChildByName(leafNode).get();
String actual = provider.getTypeDefaultConstruction(leaf);
String expected = "new " + PKG + "NestedUnion(\"111\".toCharArray())";
}
@Test
- public void testGetParamNameFromType() throws ParseException {
- m = context.findModuleByName("ietf-inet-types", new SimpleDateFormat("yyyy-MM-dd").parse("2010-09-24"));
- Set<TypeDefinition<?>> types = m.getTypeDefinitions();
+ public void testGetParamNameFromType() {
+ module = CONTEXT.findModule("ietf-inet-types", Revision.of("2010-09-24")).get();
+ Set<TypeDefinition<?>> types = module.getTypeDefinitions();
TypeDefinition<?> ipv4 = null;
TypeDefinition<?> ipv6 = null;
TypeDefinition<?> ipv4Pref = null;
assertEquals("ipv4Prefix", provider.getParamNameFromType(ipv4Pref));
assertEquals("ipv6Prefix", provider.getParamNameFromType(ipv6Pref));
}
-}
\ No newline at end of file
+}