2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.statistics;
11 import static org.mockito.Matchers.any;
12 import static org.mockito.Matchers.anyString;
13 import static org.mockito.Mockito.doNothing;
14 import static org.mockito.Mockito.mock;
15 import static org.mockito.Mockito.when;
17 import javax.ws.rs.core.MultivaluedMap;
19 import java.util.concurrent.ScheduledExecutorService;
21 import com.sun.jersey.api.client.ClientResponse;
22 import org.junit.Before;
23 import org.junit.Test;
24 import org.mockito.Mockito;
25 import org.opendaylight.groupbasedpolicy.api.StatisticsManager;
27 public class ReadGbpFlowCacheTaskTest {
29 ReadGbpFlowCacheTask task;
30 private JsonRestClientResponse response;
34 StatisticsManager statisticsManager = mock(StatisticsManager.class);
35 ScheduledExecutorService executor = mock(ScheduledExecutorService.class);
36 ClientResponse clientResponse = mock(ClientResponse.class);
37 response = mock(JsonRestClientResponse.class);
38 when(response.getJsonResponse()).thenReturn("[{\"one\":1, \"two\":2, \"three\":3}]");
39 when(response.getStatusCode()).thenReturn(200);
40 when(response.getClientResponse()).thenReturn(clientResponse);
41 SFlowRTConnection connection = mock(SFlowRTConnection.class);
42 when(connection.get(anyString(), Mockito.<MultivaluedMap<String, String>>any())).thenReturn(response);
43 when(connection.getExecutor()).thenReturn(executor);
44 doNothing().when(executor).execute(any(Runnable.class));
46 task = new ReadGbpFlowCacheTask("cache1", connection, statisticsManager, 100, 0.1, "sum");
50 public void testRun() {
55 public void testRun_response300() {
56 when(response.getStatusCode()).thenReturn(300);
61 public void testRun_response400() {
62 when(response.getStatusCode()).thenReturn(400);