Add VFC Actor
[policy/models.git] / models-interactions / model-actors / actor.vfc / src / test / java / org / onap / policy / controlloop / actor / vfc / BasicVfcOperation.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.onap.policy.controlloop.actor.vfc;
22
23 import static org.mockito.Mockito.when;
24
25 import org.mockito.Mock;
26 import org.onap.policy.controlloop.actor.test.BasicHttpOperation;
27 import org.onap.policy.vfc.VfcRequest;
28 import org.onap.policy.vfc.VfcResponse;
29
30 public abstract class BasicVfcOperation extends BasicHttpOperation<VfcRequest> {
31     public static final String PATH_GET = "my-path-get/";
32     public static final int MAX_GETS = 3;
33     public static final int WAIT_SEC_GETS = 20;
34
35     @Mock
36     protected VfcConfig config;
37
38     protected VfcResponse response;
39
40     /**
41      * Constructs the object using a default actor and operation name.
42      */
43     public BasicVfcOperation() {
44         super();
45     }
46
47     /**
48      * Constructs the object.
49      *
50      * @param actor actor name
51      * @param operation operation name
52      */
53     public BasicVfcOperation(String actor, String operation) {
54         super(actor, operation);
55     }
56
57     /**
58      * Initializes mocks and sets up.
59      */
60     public void setUp() throws Exception {
61         super.setUpBasic();
62
63         response = new VfcResponse();
64
65         // PLD
66
67         when(rawResponse.getStatus()).thenReturn(200);
68         when(rawResponse.readEntity(String.class)).thenReturn(coder.encode(response));
69
70         initConfig();
71     }
72
73     @Override
74     protected void initConfig() {
75         super.initConfig();
76         when(config.getClient()).thenReturn(client);
77         when(config.getMaxGets()).thenReturn(MAX_GETS);
78         when(config.getPathGet()).thenReturn(PATH_GET);
79         when(config.getWaitSecGet()).thenReturn(WAIT_SEC_GETS);
80     }
81
82 }