use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput in project openflowplugin by opendaylight.
the class SalGroupServiceImplTest method removeGroup.
private void removeGroup() throws Exception {
final GroupId dummyGroupId = new GroupId(DUMMY_GROUP_ID);
RemoveGroupInput removeGroupInput = new RemoveGroupInputBuilder().setGroupId(dummyGroupId).build();
this.<RemoveGroupOutput>mockSuccessfulFuture();
salGroupService.removeGroup(removeGroupInput);
verify(mockedRequestContextStack).createRequestContext();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput in project openflowplugin by opendaylight.
the class SalGroupsBatchServiceImplTest method testRemoveGroupsBatch_success.
@Test
public void testRemoveGroupsBatch_success() throws Exception {
Mockito.when(salGroupService.removeGroup(Mockito.<RemoveGroupInput>any())).thenReturn(RpcResultBuilder.success(new RemoveGroupOutputBuilder().build()).buildFuture());
final RemoveGroupsBatchInput input = new RemoveGroupsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchRemoveGroups(Lists.newArrayList(createEmptyBatchRemoveGroup(42L), createEmptyBatchRemoveGroup(43L))).build();
final Future<RpcResult<RemoveGroupsBatchOutput>> resultFuture = salGroupsBatchService.removeGroupsBatch(input);
Assert.assertTrue(resultFuture.isDone());
Assert.assertTrue(resultFuture.get().isSuccessful());
final InOrder inOrder = Mockito.inOrder(salGroupService, transactionService);
inOrder.verify(salGroupService, Mockito.times(2)).removeGroup(removeGroupInputCpt.capture());
final List<RemoveGroupInput> allValues = removeGroupInputCpt.getAllValues();
Assert.assertEquals(2, allValues.size());
Assert.assertEquals(42L, allValues.get(0).getGroupId().getValue().longValue());
Assert.assertEquals(43L, allValues.get(1).getGroupId().getValue().longValue());
inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput in project openflowplugin by opendaylight.
the class GroupListenerTest method removeGroupTest.
@Test
public void removeGroupTest() throws Exception {
addFlowCapableNode(NODE_KEY);
GroupKey groupKey = new GroupKey(new GroupId((long) 255));
InstanceIdentifier<Group> groupII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Group.class, groupKey);
Group group = new GroupBuilder().setKey(groupKey).setGroupName("Group1").build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, groupII, group);
assertCommit(writeTx.submit());
SalGroupServiceMock salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
List<AddGroupInput> addGroupCalls = salGroupService.getAddGroupCalls();
assertEquals(1, addGroupCalls.size());
assertEquals("DOM-0", addGroupCalls.get(0).getTransactionUri().getValue());
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.CONFIGURATION, groupII);
assertCommit(writeTx.submit());
salGroupService = (SalGroupServiceMock) forwardingRulesManager.getSalGroupService();
List<RemoveGroupInput> removeGroupCalls = salGroupService.getRemoveGroupCalls();
assertEquals(1, removeGroupCalls.size());
assertEquals("DOM-1", removeGroupCalls.get(0).getTransactionUri().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput in project openflowplugin by opendaylight.
the class GroupForwarderTest method testRemove.
@Test
public void testRemove() throws Exception {
Mockito.when(salGroupService.removeGroup(removeGroupInputCpt.capture())).thenReturn(RpcResultBuilder.success(new RemoveGroupOutputBuilder().setTransactionId(txId).build()).buildFuture());
final Future<RpcResult<RemoveGroupOutput>> addResult = groupForwarder.remove(groupPath, group, flowCapableNodePath);
Mockito.verify(salGroupService).removeGroup(Matchers.<RemoveGroupInput>any());
Assert.assertTrue(addResult.isDone());
final RpcResult<RemoveGroupOutput> result = addResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(result.isSuccessful());
Assert.assertEquals(1, result.getResult().getTransactionId().getValue().intValue());
final RemoveGroupInput removeGroupInput = removeGroupInputCpt.getValue();
Assert.assertEquals(groupPath, removeGroupInput.getGroupRef().getValue());
Assert.assertNull(removeGroupInput.getBuckets());
Assert.assertEquals(nodePath, removeGroupInput.getNode().getValue());
Assert.assertEquals("test-group", removeGroupInput.getGroupName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInput in project openflowplugin by opendaylight.
the class SalGroupsBatchServiceImplTest method testRemoveGroupsBatch_failure.
@Test
public void testRemoveGroupsBatch_failure() throws Exception {
Mockito.when(salGroupService.removeGroup(Mockito.<RemoveGroupInput>any())).thenReturn(RpcResultBuilder.<RemoveGroupOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-groupRemoveError").buildFuture());
final RemoveGroupsBatchInput input = new RemoveGroupsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchRemoveGroups(Lists.newArrayList(createEmptyBatchRemoveGroup(42L), createEmptyBatchRemoveGroup(43L))).build();
final Future<RpcResult<RemoveGroupsBatchOutput>> resultFuture = salGroupsBatchService.removeGroupsBatch(input);
Assert.assertTrue(resultFuture.isDone());
Assert.assertFalse(resultFuture.get().isSuccessful());
Assert.assertEquals(2, resultFuture.get().getResult().getBatchFailedGroupsOutput().size());
Assert.assertEquals(42L, resultFuture.get().getResult().getBatchFailedGroupsOutput().get(0).getGroupId().getValue().longValue());
Assert.assertEquals(43L, resultFuture.get().getResult().getBatchFailedGroupsOutput().get(1).getGroupId().getValue().longValue());
Assert.assertEquals(2, resultFuture.get().getErrors().size());
final InOrder inOrder = Mockito.inOrder(salGroupService, transactionService);
inOrder.verify(salGroupService, Mockito.times(2)).removeGroup(removeGroupInputCpt.capture());
final List<RemoveGroupInput> allValues = removeGroupInputCpt.getAllValues();
Assert.assertEquals(2, allValues.size());
Assert.assertEquals(42L, allValues.get(0).getGroupId().getValue().longValue());
Assert.assertEquals(43L, allValues.get(1).getGroupId().getValue().longValue());
inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
Aggregations