summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Blimkie <Steven.Blimkie@amdocs.com>2018-03-28 15:48:09 +0000
committerGerrit Code Review <gerrit@onap.org>2018-03-28 15:48:09 +0000
commita0727ffb7ee413d56f0b969c8f47861510ee8d98 (patch)
tree1cfff37f1045980e16a3ee94b9cc1aef65baabd8
parentde197e955ffb3a55de48817aa70f9bc7ef6475e5 (diff)
parentdc48060d3bdbd51583d61544311a3db7e9438496 (diff)
Merge "Add test cases to increase coverage"
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java84
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java155
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java2
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java34
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java98
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java203
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNodeLink.java73
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProviderTest.java60
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilderTest.java30
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java83
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/GizmoAdapterTest.java60
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java97
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java64
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/AggregationEntityTest.java33
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilderTest.java31
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntityTest.java30
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/SearchFilterTest.java35
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntityTest.java55
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntityTest.java39
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/TestUserManager.java32
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/subscription/services/SubscriptionServiceTest.java51
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java34
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java59
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java96
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoEntityTest.java62
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipEntityTest.java62
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipHintTest.java37
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContextTest.java110
28 files changed, 1147 insertions, 662 deletions
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java
index b58d91b..a2df3b5 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateSummaryProcessor.java
@@ -43,29 +43,31 @@ import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
public class AggregateSummaryProcessor {
- private static final Logger LOG = LoggerFactory.getInstance().getLogger(AggregateSummaryProcessor.class);
+ private static final Logger LOG =
+ LoggerFactory.getInstance().getLogger(AggregateSummaryProcessor.class);
private static final String KEY_FILTERS = "filters";
private ElasticSearchAdapter elasticSearchAdapter = null;
-
+
private String vnfAggregationIndexName;
private FiltersConfig filtersConfig;
-
- public AggregateSummaryProcessor(ElasticSearchAdapter elasticSearchAdapter, FiltersConfig filtersConfig) {
+
+ public AggregateSummaryProcessor(ElasticSearchAdapter elasticSearchAdapter,
+ FiltersConfig filtersConfig) {
this.elasticSearchAdapter = elasticSearchAdapter;
this.filtersConfig = filtersConfig;
}
-
+
public void setVnfAggregationIndexName(String vnfAggregationIndexName) {
this.vnfAggregationIndexName = vnfAggregationIndexName;
}
-
+
public void getFilteredAggregation(Exchange exchange) {
HttpServletRequest request = exchange.getIn().getBody(HttpServletRequest.class);
ServletUtils.setUpMdcContext(exchange, request);
-
+
try {
String payload = exchange.getIn().getBody(String.class);
@@ -86,29 +88,29 @@ public class AggregateSummaryProcessor {
if (parameters.has(KEY_FILTERS)) {
requestFilters = parameters.getJSONArray(KEY_FILTERS);
} else {
-
+
JSONObject zeroResponsePayload = new JSONObject();
zeroResponsePayload.put("count", 0);
- //response.setStatus(Status.SUCCESS_OK);
- //response.setEntity(zeroResponsePayload.toString(), MediaType.APPLICATION_JSON);
+ // response.setStatus(Status.SUCCESS_OK);
+ // response.setEntity(zeroResponsePayload.toString(), MediaType.APPLICATION_JSON);
exchange.getOut().setBody(zeroResponsePayload.toString());
-
+
LOG.error(AaiUiMsgs.ERROR_FILTERS_NOT_FOUND);
return;
}
-
+
if (requestFilters != null && requestFilters.length() > 0) {
List<JSONObject> filtersToQuery = new ArrayList<JSONObject>();
- for(int i = 0; i < requestFilters.length(); i++) {
+ for (int i = 0; i < requestFilters.length(); i++) {
JSONObject filterEntry = requestFilters.getJSONObject(i);
filtersToQuery.add(filterEntry);
}
-
+
String jsonResponsePayload = getVnfFilterAggregations(filtersToQuery);
exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 200);
exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "application/json");
exchange.getOut().setBody(jsonResponsePayload);
-
+
} else {
String emptyResponse = getEmptyAggResponse();
exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE, 200);
@@ -118,10 +120,11 @@ public class AggregateSummaryProcessor {
}
}
} catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, "FilterProcessor failed to get filter list due to error = " + exc.getMessage());
+ LOG.error(AaiUiMsgs.ERROR_GENERIC,
+ "FilterProcessor failed to get filter list due to error = " + exc.getMessage());
}
}
-
+
private String getEmptyAggResponse() {
JSONObject aggPayload = new JSONObject();
aggPayload.put("totalChartHits", 0);
@@ -130,44 +133,45 @@ public class AggregateSummaryProcessor {
payload.append("groupby_aggregation", aggPayload);
return payload.toString();
- }
-
+ }
+
private static final String FILTER_ID_KEY = "filterId";
private static final String FILTER_VALUE_KEY = "filterValue";
private static final int DEFAULT_SHOULD_MATCH_SCORE = 1;
private static final String VNF_FILTER_AGGREGATION = "vnfFilterAggregation";
-
+
private String getVnfFilterAggregations(List<JSONObject> filtersToQuery) throws IOException {
-
+
List<SearchFilter> searchFilters = new ArrayList<SearchFilter>();
- for(JSONObject filterEntry : filtersToQuery) {
-
+ for (JSONObject filterEntry : filtersToQuery) {
+
String filterId = filterEntry.getString(FILTER_ID_KEY);
- if(filterId != null) {
+ if (filterId != null) {
SearchFilter filter = new SearchFilter();
filter.setFilterId(filterId);
-
- if(filterEntry.has(FILTER_VALUE_KEY)) {
+
+ if (filterEntry.has(FILTER_VALUE_KEY)) {
String filterValue = filterEntry.getString(FILTER_VALUE_KEY);
filter.addValue(filterValue);
}
-
+
searchFilters.add(filter);
}
}
-
+
// Create query for summary by entity type
- JsonObject vnfSearch = FilterQueryBuilder.createCombinedBoolAndAggQuery(filtersConfig, searchFilters, DEFAULT_SHOULD_MATCH_SCORE);
+ JsonObject vnfSearch = FilterQueryBuilder.createCombinedBoolAndAggQuery(filtersConfig,
+ searchFilters, DEFAULT_SHOULD_MATCH_SCORE);
// Parse response for summary by entity type query
OperationResult opResult = elasticSearchAdapter.doPost(
elasticSearchAdapter.buildElasticSearchUrlForApi(vnfAggregationIndexName,
SparkyConstants.ES_SEARCH_API),
vnfSearch.toString(), javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE);
-
- if ( opResult.wasSuccessful()) {
- return buildAggregateVnfResponseJson(opResult.getResult());
+
+ if (opResult.wasSuccessful()) {
+ return buildAggregateVnfResponseJson(opResult.getResult());
} else {
return buildEmptyAggregateVnfResponseJson();
}
@@ -178,27 +182,27 @@ public class AggregateSummaryProcessor {
finalOutputToFe.put("total", 0);
return finalOutputToFe.toString();
}
-
+
private String buildAggregateVnfResponseJson(String responseJsonStr) {
-
+
JSONObject finalOutputToFe = new JSONObject();
JSONObject responseJson = new JSONObject(responseJsonStr);
-
-
+
+
JSONObject hits = responseJson.getJSONObject("hits");
int totalHits = hits.getInt("total");
finalOutputToFe.put("total", totalHits);
-
+
JSONObject aggregations = responseJson.getJSONObject("aggregations");
String[] aggKeys = JSONObject.getNames(aggregations);
JSONObject aggregationsList = new JSONObject();
-
- for(String aggName : aggKeys) {
+
+ for (String aggName : aggKeys) {
JSONObject aggregation = aggregations.getJSONObject(aggName);
JSONArray buckets = aggregation.getJSONArray("buckets");
aggregationsList.put(aggName, buckets);
}
-
+
finalOutputToFe.put("aggregations", aggregationsList);
return finalOutputToFe.toString();
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java
index 252ff75..5fd0dc9 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProvider.java
@@ -20,46 +20,55 @@
*/
package org.onap.aai.sparky.aggregatevnf.search;
+import java.io.IOException;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
-import javax.json.JsonObject;
-import javax.ws.rs.core.MediaType;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
import org.onap.aai.cl.api.Logger;
import org.onap.aai.cl.eelf.LoggerFactory;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.sparky.common.search.CommonSearchSuggestion;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
import org.onap.aai.sparky.logging.AaiUiMsgs;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
import org.onap.aai.sparky.search.api.SearchProvider;
import org.onap.aai.sparky.search.entity.QuerySearchEntity;
import org.onap.aai.sparky.search.entity.SearchSuggestion;
import org.onap.aai.sparky.search.filters.entity.UiFilterValueEntity;
import org.onap.aai.sparky.util.NodeUtils;
-import org.onap.aai.sparky.viewandinspect.config.SparkyConstants;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
public class AggregateVnfSearchProvider implements SearchProvider {
-
- private static final Logger LOG = LoggerFactory.getInstance().getLogger(AggregateVnfSearchProvider.class);
+
+ private static final Logger LOG =
+ LoggerFactory.getInstance().getLogger(AggregateVnfSearchProvider.class);
private ObjectMapper mapper;
- private ElasticSearchAdapter elasticSearchAdapter = null;
+ private SearchServiceAdapter searchServiceAdapter = null;
private String autoSuggestIndexName;
private String vnfSearchSuggestionRoute;
- public AggregateVnfSearchProvider(ElasticSearchAdapter elasticSearchAdapter,
+ private static final String AUTO_SUGGEST_TEMPLATE = "{ " + "\"results-size\": %d,"
+ + "\"suggest-text\": \"%s\"," + "\"suggest-field\": \"%s\"" + "}";
+
+ private static final String KEY_SEARCH_RESULT = "searchResult";
+ private static final String KEY_HITS = "hits";
+ private static final String KEY_DOCUMENT = "document";
+ private static final String KEY_CONTENT = "content";
+ private static final String KEY_TEXT = "text";
+ private static final String KEY_FILTER_LIST = "filterList";
+
+ public AggregateVnfSearchProvider(SearchServiceAdapter searchServiceAdapter,
String autoSuggestIndexName, String vnfSearchSuggestionRoute) {
mapper = new ObjectMapper();
- this.elasticSearchAdapter = elasticSearchAdapter;
+ this.searchServiceAdapter = searchServiceAdapter;
this.autoSuggestIndexName = autoSuggestIndexName;
this.vnfSearchSuggestionRoute = vnfSearchSuggestionRoute;
}
-
+
public void setAutoSuggestIndexName(String autoSuggestIndexName) {
this.autoSuggestIndexName = autoSuggestIndexName;
}
@@ -68,58 +77,96 @@ public class AggregateVnfSearchProvider implements SearchProvider {
public List<SearchSuggestion> search(QuerySearchEntity queryRequest) {
List<SearchSuggestion> returnList = new ArrayList<SearchSuggestion>();
-
try {
- /* Create suggestions query */
- JsonObject vnfSearch = VnfSearchQueryBuilder.createSuggestionsQuery(String.valueOf(queryRequest.getMaxResults()), queryRequest.getQueryStr());
+ final String fullUrlStr =
+ searchServiceAdapter.buildSuggestServiceQueryUrl(autoSuggestIndexName);
+ String postBody =
+ String.format(AUTO_SUGGEST_TEMPLATE, Integer.parseInt(queryRequest.getMaxResults()),
+ queryRequest.getQueryStr(), "entity_suggest");
+ OperationResult opResult =
+ searchServiceAdapter.doPost(fullUrlStr, postBody, "application/json");
+ if (opResult.getResultCode() == 200) {
+ returnList = generateSuggestionsForSearchResponse(opResult.getResult());
+ } else {
+ LOG.error(AaiUiMsgs.ERROR_PARSING_JSON_PAYLOAD_VERBOSE, opResult.getResult());
+ return returnList;
+ }
+ } catch (Exception exc) {
+ LOG.error(AaiUiMsgs.ERROR_GENERIC, "Search failed due to error = " + exc.getMessage());
+ }
- /* Parse suggestions response */
- OperationResult opResult = elasticSearchAdapter.doPost(
- elasticSearchAdapter.buildElasticSearchUrlForApi(autoSuggestIndexName,
- SparkyConstants.ES_SUGGEST_API),
- vnfSearch.toString(), MediaType.APPLICATION_JSON_TYPE);
+ return returnList;
+ }
- String result = opResult.getResult();
+ private List<SearchSuggestion> generateSuggestionsForSearchResponse(String operationResult) {
- if (!opResult.wasSuccessful()) {
- LOG.error(AaiUiMsgs.ERROR_PARSING_JSON_PAYLOAD_VERBOSE, result);
- return returnList;
- }
+ if (operationResult == null || operationResult.length() == 0) {
+ return null;
+ }
- JSONObject responseJson = new JSONObject(result);
- String suggestionsKey = "vnfs";
- JSONArray suggestionsArray = new JSONArray();
- JSONArray suggestions = responseJson.getJSONArray(suggestionsKey);
- if (suggestions.length() > 0) {
- suggestionsArray = suggestions.getJSONObject(0).getJSONArray("options");
- for (int i = 0; i < suggestionsArray.length(); i++) {
- JSONObject querySuggestion = suggestionsArray.getJSONObject(i);
- if (querySuggestion != null) {
- CommonSearchSuggestion responseSuggestion = new CommonSearchSuggestion();
- responseSuggestion.setText(querySuggestion.getString("text"));
- responseSuggestion.setRoute(vnfSearchSuggestionRoute);
- responseSuggestion.setHashId(NodeUtils.generateUniqueShaDigest(querySuggestion.getString("text")));
-
- // Extract filter list from JSON and add to response suggestion
- JSONObject payload = querySuggestion.getJSONObject("payload");
- if (payload.length() > 0) {
- JSONArray filterList = payload.getJSONArray("filterList");
- for (int filter = 0; filter < filterList.length(); filter++) {
- String filterValueString = filterList.getJSONObject(filter).toString();
- UiFilterValueEntity filterValue = mapper.readValue(filterValueString, UiFilterValueEntity.class);
- responseSuggestion.getFilterValues().add(filterValue);
- }
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode rootNode = null;
+ List<SearchSuggestion> suggestionEntityList = new ArrayList<SearchSuggestion>();
+
+ try {
+ rootNode = mapper.readTree(operationResult);
+ JsonNode hitsNode = rootNode.get(KEY_SEARCH_RESULT);
+ // Check if there are hits that are coming back
+ if (hitsNode.has(KEY_HITS)) {
+ ArrayNode hitsArray = (ArrayNode) hitsNode.get(KEY_HITS);
+
+ /*
+ * next we iterate over the values in the hit array elements
+ */
+ Iterator<JsonNode> nodeIterator = hitsArray.elements();
+ JsonNode entityNode = null;
+ CommonSearchSuggestion responseSuggestion = null;
+ JsonNode sourceNode = null;
+
+ while (nodeIterator.hasNext()) {
+ entityNode = nodeIterator.next();
+ String responseText = getValueFromNode(entityNode, KEY_TEXT);
+ // do the point transformation as we build the response?
+ responseSuggestion = new CommonSearchSuggestion();
+ responseSuggestion.setRoute(vnfSearchSuggestionRoute);
+ responseSuggestion.setText(responseText);
+ responseSuggestion.setHashId(NodeUtils.generateUniqueShaDigest(responseText));
+
+ sourceNode = entityNode.get(KEY_DOCUMENT).get(KEY_CONTENT);
+ if (sourceNode.has(KEY_FILTER_LIST)) {
+ ArrayNode filtersArray = (ArrayNode) sourceNode.get(KEY_FILTER_LIST);
+ for (int i = 0; i < filtersArray.size(); i++) {
+ String filterValueString = filtersArray.get(i).toString();
+ UiFilterValueEntity filterValue =
+ mapper.readValue(filterValueString, UiFilterValueEntity.class);
+ responseSuggestion.getFilterValues().add(filterValue);
}
- returnList.add(responseSuggestion);
}
+ suggestionEntityList.add(responseSuggestion);
}
}
- } catch (Exception exc) {
- LOG.error(AaiUiMsgs.ERROR_GENERIC, "Search failed due to error = " + exc.getMessage());
+ } catch (IOException exc) {
+ LOG.warn(AaiUiMsgs.SEARCH_RESPONSE_BUILDING_EXCEPTION, exc.getLocalizedMessage());
}
+ return suggestionEntityList;
- return returnList;
}
-
+
+ private String getValueFromNode(JsonNode node, String fieldName) {
+
+ if (node == null || fieldName == null) {
+ return null;
+ }
+
+ JsonNode valueNode = node.get(fieldName);
+
+ if (valueNode != null) {
+ return valueNode.asText();
+ }
+
+ return null;
+
+ }
+
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java
index 62d287e..c833bd3 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilder.java
@@ -34,7 +34,7 @@ import javax.json.JsonObjectBuilder;
*/
public class VnfSearchQueryBuilder {
-
+
/**
* Creates the suggestions query.
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java
index 59de87c..614968e 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/search/SearchServiceAdapter.java
@@ -42,7 +42,8 @@ import org.slf4j.MDC;
public class SearchServiceAdapter {
private static final String VALUE_QUERY = "query";
-
+ private static final String SUGGEST_QUERY = "suggest";
+
private RestClient client;
private RestEndpointConfig endpointConfig;
private String serviceApiVersion;
@@ -51,20 +52,22 @@ public class SearchServiceAdapter {
/**
* Instantiates a new search adapter.
- * @throws Exception
+ *
+ * @throws Exception
*/
- public SearchServiceAdapter(RestEndpointConfig endpointConfig, String serviceApiVersion) throws Exception {
+ public SearchServiceAdapter(RestEndpointConfig endpointConfig, String serviceApiVersion)
+ throws Exception {
client = RestClientFactory.buildClient(endpointConfig);
commonHeaders = new HashMap<String, List<String>>();
commonHeaders.put("Accept", Arrays.asList("application/json"));
commonHeaders.put(Headers.FROM_APP_ID, Arrays.asList("AAI-UI"));
-
+
this.serviceApiVersion = serviceApiVersion;
this.endpointConfig = endpointConfig;
}
-
+
public String getServiceApiVersion() {
return serviceApiVersion;
}
@@ -88,21 +91,19 @@ public class SearchServiceAdapter {
}
public OperationResult doGet(String url, String acceptContentType) {
- OperationResult or =
- client.get(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE);
+ OperationResult or = client.get(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE);
return new OperationResult(or.getResultCode(), or.getResult());
}
public OperationResult doPut(String url, String payload, String acceptContentType) {
- OperationResult or = client.put(url, payload, getTxnHeader(),
- MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE);
+ OperationResult or = client.put(url, payload, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE,
+ MediaType.APPLICATION_JSON_TYPE);
return new OperationResult(or.getResultCode(), or.getResult());
}
public OperationResult doDelete(String url, String acceptContentType) {
- OperationResult or =
- client.delete(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE);
+ OperationResult or = client.delete(url, getTxnHeader(), MediaType.APPLICATION_JSON_TYPE);
return new OperationResult(or.getResultCode(), or.getResult());
}
@@ -125,6 +126,17 @@ public class SearchServiceAdapter {
return buildSearchServiceUrlForApi(indexName, VALUE_QUERY);
}
+ /**
+ * Get Full URL for search
+ *
+ * @param api the api
+ * @param indexName
+ * @return the full url
+ */
+ public String buildSuggestServiceQueryUrl(String indexName) {
+ return buildSearchServiceUrlForApi(indexName, SUGGEST_QUERY);
+ }
+
public String buildSearchServiceUrlForApi(String indexName, String api) {
return String.format("https://%s:%s/services/search-data-service/%s/search/indexes/%s/%s",
endpointConfig.getEndpointIpAddress(), endpointConfig.getEndpointServerPort(),
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java
deleted file mode 100644
index ba64db0..0000000
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/config/TierSupportUiConstants.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.viewandinspect.config;
-
-/**
- * The Class TierSupportUiConstants.
- */
-public class TierSupportUiConstants {
-
- public static String APP_NAME = "AAIUI";
-
- /** Default to unix file separator if system property file.separator is null */
- public static final String FILESEP =
- (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
-
- public static String CONFIG_HOME = System.getProperty("CONFIG_HOME") + FILESEP;
- public static String AJSC_HOME = System.getProperty("AJSC_HOME") + FILESEP;
- public static String CONFIG_ROOT_LOCATION =
- AJSC_HOME + "bundleconfig" + FILESEP + "etc" + FILESEP;
- public static String STATIC_CONFIG_APP_LOCATION = CONFIG_ROOT_LOCATION + "appprops" + FILESEP;
- public static String DYNAMIC_CONFIG_APP_LOCATION = CONFIG_HOME;
-
- public static String CONFIG_OXM_LOCATION = CONFIG_HOME + "model" + FILESEP;
- public static String CONFIG_FILTERS_BASE_LOCATION = CONFIG_HOME + FILESEP;
- public static String CONFIG_AUTH_LOCATION = CONFIG_HOME + "auth" + FILESEP;
-
- public static String HOST = "host";
- public static String IP_ADDRESS = "ipAddress";
- public static String PORT = "port";
- public static String HTTP_PORT = "httpPort";
- public static String RETRIES = "numRequestRetries";
- public static String RESOURCE_VERSION = "resource-version";
- public static String URI = "URI";
-
- public static String AUTHORIZED_USERS_FILE_LOCATION =
- DYNAMIC_CONFIG_APP_LOCATION + "authorized-users.config";
- public static String USERS_FILE_LOCATION = DYNAMIC_CONFIG_APP_LOCATION + "users.config";
- public static String ROLES_FILE_LOCATION = DYNAMIC_CONFIG_APP_LOCATION + "roles.config";
- public static String PORTAL_AUTHENTICATION_FILE_LOCATION =
- DYNAMIC_CONFIG_APP_LOCATION + "portal" + FILESEP + "portal-authentication.properties";
-
- // Related to data-router properties
- public static String DR_URI_SUFFIX = "uriSuffix";
- public static String DR_CERT_NAME = "cert-name";
- public static String DR_KEYSTORE_PASSWORD = "keystore-password";
- public static String DR_KEYSTORE = "keystore";
- public static String DR_CONNECT_TIMEOUT = "connectTimeoutMs";
- public static String DR_READ_TIMEOUT = "readTimeoutMs";
-
- public static final String ES_SUGGEST_API = "_suggest";
- public static final String ES_COUNT_API = "_count";
- public static final String ES_SEARCH_API = "_search";
-
- public static final String UI_FILTER_VIEW_NAME_PARAMETER = "viewName";
- public static final String UI_FILTER_ID_LIST_PARAMETER = "filterIdList";
-
- public static final String ENTITY_AUTO_SUGGEST_INDEX_NAME_DEFAULT =
- "entityautosuggestindex-localhost";
- public static final String ENTITY_AUTO_SUGGEST_SETTINGS_FILE_DEFAULT =
- "/etc/autoSuggestSettings.json";
- public static final String ENTITY_AUTO_SUGGEST_MAPPINGS_FILE_DEFAULT =
- "/etc/autoSuggestMappings.json";
- public static final String ENTITY_DYNAMIC_MAPPINGS_FILE_DEFAULT = "/etc/dynamicMappings.json";
- public static final String FILTER_LIST_FILE_DEFAULT =
- CONFIG_FILTERS_BASE_LOCATION + "filters" + FILESEP + "aaiui_filters.json";
- public static final String FILTER_MAPPING_FILE_DEFAULT =
- CONFIG_FILTERS_BASE_LOCATION + "filters" + FILESEP + "aaiui_views.json";
-
- public static final String SUGGESTION_TEXT_SEPARATOR = " -- ";
-
- // Injected Attributes
- public static String URI_ATTR_NAME = "uri";
-
- public static final String URI_VERSION_REGEX_PATTERN = "aai/v[\\d]+/";
-
- public static final String getConfigPath(String configFile) {
- return AJSC_HOME + FILESEP + configFile;
- }
-
-}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java
deleted file mode 100644
index 67dd669..0000000
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNode.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.viewandinspect.entity;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
-/*
- * We can use annotations to differentiate between intermediate data we use to build the node, and
- * the data that we actually want to appear in the exported JSON.
- */
-
-/*
- * This is our current ( 14-June-2016 ) working schema that will remain organic until we get it just
- * right.
- *
- * { "item-type": "customer", "item-name-key": "subscriber-name", “item-name-value” :
- * “subscriber-name-123456789-aai847-data-01”, "item-properties": [{ "property-name":
- * "subscriber-name", "property-value": "subscriber-name-123456789-aai847-data-01" }, {
- * "property-name": "global-customer-id", "property-value":
- * "global-customer-id-123456789-aai847-data-01" } ], "node-meta": { “color” : “#f2d2d2”,
- * "isSearchTarget" : false, "nodeGroups" : "1,2,3,4" }, }
- *
- */
-
-
-/**
- * The Class JsonNode.
- */
-public class JsonNode {
-
- private String id;
- private String itemType;
- private String itemNameKey;
- private String itemNameValue;
- private Map<String, String> itemProperties;
- private NodeMeta nodeMeta;
-
- @JsonIgnore
- private boolean isRootNode;
-
-
- @JsonIgnore
- private String resourceKey;
- @JsonIgnore
- private Collection<String> inboundNeighbors;
-
- @JsonIgnore
- private Collection<String> outboundNeighbors;
-
-
- @JsonIgnore
- private static final Logger LOG = Logger.getLogger(JsonNode.class);
-
- private VisualizationConfigs visualizationConfigs;
-
-
- /**
- * Instantiates a new json node.
- *
- * @param ain the ain
- */
- public JsonNode(ActiveInventoryNode ain, VisualizationConfigs visualizationConfigs) {
- this.resourceKey = ain.getNodeId();
- this.itemProperties = ain.getProperties();
- this.setItemType(ain.getEntityType());
- this.setItemNameKey(ain.getPrimaryKeyName());
- this.setItemNameValue(ain.getPrimaryKeyValue());
- this.setId(ain.getNodeId());
- this.isRootNode = ain.isRootNode();
- this.visualizationConfigs = visualizationConfigs;
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("---");
- LOG.debug("JsonNode constructor using AIN = " + ain.dumpNodeTree(true));
- LOG.debug("---");
- }
-
- inboundNeighbors = ain.getInboundNeighbors();
- outboundNeighbors = ain.getOutboundNeighbors();
-
- nodeMeta = new NodeMeta(this.visualizationConfigs);
-
- nodeMeta.setNodeIssue(ain.isNodeIssue());
- nodeMeta.setNodeValidated(ain.isNodeValidated());
- nodeMeta.setNodeDepth(ain.getNodeDepth());
-
- nodeMeta.setNumInboundNeighbors(ain.getInboundNeighbors().size());
- nodeMeta.setNumOutboundNeighbors(ain.getOutboundNeighbors().size());
-
- nodeMeta.setAtMaxDepth(ain.isAtMaxDepth());
- nodeMeta.setSelfLinkResolved(!ain.isSelflinkRetrievalFailure());
- nodeMeta.setProcessingErrorOccurred(ain.isProcessingErrorOccurred());
- nodeMeta.setHasNeighbors(
- ain.getOutboundNeighbors().size() > 0 || ain.getInboundNeighbors().size() > 0);
- nodeMeta.setProcessingState(ain.getState());
-
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getItemNameKey() {
- return itemNameKey;
- }
-
- public String getItemNameValue() {
- return itemNameValue;
- }
-
- public Map<String, String> getItemProperties() {
- return itemProperties;
- }
-
- public String getItemType() {
- return itemType;
- }
-
- public String getResourceKey() {
- return resourceKey;
- }
-
- public void setItemNameKey(String itemNameKey) {
- this.itemNameKey = itemNameKey;
- }
-
- public void setItemNameValue(String itemNameValue) {
- this.itemNameValue = itemNameValue;
- }
-
- public void setItemProperties(HashMap<String, String> itemProperties) {
- this.itemProperties = itemProperties;
- }
-
- public void setItemType(String itemType) {
- this.itemType = itemType;
- }
-
- public void setResourceKey(String resourceKey) {
- this.resourceKey = resourceKey;
- }
-
- public NodeMeta getNodeMeta() {
- return nodeMeta;
- }
-
- public void setNodeMeta(NodeMeta nodeMeta) {
- this.nodeMeta = nodeMeta;
- }
-
- public boolean isRootNode() {
- return isRootNode;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "JsonNode [" + (id != null ? "id=" + id + ", " : "")
- + (itemType != null ? "itemType=" + itemType + ", " : "")
- + (itemNameKey != null ? "itemNameKey=" + itemNameKey + ", " : "")
- + (itemNameValue != null ? "itemNameValue=" + itemNameValue + ", " : "")
- + (itemProperties != null ? "itemProperties=" + itemProperties + ", " : "")
- + (nodeMeta != null ? "nodeMeta=" + nodeMeta + ", " : "")
- + (resourceKey != null ? "resourceKey=" + resourceKey + ", " : "")
- + (inboundNeighbors != null ? "inboundNeighbors=" + inboundNeighbors + ", " : "")
- + (outboundNeighbors != null ? "outboundNeighbors=" + outboundNeighbors : "") + "]";
- }
-
-
-}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNodeLink.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNodeLink.java
deleted file mode 100644
index 05672f3..0000000
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/viewandinspect/entity/JsonNodeLink.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.onap.aai.sparky.viewandinspect.entity;
-
-/*
- * Expected JSON Output:
- *
- * { JsonNodeLink : { id : <value>, source : <value>, target : <value> } }
- *
- */
-
-/**
- * The Class JsonNodeLink.
- */
-public class JsonNodeLink {
-
- protected String id;
- protected String source;
- protected String target;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getSource() {
- return source;
- }
-
- public void setSource(String source) {
- this.source = source;
- }
-
- public String getTarget() {
- return target;
- }
-
- public void setTarget(String target) {
- this.target = target;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- return "JsonNodeLink [id=" + id + ", source=" + source + ", target=" + target + "]";
- }
-
-}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProviderTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProviderTest.java
new file mode 100644
index 0000000..06ebafa
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProviderTest.java
@@ -0,0 +1,60 @@
+package org.onap.aai.sparky.aggregatevnf.search;
+
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.ws.rs.core.MediaType;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.aai.restclient.client.OperationResult;
+import org.onap.aai.restclient.enums.RestAuthenticationMode;
+import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
+import org.onap.aai.sparky.search.entity.QuerySearchEntity;
+
+public class AggregateVnfSearchProviderTest {
+
+ private AggregateVnfSearchProvider aggregateVnfSearchProvider;
+ private RestEndpointConfig restEndpointConfig;
+ private SearchServiceAdapter searchserviceAdapter;
+ private QuerySearchEntity querySearchEntity;
+ private String successResponsePayload;
+ private OperationResult successResult = null;
+ private OperationResult resultValue = null;
+ private String goodDrTargetUrl = "https://0.0.0.0:9502/ui-request/servicegraph";
+
+ @Before
+ public void init() throws Exception {
+
+ restEndpointConfig = new RestEndpointConfig();
+ successResponsePayload = "good-payload";
+ successResult = new OperationResult(200, successResponsePayload);
+ restEndpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
+ searchserviceAdapter = Mockito.mock(SearchServiceAdapter.class);
+ resultValue = Mockito.mock(OperationResult.class);
+ aggregateVnfSearchProvider =
+ new AggregateVnfSearchProvider(searchserviceAdapter, "auto-suggest", "schema");
+ querySearchEntity = new QuerySearchEntity();
+
+ }
+
+ @Test
+ public void updateValues() {
+
+ assertNotNull(aggregateVnfSearchProvider.search(querySearchEntity));
+ aggregateVnfSearchProvider.setAutoSuggestIndexName("auto-suggest-index-1");
+
+ }
+
+ @Test
+ public void testProxyMessage_Success() {
+ Mockito.when(searchserviceAdapter.doPost(Mockito.eq(goodDrTargetUrl), Mockito.anyString(),
+ Mockito.eq(MediaType.APPLICATION_JSON_TYPE.toString()))).thenReturn(successResult);
+ Mockito.when(resultValue.getResultCode()).thenReturn(200);
+ aggregateVnfSearchProvider.search(querySearchEntity);
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilderTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilderTest.java
new file mode 100644
index 0000000..9949702
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/VnfSearchQueryBuilderTest.java
@@ -0,0 +1,30 @@
+package org.onap.aai.sparky.aggregatevnf.search;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class VnfSearchQueryBuilderTest {
+
+ private VnfSearchQueryBuilder vnfSearchQueryBuilder;
+
+ @Before
+ public void init() throws Exception {
+
+ vnfSearchQueryBuilder = new VnfSearchQueryBuilder();
+
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateValues() {
+
+
+
+ assertNotNull(vnfSearchQueryBuilder.createSuggestionsQuery("10","queryString"));
+ assertNotNull(vnfSearchQueryBuilder.getTermBlob("suggest-vnf","firewall"));
+ assertNotNull(vnfSearchQueryBuilder.getSortCriteria("term","ascending"));
+
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java
index 1273e80..af441c7 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/ActiveInventoryAdapterTest.java
@@ -5,7 +5,6 @@ import static org.junit.Assert.assertNull;
import java.util.ArrayList;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.restclient.enums.RestAuthenticationMode;
@@ -14,50 +13,44 @@ import org.onap.aai.sparky.config.oxm.OxmModelLoader;
import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
public class ActiveInventoryAdapterTest {
-
- private OxmModelLoader oxmModelLoader;
- private OxmEntityLookup oxmEntityLookup;
- private RestEndpointConfig endpointConfig;
- private ActiveInventoryAdapter aaiAdapter;
- private ArrayList<String> queryParams;
-
- @Before
- public void init() throws Exception {
-
- oxmModelLoader = new OxmModelLoader();
- oxmEntityLookup = new OxmEntityLookup();
- endpointConfig = new RestEndpointConfig();
- queryParams = new ArrayList<String>();
- endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
- aaiAdapter = new ActiveInventoryAdapter(oxmModelLoader,oxmEntityLookup,endpointConfig);
- }
-
-
- @SuppressWarnings("static-access")
- @Test
- public void updateValues()throws Exception {
-
- assertNotNull(aaiAdapter.getMessageHeaders());
- assertNotNull(aaiAdapter.getBasicAuthenticationCredentials());
- assertNotNull(aaiAdapter.getResourceBasePath());
- assertNotNull(aaiAdapter.extractResourcePath(""));
- assertNotNull(aaiAdapter.getGenericQueryForSelfLink("",queryParams));
- assertNull(aaiAdapter.getSelfLinkForEntity("","",""));
- assertNotNull(aaiAdapter.queryActiveInventory("",""));
- assertNotNull(aaiAdapter.queryActiveInventoryWithRetries("","",4));
- aaiAdapter.setOxmEntityLookup(oxmEntityLookup);
- assertNotNull(aaiAdapter.getOxmEntityLookup());
- aaiAdapter.setEndpointConfig(endpointConfig);
- assertNotNull(aaiAdapter.getEndpointConfig());
-
- //assertNull(aaiAdapter.repairSelfLink("",""));
- //assertNotNull(aaiAdapter.repairSelfLink(null,""));
- //assertNotNull(aaiAdapter.getSelfLinkForEntity(null,"",""));
- //assertNull(aaiAdapter.getSelfLinkForEntity("",null,""));
- //assertNotNull(aaiAdapter.getSelfLinkForEntity("","",null));
- //assertNotNull(aaiAdapter.getSelfLinksByEntityType(""));
- //assertNotNull(aaiAdapter.getSelfLinksByEntityType(null));
- }
+
+ private OxmModelLoader oxmModelLoader;
+ private OxmEntityLookup oxmEntityLookup;
+ private RestEndpointConfig endpointConfig;
+ private ActiveInventoryAdapter aaiAdapter;
+ private ArrayList<String> queryParams;
+
+ @Before
+ public void init() throws Exception {
+
+ oxmModelLoader = new OxmModelLoader();
+ oxmEntityLookup = new OxmEntityLookup();
+ endpointConfig = new RestEndpointConfig();
+ queryParams = new ArrayList<String>();
+ endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
+ aaiAdapter = new ActiveInventoryAdapter(oxmModelLoader, oxmEntityLookup, endpointConfig);
+ }
+
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateValues() throws Exception {
+
+ assertNotNull(aaiAdapter.getMessageHeaders());
+ assertNotNull(aaiAdapter.getBasicAuthenticationCredentials());
+ assertNotNull(aaiAdapter.getResourceBasePath());
+ assertNotNull(aaiAdapter.extractResourcePath("/services/inventory/v12/"));
+ assertNotNull(aaiAdapter.getGenericQueryForSelfLink("", queryParams));
+ assertNull(aaiAdapter.getSelfLinkForEntity("pserver", "PrimaryKeyName", "PrimaryKeyValue"));
+ assertNotNull(
+ aaiAdapter.queryActiveInventory("https://server.proxy:8443/aai/v11/", "application/json"));
+ assertNotNull(aaiAdapter.queryActiveInventoryWithRetries(
+ "https://server.proxy:8443/aai/v11/business/customers/", "application/json", 4));
+ aaiAdapter.setOxmEntityLookup(oxmEntityLookup);
+ assertNotNull(aaiAdapter.getOxmEntityLookup());
+ aaiAdapter.setEndpointConfig(endpointConfig);
+ assertNotNull(aaiAdapter.getEndpointConfig());
+ }
}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/GizmoAdapterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/GizmoAdapterTest.java
new file mode 100644
index 0000000..b17b6fb
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/GizmoAdapterTest.java
@@ -0,0 +1,60 @@
+package org.onap.aai.sparky.dal;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.restclient.enums.RestAuthenticationMode;
+import org.onap.aai.sparky.config.oxm.OxmModelLoader;
+import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
+
+public class GizmoAdapterTest {
+
+ private OxmModelLoader oxmModelLoader;
+ private RestEndpointConfig endpointConfig;
+ private GizmoAdapter gizmoAdapter;
+
+ @Before
+ public void init() throws Exception {
+
+ oxmModelLoader = new OxmModelLoader();
+ endpointConfig = new RestEndpointConfig();
+ endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
+ endpointConfig.setEndpointIpAddress("10.147.110.199");
+ endpointConfig.setEndpointServerPort("9885");
+ endpointConfig.setBasicAuthUserName("sparky");
+ endpointConfig.setBasicAuthPassword("sparky");
+ gizmoAdapter = new GizmoAdapter(oxmModelLoader, endpointConfig);
+ }
+
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateValues() throws Exception {
+
+ assertNotNull(gizmoAdapter.getMessageHeaders());
+ assertNotNull(gizmoAdapter.getBasicAuthenticationCredentials());
+ gizmoAdapter.setRelationshipsBasePath("/services/inventory/relationships/v10/");
+ assertNotNull(gizmoAdapter.getRelationshipsBasePath());
+ gizmoAdapter.setInventoryBasePath("/services/inventory/v10/");
+ assertNotNull(gizmoAdapter.getInventoryBasePath());
+ assertNotNull(gizmoAdapter.extractResourcePath("/services/inventory/v10/"));
+ assertNotNull(gizmoAdapter.getFullInventoryUrl("/services/inventory/v10/"));
+ assertNotNull(gizmoAdapter.addServerDetailsToUrl("/services/inventory/v10/"));
+ assertNotNull(gizmoAdapter.getFullRelationshipUrl(
+ "https://server.proxy:8443/aai/v11/business/customers/customer/customer-4"));
+ assertNotNull(gizmoAdapter.getBasicAuthenticationCredentials());
+ assertNotNull(gizmoAdapter.repairRelationshipSelfLink(
+ "https://server.proxy:8443/aai/v11/business/customers/", "PrimaryKeyValue"));
+ assertNotNull(gizmoAdapter.repairInventorySelfLink(
+ "https://server.proxy:8443/aai/v11/business/customers/", "PrimaryKeyValue"));
+ assertNotNull(gizmoAdapter.queryGizmo("https://server.proxy:8443/aai/v11/business/customers/",
+ "application/json"));
+ assertNotNull(gizmoAdapter.queryGizmoWithRetries(
+ "https://server.proxy:8443/aai/v11/business/customers/", "application/json", 4));
+ assertNull(gizmoAdapter.getSelfLinksByEntityType("vserver"));
+ gizmoAdapter.setEndpointConfig(endpointConfig);
+ assertNotNull(gizmoAdapter.getEndpointConfig());
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java
index 63b3ff4..3dbc36b 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/editattributes/AttributeUpdaterTest.java
@@ -1,4 +1,3 @@
-package org.onap.aai.sparky.editattributes;
/**
* ============LICENSE_START===================================================
* SPARKY (AAI UI service)
@@ -23,8 +22,8 @@ package org.onap.aai.sparky.editattributes;
* ECOMP and OpenECOMP are trademarks
* and service marks of AT&T Intellectual Property.
*/
-/*
-package org.openecomp.sparky.editattributes;
+
+package org.onap.aai.sparky.editattributes;
import static org.junit.Assert.assertEquals;
@@ -33,46 +32,53 @@ import java.util.Map;
import javax.ws.rs.core.Response.Status;
+import org.eclipse.persistence.dynamic.DynamicType;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.Mockito;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.sparky.config.oxm.OxmEntityDescriptor;
import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
import org.onap.aai.sparky.config.oxm.OxmModelLoader;
-import org.onap.aai.sparky.dal.aai.config.ActiveInventoryConfig;
+import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
import org.onap.aai.sparky.editattributes.AttributeUpdater;
-import org.openecomp.sparky.dal.aai.config.ActiveInventoryConfigUtil;
+import org.onap.aai.sparky.editattributes.AttributeUpdater.AaiEditObject;
+
/**
* The Class AttributeUpdaterTest.
- *
+ */
public class AttributeUpdaterTest {
+ private ActiveInventoryAdapter aaiAdapter;
+
/**
* Sets the up.
*
* @throws Exception the exception
- *
+ */
@Before
- public void setUp() throws Exception {}
+ public void setUp() throws Exception {
+
+ aaiAdapter = Mockito.mock(ActiveInventoryAdapter.class);
+ }
/**
- * @throws Exception
+ * @throws Exception
*/
- /*
+
@Test
public void testUpdateObjectAttribute() throws Exception {
-
+
OxmEntityDescriptor desc = new OxmEntityDescriptor();
desc.addPrimaryKeyName("hostname");
desc.setEntityName("pserver");
-
- OxmEntityLookup entityLookup = OxmEntityLookup.getInstance();
+
+ OxmEntityLookup entityLookup = new OxmEntityLookup();
entityLookup.addEntityDescriptor("pserver", desc);
-
- AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup,
- new ActiveInventoryConfig(ActiveInventoryConfigUtil.getValidTestProperties()));
+
+ AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup, aaiAdapter);
Map<String, Object> attributes = new HashMap<>();
attributes.put("prov-status", "PREPROV");
attributes.put("in-maint", "true");
@@ -80,7 +86,7 @@ public class AttributeUpdaterTest {
"cloud-infrastructure/pservers/pserver/something", attributes, "someid");
assertEquals(Status.FORBIDDEN.getStatusCode(), result.getResultCode());
}
- */
+
// This needs the OXM file in place to work.
/**
@@ -88,62 +94,58 @@ public class AttributeUpdaterTest {
*
* @throws Exception the exception
*/
- //@Test
- /*public void testGetEditObjectFromUri() throws Exception {
-
+ @Test(expected = NullPointerException.class)
+ public void testGetEditObjectFromUri() throws Exception {
+
OxmModelLoader loader = new OxmModelLoader();
loader.setLatestVersionNum(11);
-
+
OxmEntityDescriptor desc = new OxmEntityDescriptor();
desc.addPrimaryKeyName("hostname");
desc.setEntityName("pserver");
-
- OxmEntityLookup entityLookup = OxmEntityLookup.getInstance();
+
+ OxmEntityLookup entityLookup = new OxmEntityLookup();
entityLookup.addEntityDescriptor("pserver", desc);
-
- DynamicType mockType = Mockito.mock(DynamicType.class);
- Class<? extends DynamicEntity> mockDynamicEntity = Mockito.mock(DynamicEntity.class);
- Mockito.when(mockType.getJavaClass()).thenReturn(mockDynamicEntity);
+ // DynamicType mockType = Mockito.mock(DynamicType.class);
+ // Class<? extends DynamicEntity> mockDynamicEntity = Mockito.mock(DynamicEntity.class);
-
-
-
- HashMap<String, DynamicType> typeLookup = new HashMap<String,DynamicType>();
- typeLookup.put("pserver", mockType);
+ // Mockito.when(mockType.getJavaClass()).thenReturn(mockDynamicEntity);
+
+
+
+ HashMap<String, DynamicType> typeLookup = new HashMap<String, DynamicType>();
+ // typeLookup.put("pserver", mockType);
entityLookup.setEntityTypeLookup(typeLookup);
-
-
- AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup,
- new ActiveInventoryConfig(ActiveInventoryConfigUtil.getValidTestProperties()));
- AaiEditObject result =
- updater.getEditObjectFromUri("cloud-infrastructure/pservers/pserver/mtznjtax101");
+
+
+ AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup, aaiAdapter);
+ AaiEditObject result = updater.getEditObjectFromUri(null);
assertEquals("Pserver", result.getObjectType());
assertEquals("pserver", result.getRootElement());
assertEquals("hostname", result.getKeyName());
assertEquals("mtznjtax101", result.getKeyValue());
- }*/
+ }
/**
* Test get relative uri.
*
* @throws Exception the exception
*/
- /*
+
@Test
public void testGetRelativeUri() throws Exception {
-
+
OxmEntityDescriptor desc = new OxmEntityDescriptor();
desc.addPrimaryKeyName("hostname");
desc.setEntityName("pserver");
-
- OxmEntityLookup entityLookup = OxmEntityLookup.getInstance();
+
+ OxmEntityLookup entityLookup = new OxmEntityLookup();
entityLookup.addEntityDescriptor("pserver", desc);
-
- AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup,
- new ActiveInventoryConfig(ActiveInventoryConfigUtil.getValidTestProperties()));
+
+ AttributeUpdater updater = new AttributeUpdater(new OxmModelLoader(), entityLookup, aaiAdapter);
// Test entity uri without "/aai/version/"
String result = updater.getRelativeUri("cloud-infrastructure/pservers/pserver/mtznjtax101");
assertEquals("/cloud-infrastructure/pservers/pserver/mtznjtax101", result);
@@ -159,6 +161,5 @@ public class AttributeUpdaterTest {
result = updater.getRelativeUri("/cloud-infrastructure/pservers/pserver/mtznjtax101");
assertEquals("/cloud-infrastructure/pservers/pserver/mtznjtax101", result);
}
-
+
}
-*/ \ No newline at end of file
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java
index 7963528..e463dde 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java
@@ -13,35 +13,39 @@ import org.onap.aai.restclient.enums.RestAuthenticationMode;
import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
public class SearchServiceAdapterTest {
-
- private SearchServiceAdapter searchServiceAdapter;
- private RestEndpointConfig endpointConfig;
-
- @Before
- public void init() throws Exception {
-
- endpointConfig = new RestEndpointConfig();
- endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
- searchServiceAdapter = new SearchServiceAdapter(endpointConfig,"1.0");
- }
-
-
- @Test
- public void updateValues() {
-
- searchServiceAdapter.setServiceApiVersion("2.0");
- assertNotNull(searchServiceAdapter.getServiceApiVersion());
- searchServiceAdapter.setEndpointConfig(endpointConfig);
- assertNotNull(searchServiceAdapter.getEndpointConfig());
- assertNotNull(searchServiceAdapter.doPost("https://10.247.40.25:8000","{maxResults:10, queryStr: f}","application/json"));
- assertNotNull(searchServiceAdapter.doGet("https://10.247.40.25:8000","application/json"));
- assertNotNull(searchServiceAdapter.doPut("https://10.247.40.25:8000","{maxResults:10, queryStr: f}","application/json"));
- assertNotNull(searchServiceAdapter.doDelete("https://10.247.40.25:8000","application/json"));
- assertNotNull(searchServiceAdapter.getTxnHeader());
- assertNotNull(searchServiceAdapter.buildSearchServiceQueryUrl("searchentity-localhost"));
- assertNotNull(searchServiceAdapter.buildSearchServiceUrlForApi("searchentity-localhost","2.0"));
-
-
- }
+
+ private SearchServiceAdapter searchServiceAdapter;
+ private RestEndpointConfig endpointConfig;
+
+ @Before
+ public void init() throws Exception {
+
+ endpointConfig = new RestEndpointConfig();
+ endpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
+ searchServiceAdapter = new SearchServiceAdapter(endpointConfig, "1.0");
+ }
+
+
+ @Test
+ public void updateValues() {
+
+ searchServiceAdapter.setServiceApiVersion("2.0");
+ assertNotNull(searchServiceAdapter.getServiceApiVersion());
+ searchServiceAdapter.setEndpointConfig(endpointConfig);
+ assertNotNull(searchServiceAdapter.getEndpointConfig());
+ assertNotNull(searchServiceAdapter.doPost("https://10.247.40.25:8000",
+ "{maxResults:10, queryStr: f}", "application/json"));
+ assertNotNull(searchServiceAdapter.doGet("https://10.247.40.25:8000", "application/json"));
+ assertNotNull(searchServiceAdapter.doPut("https://10.247.40.25:8000",
+ "{maxResults:10, queryStr: f}", "application/json"));
+ assertNotNull(searchServiceAdapter.doDelete("https://10.247.40.25:8000", "application/json"));
+ assertNotNull(searchServiceAdapter.getTxnHeader());
+ assertNotNull(searchServiceAdapter.buildSearchServiceQueryUrl("searchentity-localhost"));
+ assertNotNull(
+ searchServiceAdapter.buildSearchServiceUrlForApi("searchentity-localhost", "2.0"));
+ assertNotNull(searchServiceAdapter.buildSuggestServiceQueryUrl("searchentity-localhost"));
+
+
+ }
}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/AggregationEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/AggregationEntityTest.java
new file mode 100644
index 0000000..fd9f112
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/AggregationEntityTest.java
@@ -0,0 +1,33 @@
+package org.onap.aai.sparky.search.filters.entity;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class AggregationEntityTest {
+
+ private AggregationEntity aggregateEntity;
+
+ @Before
+ public void init() throws Exception {
+ aggregateEntity = new AggregationEntity("aggregate-1", "autosuggest", 10);
+
+ }
+
+ @Test
+ public void updateValues() {
+
+ aggregateEntity.setAggregationName("aggregate-2");
+ assertNotNull(aggregateEntity.getAggregationName());
+ aggregateEntity.setAggregationFieldName("autosearch");
+ assertNotNull(aggregateEntity.getAggregationFieldName());
+ assertNotNull(aggregateEntity.getJsonObject());
+ aggregateEntity.setSize(25);
+ assertEquals(25, aggregateEntity.getSize());
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilderTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilderTest.java
new file mode 100644
index 0000000..df2d0e9
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/BoolQueryBuilderTest.java
@@ -0,0 +1,31 @@
+package org.onap.aai.sparky.search.filters.entity;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class BoolQueryBuilderTest {
+
+ private BoolQueryBuilder boolQueryBuilder;
+ private MatchFilterCriteriaEntity matchQueryEntity;
+
+ @Before
+ public void init() throws Exception {
+
+ boolQueryBuilder = new BoolQueryBuilder();
+ matchQueryEntity = new MatchFilterCriteriaEntity("Criteria-1", "Value-1");
+
+ }
+
+ @Test
+ public void updateValues() {
+
+ boolQueryBuilder.addShouldFilter(matchQueryEntity);
+ boolQueryBuilder.addMustFilter(matchQueryEntity);
+ boolQueryBuilder.isMatchAll();
+ assertNotNull(boolQueryBuilder.getJsonObject());
+ boolQueryBuilder.setMinShouldMatch(25);
+
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntityTest.java
new file mode 100644
index 0000000..bf14cd7
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/MatchFilterCriteriaEntityTest.java
@@ -0,0 +1,30 @@
+package org.onap.aai.sparky.search.filters.entity;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class MatchFilterCriteriaEntityTest {
+
+ private MatchFilterCriteriaEntity matchFilterCriteriaEntity;
+
+ @Before
+ public void init() throws Exception {
+ matchFilterCriteriaEntity = new MatchFilterCriteriaEntity("criteria-1", "value-1");
+
+ }
+
+ @Test
+ public void updateValues() {
+
+ matchFilterCriteriaEntity.setCriteriaName("criteria-2");
+ assertNotNull(matchFilterCriteriaEntity.getCriteriaName());
+ matchFilterCriteriaEntity.setCriteriaValue("value-2");
+ assertNotNull(matchFilterCriteriaEntity.getCriteriaValue());
+ assertNotNull(matchFilterCriteriaEntity.getJsonObject());
+ assertNotNull(matchFilterCriteriaEntity.toString());
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/SearchFilterTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/SearchFilterTest.java
new file mode 100644
index 0000000..04744ac
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/SearchFilterTest.java
@@ -0,0 +1,35 @@
+package org.onap.aai.sparky.search.filters.entity;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class SearchFilterTest {
+
+ private SearchFilter searchFilter, searchFilter2, searchFilter3;
+ private ArrayList<String> lst = new ArrayList<String>();
+
+ @Before
+ public void init() throws Exception {
+ searchFilter = new SearchFilter();
+ searchFilter2 = new SearchFilter("Filter-1");
+ searchFilter3 = new SearchFilter("Filter-2", "running");
+
+ }
+
+ @Test
+ public void updateValues() {
+
+ searchFilter.setFilterId("filterID");
+ assertNotNull(searchFilter.getFilterId());
+ searchFilter.setValues(lst);
+ assertNotNull(searchFilter.getValues());
+ searchFilter.addValue(null);
+ assertNotNull(searchFilter.toString());
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntityTest.java
new file mode 100644
index 0000000..3af51f8
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterEntityTest.java
@@ -0,0 +1,55 @@
+package org.onap.aai.sparky.search.filters.entity;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.sparky.search.filters.config.UiFilterConfig;
+
+
+public class UiFilterEntityTest {
+
+ private UiFilterEntity uiFilterEntity, uiFilterEntity2;
+ private UiFilterConfig filterConfig;
+
+
+
+ @Before
+ public void init() throws Exception {
+
+ filterConfig = new UiFilterConfig("1", "Prov-Status", "Prov-Status", "DropDown", "false",
+ "Any Prov Status", null, "options", null, null);
+ uiFilterEntity = new UiFilterEntity();
+ uiFilterEntity2 = new UiFilterEntity(filterConfig);
+ }
+
+
+ @Test
+ public void updateValues() {
+
+ uiFilterEntity.setOptionsValues(null);
+ assertNull(uiFilterEntity.getOptionsValues());
+ uiFilterEntity.setDefaultValue(null);
+ assertNull(uiFilterEntity.getDefaultValue());
+ uiFilterEntity.setFilterValueList(null);
+ assertNull(uiFilterEntity.getFilterValueList());
+ uiFilterEntity.setFilterId("1");
+ assertNotNull(uiFilterEntity.getFilterId());
+ uiFilterEntity.setFilterName("Prov-Status");
+ assertNotNull(uiFilterEntity.getFilterName());
+ uiFilterEntity.setDisplayName("Prov-Status");
+ assertNotNull(uiFilterEntity.getDisplayName());
+ uiFilterEntity.setDataType("DropDown");
+ assertNotNull(uiFilterEntity.getDataType());
+ uiFilterEntity.setMultiSelect("false");
+ assertNotNull(uiFilterEntity.getMultiSelect());
+ uiFilterEntity.setWatermark("Any Prov Status");
+ assertNotNull(uiFilterEntity.getWatermark());
+ uiFilterEntity.setOptionsType("options");
+ assertNotNull(uiFilterEntity.getOptionsType());
+
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntityTest.java
new file mode 100644
index 0000000..07e8430
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/entity/UiFilterValueEntityTest.java
@@ -0,0 +1,39 @@
+package org.onap.aai.sparky.search.filters.entity;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class UiFilterValueEntityTest {
+
+ private UiFilterValueEntity uiFilterValueEntity;
+ private UiFilterValueEntity uiFilterValueEntity2;
+
+
+
+ @Before
+ public void init() throws Exception {
+ uiFilterValueEntity = new UiFilterValueEntity();
+ uiFilterValueEntity = new UiFilterValueEntity("1", "Prov", "Prov-Status");
+ }
+
+
+ @Test
+ public void updateValues() {
+
+ uiFilterValueEntity.setFilterId("1");
+ assertNotNull(uiFilterValueEntity.getFilterId());
+ uiFilterValueEntity.setFilterValue("Prov");
+ assertNotNull(uiFilterValueEntity.getFilterValue());
+ uiFilterValueEntity.setDisplayName("Prov-Status");
+ assertNotNull(uiFilterValueEntity.getDisplayName());
+ assertNotNull(uiFilterValueEntity.toString());
+ uiFilterValueEntity.setFilterId(null);
+ uiFilterValueEntity.setFilterValue(null);
+ uiFilterValueEntity.setDisplayName(null);
+ assertNotNull(uiFilterValueEntity.toString());
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/TestUserManager.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/TestUserManager.java
index c34854a..784d807 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/TestUserManager.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/TestUserManager.java
@@ -55,7 +55,7 @@ import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
-@RunWith(PowerMockRunner.class)
+
// @PrepareForTest(RolesConfig.class)
public class TestUserManager {
@@ -72,14 +72,20 @@ public class TestUserManager {
enum TestData {
// @formatter:off
- NO_FILE ("src/test/resources/portal/no-users.config"),
- CONCURRENT_USERS ("src/test/resources/portal/concurrent-users.config"),
- CONCURRENT_EDIT_USERS ("src/test/resources/portal/concurrent-edit-users.config");
-// ROLES_CONFIG_FILE ("src/test/resources/portal/roles.config");
+ NO_FILE("src/test/resources/portal/no-users.config"), CONCURRENT_USERS(
+ "src/test/resources/portal/concurrent-users.config"), CONCURRENT_EDIT_USERS(
+ "src/test/resources/portal/concurrent-edit-users.config");
+ // ROLES_CONFIG_FILE ("src/test/resources/portal/roles.config");
private String filename;
- TestData(String filename) {this.filename = filename;}
- public String getFilename() {return this.filename;}
+
+ TestData(String filename) {
+ this.filename = filename;
+ }
+
+ public String getFilename() {
+ return this.filename;
+ }
// @formatter:on
}
@@ -131,8 +137,8 @@ public class TestUserManager {
return pushTask(concurrentUsers, String.valueOf(NodeUtils.getRandomTxnId()));
};
- List<Callable<EcompUser>> callables = Arrays.asList(pushTask, pushTask, pushTask, pushTask,
- pushTask);
+ List<Callable<EcompUser>> callables =
+ Arrays.asList(pushTask, pushTask, pushTask, pushTask, pushTask);
ExecutorService executor = Executors.newWorkStealingPool();
executor.invokeAll(callables).stream().map(future -> {
@@ -174,9 +180,9 @@ public class TestUserManager {
return editTask(LOGINID_3, "Amy");
};
- List<Callable<EcompUser>> callables = Arrays.asList(pushTaskRandomId, pushTaskRandomId,
- pushTaskId3, editTaskId1, pushTaskRandomId, pushTaskRandomId, editTaskId3, editTaskId2,
- pushTaskRandomId);
+ List<Callable<EcompUser>> callables =
+ Arrays.asList(pushTaskRandomId, pushTaskRandomId, pushTaskId3, editTaskId1,
+ pushTaskRandomId, pushTaskRandomId, editTaskId3, editTaskId2, pushTaskRandomId);
ExecutorService executor = Executors.newWorkStealingPool();
List<EcompUser> userTasks = executor.invokeAll(callables).stream().map(future -> {
@@ -262,4 +268,4 @@ public class TestUserManager {
return user;
}
-} \ No newline at end of file
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/subscription/services/SubscriptionServiceTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/subscription/services/SubscriptionServiceTest.java
new file mode 100644
index 0000000..c32c13f
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/subscription/services/SubscriptionServiceTest.java
@@ -0,0 +1,51 @@
+package org.onap.aai.sparky.subscription.services;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aai.sparky.subscription.config.SubscriptionConfig;
+
+public class SubscriptionServiceTest {
+
+ private SubscriptionService subscriptionService, subscriptionService2;
+ private SubscriptionConfig subscriptionConfig, subscriptionConfig2;
+
+ @Before
+ public void init() throws Exception {
+ subscriptionConfig = new SubscriptionConfig();
+ subscriptionConfig.setSubscriptionTarget("portal");
+ subscriptionConfig.setSubscriptionOrigin("sparky");
+ subscriptionConfig.setSubscriptionMessageType("subscribe");
+ subscriptionConfig.setSubscriptionTopic("portal-dispalyNotification");
+ subscriptionConfig.setLaunchOITarget("portal");
+ subscriptionConfig.setLaunchOIOrigin("sparky");
+ subscriptionConfig.setLaunchOIMessageType("publish");
+ subscriptionConfig.setLaunchOITopic("portal-displayNotification");
+ subscriptionConfig.setIsLaunchOIEnabled(true);
+
+ subscriptionConfig2 = new SubscriptionConfig();
+ subscriptionConfig2.setSubscriptionTarget("");
+ subscriptionConfig2.setSubscriptionOrigin("");
+ subscriptionConfig2.setSubscriptionMessageType("");
+ subscriptionConfig2.setSubscriptionTopic("");
+ subscriptionConfig2.setLaunchOITarget("");
+ subscriptionConfig2.setLaunchOIOrigin("");
+ subscriptionConfig2.setLaunchOIMessageType("");
+ subscriptionConfig2.setLaunchOITopic("");
+ subscriptionConfig2.setIsLaunchOIEnabled(true);
+
+ subscriptionService = new SubscriptionService(subscriptionConfig);
+ subscriptionService2 = new SubscriptionService(subscriptionConfig2);
+
+ }
+
+ @Test
+ public void updateValues() throws Exception {
+
+ assertNotNull(subscriptionService.buildSubscriptionPayload());
+ assertNotNull(subscriptionService2.buildSubscriptionPayload());
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java
new file mode 100644
index 0000000..a55e3ee
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java
@@ -0,0 +1,34 @@
+package org.onap.aai.sparky.util;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.Properties;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ConfigHelperTest {
+
+ private ConfigHelper configHelper;
+ private Properties props;
+
+ @Before
+ public void init() throws Exception {
+ configHelper = new ConfigHelper();
+ props = new Properties();
+
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateValues() throws Exception {
+
+
+ assertNotNull(configHelper.getConfigWithPrefix("aai-ui", props));
+ assertFalse(configHelper.isEssDevModeEnabled());
+ assertNotNull(configHelper.getFilepath("sparky-aaui", false));
+
+ }
+
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java
new file mode 100644
index 0000000..75b1ed1
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/NodeUtilsTest.java
@@ -0,0 +1,59 @@
+package org.onap.aai.sparky.util;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.ArrayList;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+
+public class NodeUtilsTest {
+
+
+ private NodeUtils nodeUtils;
+ private JsonNode jsonNode, jsonNode2;
+ private ArrayList<String> lst;
+ private Object obj;
+
+ @Before
+ public void init() throws Exception {
+ nodeUtils = new NodeUtils();
+ jsonNode = JsonNodeFactory.instance.objectNode();
+ jsonNode2 = jsonNode;
+ lst = new ArrayList<String>();
+ obj = new Object();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateValues() throws IOException {
+
+
+ assertNotNull(nodeUtils.buildDepthPadding(2));
+ assertNotNull(nodeUtils.isNumeric("234"));
+ assertNull(nodeUtils.calculateEditAttributeUri(null));
+ assertNotNull(nodeUtils.generateUniqueShaDigest("unique-101"));
+ assertNull(nodeUtils.getNodeFieldAsText(jsonNode,""));
+ assertNotNull(nodeUtils.getDurationBreakdown(2));
+ assertTrue(nodeUtils.isEqual(jsonNode,jsonNode2));
+ assertNotNull(nodeUtils.concatArray(lst));
+ assertNotNull(nodeUtils.concatArray(lst," "));
+ assertNotNull(nodeUtils.getDurationBreakdown(2));
+ assertNotNull(nodeUtils.buildEntityResourceKey("vserver","1232342"));
+ assertNull(nodeUtils.extractResourceIdFromLink(null));
+ assertNotNull(nodeUtils.getXmlStreamConstantAsStr(2));
+ assertNotNull(nodeUtils.convertObjectToJson(obj,false));
+ assertNull(nodeUtils.convertJsonStrToJsonNode(null));
+ assertNull(nodeUtils.extractObjectValueByKey(null,null));
+ assertNull(nodeUtils.extractFieldValueFromObject(null,null));
+
+
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java
index 5dbf7bb..dfa4b27 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/config/VisualizationConfigTest.java
@@ -13,50 +13,54 @@ import org.junit.Test;
public class VisualizationConfigTest {
- private VisualizationConfigs visualConfig;
- private ArrayList<String> shallowEntities;
-
- @Before
- public void init() throws Exception {
- visualConfig = new VisualizationConfigs();
- shallowEntities = new ArrayList<String>();
-
- }
-
-
- @Test
- public void updateValues() {
-
- visualConfig.setShallowEntities(shallowEntities);
- assertNotNull(visualConfig.getShallowEntities());
- visualConfig.setMakeAllNeighborsBidirectional(true);
- assertTrue(visualConfig.makeAllNeighborsBidirectional());
- visualConfig.setSelectedSearchedNodeClassName("selectedsearchedNodeClass");
- assertNotNull(visualConfig.getSelectedSearchedNodeClassName());
- visualConfig.setGeneralNodeClassName("generalNodeClass");
- assertNotNull(visualConfig.getGeneralNodeClassName());
- visualConfig.setSearchNodeClassName("searchedNodeClass");
- assertNotNull(visualConfig.getSearchNodeClassName());
- visualConfig.setAaiEntityNodeDescriptors("/etc/aaiEntityNodeDescriptors.json");
- assertNotNull(visualConfig.getAaiEntityNodeDescriptors());
- visualConfig.setVisualizationDebugEnabled(true);
- assertTrue(visualConfig.isVisualizationDebugEnabled());
- visualConfig.setMaxSelfLinkTraversalDepth(3);
- assertEquals(3,visualConfig.getMaxSelfLinkTraversalDepth());
- visualConfig.setNumOfThreadsToFetchNodeIntegrity(25);
- assertEquals(25,visualConfig.getNumOfThreadsToFetchNodeIntegrity());
- assertNotNull(visualConfig.toString());
- visualConfig.setAaiEntityNodeDescriptors(null);
- assertNull(visualConfig.getAaiEntityNodeDescriptors());
- visualConfig.setGeneralNodeClassName(null);
- assertNull(visualConfig.getGeneralNodeClassName());
- visualConfig.setSearchNodeClassName(null);
- assertNull(visualConfig.getSearchNodeClassName());
- visualConfig.setSelectedSearchedNodeClassName(null);
- assertNull(visualConfig.getSelectedSearchedNodeClassName());
- assertNotNull(visualConfig.toString());
-
-
- }
-
+ private VisualizationConfigs visualConfig;
+ private ArrayList<String> shallowEntities;
+
+ @Before
+ public void init() throws Exception {
+ visualConfig = new VisualizationConfigs();
+ shallowEntities = new ArrayList<String>();
+
+ }
+
+
+ @Test
+ public void updateValues() {
+
+ visualConfig.setShallowEntities(shallowEntities);
+ assertNotNull(visualConfig.getShallowEntities());
+ visualConfig.setGizmoEnabled(true);
+ assertTrue(visualConfig.isGizmoEnabled());
+ visualConfig.setMakeAllNeighborsBidirectional(true);
+ assertTrue(visualConfig.makeAllNeighborsBidirectional());
+ visualConfig.setSelectedSearchedNodeClassName("selectedsearchedNodeClass");
+ assertNotNull(visualConfig.getSelectedSearchedNodeClassName());
+ visualConfig.setGeneralNodeClassName("generalNodeClass");
+ assertNotNull(visualConfig.getGeneralNodeClassName());
+ visualConfig.setSearchNodeClassName("searchedNodeClass");
+ assertNotNull(visualConfig.getSearchNodeClassName());
+ visualConfig.setAaiEntityNodeDescriptors("/etc/aaiEntityNodeDescriptors.json");
+ assertNotNull(visualConfig.getAaiEntityNodeDescriptors());
+ visualConfig.setVisualizationDebugEnabled(true);
+ assertTrue(visualConfig.isVisualizationDebugEnabled());
+ visualConfig.setMaxSelfLinkTraversalDepth(3);
+ assertEquals(3, visualConfig.getMaxSelfLinkTraversalDepth());
+ visualConfig.setNumOfThreadsToFetchNodeIntegrity(25);
+ assertEquals(25, visualConfig.getNumOfThreadsToFetchNodeIntegrity());
+ assertNotNull(visualConfig.toString());
+ visualConfig.setShallowEntities(null);
+ assertNull(visualConfig.getShallowEntities());
+ visualConfig.setAaiEntityNodeDescriptors(null);
+ assertNull(visualConfig.getAaiEntityNodeDescriptors());
+ visualConfig.setGeneralNodeClassName(null);
+ assertNull(visualConfig.getGeneralNodeClassName());
+ visualConfig.setSearchNodeClassName(null);
+ assertNull(visualConfig.getSearchNodeClassName());
+ visualConfig.setSelectedSearchedNodeClassName(null);
+ assertNull(visualConfig.getSelectedSearchedNodeClassName());
+ assertNotNull(visualConfig.toString());
+
+
+ }
+
}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoEntityTest.java
new file mode 100644
index 0000000..4080a02
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoEntityTest.java
@@ -0,0 +1,62 @@
+package org.onap.aai.sparky.viewandinspect.entity;
+
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class GizmoEntityTest {
+
+ private GizmoEntity gizmoEntity;
+ private Map<String, String> props;
+ private GizmoRelationshipHint[] gizmoRelationshipHintArr;
+
+
+
+ @Before
+ public void init() throws Exception {
+
+ gizmoEntity = new GizmoEntity();
+ props = new HashMap<String, String>();
+ }
+
+ @Test
+ public void updateValues() {
+
+
+ gizmoEntity.setId("1664646");
+ assertNotNull(gizmoEntity.getId());
+ gizmoEntity.setType("pserver");
+ assertNotNull(gizmoEntity.getType());
+ gizmoEntity.setUrl("https://magicaltest.com:6666/v2/tenant-id/servers/vserver-id");
+ assertNotNull(gizmoEntity.getUrl());
+ gizmoEntity.setProperties(props);
+ assertNotNull(gizmoEntity.getProperties());
+ gizmoEntity.setIn(gizmoRelationshipHintArr);
+ assertNull(gizmoEntity.getIn());
+ gizmoEntity.setOut(gizmoRelationshipHintArr);
+ assertNull(gizmoEntity.getOut());
+ assertNotNull(gizmoEntity.toString());
+
+
+ gizmoEntity.setId(null);
+ assertNull(gizmoEntity.getId());
+ gizmoEntity.setType(null);
+ assertNull(gizmoEntity.getType());
+ gizmoEntity.setUrl(null);
+ assertNull(gizmoEntity.getUrl());
+ gizmoEntity.setProperties(null);
+ assertNull(gizmoEntity.getProperties());
+ gizmoEntity.setIn(null);
+ assertNull(gizmoEntity.getIn());
+ gizmoEntity.setOut(null);
+ assertNull(gizmoEntity.getOut());
+ assertNotNull(gizmoEntity.toString());
+
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipEntityTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipEntityTest.java
new file mode 100644
index 0000000..2f00a5d
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipEntityTest.java
@@ -0,0 +1,62 @@
+package org.onap.aai.sparky.viewandinspect.entity;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class GizmoRelationshipEntityTest {
+
+
+ private GizmoRelationshipEntity gizmoRelationshipEntity;
+ private Map<String, String> props;
+
+
+
+ @Before
+ public void init() throws Exception {
+
+ gizmoRelationshipEntity = new GizmoRelationshipEntity();
+ props = new HashMap<String, String>();
+
+ }
+
+ @Test
+ public void updateValues() {
+
+
+ gizmoRelationshipEntity.setId("1664646");
+ assertNotNull(gizmoRelationshipEntity.getId());
+ gizmoRelationshipEntity.setType("pserver");
+ assertNotNull(gizmoRelationshipEntity.getType());
+ gizmoRelationshipEntity.setUrl("https://magicaltest.com:6666/v2/tenant-id/servers/vserver-id");
+ assertNotNull(gizmoRelationshipEntity.getUrl());
+ gizmoRelationshipEntity.setSource("pserver");
+ assertNotNull(gizmoRelationshipEntity.getSource());
+ gizmoRelationshipEntity.setTarget("generic-vnf");
+ assertNotNull(gizmoRelationshipEntity.getTarget());
+ gizmoRelationshipEntity.setProperties(props);
+ assertNotNull(gizmoRelationshipEntity.getProperties());
+ assertNotNull(gizmoRelationshipEntity.toString());
+
+ gizmoRelationshipEntity.setId(null);
+ assertNull(gizmoRelationshipEntity.getId());
+ gizmoRelationshipEntity.setType(null);
+ assertNull(gizmoRelationshipEntity.getType());
+ gizmoRelationshipEntity.setUrl(null);
+ assertNull(gizmoRelationshipEntity.getUrl());
+ gizmoRelationshipEntity.setSource(null);
+ assertNull(gizmoRelationshipEntity.getSource());
+ gizmoRelationshipEntity.setTarget(null);
+ assertNull(gizmoRelationshipEntity.getTarget());
+ gizmoRelationshipEntity.setProperties(null);
+ assertNull(gizmoRelationshipEntity.getProperties());
+ assertNotNull(gizmoRelationshipEntity.toString());
+
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipHintTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipHintTest.java
new file mode 100644
index 0000000..b2c6ad9
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/entity/GizmoRelationshipHintTest.java
@@ -0,0 +1,37 @@
+package org.onap.aai.sparky.viewandinspect.entity;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class GizmoRelationshipHintTest {
+
+ private GizmoRelationshipHint gizmoRelationshipHint;
+
+ @Before
+ public void init() throws Exception {
+
+ gizmoRelationshipHint = new GizmoRelationshipHint();
+
+ }
+
+ @Test
+ public void updateValues() {
+
+
+ gizmoRelationshipHint.setId("1664646");
+ assertNotNull(gizmoRelationshipHint.getId());
+ gizmoRelationshipHint.setType("pserver");
+ assertNotNull(gizmoRelationshipHint.getType());
+ gizmoRelationshipHint.setUrl("https://magicaltest.com:6666/v2/tenant-id/servers/vserver-id");
+ assertNotNull(gizmoRelationshipHint.getUrl());
+ gizmoRelationshipHint.setSource("pserver");
+ assertNotNull(gizmoRelationshipHint.getSource());
+ gizmoRelationshipHint.setTarget("generic-vnf");
+ assertNotNull(gizmoRelationshipHint.getTarget());
+
+
+
+ }
+}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContextTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContextTest.java
new file mode 100644
index 0000000..ed7caeb
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseGizmoVisualizationContextTest.java
@@ -0,0 +1,110 @@
+package org.onap.aai.sparky.viewandinspect.services;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.security.SecureRandom;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+
+import org.hamcrest.Matcher;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
+import org.onap.aai.cl.api.Logger;
+import org.onap.aai.cl.eelf.LoggerFactory;
+import org.onap.aai.cl.mdc.MdcContext;
+import org.onap.aai.restclient.client.OperationResult;
+import org.onap.aai.sparky.config.oxm.OxmEntityLookup;
+import org.onap.aai.sparky.config.oxm.OxmModelLoader;
+import org.onap.aai.sparky.config.oxm.OxmModelProcessor;
+import org.onap.aai.sparky.dal.ActiveInventoryAdapter;
+import org.onap.aai.sparky.dal.GizmoAdapter;
+import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
+import org.onap.aai.sparky.sync.entity.SearchableEntity;
+import org.onap.aai.sparky.util.NodeUtils;
+import org.onap.aai.sparky.util.StringCollectionContainsMatcher;
+import org.onap.aai.sparky.util.TestResourceLoader;
+import org.onap.aai.sparky.viewandinspect.config.VisualizationConfigs;
+import org.onap.aai.sparky.viewandinspect.entity.ActiveInventoryNode;
+import org.onap.aai.sparky.viewandinspect.entity.QueryParams;
+import org.onap.aai.sparky.viewandinspect.enumeration.NodeProcessingState;
+
+public class BaseGizmoVisualizationContextTest {
+
+
+
+ private static SecureRandom secureRandom = new SecureRandom();
+ private static Logger LOG =
+ LoggerFactory.getInstance().getLogger(BaseGizmoVisualizationContextTest.class);
+
+ private BaseGizmoVisualizationContext baseGizmoVisualizationContext;
+ private ExecutorService graphExecutorService;
+ private VisualizationConfigs visualizationConfig;
+
+ private OxmEntityLookup oxmEntityLookup;
+
+ private GizmoAdapter gizmoAdapter;
+ private RestEndpointConfig gizmoRestEndPointConfig;
+
+ @Before
+ public void init() throws Exception {
+ long contextId = secureRandom.nextLong();
+ baseGizmoVisualizationContext = new BaseGizmoVisualizationContext(contextId, gizmoAdapter,
+ graphExecutorService, visualizationConfig, oxmEntityLookup);
+
+ graphExecutorService = NodeUtils.createNamedExecutor("SLNC-WORKER", 5, LOG);
+ visualizationConfig = new VisualizationConfigs();
+
+ ArrayList<String> shallowEntities = new ArrayList<String>();
+ shallowEntities.add("cloud-region");
+
+ visualizationConfig.setShallowEntities(shallowEntities);
+ visualizationConfig.setMaxSelfLinkTraversalDepth(2);
+
+ oxmEntityLookup = new OxmEntityLookup();
+
+ gizmoAdapter = Mockito.mock(GizmoAdapter.class);
+
+
+ Set<OxmModelProcessor> processors = new HashSet<OxmModelProcessor>();
+
+ processors.add(oxmEntityLookup);
+
+
+ OxmModelLoader oxmModelLoader = new OxmModelLoader(-1, processors);
+ oxmModelLoader.loadLatestOxmModel();
+
+ gizmoRestEndPointConfig = new RestEndpointConfig();
+ gizmoRestEndPointConfig.setNumRequestRetries(5);
+
+ Mockito.when(gizmoAdapter.getEndpointConfig()).thenReturn(gizmoRestEndPointConfig);
+
+ MdcContext.initialize("" + secureRandom.nextLong(), "AAI-UI", "", "partner-name",
+ "localhost:4242");
+
+
+ }
+
+ @Test
+ public void validateBasicConstruction() throws Exception {
+
+ long contextId = secureRandom.nextLong();
+
+ baseGizmoVisualizationContext = new BaseGizmoVisualizationContext(contextId, gizmoAdapter,
+ graphExecutorService, visualizationConfig, oxmEntityLookup);
+
+ assertEquals(contextId, baseGizmoVisualizationContext.getContextId());
+
+ }
+
+
+
+}