* ============LICENSE_START=======================================================
* VID
* ================================================================================
- * Copyright (C) 2018 Nokia Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 - 2019 Nokia Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
package org.onap.vid.aai;
import com.google.common.collect.ImmutableMap;
-import java.util.Collections;
-import java.util.Map;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Matchers;
+import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.vid.aai.model.AaiNodeQueryResponse;
+
import org.onap.vid.aai.model.ResourceType;
import org.onap.vid.client.SyncRestClient;
import org.onap.vid.model.SubscriberList;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.Collections;
+import java.util.Map;
+
+import static org.mockito.ArgumentMatchers.contains;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.MockitoAnnotations.initMocks;
-@RunWith(MockitoJUnitRunner.class)
public class AaiOverTLSClientTest {
- private static final String SEARCH_NODES_QUERY_SEARCH_NODE_TYPE = "search/nodes-query?search-node-type=generic-vnf&filter=vnf-name:EQUALS:name";
+ private static final String SEARCH_NODES_QUERY_SEARCH_NODE_TYPE = "nodes/generic-vnfs?vnf-name=name";
private static final String SUBSCRIBERS = "business/customers?subscriber-type=INFRA&depth=0";
private AaiOverTLSClient aaiRestClient;
- @Mock
+ @Mock(answer = Answers.RETURNS_MOCKS)
private SyncRestClient syncRestClient;
@Mock
private AaiOverTLSPropertySupplier propertySupplier;
- @Before
+ @BeforeMethod
public void setUp() {
+ initMocks(this);
aaiRestClient = new AaiOverTLSClient(syncRestClient, propertySupplier);
}
@Test
- public void testSearchNodeTypeByName() {
+ public void testIsNodeTypeExistsByName() {
mockPropertyReader();
- aaiRestClient.searchNodeTypeByName("name", ResourceType.GENERIC_VNF);
- Mockito.verify(syncRestClient).get(Matchers.contains(SEARCH_NODES_QUERY_SEARCH_NODE_TYPE),
- Matchers.eq(getHeaders()), Matchers.eq(Collections.emptyMap()), Matchers.eq(AaiNodeQueryResponse.class));
+ aaiRestClient.isNodeTypeExistsByName("name", ResourceType.GENERIC_VNF);
+ Mockito.verify(syncRestClient).get(contains(SEARCH_NODES_QUERY_SEARCH_NODE_TYPE),
+ eq(getHeaders()), eq(Collections.emptyMap()));
}
@Test
mockPropertyReader();
aaiRestClient.getAllSubscribers();
- Mockito.verify(syncRestClient).get(Matchers.contains(SUBSCRIBERS),
- Matchers.eq(getHeaders()), Matchers.eq(Collections.emptyMap()), Matchers.eq(SubscriberList.class));
+ Mockito.verify(syncRestClient).get(contains(SUBSCRIBERS),
+ eq(getHeaders()), eq(Collections.emptyMap()), eq(SubscriberList.class));
}
private void mockPropertyReader() {
put("X-TransactionId", "2").put("Content-Type", "application/json").build();
}
-}
\ No newline at end of file
+}