X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Foperations%2FValidateTest.java;h=f840fe36694b39be87f8f01c75683a69e2baa66b;hb=b2e81149739c87f0ecc2ce7f06448d7a5d3162b8;hp=8d14e9680c3b7e121d73a90b1a93525b4f431706;hpb=a92d9d6a21a0f6ca8d2153795721f500eaf29ee9;p=controller.git
diff --git a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/ValidateTest.java b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/ValidateTest.java
index 8d14e9680c..f840fe3669 100644
--- a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/ValidateTest.java
+++ b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/ValidateTest.java
@@ -8,74 +8,76 @@
package org.opendaylight.controller.netconf.confignetconfconnector.operations;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+
import org.junit.Test;
import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
-import org.opendaylight.controller.netconf.confignetconfconnector.transactions.TransactionProvider;
-import org.opendaylight.controller.netconf.util.xml.XmlElement;
-import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
-import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
import org.w3c.dom.Element;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.*;
-
public class ValidateTest {
public static final String NETCONF_SESSION_ID_FOR_REPORTING = "foo";
- @Test(expected = NetconfDocumentedException.class)
+ @Test(expected = DocumentedException.class)
public void test() throws Exception {
final XmlElement xml = XmlElement.fromString("");
- final Validate validate = new Validate(null, null, NETCONF_SESSION_ID_FOR_REPORTING);
- validate.handle(null, xml);
+ final Validate validate = new Validate(null, NETCONF_SESSION_ID_FOR_REPORTING);
+ validate.handleWithNoSubsequentOperations(null, xml);
}
- @Test(expected = NetconfDocumentedException.class)
+ @Test(expected = DocumentedException.class)
public void testNoSource() throws Exception {
final XmlElement xml = XmlElement.fromString("");
- final Validate validate = new Validate(null, null, NETCONF_SESSION_ID_FOR_REPORTING);
- validate.handle(null, xml);
+ final Validate validate = new Validate(null, NETCONF_SESSION_ID_FOR_REPORTING);
+ validate.handleWithNoSubsequentOperations(null, xml);
}
- @Test(expected = NetconfDocumentedException.class)
+ @Test(expected = DocumentedException.class)
public void testNoNamespace() throws Exception {
final XmlElement xml = XmlElement.fromString("");
- final Validate validate = new Validate(null, null, NETCONF_SESSION_ID_FOR_REPORTING);
- validate.handle(null, xml);
+ final Validate validate = new Validate(null, NETCONF_SESSION_ID_FOR_REPORTING);
+ validate.handleWithNoSubsequentOperations(null, xml);
}
- @Test(expected = NetconfDocumentedException.class)
+ @Test(expected = DocumentedException.class)
public void testRunningSource() throws Exception {
final XmlElement xml = XmlElement.fromString("");
- final Validate validate = new Validate(null, null, NETCONF_SESSION_ID_FOR_REPORTING);
- validate.handle(null, xml);
+ final Validate validate = new Validate(null, NETCONF_SESSION_ID_FOR_REPORTING);
+ validate.handleWithNoSubsequentOperations(null, xml);
}
- @Test(expected = NetconfDocumentedException.class)
+ @Test(expected = DocumentedException.class)
public void testNoTransaction() throws Exception {
final XmlElement xml = XmlElement.fromString("");
- final TransactionProvider transactionProvider = mock(TransactionProvider.class);
- doThrow(IllegalStateException.class).when(transactionProvider).validateTransaction();
- final Validate validate = new Validate(transactionProvider, null, NETCONF_SESSION_ID_FOR_REPORTING);
- validate.handle(null, xml);
+ final ConfigSubsystemFacade facade = mock(ConfigSubsystemFacade.class);
+ doThrow(IllegalStateException.class).when(facade).validateConfiguration();
+ final Validate validate = new Validate(facade, NETCONF_SESSION_ID_FOR_REPORTING);
+ validate.handleWithNoSubsequentOperations(null, xml);
}
- @Test(expected = NetconfDocumentedException.class)
+ @Test(expected = DocumentedException.class)
public void testValidationException() throws Exception {
final XmlElement xml = XmlElement.fromString(">");
- final TransactionProvider transactionProvider = mock(TransactionProvider.class);
- doThrow(ValidationException.class).when(transactionProvider).validateTransaction();
- final Validate validate = new Validate(transactionProvider, null, NETCONF_SESSION_ID_FOR_REPORTING);
- validate.handle(null, xml);
+ final ConfigSubsystemFacade facade = mock(ConfigSubsystemFacade.class);
+ doThrow(ValidationException.class).when(facade).validateConfiguration();
+ final Validate validate = new Validate(facade, NETCONF_SESSION_ID_FOR_REPORTING);
+ validate.handleWithNoSubsequentOperations(null, xml);
}
@Test
@@ -83,11 +85,11 @@ public class ValidateTest {
final XmlElement xml = XmlElement.fromString("");
- final TransactionProvider transactionProvider = mock(TransactionProvider.class);
final Element okElement = XmlUtil.readXmlToElement("");
- doNothing().when(transactionProvider).validateTransaction();
- final Validate validate = new Validate(transactionProvider, null, NETCONF_SESSION_ID_FOR_REPORTING);
- Element ok = validate.handle(XmlUtil.newDocument(), xml);
+ final ConfigSubsystemFacade facade = mock(ConfigSubsystemFacade.class);
+ doNothing().when(facade).validateConfiguration();
+ final Validate validate = new Validate(facade, NETCONF_SESSION_ID_FOR_REPORTING);
+ Element ok = validate.handleWithNoSubsequentOperations(XmlUtil.newDocument(), xml);
assertEquals(XmlUtil.toString(okElement), XmlUtil.toString(ok));
}