use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput in project openflowplugin by opendaylight.
the class GroupDirectStatisticsService method buildReply.
@Override
protected GetGroupStatisticsOutput buildReply(List<MultipartReply> input, boolean success) {
final List<GroupStats> groupStats = new ArrayList<>();
if (success) {
for (final MultipartReply mpReply : input) {
final MultipartReplyGroupCase caseBody = (MultipartReplyGroupCase) mpReply.getMultipartReplyBody();
final MultipartReplyGroup replyBody = caseBody.getMultipartReplyGroup();
final Optional<List<GroupStats>> groupStatsList = getConvertorExecutor().convert(replyBody.getGroupStats(), data);
groupStatsList.ifPresent(groupStats::addAll);
}
}
return new GetGroupStatisticsOutputBuilder().setGroupStats(groupStats).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput in project openflowplugin by opendaylight.
the class OpendaylightGroupStatisticsServiceImplTest method testGetGroupStatistics.
@Test
public void testGetGroupStatistics() throws Exception {
GetGroupStatisticsInputBuilder input = new GetGroupStatisticsInputBuilder().setNode(createNodeRef("unitProt:123")).setGroupId(new GroupId(21L));
rpcResult = buildGroupStatsResponse();
final Future<RpcResult<GetGroupStatisticsOutput>> resultFuture = groupStatisticsService.getGroupStatistics(input.build());
Assert.assertTrue(resultFuture.isDone());
final RpcResult<GetGroupStatisticsOutput> rpcResult = resultFuture.get();
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(MultipartType.OFPMPGROUP, requestInput.getValue().getType());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput in project openflowplugin by opendaylight.
the class OpendaylightDirectStatisticsServiceImplTest method testGetGroupStatisticsFail.
@Test
public void testGetGroupStatisticsFail() throws Exception {
RpcResult<GetGroupStatisticsOutput> result = emptyService.getGroupStatistics(getGroupStatisticsInput).get();
assertFalse(result.isSuccessful());
for (RpcError error : result.getErrors()) {
assertTrue(error.getMessage().contains(AbstractGroupDirectStatisticsService.class.getSimpleName()));
}
verify(groupDirectStatisticsService, times(0)).handleAndReply(getGroupStatisticsInput);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput in project openflowplugin by opendaylight.
the class GroupDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final MultipartReply reply = mock(MultipartReply.class);
final MultipartReplyGroupCase groupCase = mock(MultipartReplyGroupCase.class);
final MultipartReplyGroup group = mock(MultipartReplyGroup.class);
final GroupStats groupStat = new GroupStatsBuilder().setGroupId(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId(GROUP_NO)).setByteCount(BigInteger.ONE).setPacketCount(BigInteger.ONE).setBucketStats(Collections.emptyList()).setDurationSec(1L).setDurationNsec(1L).setRefCount(0L).build();
final List<GroupStats> groupStats = Collections.singletonList(groupStat);
final List<MultipartReply> input = Collections.singletonList(reply);
when(group.getGroupStats()).thenReturn(groupStats);
when(groupCase.getMultipartReplyGroup()).thenReturn(group);
when(reply.getMultipartReplyBody()).thenReturn(groupCase);
final GetGroupStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getGroupStats().size() > 0);
final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = output.getGroupStats().get(0);
assertEquals(stats.getGroupId().getValue(), GROUP_NO);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput in project openflowplugin by opendaylight.
the class GroupDirectStatisticsServiceTest method testStoreStatistics.
@Override
public void testStoreStatistics() throws Exception {
final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stat = mock(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats.class);
when(stat.getGroupId()).thenReturn(new GroupId(GROUP_NO));
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats> stats = Collections.singletonList(stat);
final GetGroupStatisticsOutput output = mock(GetGroupStatisticsOutput.class);
when(output.getGroupStats()).thenReturn(stats);
multipartWriterProvider.lookup(MultipartType.OFPMPGROUP).get().write(output, true);
verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
}
Aggregations