import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import java.io.File;
import java.util.List;
import org.junit.Test;
import org.opendaylight.mdsal.binding.generator.api.BindingGenerator;
-import org.opendaylight.mdsal.binding.generator.impl.BindingGeneratorImpl;
import org.opendaylight.mdsal.binding.model.api.GeneratedProperty;
import org.opendaylight.mdsal.binding.model.api.GeneratedTransferObject;
import org.opendaylight.mdsal.binding.model.api.GeneratedType;
import org.opendaylight.mdsal.binding.model.api.MethodSignature;
import org.opendaylight.mdsal.binding.model.api.Type;
+import org.opendaylight.mdsal.binding.spec.naming.BindingMapping;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
public class AugmentedTypeTest {
@Test
- public void augmentedAbstractTopologyTest() throws Exception {
- File abstractTopology = new File(getClass().getResource(
- "/augment-test-models/abstract-topology@2013-02-08.yang").toURI());
- File augmentTopology = new File(getClass().getResource(
- "/augment-test-models/augment-abstract-topology@2013-05-03.yang").toURI());
- File augmentNetworkLink = new File(getClass().getResource(
- "/augment-test-models/augment-network-link-attributes@2013-05-03.yang").toURI());
- File augmentTopologyTunnels = new File(getClass().getResource(
- "/augment-test-models/augment-topology-tunnels@2013-05-03.yang").toURI());
- File ietfInterfaces = new File(getClass().getResource("/augment-test-models/ietf-interfaces@2012-11-15.yang")
- .toURI());
-
- final SchemaContext context = YangParserTestUtils.parseYangSources(abstractTopology, augmentTopology,
- augmentNetworkLink, augmentTopologyTunnels, ietfInterfaces);
+ public void augmentedAbstractTopologyTest() {
+ final SchemaContext context = YangParserTestUtils.parseYangResources(AugmentedTypeTest.class,
+ "/augment-test-models/abstract-topology@2013-02-08.yang",
+ "/augment-test-models/augment-abstract-topology@2013-05-03.yang",
+ "/augment-test-models/augment-network-link-attributes@2013-05-03.yang",
+ "/augment-test-models/augment-topology-tunnels@2013-05-03.yang",
+ "/augment-test-models/ietf-interfaces@2012-11-15.yang");
assertNotNull("Schema Context is null", context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl(true);
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();
final List<Type> genTypes = bindingGen.generateTypes(context);
assertNotNull("genTypes is null", genTypes);
GeneratedType gtNetworkLink2 = null;
for (final Type type : genTypes) {
- if (type.getName().equals("InterfaceKey") && type.getPackageName().contains("augment._abstract.topology")) {
+ if (!type.getPackageName().contains("augment._abstract.topology")) {
+ continue;
+ }
+
+ if (type.getName().equals("InterfaceKey")) {
gtInterfaceKey = (GeneratedTransferObject) type;
- } else if (type.getName().equals("Interface")
- && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("Interface")) {
gtInterface = (GeneratedType) type;
- } else if (type.getName().equals("Tunnel") && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("Tunnel")) {
gtTunnel = (GeneratedType) type;
- } else if (type.getName().equals("TunnelKey")
- && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("TunnelKey")) {
gtTunnelKey = (GeneratedTransferObject) type;
- } else if (type.getName().equals("NetworkLink2")
- && type.getPackageName().contains("augment._abstract.topology")) {
+ } else if (type.getName().equals("NetworkLink2")) {
gtNetworkLink2 = (GeneratedType) type;
}
}
assertNotNull("gtInterfaceMethods is null", gtInterfaceMethods);
MethodSignature getIfcKeyMethod = null;
for (final MethodSignature method : gtInterfaceMethods) {
- if (method.getName().equals("getKey")) {
+ if (BindingMapping.IDENTIFIABLE_KEY_NAME.equals(method.getName())) {
getIfcKeyMethod = method;
break;
}
assertNotNull("Tunnel methods are null", tunnelMethods);
MethodSignature getTunnelKeyMethod = null;
for (MethodSignature method : tunnelMethods) {
- if (method.getName().equals("getKey")) {
+ if (BindingMapping.IDENTIFIABLE_KEY_NAME.equals(method.getName())) {
getTunnelKeyMethod = method;
break;
}