2 * ============LICENSE_START=======================================================
3 * SPARKY (AAI UI service)
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 package org.openecomp.sparky.viewandinspect;
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;
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;
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;
49 * The Class SearchAdapterTest.
51 public class SearchAdapterTest {
53 private RestClientBuilder clientBuilderMock;
54 private Client mockClient;
55 private ClientResponse mockClientResponse;
56 private WebResource mockWebResource;
57 private Builder mockBuilder;
64 * @throws Exception the exception
67 public void init() throws Exception {
70 * common collaborator mocking setup
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);
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());
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));