Initial commit for AAI-UI(sparky-backend)
[aai/sparky-be.git] / src / test / java / org / openecomp / sparky / viewandinspect / SearchAdapterTest.java
1 /* 
2 * ============LICENSE_START=======================================================
3 * SPARKY (AAI UI service)
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
7 * All rights reserved.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12
13 *      http://www.apache.org/licenses/LICENSE-2.0
14
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
21
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
24 */
25
26 package org.openecomp.sparky.viewandinspect;
27
28 import static org.junit.Assert.assertEquals;
29 import static org.mockito.Matchers.anyObject;
30 import static org.mockito.Matchers.anyString;
31 import static org.mockito.Matchers.same;
32 import static org.mockito.Mockito.doReturn;
33 import static org.mockito.Mockito.doThrow;
34 import static org.mockito.Mockito.mock;
35
36 import org.junit.Before;
37 import org.junit.Test;
38 import org.openecomp.sparky.dal.elasticsearch.SearchAdapter;
39 import org.openecomp.sparky.dal.rest.OperationResult;
40 import org.openecomp.sparky.dal.rest.RestClientBuilder;
41
42 import com.sun.jersey.api.client.Client;
43 import com.sun.jersey.api.client.ClientResponse;
44 import com.sun.jersey.api.client.WebResource;
45 import com.sun.jersey.api.client.WebResource.Builder;
46
47
48 /**
49  * The Class SearchAdapterTest.
50  */
51 public class SearchAdapterTest {
52
53   private RestClientBuilder clientBuilderMock;
54   private Client mockClient;
55   private ClientResponse mockClientResponse;
56   private WebResource mockWebResource;
57   private Builder mockBuilder;
58
59   
60
61   /**
62    * Inits the.
63    *
64    * @throws Exception the exception
65    */
66   @Before
67   public void init() throws Exception {
68
69     /*
70      * common collaborator mocking setup
71      */
72
73     clientBuilderMock = mock(RestClientBuilder.class);
74     mockClient = mock(Client.class);
75     mockClientResponse = mock(ClientResponse.class);
76     mockWebResource = mock(WebResource.class);
77     mockBuilder = mock(Builder.class);
78
79     doReturn(mockClient).when(clientBuilderMock).getClient();
80     doReturn(mockWebResource).when(mockClient).resource(anyString());
81     doReturn(mockBuilder).when(mockWebResource).accept(anyString());
82     doReturn(mockBuilder).when(mockBuilder).header(anyString(), anyObject());
83
84     doReturn(mockClientResponse).when(mockBuilder).get(same(ClientResponse.class));
85     doReturn(mockClientResponse).when(mockBuilder).put(same(ClientResponse.class), anyObject());
86     doReturn(mockClientResponse).when(mockBuilder).post(same(ClientResponse.class), anyObject());
87     doReturn(mockClientResponse).when(mockBuilder).delete(same(ClientResponse.class));
88   }
89
90 }