import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
import org.opendaylight.netconf.sal.restconf.impl.InstanceIdentifierContext;
-import org.opendaylight.netconf.sal.restconf.impl.PATCHContext;
-import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusContext;
+import org.opendaylight.netconf.sal.restconf.impl.PatchContext;
+import org.opendaylight.netconf.sal.restconf.impl.PatchStatusContext;
import org.opendaylight.netconf.sal.restconf.impl.PutResult;
import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
import org.opendaylight.netconf.sal.restconf.impl.RestconfError;
@Mock
private DOMMountPoint mockMountInstance;
@Mock
- private DOMDataReadOnlyTransaction rTransaction;
+ private DOMDataReadOnlyTransaction readTransaction;
@Mock
- private DOMDataWriteTransaction wTransaction;
+ private DOMDataWriteTransaction writeTransaction;
@Mock
private DOMDataReadWriteTransaction rwTransaction;
this.brokerFacade.setDomNotificationService(this.domNotification);
this.brokerFacade.setRpcService(this.mockRpcService);
this.brokerFacade.setContext(this.context);
- when(this.domDataBroker.newReadOnlyTransaction()).thenReturn(this.rTransaction);
- when(this.domDataBroker.newWriteOnlyTransaction()).thenReturn(this.wTransaction);
+ when(this.domDataBroker.newReadOnlyTransaction()).thenReturn(this.readTransaction);
+ when(this.domDataBroker.newWriteOnlyTransaction()).thenReturn(this.writeTransaction);
when(this.domDataBroker.newReadWriteTransaction()).thenReturn(this.rwTransaction);
ControllerContext.getInstance().setSchemas(TestUtils.loadSchemaContext("/full-versions/test-module"));
private static CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> wrapDummyNode(
final NormalizedNode<?, ?> dummyNode) {
- return Futures.immediateCheckedFuture(Optional.<NormalizedNode<?, ?>> of(dummyNode));
+ return Futures.immediateCheckedFuture(Optional.<NormalizedNode<?, ?>>of(dummyNode));
}
private static CheckedFuture<Boolean, ReadFailedException> wrapExistence(final Boolean exists) {
}
/**
- * Value of this node shouldn't be important for testing purposes
+ * Value of this node shouldn't be important for testing purposes.
*/
private static NormalizedNode<?, ?> createDummyNode(final String namespace, final String date,
final String localName) {
@Test
public void testReadConfigurationData() {
- when(this.rTransaction.read(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class))).thenReturn(
+ when(this.readTransaction.read(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class))).thenReturn(
this.dummyNodeInFuture);
final NormalizedNode<?, ?> actualNode = this.brokerFacade.readConfigurationData(this.instanceID);
@Test
public void testReadOperationalData() {
- when(this.rTransaction.read(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class))).thenReturn(
+ when(this.readTransaction.read(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class))).thenReturn(
this.dummyNodeInFuture);
final NormalizedNode<?, ?> actualNode = this.brokerFacade.readOperationalData(this.instanceID);
"Master is down. Please try again.");
final ReadFailedException exception503 = new ReadFailedException("Read from transaction failed", error);
doReturn(Futures.immediateFailedCheckedFuture(exception503))
- .when(rTransaction).read(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class));
+ .when(readTransaction).read(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class));
try {
brokerFacade.readConfigurationData(this.instanceID, "explicit");
fail("This test should fail.");
} catch (final RestconfDocumentedException e) {
assertEquals("getErrorTag", ErrorTag.RESOURCE_DENIED_TRANSPORT, e.getErrors().get(0).getErrorTag());
assertEquals("getErrorType", ErrorType.TRANSPORT, e.getErrors().get(0).getErrorType());
- assertEquals("getErrorMessage", "Master is down. Please try again.", e.getErrors().get(0).getErrorMessage());
+ assertEquals("getErrorMessage", "Master is down. Please try again.",
+ e.getErrors().get(0).getErrorMessage());
}
}
/**
* Prepare conditions to test delete operation. Data to delete exists or does not exist according to value of
* {@code assumeDataExists} parameter.
- * @param assumeDataExists
+ * @param assumeDataExists boolean to assume if data exists
*/
private void prepareDataForDelete(final boolean assumeDataExists) {
when(this.rwTransaction.exists(LogicalDatastoreType.CONFIGURATION, this.instanceID))
final DOMTransactionChain transactionChain = mock(DOMTransactionChain.class);
final DOMDataWriteTransaction wTx = mock(DOMDataWriteTransaction.class);
- final CheckedFuture checked = Futures.immediateCheckedFuture("");
+ final CheckedFuture<Void, TransactionCommitFailedException> checked = Futures.immediateCheckedFuture(null);
when(wTx.submit()).thenReturn(checked);
when(transactionChain.newWriteOnlyTransaction()).thenReturn(wTx);
final TransactionChainHandler transactionChainHandler = new TransactionChainHandler(transactionChain);
}
/**
- * Test PATCH method on the server with no data
+ * Test Patch method on the server with no data.
*/
@Test
@SuppressWarnings("unchecked")
public void testPatchConfigurationDataWithinTransactionServer() throws Exception {
- final PATCHContext patchContext = mock(PATCHContext.class);
+ final PatchContext patchContext = mock(PatchContext.class);
final InstanceIdentifierContext identifierContext = mock(InstanceIdentifierContext.class);
final CheckedFuture<Void, TransactionCommitFailedException> expFuture = Futures.immediateCheckedFuture(null);
when(this.rwTransaction.submit()).thenReturn(expFuture);
- final PATCHStatusContext status = this.brokerFacade.patchConfigurationDataWithinTransaction(patchContext);
+ final PatchStatusContext status = this.brokerFacade.patchConfigurationDataWithinTransaction(patchContext);
// assert success
- assertTrue("PATCH operation should be successful on server", status.isOk());
+ assertTrue("Patch operation should be successful on server", status.isOk());
}
/**
- * Test PATCH method on mounted device with no data
+ * Test Patch method on mounted device with no data.
*/
@Test
@SuppressWarnings("unchecked")
public void testPatchConfigurationDataWithinTransactionMount() throws Exception {
- final PATCHContext patchContext = mock(PATCHContext.class);
+ final PatchContext patchContext = mock(PatchContext.class);
final InstanceIdentifierContext identifierContext = mock(InstanceIdentifierContext.class);
final DOMMountPoint mountPoint = mock(DOMMountPoint.class);
final DOMDataBroker mountDataBroker = mock(DOMDataBroker.class);
when(mountDataBroker.newReadWriteTransaction()).thenReturn(transaction);
when(transaction.submit()).thenReturn(expFuture);
- final PATCHStatusContext status = this.brokerFacade.patchConfigurationDataWithinTransaction(patchContext);
+ final PatchStatusContext status = this.brokerFacade.patchConfigurationDataWithinTransaction(patchContext);
// assert success
- assertTrue("PATCH operation should be successful on mounted device", status.isOk());
+ assertTrue("Patch operation should be successful on mounted device", status.isOk());
}
/**
- * Negative test for PATCH operation when mounted device does not support {@link DOMDataBroker service.
- * PATCH operation should fail with global error.
+ * Negative test for Patch operation when mounted device does not support {@link DOMDataBroker service.}
+ * Patch operation should fail with global error.
*/
@Test
@SuppressWarnings("unchecked")
public void testPatchConfigurationDataWithinTransactionMountFail() throws Exception {
- final PATCHContext patchContext = mock(PATCHContext.class);
+ final PatchContext patchContext = mock(PatchContext.class);
final InstanceIdentifierContext identifierContext = mock(InstanceIdentifierContext.class);
final DOMMountPoint mountPoint = mock(DOMMountPoint.class);
final DOMDataBroker mountDataBroker = mock(DOMDataBroker.class);
when(mountDataBroker.newReadWriteTransaction()).thenReturn(transaction);
when(transaction.submit()).thenReturn(expFuture);
- final PATCHStatusContext status = this.brokerFacade.patchConfigurationDataWithinTransaction(patchContext);
+ final PatchStatusContext status = this.brokerFacade.patchConfigurationDataWithinTransaction(patchContext);
// assert not successful operation with error
assertNotNull(status.getGlobalErrors());
assertEquals(ErrorType.APPLICATION, status.getGlobalErrors().get(0).getErrorType());
assertEquals(ErrorTag.OPERATION_FAILED, status.getGlobalErrors().get(0).getErrorTag());
- assertFalse("PATCH operation should fail on mounted device without Broker", status.isOk());
+ assertFalse("Patch operation should fail on mounted device without Broker", status.isOk());
}
}