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