summaryrefslogtreecommitdiffstats
path: root/sparkybe-onap-service/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'sparkybe-onap-service/src/test/java')
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregatevnf/search/AggregateVnfSearchProviderTest.java3
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/SearchServiceAdapterTest.java3
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/FilterProcessorTest.java98
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/SparkyTestConstants.java4
4 files changed, 18 insertions, 90 deletions
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
index 06ebafa..2a8e503 100644
--- 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
@@ -50,8 +50,7 @@ public class AggregateVnfSearchProviderTest {
@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(searchserviceAdapter.doPost(Mockito.eq(goodDrTargetUrl), Mockito.anyString())).thenReturn(successResult);
Mockito.when(resultValue.getResultCode()).thenReturn(200);
aggregateVnfSearchProvider.search(querySearchEntity);
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 ca7eab9..59db5c2 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
@@ -33,8 +33,7 @@ public class SearchServiceAdapterTest {
assertNotNull(searchServiceAdapter.getServiceApiVersion());
searchServiceAdapter.setEndpointConfig(endpointConfig);
assertNotNull(searchServiceAdapter.getEndpointConfig());
- assertNotNull(searchServiceAdapter.doPost("https://aai.search.service:8000",
- "{maxResults:10, queryStr: f}", "application/json"));
+ assertNotNull(searchServiceAdapter.doPost("https://aai.search.service:8000", "{maxResults:10, queryStr: f}"));
assertNotNull(searchServiceAdapter.doGet("https://aai.search.service:8000", "application/json"));
assertNotNull(searchServiceAdapter.doPut("https://aai.search.service:8000",
"{maxResults:10, queryStr: f}", "application/json"));
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/FilterProcessorTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/FilterProcessorTest.java
index 0644a53..f313a3a 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/FilterProcessorTest.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/search/filters/FilterProcessorTest.java
@@ -35,7 +35,6 @@ import java.util.ArrayList;
import java.util.List;
import javax.json.Json;
-import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.json.stream.JsonParsingException;
@@ -44,25 +43,22 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
-import org.apache.camel.component.restlet.RestletConstants;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.impl.DefaultExchange;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.onap.aai.restclient.enums.RestAuthenticationMode;
import org.onap.aai.sparky.config.SparkyResourceLoader;
-import org.onap.aai.sparky.dal.ElasticSearchAdapter;
import org.onap.aai.sparky.dal.rest.RestClientConstructionException;
import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig;
-import org.onap.aai.sparky.search.filters.FilterProcessor;
-import org.onap.aai.sparky.search.filters.FilteredSearchHelper;
+import org.onap.aai.sparky.search.SearchServiceAdapter;
+import org.onap.aai.sparky.search.filters.config.FiltersConfig;
+import org.onap.aai.sparky.search.filters.config.FiltersDetailsConfig;
+import org.onap.aai.sparky.search.filters.config.FiltersForViewsConfig;
import org.onap.aai.sparky.search.filters.config.UiFilterConfig;
import org.onap.aai.sparky.search.filters.config.UiFilterListItemConfig;
import org.onap.aai.sparky.search.filters.config.UiFilterOptionsValuesConfig;
-import org.onap.aai.sparky.search.filters.config.FiltersDetailsConfig;
-import org.onap.aai.sparky.search.filters.config.FiltersConfig;
import org.onap.aai.sparky.search.filters.config.UiViewListItemConfig;
import org.onap.aai.sparky.search.filters.entity.DiscoverFiltersRequest;
import org.onap.aai.sparky.search.filters.entity.ViewConfiguration;
@@ -70,10 +66,6 @@ import org.onap.aai.sparky.search.filters.entity.ViewFilter;
import org.onap.aai.sparky.util.HttpServletHelper;
import org.onap.aai.sparky.util.NodeUtils;
import org.onap.aai.sparky.util.SparkyTestConstants;
-import org.onap.aai.sparky.search.filters.config.FiltersForViewsConfig;
-import org.restlet.Request;
-import org.restlet.Response;
-import org.restlet.data.MediaType;
import org.restlet.data.Status;
import org.springframework.core.io.DefaultResourceLoader;
@@ -130,14 +122,6 @@ public class FilterProcessorTest {
ViewConfiguration viewInspectConfig = new ViewConfiguration("viewInspect");
views.add(generateViewConfig(viewInspectConfig));
- // Data Integrity - 4 Filters
- ViewConfiguration dataIntegrityConfig = new ViewConfiguration("dataIntegrity");
- dataIntegrityConfig.addViewFilter(new ViewFilter("3", null));
- dataIntegrityConfig.addViewFilter(new ViewFilter("4", null));
- dataIntegrityConfig.addViewFilter(new ViewFilter("5", defaultValue));
- dataIntegrityConfig.addViewFilter(new ViewFilter("6", null));
- views.add(generateViewConfig(dataIntegrityConfig));
-
uiViewsConfig.setViews(views);
viewFilterConfig.setViewsConfig(uiViewsConfig);
@@ -156,10 +140,7 @@ public class FilterProcessorTest {
List<UiFilterConfig> uiFilterConfig = new ArrayList<UiFilterConfig>();
uiFilterConfig.add(new UiFilterConfig("1", "filterName1", "Display Name 1", "dropDown", "false", "Any 1", null, "options", null, null));
uiFilterConfig.add(new UiFilterConfig("2", "filterName2", "Display Name 2", "dropDown", "false", "Any 2", null, "options", null, null));
- uiFilterConfig.add(new UiFilterConfig("3", "filterName3", "Display Name 3", "dropDown", "false", "Any 3", null, "options", null, null));
- uiFilterConfig.add(new UiFilterConfig("4", "filterName4", "Display Name 4", "dropDown", "false", "Any 4", null, "options", null, null));
uiFilterConfig.add(new UiFilterConfig("5", "filterName5", "Display Name 5", "date", "false", "Any 5", defaultValue, "dynamicOptions", optionsValues, null));
- uiFilterConfig.add(new UiFilterConfig("6", "filterName6", "Display Name 6", "dropDown", "false", "Any 6", null, "options", null, null));
uiFilterConfig.add(new UiFilterConfig("7", "filterName7", "Display Name 7", "dropDown", "false", "Any 7", null, "options", null, null));
uiFilterConfig.add(new UiFilterConfig("8", "filterName8", "Display Name 8", "dropDown", "false", "Any 8", null, "options", null, null));
@@ -171,7 +152,7 @@ public class FilterProcessorTest {
}
@Before
- public void init()throws RestClientConstructionException {
+ public void init() throws Exception {
camelContext = new DefaultCamelContext();
exchange = new DefaultExchange(camelContext);
@@ -183,8 +164,12 @@ public class FilterProcessorTest {
//TODO-> edit the following:FilteredSearchHelper & FilterProcessor to pass in the correct parameters
restEndpointConfig = new RestEndpointConfig();
restEndpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
- filteredSearchHelper = new FilteredSearchHelper(new FiltersConfig(),
- new FilterElasticSearchAdapter(new ElasticSearchAdapter(restEndpointConfig)));
+
+ SparkyResourceLoader resourceLoader = new SparkyResourceLoader();
+ resourceLoader.setResourceLoader(new DefaultResourceLoader());
+ FiltersConfig filtersConfig = new FiltersConfig(SparkyTestConstants.FILTERS_JSON_FILE, SparkyTestConstants.VIEWS_JSON_FILE, resourceLoader);
+
+ filteredSearchHelper = new FilteredSearchHelper(filtersConfig, new SearchServiceAdapter(restEndpointConfig, "1.0"));
filterProcessor = new FilterProcessor();
mapper = new ObjectMapper();
@@ -227,14 +212,9 @@ public class FilterProcessorTest {
SparkyResourceLoader resourceLoader = new SparkyResourceLoader();
resourceLoader.setResourceLoader(new DefaultResourceLoader());
- filterProcessor.setFilteredSearchHelper(filteredSearchHelper);
-
- FiltersConfig filtersConfig = new FiltersConfig();
- filtersConfig.initializeFiltersDetailsConfig(resourceLoader.getResourceAsFile(SparkyTestConstants.FILTERS_JSON_FILE, false));
- filtersConfig.initializeFiltersForViewsConfig(resourceLoader.getResourceAsFile(SparkyTestConstants.VIEWS_JSON_FILE, false));
-
+ FiltersConfig filtersConfig = new FiltersConfig(SparkyTestConstants.FILTERS_JSON_FILE, SparkyTestConstants.VIEWS_JSON_FILE, resourceLoader);
filteredSearchHelper.setFiltersConfig(filtersConfig);
-
+ filterProcessor.setFilteredSearchHelper(filteredSearchHelper);
}
@@ -260,57 +240,7 @@ public class FilterProcessorTest {
JsonObject vnfFilters = vnfResponsePayload.getJsonObject("filters");
assertNotNull(vnfFilters);
- assertEquals(0, vnfFilters.size());
-
- //JsonObject filterOne = vnfFilters.getJsonObject("1");
- //assertNotNull(filterOne);
- //assertEquals("Display Name 1", filterOne.getString("label"));
-
- JsonObject filterEight = vnfFilters.getJsonObject("8");
- //assertNotNull(filterEight);
- // JsonObject eightInnerControl = filterEight.getJsonObject("controls").getJsonObject("filterName8");
- // assertEquals(4, eightInnerControl.size());
- //assertEquals("dropDown", eightInnerControl.getString("type"));
- //assertEquals("false", eightInnerControl.getString("multiSelect"));
- //assertEquals("Any 8", eightInnerControl.getString("watermark"));
- //assertEquals(0, eightInnerControl.getJsonArray("options").size());
-
- // Initialize for call against 'dataIntegrity'
- DiscoverFiltersRequest dataIntegrityRequest = new DiscoverFiltersRequest();
- dataIntegrityRequest.setViewName("dataIntegrity");
-
- initializeMocks(NodeUtils.convertObjectToJson(dataIntegrityRequest, false));
-
- // Test call against 'dataIntegrity'
- filterProcessor.getFiltersWithValues(exchange);
-
- assertEquals(200, exchange.getOut().getHeader(Exchange.HTTP_RESPONSE_CODE));
-
- entityPayload = exchange.getOut().getBody(String.class);
- assertNotNull(entityPayload);
-
- JsonReader dIJsonReader = Json.createReader(new StringReader(entityPayload));
- JsonObject dIResponsePayload = dIJsonReader.readObject();
-
- JsonObject dIFilters = dIResponsePayload.getJsonObject("filters");
- assertNotNull(dIFilters);
- // assertEquals(4, dIFilters.size());
-
- //JsonObject filterFour = dIFilters.getJsonObject("4");
- //// assertNotNull(filterFour);
- // assertEquals("Display Name 4", filterFour.getString("label"));
-
- JsonObject filterFive = dIFilters.getJsonObject("5");
- //assertNotNull(filterFive);
- //JsonObject fiveInnerControl = filterFive.getJsonObject("controls").getJsonObject("filterName5");
- //assertEquals(5, fiveInnerControl.size());
- //assertEquals("date", fiveInnerControl.getString("type"));
- // assertEquals("false", fiveInnerControl.getString("multiSelect"));
- //assertEquals("Any 5", fiveInnerControl.getString("watermark"));
- // JsonArray dynamicOptions = fiveInnerControl.getJsonArray("dynamicOptions");
- //assertEquals(5, dynamicOptions.size());
- //JsonObject today = dynamicOptions.getJsonObject(0);
- //assertEquals("Today", today.getString("decode"));
+ assertEquals(4, vnfFilters.size());
}
@Test
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/SparkyTestConstants.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/SparkyTestConstants.java
index ffb27fa..b5ff1fd 100644
--- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/SparkyTestConstants.java
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/SparkyTestConstants.java
@@ -14,6 +14,6 @@ public class SparkyTestConstants {
+ FILESEP + "src" + FILESEP + "test" + FILESEP + "resources";
public static final String PATH_TO_FILTERS_CONFIG = PATH_TO_TEST_RESOURCES + FILESEP + "filters";
- public static final String FILTERS_JSON_FILE = PATH_TO_FILTERS_CONFIG + FILESEP + "aaiui_filters.json";
- public static final String VIEWS_JSON_FILE = PATH_TO_FILTERS_CONFIG + FILESEP + "aaiui_views.json";
+ public static final String FILTERS_JSON_FILE = "file:" + PATH_TO_FILTERS_CONFIG + FILESEP + "aaiui_filters.json";
+ public static final String VIEWS_JSON_FILE = "file:" + PATH_TO_FILTERS_CONFIG + FILESEP + "aaiui_views.json";
}