use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService in project openflowplugin by opendaylight.
the class TableForwarderTest method setUp.
@Before
public void setUp() throws Exception {
tableForwarder = new TableForwarder(salTableService);
txId = new TransactionId(BigInteger.ONE);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService in project openflowplugin by opendaylight.
the class TableForwarderTest method testUpdate.
@Test
public void testUpdate() throws Exception {
Mockito.when(salTableService.updateTable(updateTableInputCpt.capture())).thenReturn(RpcResultBuilder.success(new UpdateTableOutputBuilder().setTransactionId(txId).build()).buildFuture());
final TableFeatures tableFeaturesUpdate = new TableFeaturesBuilder(tableFeatures).setName("another-table").build();
final Future<RpcResult<UpdateTableOutput>> updateResult = tableForwarder.update(tableFeaturesPath, tableFeatures, tableFeaturesUpdate, flowCapableNodePath);
Mockito.verify(salTableService).updateTable(Matchers.<UpdateTableInput>any());
Assert.assertTrue(updateResult.isDone());
final RpcResult<UpdateTableOutput> updateTableResult = updateResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(updateTableResult.isSuccessful());
Assert.assertEquals(1, updateTableResult.getResult().getTransactionId().getValue().intValue());
final UpdateTableInput updateTableInput = updateTableInputCpt.getValue();
Assert.assertEquals(tablePath, updateTableInput.getTableRef().getValue());
Assert.assertEquals(nodePath, updateTableInput.getNode().getValue());
Assert.assertEquals(1, updateTableInput.getOriginalTable().getTableFeatures().size());
Assert.assertEquals("test-table", updateTableInput.getOriginalTable().getTableFeatures().get(0).getName());
Assert.assertEquals(1, updateTableInput.getUpdatedTable().getTableFeatures().size());
Assert.assertEquals("another-table", updateTableInput.getUpdatedTable().getTableFeatures().get(0).getName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService in project openflowplugin by opendaylight.
the class OpenflowpluginTableFeaturesTestServiceProvider method register.
public ObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider> register(final ProviderContext ctx) {
RoutedRpcRegistration<SalTableService> addRoutedRpcImplementation = ctx.<SalTableService>addRoutedRpcImplementation(SalTableService.class, this);
setTableRegistration(addRoutedRpcImplementation);
InstanceIdentifierBuilder<Nodes> builder1 = InstanceIdentifier.<Nodes>builder(Nodes.class);
NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
NodeKey nodeKey = new NodeKey(nodeId);
InstanceIdentifierBuilder<Node> nodeIndentifier = builder1.<Node, NodeKey>child(Node.class, nodeKey);
InstanceIdentifier<Node> instance = nodeIndentifier.build();
tableRegistration.registerPath(NodeContext.class, instance);
RoutedRpcRegistration<SalTableService> tableRegistration1 = this.getTableRegistration();
return new AbstractObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider>(this) {
@Override
protected void removeRegistration() {
tableRegistration1.close();
}
};
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService in project openflowplugin by opendaylight.
the class SalTableServiceImplTest method setup.
@Override
public void setup() {
handleResultFuture = SettableFuture.create();
when(mockedRequestContext.getFuture()).thenReturn(handleResultFuture);
Mockito.doAnswer((Answer<Void>) invocation -> {
final FutureCallback<OfHeader> callback = (FutureCallback<OfHeader>) invocation.getArguments()[2];
callback.onSuccess(null);
return null;
}).when(mockedOutboundQueue).commitEntry(Matchers.anyLong(), Matchers.<OfHeader>any(), Matchers.<FutureCallback<OfHeader>>any());
final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
salTableService = new SalTableServiceImpl(mockedRequestContextStack, mockedDeviceContext, convertorManager, MultipartWriterProviderFactory.createDefaultProvider(mockedDeviceContext));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.SalTableService in project openflowplugin by opendaylight.
the class TableForwarder method update.
@Override
public Future<RpcResult<UpdateTableOutput>> update(final InstanceIdentifier<TableFeatures> identifier, final TableFeatures original, final TableFeatures update, final InstanceIdentifier<FlowCapableNode> nodeIdent) {
LOG.debug("Forwarding Table Update request [Tbl id, node Id {} {}", identifier, nodeIdent);
final UpdateTableInputBuilder builder = new UpdateTableInputBuilder();
builder.setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class)));
final InstanceIdentifier<Table> iiToTable = nodeIdent.child(Table.class, new TableKey(identifier.firstKeyOf(TableFeatures.class).getTableId()));
builder.setTableRef(new TableRef(iiToTable));
builder.setUpdatedTable(new UpdatedTableBuilder().setTableFeatures(Collections.singletonList(update)).build());
builder.setOriginalTable(new OriginalTableBuilder().setTableFeatures(Collections.singletonList(original)).build());
LOG.debug("Invoking SalTableService {} ", nodeIdent);
return salTableService.updateTable(builder.build());
}
Aggregations