Search in sources :

Example 26 with Statistic

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);
    }
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) Statistic(org.ovirt.engine.api.model.Statistic) ArrayList(java.util.ArrayList)

Example 27 with Statistic

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);
}
Also used : Statistic(org.ovirt.engine.api.model.Statistic) Statistics(org.ovirt.engine.api.model.Statistics)

Aggregations

Statistic (org.ovirt.engine.api.model.Statistic)27 Statistics (org.ovirt.engine.api.model.Statistics)6 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 Values (org.ovirt.engine.api.model.Values)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)2 BigDecimal (java.math.BigDecimal)1 MathContext (java.math.MathContext)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 Host (org.ovirt.engine.api.model.Host)1 Value (org.ovirt.engine.api.model.Value)1 Vm (org.ovirt.engine.api.model.Vm)1 V3Statistic (org.ovirt.engine.api.v3.types.V3Statistic)1 V3Values (org.ovirt.engine.api.v3.types.V3Values)1 VdsStatistics (org.ovirt.engine.core.common.businessentities.VdsStatistics)1 GlusterVolumeTaskStatusForHost (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusForHost)1 Guid (org.ovirt.engine.core.compat.Guid)1