@Test
public void getLoadBalanceFactor() throws Exception {

    Engine engine = mock(Engine.class);
    Set<LoadMetric> metrics = new HashSet<>();
    LoadMetric metric = mock(LoadMetric.class);
    when(metric.getWeight()).thenReturn(LoadMetric.DEFAULT_WEIGHT);
    when(metric.getLoad(engine)).thenThrow(new NodeUnavailableException());
    metrics.add(metric);
    DynamicLoadBalanceFactorProvider provider = new DynamicLoadBalanceFactorProvider(metrics);
    int loadBalanceFactor = provider.getLoadBalanceFactor(engine);
    assertEquals(-1, loadBalanceFactor);
}