2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
 
   8  * you may not use this file except in compliance with the License.
 
   9  * You may obtain a copy of the License at
 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
 
  13  * Unless required by applicable law or agreed to in writing, software
 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  * See the License for the specific language governing permissions and
 
  17  * limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.policy.controlloop.actor.vfc;
 
  23 import static org.junit.Assert.assertEquals;
 
  24 import static org.junit.Assert.assertSame;
 
  25 import static org.mockito.Mockito.when;
 
  27 import java.util.concurrent.Executor;
 
  28 import org.junit.Before;
 
  29 import org.junit.Test;
 
  30 import org.mockito.Mock;
 
  31 import org.mockito.MockitoAnnotations;
 
  32 import org.onap.policy.common.endpoints.http.client.HttpClient;
 
  33 import org.onap.policy.common.endpoints.http.client.HttpClientFactory;
 
  35 public class VfcConfigTest {
 
  36     private static final String MY_CLIENT = "my-client";
 
  37     private static final String MY_PATH = "my-path";
 
  38     private static final String GET_PATH = "get-path";
 
  39     private static final int TIMEOUT_SEC = 10;
 
  40     private static final int MAX_GETS = 20;
 
  41     private static final int WAIT_SEC = 30;
 
  44     private HttpClient client;
 
  46     private HttpClientFactory factory;
 
  48     private Executor executor;
 
  50     private VfcParams params;
 
  51     private VfcConfig config;
 
  56      * @throws Exception Exception
 
  59     public void setUp() throws Exception {
 
  60         MockitoAnnotations.initMocks(this);
 
  62         when(factory.get(MY_CLIENT)).thenReturn(client);
 
  64         params = VfcParams.builder().maxGets(MAX_GETS).pathGet(GET_PATH).waitSecGet(WAIT_SEC).clientName(MY_CLIENT)
 
  65                 .path(MY_PATH).timeoutSec(TIMEOUT_SEC).build();
 
  66         config = new VfcConfig(executor, params, factory);
 
  71         assertEquals(GET_PATH + "/", config.getPathGet());
 
  72         assertEquals(MAX_GETS, config.getMaxGets());
 
  73         assertEquals(WAIT_SEC, config.getWaitSecGet());
 
  75         // check value from superclass
 
  76         assertSame(executor, config.getBlockingExecutor());
 
  77         assertSame(client, config.getClient());
 
  79         // path with trailing "/"
 
  80         params = params.toBuilder().pathGet(GET_PATH + "/").build();
 
  81         config = new VfcConfig(executor, params, factory);
 
  82         assertEquals(GET_PATH + "/", config.getPathGet());