import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot;
import org.opendaylight.controller.config.yang.store.impl.MbeParser;
-import org.opendaylight.controller.config.yang.test.impl.*;
+import org.opendaylight.controller.config.yang.test.impl.Asdf;
+import org.opendaylight.controller.config.yang.test.impl.ComplexDtoBInner;
+import org.opendaylight.controller.config.yang.test.impl.ComplexList;
+import org.opendaylight.controller.config.yang.test.impl.Deep;
+import org.opendaylight.controller.config.yang.test.impl.Deep2;
+import org.opendaylight.controller.config.yang.test.impl.Deep3;
+import org.opendaylight.controller.config.yang.test.impl.Deep4;
+import org.opendaylight.controller.config.yang.test.impl.DepTestImplModuleFactory;
+import org.opendaylight.controller.config.yang.test.impl.DtoAInner;
+import org.opendaylight.controller.config.yang.test.impl.DtoAInnerInner;
+import org.opendaylight.controller.config.yang.test.impl.DtoC;
+import org.opendaylight.controller.config.yang.test.impl.DtoD;
+import org.opendaylight.controller.config.yang.test.impl.InnerInnerRunningDataRuntimeMXBean;
+import org.opendaylight.controller.config.yang.test.impl.InnerRunningDataAdditionalRuntimeMXBean;
+import org.opendaylight.controller.config.yang.test.impl.InnerRunningDataRuntimeMXBean;
+import org.opendaylight.controller.config.yang.test.impl.InnerRunningDataRuntimeRegistration;
+import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleFactory;
+import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleMXBean;
+import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplRuntimeMXBean;
+import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplRuntimeRegistration;
+import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplRuntimeRegistrator;
+import org.opendaylight.controller.config.yang.test.impl.NotStateBean;
+import org.opendaylight.controller.config.yang.test.impl.NotStateBeanInternal;
+import org.opendaylight.controller.config.yang.test.impl.Peers;
+import org.opendaylight.controller.config.yang.test.impl.RetValContainer;
+import org.opendaylight.controller.config.yang.test.impl.RetValList;
import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfOperationRouter;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigInteger;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
public class NetconfMappingTest extends AbstractConfigTest {
private static final Logger logger = LoggerFactory.getLogger(NetconfMappingTest.class);
// check after edit
commit();
Element response = getConfigRunning();
- // System.out.println(Xml.toString(response));
checkBinaryLeafEdited(response);
checkTypeConfigAttribute(response);
+ checkTypedefs(response);
+ checkEnum(response);
edit("netconfMessages/editConfig_remove.xml");
try {
edit(file);
} catch (NetconfDocumentedException e) {
- Assert.assertThat(e.getMessage(), JUnitMatchers.containsString("Unrecognised elements"));
- Assert.assertThat(e.getMessage(), JUnitMatchers.containsString("unknownAttribute"));
+ assertThat(e.getMessage(), JUnitMatchers.containsString("Unrecognised elements"));
+ assertThat(e.getMessage(), JUnitMatchers.containsString("unknownAttribute"));
continue;
}
fail("Unrecognised test should throw exception " + file);
response = getConfigRunning();
final int afterReplace = response.getElementsByTagName("instance").getLength();
- Assert.assertEquals(4 + 4 /* Instances from services */, allInstances);
- Assert.assertEquals(3 + 3, afterReplace);
+ assertEquals(4 + 4 /* Instances from services */, allInstances);
+ assertEquals(3 + 3, afterReplace);
}
@Test(expected = NetconfDocumentedException.class)
buf.append(XmlElement.fromDomElement(e).getTextContent());
}
assertEquals("810", buf.toString());
+ }
+
+ private void checkTypedefs(final Element response) {
+ NodeList children = response.getElementsByTagName("extended");
+ assertEquals(1, children.getLength());
+
+ children = response.getElementsByTagName("extended-twice");
+ 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) {
System.err.println(XmlUtil.toString(response));
- assertEquals(2, getElementsSize(response, "instance"));
+ assertEquals(2, getElementsSize(response, "module"));
assertEquals(2, getElementsSize(response, "asdf"));
assertEquals(5, getElementsSize(response, "inner-running-data"));
assertEquals(5, getElementsSize(response, "deep2"));
private List<InputStream> getYangs() throws FileNotFoundException {
List<String> paths = Arrays.asList("/META-INF/yang/config.yang", "/META-INF/yang/rpc-context.yang",
- "/META-INF/yang/config-test.yang", "/META-INF/yang/config-test-impl.yang",
+ "/META-INF/yang/config-test.yang", "/META-INF/yang/config-test-impl.yang", "/META-INF/yang/test-types.yang",
"/META-INF/yang/ietf-inet-types.yang");
final Collection<InputStream> yangDependencies = new ArrayList<>();
for (String path : paths) {