if (isArray()) {
return getArrayType();
+ } else if (isEnum(baseType)) {
+ return getSimpleType(baseType);
} else if (isDerivedType(baseType)) {
return getCompositeType(baseType, baseTypeDefinition);
}
- return getSimpleType();
+ return getSimpleType(getType());
}
- private OpenType<?> getSimpleType() {
- SimpleType<?> simpleType = SimpleTypeResolver.getSimpleType(getType());
+ private boolean isEnum(Type baseType) {
+ return baseType.getFullyQualifiedName().equals(Enum.class.getName());
+ }
+
+ private OpenType<?> getSimpleType(Type type) {
+ SimpleType<?> simpleType = SimpleTypeResolver.getSimpleType(type);
return simpleType;
}
return expectedSimpleType;
}
- private static final Map<String, SimpleType<?>> JAVA_TYPE_TO_SIMPLE_TYPE = Maps
- .newHashMap();
+ private static final Map<String, SimpleType<?>> JAVA_TYPE_TO_SIMPLE_TYPE = Maps.newHashMap();
static {
// TODO add all
- JAVA_TYPE_TO_SIMPLE_TYPE.put(Integer.class.getName(),
- SimpleType.INTEGER);
+ JAVA_TYPE_TO_SIMPLE_TYPE.put(Integer.class.getName(), SimpleType.INTEGER);
JAVA_TYPE_TO_SIMPLE_TYPE.put(int.class.getName(), SimpleType.INTEGER);
JAVA_TYPE_TO_SIMPLE_TYPE.put(Short.class.getName(), SimpleType.SHORT);
JAVA_TYPE_TO_SIMPLE_TYPE.put(short.class.getName(), SimpleType.SHORT);
JAVA_TYPE_TO_SIMPLE_TYPE.put(Long.class.getName(), SimpleType.LONG);
JAVA_TYPE_TO_SIMPLE_TYPE.put(long.class.getName(), SimpleType.LONG);
JAVA_TYPE_TO_SIMPLE_TYPE.put(String.class.getName(), SimpleType.STRING);
- JAVA_TYPE_TO_SIMPLE_TYPE.put(Boolean.class.getName(),
- SimpleType.BOOLEAN);
- JAVA_TYPE_TO_SIMPLE_TYPE.put(boolean.class.getName(),
- SimpleType.BOOLEAN);
- JAVA_TYPE_TO_SIMPLE_TYPE.put(BigInteger.class.getName(),
- SimpleType.BIGINTEGER);
- JAVA_TYPE_TO_SIMPLE_TYPE.put(BigDecimal.class.getName(),
- SimpleType.BIGDECIMAL);
+ JAVA_TYPE_TO_SIMPLE_TYPE.put(Enum.class.getName(), SimpleType.STRING);
+ JAVA_TYPE_TO_SIMPLE_TYPE.put(Boolean.class.getName(), SimpleType.BOOLEAN);
+ JAVA_TYPE_TO_SIMPLE_TYPE.put(boolean.class.getName(), SimpleType.BOOLEAN);
+ JAVA_TYPE_TO_SIMPLE_TYPE.put(BigInteger.class.getName(), SimpleType.BIGINTEGER);
+ JAVA_TYPE_TO_SIMPLE_TYPE.put(BigDecimal.class.getName(), SimpleType.BIGDECIMAL);
JAVA_TYPE_TO_SIMPLE_TYPE.put(Byte.class.getName(), SimpleType.BYTE);
JAVA_TYPE_TO_SIMPLE_TYPE.put(byte.class.getName(), SimpleType.BYTE);
JAVA_TYPE_TO_SIMPLE_TYPE.put(Date.class.getName(), SimpleType.DATE);
// check after edit
commit();
Element response = getConfigRunning();
- System.err.println(XmlUtil.toString(response));
+
checkBinaryLeafEdited(response);
checkTypeConfigAttribute(response);
checkTypedefs(response);
+ checkEnum(response);
edit("netconfMessages/editConfig_remove.xml");
assertEquals(1, children.getLength());
}
+ private void checkEnum(final Element response) {
+ XmlElement modulesElement = XmlElement.fromDomElement(response).getOnlyChildElement("data")
+ .getOnlyChildElement("modules");
+
+ String enumName = "extended-enum";
+ String enumContent = "TWO";
+
+ for (XmlElement moduleElement : modulesElement.getChildElements("module")) {
+ String name = moduleElement.getOnlyChildElement("name").getTextContent();
+ if(name.equals("test1")) {
+ XmlElement enumAttr = moduleElement.getOnlyChildElement(enumName);
+ assertEquals(enumContent, enumAttr.getTextContent());
+
+ return;
+ }
+ }
+
+ fail("Enum attribute " + enumName + ":" + enumContent + " not present in " + XmlUtil.toString(response));
+ }
+
private void checkTypeConfigAttribute(Element response) {
XmlElement modulesElement = XmlElement.fromDomElement(response).getOnlyChildElement("data")