+
+ //check abort after tx creation
+ edit("netconfMessages/editConfig.xml");
+ assertContainsElement(discard(), readXmlToElement("<ok xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>"));
+ }
+
+ @Test
+ public void testFailedDiscardChangesAbort() throws Exception {
+
+ TransactionProvider mockedTxProvider = mock(TransactionProvider.class);
+ doThrow(new RuntimeException("Mocked runtime exception, Abort has to fail")).when(mockedTxProvider).abortTransaction();
+ doReturn(Optional.of(ObjectName.getInstance("dummyDomain", "DummyKey", "DummyValue"))).when(mockedTxProvider).getTransaction();
+
+ DiscardChanges discardOp = new DiscardChanges(mockedTxProvider, configRegistryClient, NETCONF_SESSION_ID);
+
+ try {
+ executeOp(discardOp, "netconfMessages/discardChanges.xml");
+ fail("Should've failed, abort on mocked is supposed to throw RuntimeException");
+ } catch (NetconfDocumentedException e) {
+ assertTrue(e.getErrorTag() == ErrorTag.operation_failed);
+ assertTrue(e.getErrorSeverity() == ErrorSeverity.error);
+ assertTrue(e.getErrorType() == ErrorType.application);
+ }
+