use of org.opendaylight.netconf.sal.restconf.impl.PutResult in project netconf by opendaylight.
the class RestPutConfigTest method mockingBrokerPut.
private void mockingBrokerPut(final YangInstanceIdentifier yii, final NormalizedNode data) {
final PutResult result = Mockito.mock(PutResult.class);
Mockito.when(this.brokerFacade.commitConfigurationDataPut(schemaContext, yii, data, null, null)).thenReturn(result);
Mockito.doReturn(CommitInfo.emptyFluentFuture()).when(result).getFutureOfPutData();
Mockito.when(result.getStatus()).thenReturn(Status.OK);
}
use of org.opendaylight.netconf.sal.restconf.impl.PutResult in project netconf by opendaylight.
the class JSONRestconfServiceImplTest method testPut.
@SuppressWarnings("rawtypes")
@Test
public void testPut() throws Exception {
final PutResult result = mock(PutResult.class);
when(brokerFacade.commitConfigurationDataPut(notNull(EffectiveModelContext.class), notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class), isNull(), isNull())).thenReturn(result);
doReturn(CommitInfo.emptyFluentFuture()).when(result).getFutureOfPutData();
when(result.getStatus()).thenReturn(Status.OK);
final String uriPath = "ietf-interfaces:interfaces/interface/eth0";
final String payload = loadData("/parts/ietf-interfaces_interfaces.json");
this.service.put(uriPath, payload);
final ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
verify(brokerFacade).commitConfigurationDataPut(notNull(EffectiveModelContext.class), capturedPath.capture(), capturedNode.capture(), isNull(), isNull());
verifyPath(capturedPath.getValue(), INTERFACES_QNAME, INTERFACE_QNAME, new Object[] { INTERFACE_QNAME, NAME_QNAME, "eth0" });
assertTrue("Expected MapEntryNode. Actual " + capturedNode.getValue().getClass(), capturedNode.getValue() instanceof MapEntryNode);
final MapEntryNode actualNode = (MapEntryNode) capturedNode.getValue();
assertEquals("MapEntryNode node type", INTERFACE_QNAME, actualNode.getIdentifier().getNodeType());
verifyLeafNode(actualNode, NAME_QNAME, "eth0");
verifyLeafNode(actualNode, TYPE_QNAME, "ethernetCsmacd");
verifyLeafNode(actualNode, ENABLED_QNAME, Boolean.FALSE);
verifyLeafNode(actualNode, DESC_QNAME, "some interface");
}
use of org.opendaylight.netconf.sal.restconf.impl.PutResult in project netconf by opendaylight.
the class JSONRestconfServiceImplTest method testPutBehindMountPoint.
@SuppressWarnings("rawtypes")
@Test
public void testPutBehindMountPoint() throws Exception {
final PutResult result = mock(PutResult.class);
when(brokerFacade.commitMountPointDataPut(notNull(DOMMountPoint.class), notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class), isNull(), isNull())).thenReturn(result);
doReturn(CommitInfo.emptyFluentFuture()).when(result).getFutureOfPutData();
when(result.getStatus()).thenReturn(Status.OK);
final String uriPath = "ietf-interfaces:interfaces/yang-ext:mount/test-module:cont/cont1";
final String payload = loadData("/full-versions/testCont1Data.json");
this.service.put(uriPath, payload);
final ArgumentCaptor<YangInstanceIdentifier> capturedPath = ArgumentCaptor.forClass(YangInstanceIdentifier.class);
final ArgumentCaptor<NormalizedNode> capturedNode = ArgumentCaptor.forClass(NormalizedNode.class);
verify(brokerFacade).commitMountPointDataPut(same(mockMountPoint), capturedPath.capture(), capturedNode.capture(), isNull(), isNull());
verifyPath(capturedPath.getValue(), TEST_CONT_QNAME, TEST_CONT1_QNAME);
assertTrue("Expected ContainerNode", capturedNode.getValue() instanceof ContainerNode);
final ContainerNode actualNode = (ContainerNode) capturedNode.getValue();
assertEquals("ContainerNode node type", TEST_CONT1_QNAME, actualNode.getIdentifier().getNodeType());
verifyLeafNode(actualNode, TEST_LF11_QNAME, "lf11 data");
verifyLeafNode(actualNode, TEST_LF12_QNAME, "lf12 data");
}
use of org.opendaylight.netconf.sal.restconf.impl.PutResult in project netconf by opendaylight.
the class JSONRestconfServiceImplTest method testPutFailure.
@Test(expected = OperationFailedException.class)
@SuppressWarnings("checkstyle:IllegalThrows")
public void testPutFailure() throws Throwable {
final PutResult result = mock(PutResult.class);
doReturn(immediateFailedFluentFuture(new TransactionCommitFailedException("mock"))).when(result).getFutureOfPutData();
when(result.getStatus()).thenReturn(Status.OK);
when(brokerFacade.commitConfigurationDataPut(notNull(EffectiveModelContext.class), notNull(YangInstanceIdentifier.class), notNull(NormalizedNode.class), Mockito.anyString(), Mockito.anyString())).thenReturn(result);
final String uriPath = "ietf-interfaces:interfaces/interface/eth0";
final String payload = loadData("/parts/ietf-interfaces_interfaces.json");
this.service.put(uriPath, payload);
}
use of org.opendaylight.netconf.sal.restconf.impl.PutResult in project netconf by opendaylight.
the class RestPutOperationTest method testRpcResultCommitedToStatusCodesWithMountPoint.
@Test
public void testRpcResultCommitedToStatusCodesWithMountPoint() throws UnsupportedEncodingException, FileNotFoundException, URISyntaxException {
final PutResult result = mock(PutResult.class);
when(brokerFacade.commitMountPointDataPut(any(DOMMountPoint.class), any(YangInstanceIdentifier.class), any(NormalizedNode.class), null, null)).thenReturn(result);
doReturn(CommitInfo.emptyFluentFuture()).when(result).getFutureOfPutData();
when(result.getStatus()).thenReturn(Status.OK);
mockMountPoint();
String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont";
assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData2));
uri = "/config/ietf-interfaces:interfaces/yang-ext:mount/test-module:cont";
assertEquals(200, put(uri, MediaType.APPLICATION_XML, xmlData2));
}
Aggregations