package org.opendaylight.controller.sal.binding.generator.impl;
import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
+import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
assertNotNull(inetTypesPath);
assertNotNull(yangTypesPath);
- // final SchemaContext context = resolveSchemaContextFromFiles(
- // topologyPath, interfacesPath, ifTypePath, inetTypesPath,
- // yangTypesPath);
+ // final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, interfacesPath, ifTypePath,
+ // inetTypesPath, yangTypesPath);
final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, interfacesPath, inetTypesPath,
yangTypesPath);
assertNotNull(context);
GeneratedType gtDest = null;
GeneratedType gtTunnel = null;
GeneratedTransferObject gtTunnelKey = null;
+ GeneratedType gtTopology = null;
for (final Type type : genTypes) {
String name = type.getName();
if ("InterfaceKey".equals(name)) {
gtTunnel = (GeneratedType) type;
} else if ("TunnelKey".equals(name)) {
gtTunnelKey = (GeneratedTransferObject) type;
+ } else if ("Topology".equals(name)) {
+ gtTopology = (GeneratedType) type;
}
}
assertNotNull(gtDest);
assertNotNull(gtTunnel);
assertNotNull(gtTunnelKey);
+ assertNotNull(gtTopology);
+
+ // Topology
+ final List<MethodSignature> gtTopoMethods = gtTopology.getMethodDefinitions();
+ assertNotNull(gtTopoMethods);
+ MethodSignature condLeafref = null;
+ for (final MethodSignature method : gtTopoMethods) {
+ if (method.getName().equals("getCondLeafref")) {
+ condLeafref = method;
+ }
+ }
+ assertNotNull(condLeafref);
+ Type condLeafRT = condLeafref.getReturnType();
+ assertNotNull(condLeafRT);
+ assertEquals("java.lang.Object", condLeafRT.getFullyQualifiedName());
// InterfaceId
final List<GeneratedProperty> gtIfcKeyProps = gtIfcKey.getProperties();
assertNotNull(ifcIdProp);
Type ifcIdPropType = ifcIdProp.getReturnType();
assertNotNull(ifcIdPropType);
- assertFalse(ifcIdPropType.equals("java.lang.Void"));
- assertEquals(ifcIdPropType.getName(), "String");
+ assertEquals("java.lang.String", ifcIdPropType.getFullyQualifiedName());
// Interface
final List<MethodSignature> gtIfcMethods = gtIfc.getMethodDefinitions();
assertNotNull(getIfcKey);
Type getIfcKeyType = getIfcKey.getReturnType();
assertNotNull(getIfcKeyType);
- assertFalse(getIfcKeyType.equals("java.lang.Void"));
- assertEquals(getIfcKeyType.getName(), "InterfaceKey");
+ assertNotSame("java.lang.Void", getIfcKeyType);
+ assertEquals("InterfaceKey", getIfcKeyType.getName());
assertNotNull(getHigherLayerIf);
Type getHigherLayerIfType = getHigherLayerIf.getReturnType();
assertNotNull(getHigherLayerIfType);
- assertFalse(getHigherLayerIfType.equals("java.lang.Void"));
- assertEquals(getHigherLayerIfType.getName(), "List");
+ assertNotSame("java.lang.Void", getHigherLayerIfType);
+ assertEquals("List", getHigherLayerIfType.getName());
// NetworkLink
final List<MethodSignature> gtNetworkLinkMethods = gtNetworkLink.getMethodDefinitions();
assertNotNull(getIfc);
Type getIfcType = getIfc.getReturnType();
assertNotNull(getIfcType);
- assertFalse(getIfcType.equals("java.lang.Void"));
- assertEquals(getIfcType.getName(), "String");
+ assertNotSame("java.lang.Void", getIfcType);
+ assertEquals("String", getIfcType.getName());
// SourceNode
final List<MethodSignature> gtSourceMethods = gtSource.getMethodDefinitions();
assertNotNull(getIdSource);
Type getIdType = getIdSource.getReturnType();
assertNotNull(getIdType);
- assertFalse(getIdType.equals("java.lang.Void"));
- assertEquals(getIdType.getName(), "Uri");
+ assertNotSame("java.lang.Void", getIdType);
+ assertEquals("Uri", getIdType.getName());
// DestinationNode
final List<MethodSignature> gtDestMethods = gtDest.getMethodDefinitions();
assertNotNull(getIdDest);
Type getIdDestType = getIdDest.getReturnType();
assertNotNull(getIdDestType);
- assertFalse(getIdDestType.equals("java.lang.Void"));
- assertEquals(getIdDestType.getName(), "Uri");
+ assertNotSame("java.lang.Void", getIdDestType);
+ assertEquals("Uri", getIdDestType.getName());
// Tunnel
final List<MethodSignature> gtTunnelMethods = gtTunnel.getMethodDefinitions();
assertNotNull(getTunnelKey);
Type getTunnelKeyType = getTunnelKey.getReturnType();
assertNotNull(getTunnelKeyType);
- assertFalse(getTunnelKeyType.equals("java.lang.Void"));
- assertEquals(getTunnelKeyType.getName(), "TunnelKey");
+ assertNotSame("java.lang.Void", getTunnelKeyType);
+ assertEquals("TunnelKey", getTunnelKeyType.getName());
// TunnelKey
final List<GeneratedProperty> gtTunnelKeyProps = gtTunnelKey.getProperties();
assertNotNull(tunnelId);
Type tunnelIdType = tunnelId.getReturnType();
assertNotNull(tunnelIdType);
- assertFalse(tunnelIdType.equals("java.lang.Void"));
- assertEquals(tunnelIdType.getName(), "Uri");
+ assertNotSame("java.lang.Void", tunnelIdType);
+ assertEquals("Uri", tunnelIdType.getName());
}
@Test
assertEquals(3, simpleContainer.getMethodDefinitions().size());
assertEquals(2, nestedContainer.getMethodDefinitions().size());
- int setFooMethodCounter = 0;
int getFooMethodCounter = 0;
int getBarMethodCounter = 0;
int getNestedContainerCounter = 0;
String getFooMethodReturnTypeName = "";
- String setFooMethodInputParamName = "";
- String setFooMethodInputParamTypeName = "";
String getBarMethodReturnTypeName = "";
String getNestedContainerReturnTypeName = "";
for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {
getFooMethodReturnTypeName = method.getReturnType().getName();
}
- if (method.getName().equals("setFoo")) {
- setFooMethodCounter++;
- final MethodSignature.Parameter param = method.getParameters().get(0);
- setFooMethodInputParamName = param.getName();
- setFooMethodInputParamTypeName = param.getType().getName();
- }
-
if (method.getName().equals("getBar")) {
getBarMethodCounter++;
getBarMethodReturnTypeName = method.getReturnType().getName();
}
}
- assertEquals(getFooMethodCounter, 1);
- assertEquals(getFooMethodReturnTypeName, "Integer");
-
- // TODO no setter methods, because 'config' is default true
- // assertEquals(setFooMethodCounter, 1);
- // assertEquals(setFooMethodInputParamName, "foo");
- // assertEquals(setFooMethodInputParamTypeName, "Integer");
+ assertEquals(1, getFooMethodCounter);
+ assertEquals("Integer", getFooMethodReturnTypeName);
- assertEquals(getBarMethodCounter, 1);
- assertEquals(getBarMethodReturnTypeName, "String");
+ assertEquals(1, getBarMethodCounter);
+ assertEquals("String", getBarMethodReturnTypeName);
- assertEquals(getNestedContainerCounter, 1);
- assertEquals(getNestedContainerReturnTypeName, "NestedContainer");
+ assertEquals(1, getNestedContainerCounter);
+ assertEquals("NestedContainer", getNestedContainerReturnTypeName);
- setFooMethodCounter = 0;
getFooMethodCounter = 0;
getBarMethodCounter = 0;
- int setBarMethodCounter = 0;
getFooMethodReturnTypeName = "";
- setFooMethodInputParamName = "";
- setFooMethodInputParamTypeName = "";
getBarMethodReturnTypeName = "";
- String setBarMethodInputParamName = "";
- String setBarMethodInputParamTypeName = "";
for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {
getFooMethodReturnTypeName = method.getReturnType().getName();
}
- if (method.getName().equals("setFoo")) {
- setFooMethodCounter++;
- final MethodSignature.Parameter param = method.getParameters().get(0);
- setFooMethodInputParamName = param.getName();
- setFooMethodInputParamTypeName = param.getType().getName();
- }
-
if (method.getName().equals("getBar")) {
getBarMethodCounter++;
getBarMethodReturnTypeName = method.getReturnType().getName();
}
-
- if (method.getName().equals("setBar")) {
- setBarMethodCounter++;
- final MethodSignature.Parameter param = method.getParameters().get(0);
- setBarMethodInputParamName = param.getName();
- setBarMethodInputParamTypeName = param.getType().getName();
- }
}
assertEquals(1, getFooMethodCounter);
- assertEquals(getFooMethodReturnTypeName, "Short");
-
- // TODO no setter methods, because 'config' is default true
- // assertEquals(1, setFooMethodCounter);
- // assertEquals(setFooMethodInputParamName, "foo");
- // assertEquals(setFooMethodInputParamTypeName, "Short");
+ assertEquals("Short", getFooMethodReturnTypeName);
assertEquals(1, getBarMethodCounter);
- assertEquals(getBarMethodReturnTypeName, "String");
-
- // TODO no setter methods, because 'config' is default true
- // assertEquals(1, setBarMethodCounter);
- // assertEquals(setBarMethodInputParamName, "bar");
- // assertEquals(setBarMethodInputParamTypeName, "String");
+ assertEquals("String", getBarMethodReturnTypeName);
}
@Test
assertEquals(3, simpleContainer.getMethodDefinitions().size());
assertEquals(2, nestedContainer.getMethodDefinitions().size());
- int setFooMethodCounter = 0;
int getFooMethodCounter = 0;
int getBarMethodCounter = 0;
int getNestedContainerCounter = 0;
String getFooMethodReturnTypeName = "";
- String setFooMethodInputParamName = "";
- String setFooMethodInputParamTypeName = "";
String getBarMethodReturnTypeName = "";
String getNestedContainerReturnTypeName = "";
for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {
getFooMethodReturnTypeName = method.getReturnType().getName();
}
- if (method.getName().equals("setFoo")) {
- setFooMethodCounter++;
- final MethodSignature.Parameter param = method.getParameters().get(0);
- setFooMethodInputParamName = param.getName();
- setFooMethodInputParamTypeName = param.getType().getName();
- }
-
if (method.getName().equals("getBar")) {
getBarMethodCounter++;
getBarMethodReturnTypeName = method.getReturnType().getName();
}
assertEquals(1, getFooMethodCounter);
- assertEquals(getFooMethodReturnTypeName, "List");
-
- // TODO no setter methods, because 'config' is default true
- // assertEquals(1, setFooMethodCounter);
- // assertEquals(setFooMethodInputParamName, "foo");
- // assertEquals(setFooMethodInputParamTypeName, "List");
+ assertEquals("List", getFooMethodReturnTypeName);
assertEquals(1, getBarMethodCounter);
- assertEquals(getBarMethodReturnTypeName, "String");
+ assertEquals("String", getBarMethodReturnTypeName);
assertEquals(1, getNestedContainerCounter);
- assertEquals(getNestedContainerReturnTypeName, "NestedContainer");
+ assertEquals("NestedContainer", getNestedContainerReturnTypeName);
- setFooMethodCounter = 0;
getFooMethodCounter = 0;
getBarMethodCounter = 0;
getFooMethodReturnTypeName = "";
- setFooMethodInputParamName = "";
- setFooMethodInputParamTypeName = "";
getBarMethodReturnTypeName = "";
for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {
getFooMethodReturnTypeName = method.getReturnType().getName();
}
- if (method.getName().equals("setFoo")) {
- setFooMethodCounter++;
- final MethodSignature.Parameter param = method.getParameters().get(0);
- setFooMethodInputParamName = param.getName();
- setFooMethodInputParamTypeName = param.getType().getName();
- }
-
if (method.getName().equals("getBar")) {
getBarMethodCounter++;
getBarMethodReturnTypeName = method.getReturnType().getName();
}
assertEquals(1, getFooMethodCounter);
- assertEquals(getFooMethodReturnTypeName, "Short");
-
- // TODO no setter methods, because 'config' is default true
- // assertEquals(1, setFooMethodCounter);
- // assertEquals(setFooMethodInputParamName, "foo");
- // assertEquals(setFooMethodInputParamTypeName, "Short");
+ assertEquals("Short", getFooMethodReturnTypeName);
assertEquals(1, getBarMethodCounter);
- assertEquals(getBarMethodReturnTypeName, "List");
+ assertEquals("List", getBarMethodReturnTypeName);
}
@Test
assertNotNull(genTypes);
assertEquals(6, genTypes.size());
- int genTypesCount = 0;
- int genTOsCount = 0;
-
int listParentContainerMethodsCount = 0;
int simpleListMethodsCount = 0;
int listChildContainerMethodsCount = 0;
final GeneratedType genType = (GeneratedType) type;
if (genType.getName().equals("ListParentContainer")) {
listParentContainerMethodsCount = genType.getMethodDefinitions().size();
- genTypesCount++;
} else if (genType.getName().equals("SimpleList")) {
simpleListMethodsCount = genType.getMethodDefinitions().size();
final List<MethodSignature> methods = genType.getMethodDefinitions();
getBarMethodCount++;
}
}
- genTypesCount++;
} else if (genType.getName().equals("ListChildContainer")) {
listChildContainerMethodsCount = genType.getMethodDefinitions().size();
- genTypesCount++;
}
} else if (type instanceof GeneratedTransferObject) {
- genTOsCount++;
final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
final List<GeneratedProperty> properties = genTO.getProperties();
final List<GeneratedProperty> hashProps = genTO.getHashCodeIdentifiers();