X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=renderers%2Fofoverlay%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fgroupbasedpolicy%2Frenderer%2Fofoverlay%2Fstatistics%2FReadGbpFlowCacheTaskTest.java;h=873b73dc89840d2032b0a17da941dfdee5f2da51;hb=11e9cef2263b38788495e8e17a541d8f2a3c3f64;hp=41bba898d86541aa788dce5b2516774ba7cb510b;hpb=8916420c259b214fb246c0d61cb81ee216d78df6;p=groupbasedpolicy.git diff --git a/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/statistics/ReadGbpFlowCacheTaskTest.java b/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/statistics/ReadGbpFlowCacheTaskTest.java index 41bba898d..873b73dc8 100755 --- a/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/statistics/ReadGbpFlowCacheTaskTest.java +++ b/renderers/ofoverlay/src/test/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/statistics/ReadGbpFlowCacheTaskTest.java @@ -1,8 +1,14 @@ +/* + * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + package org.opendaylight.groupbasedpolicy.renderer.ofoverlay.statistics; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyMap; -import static org.mockito.Matchers.anySet; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; @@ -10,26 +16,30 @@ import static org.mockito.Mockito.when; import javax.ws.rs.core.MultivaluedMap; -import java.util.concurrent.ExecutorService; import java.util.concurrent.ScheduledExecutorService; +import com.sun.jersey.api.client.ClientResponse; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import org.opendaylight.groupbasedpolicy.api.StatisticsManager; public class ReadGbpFlowCacheTaskTest { ReadGbpFlowCacheTask task; + private JsonRestClientResponse response; @Before public void init() { StatisticsManager statisticsManager = mock(StatisticsManager.class); ScheduledExecutorService executor = mock(ScheduledExecutorService.class); - JsonRestClientResponse response = mock(JsonRestClientResponse.class); + ClientResponse clientResponse = mock(ClientResponse.class); + response = mock(JsonRestClientResponse.class); when(response.getJsonResponse()).thenReturn("[{\"one\":1, \"two\":2, \"three\":3}]"); when(response.getStatusCode()).thenReturn(200); + when(response.getClientResponse()).thenReturn(clientResponse); SFlowRTConnection connection = mock(SFlowRTConnection.class); - when(connection.get(anyString(), any(MultivaluedMap.class))).thenReturn(response); + when(connection.get(anyString(), Mockito.>any())).thenReturn(response); when(connection.getExecutor()).thenReturn(executor); doNothing().when(executor).execute(any(Runnable.class)); @@ -38,7 +48,18 @@ public class ReadGbpFlowCacheTaskTest { @Test public void testRun() { + task.run(); + } + + @Test + public void testRun_response300() { + when(response.getStatusCode()).thenReturn(300); + task.run(); + } + @Test + public void testRun_response400() { + when(response.getStatusCode()).thenReturn(400); task.run(); }