use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.
the class BackendStatisticsResourceTest method setUpQueryExpectations.
protected void setUpQueryExpectations(String unused, final Object failure) throws Exception {
VDS entity = getEntity(0);
if (failure == null) {
when(query.resolve(eq(GUIDS[1]))).thenReturn(entity);
List<Statistic> statistics = new ArrayList<>();
for (String name : STATISTICS) {
statistics.add(getPrototype(name));
}
when(query.getStatistics(same(entity))).thenReturn(statistics);
when(query.getParentType()).thenReturn(Host.class);
} else if (failure instanceof String) {
String detail = mockl10n((String) failure);
when(query.resolve(eq(GUIDS[1]))).thenThrow(new BaseBackendResource.BackendFailureException(detail, Status.CONFLICT));
} else if (failure instanceof Exception) {
when(query.resolve(eq(GUIDS[1]))).thenThrow((Exception) failure);
}
}
use of org.ovirt.engine.api.model.Statistic in project ovirt-engine by oVirt.
the class BackendNicHelper method addStatistics.
public static void addStatistics(Nic model, VmNetworkInterface entity) {
model.setStatistics(new Statistics());
NicStatisticalQuery query = new NicStatisticalQuery(model);
List<Statistic> statistics = query.getStatistics(entity);
for (Statistic statistic : statistics) {
LinkHelper.addLinks(statistic, query.getParentType());
}
model.getStatistics().getStatistics().addAll(statistics);
}
Aggregations