aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/test')
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java7
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java19
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java45
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java33
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java25
-rw-r--r--common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java31
-rw-r--r--common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java6
-rw-r--r--common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java26
8 files changed, 119 insertions, 73 deletions
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java b/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java
index d4eaf0873b..64a83f92ab 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java
@@ -80,4 +80,11 @@ public class AAIObjectTypeTest {
assertEquals("/cloud-infrastructure/pservers/pserver/{hostname}/p-interfaces/p-interface/{interface-name}", type.uriTemplate());
assertEquals("/p-interfaces/p-interface/{interface-name}", type.partialUri());
}
+
+ @Test
+ public void networkPolicyObjectTypeTest() {
+ final String id = "test1";
+ AAIUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_POLICY, id);
+ assertEquals("/network/network-policies/network-policy/test1", aaiUri.build().toString());
+ }
}
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java
index 43616ba0c2..84c3cad0f9 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java
@@ -20,11 +20,8 @@
package org.onap.so.client.aai;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -36,9 +33,8 @@ import javax.ws.rs.core.Response;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.client.RestClient;
import org.onap.so.client.aai.entities.CustomQuery;
@@ -46,6 +42,8 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.graphinventory.Format;
+import org.onap.so.client.graphinventory.GraphInventoryClient;
+import org.onap.so.client.graphinventory.GraphInventorySubgraphType;
@RunWith(MockitoJUnitRunner.class)
@@ -57,7 +55,10 @@ public class AAIQueryClientTest {
@Mock
RestClient restClient;
- @Spy
+ @Mock
+ GraphInventoryClient client;
+
+ @InjectMocks
AAIQueryClient aaiQueryClient = new AAIQueryClient();
@Test
@@ -67,16 +68,16 @@ public class AAIQueryClientTest {
Format format = Format.SIMPLE;
CustomQuery query = new CustomQuery(uris);
- doReturn(restClient).when(aaiQueryClient).createClient(isA(AAIUri.class));
+ doReturn(restClient).when(client).createClient(isA(AAIUri.class));
aaiQueryClient.query(format, query);
- verify(aaiQueryClient, times(1)).createClient(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY).queryParam("format", format.toString()));
+ verify(client, times(1)).createClient(AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY).queryParam("format", format.toString()));
verify(restClient, times(1)).put(query, String.class);
}
@Test
public void testCreateClient() {
String depth = "testDepth";
- AAISubgraphType subgraph = AAISubgraphType.STAR;
+ GraphInventorySubgraphType subgraph = GraphInventorySubgraphType.STAR;
aaiQueryClient.depth(depth);
aaiQueryClient.nodesOnly();
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java
index 32a9ca54a8..a55fbc9517 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientTest.java
@@ -35,18 +35,26 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.Relationship;
import org.onap.so.client.aai.entities.AAIEdgeLabel;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl;
+import org.onap.so.client.graphinventory.GraphInventoryClient;
import com.github.tomakehurst.wiremock.admin.NotFoundException;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
+
+@RunWith(MockitoJUnitRunner.class)
public class AAIResourcesClientTest {
@@ -56,6 +64,18 @@ public class AAIResourcesClientTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
+
+ @Spy
+ public AAIClient client;
+
+ @InjectMocks
+ public AAIResourcesClient aaiClient = new AAIResourcesClient();
+
+ @Before
+ public void beforeTest() {
+ doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties();
+ }
+
@Test
public void verifyNotExists() {
AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test");
@@ -66,7 +86,7 @@ public class AAIResourcesClientTest {
.withHeader("Content-Type", "text/plain")
.withBody("hello")
.withStatus(404)));
- AAIResourcesClient client= createClient();
+ AAIResourcesClient client= aaiClient;
boolean result = client.exists(path);
assertEquals("path not found", false, result);
}
@@ -87,7 +107,7 @@ public class AAIResourcesClientTest {
.willReturn(
aResponse()
.withStatus(204)));
- AAIResourcesClient client= createClient();
+ AAIResourcesClient client= aaiClient;
client.delete(path);
}
@@ -102,7 +122,7 @@ public class AAIResourcesClientTest {
.withHeader("Content-Type", "application/json")
.withBodyFile("aai/resources/mockObject.json")
.withStatus(200)));
- AAIResourcesClient client= createClient();
+ AAIResourcesClient client= aaiClient;
client.get(path);
}
@@ -118,7 +138,7 @@ public class AAIResourcesClientTest {
.withStatus(200)));
AAIResourceUri pathClone = path.clone();
- AAIResourcesClient client= createClient();
+ AAIResourcesClient client= aaiClient;
client.connect(path, path2);
assertEquals("uri not modified", pathClone.build().toString(), path.build().toString());
}
@@ -135,7 +155,7 @@ public class AAIResourcesClientTest {
.withStatus(204)));
AAIResourceUri pathClone = path.clone();
- AAIResourcesClient client= createClient();
+ AAIResourcesClient client= aaiClient;
client.disconnect(path, path2);
assertEquals("uri not modified", pathClone.build().toString(), path.build().toString());
}
@@ -150,7 +170,7 @@ public class AAIResourcesClientTest {
aResponse()
.withStatus(200)));
- AAIResourcesClient client= createClient();
+ AAIResourcesClient client= aaiClient;
client.update(path, "{}");
}
@@ -165,7 +185,7 @@ public class AAIResourcesClientTest {
.withHeader("Content-Type", "text/plain")
.withBody("hello")
.withStatus(404)));
- AAIResourcesClient client= createClient();
+ AAIResourcesClient client= aaiClient;
AAIResultWrapper result = client.get(path);
assertEquals("is empty", true, result.isEmpty());
}
@@ -180,7 +200,7 @@ public class AAIResourcesClientTest {
.withHeader("Content-Type", "text/plain")
.withBody("hello")
.withStatus(404)));
- AAIResourcesClient client= createClient();
+ AAIResourcesClient client= aaiClient;
thrown.expect(NotFoundException.class);
thrown.expectMessage(containsString(path.build() + " not found in A&AI"));
AAIResultWrapper result = client.get(path, NotFoundException.class);
@@ -188,7 +208,7 @@ public class AAIResourcesClientTest {
@Test
public void buildRelationshipTest() {
- AAIResourcesClient client = createClient();
+ AAIResourcesClient client = aaiClient;
AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "test");
Relationship relationship = new Relationship();
relationship.setRelatedLink(uri.build().toString());
@@ -200,10 +220,5 @@ public class AAIResourcesClientTest {
assertThat("expect equal has label", actual, sameBeanAs(relationship));
}
-
- private AAIResourcesClient createClient() {
- AAIResourcesClient client = spy(new AAIResourcesClient());
- doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties();
- return client;
- }
+
}
diff --git a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java
index 3d23213ff0..5493d6778e 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAIResourcesClientWithServiceInstanceUriTest.java
@@ -40,6 +40,10 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
import org.onap.so.client.aai.entities.uri.ServiceInstanceUri;
@@ -47,6 +51,7 @@ import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
+@RunWith(MockitoJUnitRunner.class)
public class AAIResourcesClientWithServiceInstanceUriTest {
@Rule
@@ -55,9 +60,17 @@ public class AAIResourcesClientWithServiceInstanceUriTest {
@Rule
public ExpectedException thrown = ExpectedException.none();
+ @Spy
+ public AAIClient client;
+
+ @InjectMocks
+ public AAIResourcesClient aaiClient = new AAIResourcesClient();
+
private ServiceInstanceUri uri;
@Before
public void setUp() {
+
+ doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties();
wireMockRule.stubFor(get(urlMatching("/aai/v[0-9]+/nodes.*"))
.willReturn(aResponse()
.withStatus(404)
@@ -65,12 +78,12 @@ public class AAIResourcesClientWithServiceInstanceUriTest {
.withHeader("Mock", "true")));
uri = spy((ServiceInstanceUri)AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, "id"));
- doReturn(createClient()).when(uri).getResourcesClient();
+ doReturn(aaiClient).when(uri).getResourcesClient();
}
@Test
public void getWithClass() {
- AAIResourcesClient client = createClient();
+ AAIResourcesClient client = aaiClient;
Optional<String> result = client.get(String.class, uri);
assertThat(result.isPresent(), equalTo(false));
@@ -78,42 +91,38 @@ public class AAIResourcesClientWithServiceInstanceUriTest {
@Test
public void getFullResponse() {
- AAIResourcesClient client = createClient();
+ AAIResourcesClient client = aaiClient;
Response result = client.getFullResponse(uri);
assertThat(result.getStatus(), equalTo(Status.NOT_FOUND.getStatusCode()));
}
@Test
public void getWithGenericType() {
- AAIResourcesClient client = createClient();
+ AAIResourcesClient client = aaiClient;
Optional<List<String>> result = client.get(new GenericType<List<String>>() {}, uri);
assertThat(result.isPresent(), equalTo(false));
}
@Test
public void getAAIWrapper() {
- AAIResourcesClient client = createClient();
+ AAIResourcesClient client = aaiClient;
AAIResultWrapper result = client.get(uri);
assertThat(result.isEmpty(), equalTo(true));
}
@Test
public void getWithException() {
- AAIResourcesClient client = createClient();
+ AAIResourcesClient client = aaiClient;
this.thrown.expect(IllegalArgumentException.class);
AAIResultWrapper result = client.get(uri, IllegalArgumentException.class);
}
@Test
public void existsTest() {
- AAIResourcesClient client = createClient();
+ AAIResourcesClient client = aaiClient;
doReturn(uri).when(uri).clone();
boolean result = client.exists(uri);
assertThat(result, equalTo(false));
}
- private AAIResourcesClient createClient() {
- AAIResourcesClient client = spy(new AAIResourcesClient());
- doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties();
- return client;
- }
+
}
diff --git a/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java
index 27637126c6..d875f384b0 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java
@@ -38,6 +38,10 @@ import java.util.Optional;
import org.json.JSONException;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.Pserver;
import org.onap.aai.domain.yang.v9.Complex;
import org.onap.so.client.aai.entities.singletransaction.SingleTransactionRequest;
@@ -53,6 +57,7 @@ import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
+@RunWith(MockitoJUnitRunner.class)
public class AAISingleTransactionClientTest {
private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/singletransaction/";
@@ -61,6 +66,10 @@ public class AAISingleTransactionClientTest {
ObjectMapper mapper;
+ public AAIClient client = new AAIClient();
+
+ public AAIResourcesClient aaiClient = new AAIResourcesClient();
+
@Before
public void before() throws JsonParseException, JsonMappingException, IOException {
mapper = new AAICommonObjectMapperProvider().getMapper();
@@ -69,7 +78,6 @@ public class AAISingleTransactionClientTest {
@Test
public void testRequest() throws JSONException,IOException {
- AAIResourcesClient client = createClient();
Pserver pserver = new Pserver();
pserver.setHostname("pserver-hostname");
pserver.setFqdn("pserver-bulk-process-single-transactions-multiple-actions-1-fqdn");
@@ -78,7 +86,7 @@ public class AAISingleTransactionClientTest {
Complex complex = new Complex();
complex.setCity("my-city");
AAISingleTransactionClient singleTransaction =
- client.beginSingleTransaction()
+ aaiClient.beginSingleTransaction()
.create(uriA, pserver)
.update(uriA, pserver2)
.create(uriB, complex);
@@ -93,8 +101,7 @@ public class AAISingleTransactionClientTest {
@Test
public void testFailure() throws IOException {
- AAIResourcesClient client = createClient();
- AAISingleTransactionClient singleTransaction = client.beginSingleTransaction();
+ AAISingleTransactionClient singleTransaction = aaiClient.beginSingleTransaction();
SingleTransactionResponse expected = mapper.readValue(this.getJson("sample-response-failure.json"), SingleTransactionResponse.class);
Optional<String> errorMessage = singleTransaction.locateErrorMessages(expected);
@@ -105,8 +112,7 @@ public class AAISingleTransactionClientTest {
@Test
public void testSuccessResponse() throws IOException {
- AAIResourcesClient client = createClient();
- AAISingleTransactionClient singleTransaction = client.beginSingleTransaction();
+ AAISingleTransactionClient singleTransaction = aaiClient.beginSingleTransaction();
SingleTransactionResponse expected = mapper.readValue(this.getJson("sample-response.json"), SingleTransactionResponse.class);
Optional<String> errorMessage = singleTransaction.locateErrorMessages(expected);
@@ -117,7 +123,7 @@ public class AAISingleTransactionClientTest {
@Test
public void confirmPatchFormat() {
- AAISingleTransactionClient singleTransaction = spy(new AAISingleTransactionClient(AAIVersion.LATEST));
+ AAISingleTransactionClient singleTransaction = spy(new AAISingleTransactionClient(aaiClient, client));
GraphInventoryPatchConverter mock = mock(GraphInventoryPatchConverter.class);
doReturn(mock).when(singleTransaction).getPatchConverter();
singleTransaction.update(uriA, "{}");
@@ -127,9 +133,4 @@ public class AAISingleTransactionClientTest {
return new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + filename)));
}
- private AAIResourcesClient createClient() {
- AAIResourcesClient client = spy(new AAIResourcesClient());
- doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties();
- return client;
- }
}
diff --git a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java
index 342e3b1aa4..3e2801c452 100644
--- a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java
@@ -38,7 +38,10 @@ import java.util.Optional;
import org.junit.Before;
import org.junit.Test;
-
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.Relationship;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
@@ -51,6 +54,7 @@ import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
+@RunWith(MockitoJUnitRunner.class)
public class AAITransactionalClientTest {
private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/bulkprocess/";
@@ -63,6 +67,10 @@ public class AAITransactionalClientTest {
ObjectMapper mapper;
+ public AAIClient client = new AAIClient();
+
+ public AAIResourcesClient aaiClient = new AAIResourcesClient();
+
@Before
public void before() throws JsonParseException, JsonMappingException, IOException {
mapper = new AAICommonObjectMapperProvider().getMapper();
@@ -74,7 +82,7 @@ public class AAITransactionalClientTest {
final Relationship body = new Relationship();
body.setRelatedLink(uriB.build().toString());
- AAITransactionalClient transactions = createClient().beginTransaction()
+ AAITransactionalClient transactions = aaiClient.beginTransaction()
.create(uriA.clone().relationshipAPI(), body);
String serializedTransactions = mapper.writeValueAsString(transactions.getTransactions());
@@ -90,7 +98,7 @@ public class AAITransactionalClientTest {
uris.add(uriB);
AAIResourceUri uriAClone = uriA.clone();
- AAITransactionalClient transactions = createClient()
+ AAITransactionalClient transactions = aaiClient
.beginTransaction().connect(uriA, uris).connect(uriC, uriD)
.beginNewTransaction().connect(uriE, uriF);
@@ -107,7 +115,7 @@ public class AAITransactionalClientTest {
List<AAIResourceUri> uris = new ArrayList<AAIResourceUri>();
uris.add(uriB);
- AAITransactionalClient transactions = createClient().beginTransaction()
+ AAITransactionalClient transactions = aaiClient.beginTransaction()
.disconnect(uriA, uris);
String serializedTransactions = mapper.writeValueAsString(transactions.getTransactions());
@@ -123,7 +131,7 @@ public class AAITransactionalClientTest {
body.setRelatedLink(uriB.build().toString());
AAIResourceUri uriAClone = uriA.clone().relationshipAPI();
- AAITransactionalClient transactions = createClient().beginTransaction().update(uriAClone, body);
+ AAITransactionalClient transactions = aaiClient.beginTransaction().update(uriAClone, body);
String serializedTransactions = mapper.writeValueAsString(transactions.getTransactions());
Map<String, Object> actual = mapper.readValue(serializedTransactions, new TypeReference<Map<String, Object>>(){});
@@ -134,7 +142,7 @@ public class AAITransactionalClientTest {
@Test
public void verifyResponse() throws IOException {
- AAITransactionalClient transactions = createClient()
+ AAITransactionalClient transactions = aaiClient
.beginTransaction();
assertEquals("success status", Optional.empty(), transactions.locateErrorMessages(getJson("response-success.json")));
@@ -143,10 +151,10 @@ public class AAITransactionalClientTest {
@Test
public void confirmPatchFormat() {
- AAITransactionalClient client = spy(new AAITransactionalClient(AAIVersion.LATEST));
+ AAITransactionalClient transactionClient = spy(new AAITransactionalClient(aaiClient, client));
GraphInventoryPatchConverter mock = mock(GraphInventoryPatchConverter.class);
- doReturn(mock).when(client).getPatchConverter();
- client.update(uriA, "{}");
+ doReturn(mock).when(transactionClient).getPatchConverter();
+ transactionClient.update(uriA, "{}");
verify(mock, times(1)).convertPatchFormat(any());
}
@@ -154,9 +162,4 @@ public class AAITransactionalClientTest {
return new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + filename)));
}
- private AAIResourcesClient createClient() {
- AAIResourcesClient client = spy(new AAIResourcesClient());
- doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties();
- return client;
- }
}
diff --git a/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java b/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java
index e66f43fa5f..69d46de96a 100644
--- a/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java
@@ -23,9 +23,9 @@ package org.onap.so.client.aai;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
-import org.onap.so.client.aai.entities.DSLNode;
-import org.onap.so.client.aai.entities.DSLQueryBuilder;
-import org.onap.so.client.aai.entities.__;
+import org.onap.so.client.graphinventory.entities.DSLNode;
+import org.onap.so.client.graphinventory.entities.DSLQueryBuilder;
+import org.onap.so.client.graphinventory.entities.__;
public class DSLQueryBuilderTest {
diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java
index 6059e7bd23..15c1c24ae2 100644
--- a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java
+++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java
@@ -26,7 +26,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
@@ -45,10 +44,16 @@ import java.util.Optional;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.core.UriBuilder;
+import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Spy;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.client.aai.AAIClient;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.AAIResultWrapper;
import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl;
@@ -58,6 +63,7 @@ import org.onap.so.client.graphinventory.exceptions.GraphInventoryUriNotFoundExc
import com.github.tomakehurst.wiremock.junit.WireMockRule;
+@RunWith(MockitoJUnitRunner.class)
public class ServiceInstanceUriTest {
private final static String AAI_JSON_FILE_LOCATION = "src/test/resources/__files/aai/resources/";
@@ -68,6 +74,16 @@ public class ServiceInstanceUriTest {
@Rule
public final ExpectedException exception = ExpectedException.none();
+ @Spy
+ public AAIClient client;
+
+ @InjectMocks
+ public AAIResourcesClient aaiClient = new AAIResourcesClient();
+
+ @Before
+ public void beforeTest() {
+ doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties();
+ }
@Test
public void found() throws IOException {
final String content = new String(Files.readAllBytes(Paths.get(AAI_JSON_FILE_LOCATION + "service-instance-pathed-query.json")));
@@ -179,7 +195,7 @@ public class ServiceInstanceUriTest {
public void noVertexFound() throws GraphInventoryUriNotFoundException, GraphInventoryPayloadException {
ServiceInstanceUri instance = new ServiceInstanceUri("key3");
ServiceInstanceUri spy = spy(instance);
- AAIResourcesClient client = createClient();
+ AAIResourcesClient client = aaiClient;
doReturn(client).when(spy).getResourcesClient();
stubFor(get(urlPathMatching("/aai/v[0-9]+/nodes/service-instances/service-instance/key3"))
.willReturn(aResponse()
@@ -189,10 +205,4 @@ public class ServiceInstanceUriTest {
exception.expect(NotFoundException.class);
spy.build();
}
-
- private AAIResourcesClient createClient() {
- AAIResourcesClient client = spy(new AAIResourcesClient());
- doReturn(new DefaultAAIPropertiesImpl()).when(client).getRestProperties();
- return client;
- }
}