aboutsummaryrefslogtreecommitdiffstats
path: root/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk
diff options
context:
space:
mode:
Diffstat (limited to 'ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk')
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElasticSearchPolicyUpdateTest.java18
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElkConnectorTest.java54
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PairTest.java7
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticDataTest.java12
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticSearchControllerTest.java66
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyLocatorTest.java10
-rw-r--r--ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/client/ElkConnectorImplTest.java (renamed from ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElkConnectorImplTest.java)61
7 files changed, 172 insertions, 56 deletions
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElasticSearchPolicyUpdateTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElasticSearchPolicyUpdateTest.java
index da9c4e8f5..2b95be068 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElasticSearchPolicyUpdateTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElasticSearchPolicyUpdateTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.pap.xacml.rest.elk;
import static org.junit.Assert.assertTrue;
@@ -46,21 +47,21 @@ public class ElasticSearchPolicyUpdateTest {
private XACMLPAPTest papTest;
@Before
- public void setUp() throws IOException, ServletException, SQLException{
+ public void setUp() throws IOException, ServletException, SQLException {
// Set the system property temporarily
System.setProperty("PROPERTY_FILE", "src/test/resources/policyelk.properties");
try {
ClassLoader classLoader = getClass().getClassLoader();
policyContent = IOUtils.toString(classLoader.getResourceAsStream("Config_SampleTest1206.1.xml"));
} catch (Exception e1) {
- logger.error("Exception Occured"+e1);
+ logger.error("Exception Occured" + e1);
}
papTest = new XACMLPAPTest();
papTest.setDBDao();
}
@Test
- public void testElasticSearchMainFunction() throws SQLException{
+ public void testElasticSearchMainFunction() throws SQLException {
ConfigurationDataEntity configurationEntity = new ConfigurationDataEntity();
configurationEntity.setConfigBody("Sample Test");
configurationEntity.setConfigType("OTHER");
@@ -68,8 +69,7 @@ public class ElasticSearchPolicyUpdateTest {
configurationEntity.setDescription("test");
configurationEntity.setModifiedBy("Test");
configurationEntity.setModifiedDate(new Date());
-
-
+
PolicyEntity entity = new PolicyEntity();
entity.setPolicyName("Config_SampleTest.1.xml");
entity.setPolicyData(policyContent.toString());
@@ -91,7 +91,7 @@ public class ElasticSearchPolicyUpdateTest {
}
@After
- public void reset(){
+ public void reset() {
System.clearProperty("PROPERTY_FILE");
}
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElkConnectorTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElkConnectorTest.java
new file mode 100644
index 000000000..145873981
--- /dev/null
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElkConnectorTest.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP-PAP-REST
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.pap.xacml.rest.elk;
+
+import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.onap.policy.pap.xacml.rest.elk.client.ElkConnector;
+import org.onap.policy.pap.xacml.rest.elk.client.ElkConnector.PolicyBodyType;
+import org.onap.policy.pap.xacml.rest.elk.client.ElkConnector.PolicyIndexType;
+import org.onap.policy.pap.xacml.rest.elk.client.ElkConnector.PolicyType;
+
+public class ElkConnectorTest {
+ @Test
+ public void testConnector() {
+ PolicyType type = PolicyType.Config;
+ PolicyBodyType body = PolicyBodyType.json;
+ assertNotNull(type);
+ assertNotNull(body);
+
+ assertEquals(PolicyIndexType.closedloop, ElkConnector.toPolicyIndexType("Config_Fault"));
+ assertEquals(PolicyIndexType.closedloop, ElkConnector.toPolicyIndexType("Config_PM"));
+ assertEquals(PolicyIndexType.config, ElkConnector.toPolicyIndexType("Config_FW"));
+ assertEquals(PolicyIndexType.config, ElkConnector.toPolicyIndexType("Config_MS"));
+ assertEquals(PolicyIndexType.config, ElkConnector.toPolicyIndexType("Config_OOF"));
+ assertEquals(PolicyIndexType.action, ElkConnector.toPolicyIndexType("Action"));
+ assertEquals(PolicyIndexType.decision, ElkConnector.toPolicyIndexType("Decision"));
+ assertEquals(PolicyIndexType.config, ElkConnector.toPolicyIndexType("Config"));
+
+ assertThatIllegalArgumentException().isThrownBy(() -> ElkConnector.toPolicyIndexType(null));
+
+ assertThatIllegalArgumentException().isThrownBy(() -> ElkConnector.toPolicyIndexType("Foo"));
+ }
+}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PairTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PairTest.java
index 0b8c86c1e..7d6b90831 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PairTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PairTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +21,7 @@
package org.onap.policy.pap.xacml.rest.elk;
import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
import org.onap.policy.pap.xacml.rest.elk.client.Pair;
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticDataTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticDataTest.java
index 76c0ce788..401e419bb 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticDataTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticDataTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,9 +21,11 @@
package org.onap.policy.pap.xacml.rest.elk;
import static org.junit.Assert.assertEquals;
+
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
+
import org.junit.Test;
import org.onap.policy.pap.xacml.rest.elk.client.PolicyElasticData;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
@@ -103,7 +105,7 @@ public class PolicyElasticDataTest {
data.setSupressionType(testVal);
assertEquals(data.getSupressionType(), testVal);
data.setServiceType(testVal);
- assertEquals(data.getServiceType(),testVal);
+ assertEquals(data.getServiceType(), testVal);
data.setUuid(testVal);
assertEquals(data.getUuid(), testVal);
data.setLocation(testVal);
@@ -111,7 +113,7 @@ public class PolicyElasticDataTest {
data.setPriority(testVal);
assertEquals(data.getPriority(), testVal);
data.setMsLocation(testVal);
- assertEquals(data.getMsLocation(),testVal);
+ assertEquals(data.getMsLocation(), testVal);
data.setRuleName(testVal);
assertEquals(data.getRuleName(), testVal);
data.setBrmsParamBody(testMap);
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticSearchControllerTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticSearchControllerTest.java
index bdbe1441d..38102afb0 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticSearchControllerTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyElasticSearchControllerTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,39 +17,48 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.pap.xacml.rest.elk;
+import static org.assertj.core.api.Assertions.assertThatCode;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.mockito.Mockito.when;
import java.io.BufferedReader;
+import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
-
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.onap.policy.pap.xacml.rest.elk.client.ElkConnector.PolicyIndexType;
import org.onap.policy.pap.xacml.rest.elk.client.PolicyElasticSearchController;
+import org.onap.policy.rest.adapter.PolicyRestAdapter;
+import org.onap.policy.rest.dao.CommonClassDao;
+import org.springframework.mock.web.MockHttpServletResponse;
public class PolicyElasticSearchControllerTest {
- private PolicyElasticSearchController conroller;
+ private PolicyElasticSearchController controller;
private HttpServletRequest request = null;
private HttpServletResponse response = null;
@Before
- public void setup(){
- conroller = new PolicyElasticSearchController();
+ public void setup() {
+ controller = new PolicyElasticSearchController();
request = Mockito.mock(HttpServletRequest.class);
- response = Mockito.mock(HttpServletResponse.class);
+ response = new MockHttpServletResponse();
}
@Test
- public void testSearchDictionary(){
+ public void testSearchDictionary() throws IOException {
List<String> jsonString = new ArrayList<>();
jsonString.add("{\"type\":\"attribute\",\"data\":{\"xacmlId\":\"Test\"}}");
jsonString.add("{\"type\":\"onapName\",\"data\":{\"onapName\":\"Test\"}}");
@@ -69,13 +78,36 @@ public class PolicyElasticSearchControllerTest {
jsonString.add("{\"type\":\"psGroupPolicy\",\"data\":{\"name\":\"Test\"}}");
jsonString.add("{\"type\":\"safeRisk\",\"data\":{\"name\":\"Test\"}}");
jsonString.add("{\"type\":\"safePolicyWarning\",\"data\":{\"name\":\"Test\"}}");
- for(int i = 0; i < jsonString.size(); i++){
- try(BufferedReader br = new BufferedReader(new StringReader(jsonString.get(i)))) {
- when(request.getReader()).thenReturn(br);
- conroller.searchDictionary(request, response);
- } catch (Exception e) {
- assertEquals(NullPointerException.class, e.getClass());
- }
+ for (int i = 0; i < jsonString.size(); i++) {
+ BufferedReader br = new BufferedReader(new StringReader(jsonString.get(i)));
+ when(request.getReader()).thenReturn(br);
+ assertThatCode(() -> controller.searchDictionary(request, response)).doesNotThrowAnyException();
}
}
+
+ @Test
+ public void testController() throws IOException {
+ CommonClassDao dao = Mockito.mock(CommonClassDao.class);
+ PolicyElasticSearchController controller = new PolicyElasticSearchController(dao);
+ assertEquals(PolicyIndexType.all, controller.toPolicyIndexType(null));
+ assertEquals(PolicyIndexType.config, controller.toPolicyIndexType("config"));
+
+ Map<String, String> searchKeys = new HashMap<String, String>();
+ searchKeys.put("key", "value");
+ assertThatThrownBy(() -> controller.search(PolicyIndexType.config, "text", searchKeys))
+ .isInstanceOf(Exception.class);
+
+ when(request.getParameter("policyName")).thenReturn("policyName");
+ when(request.getParameter("action")).thenReturn("search");
+ when(request.getReader())
+ .thenReturn(new BufferedReader(new StringReader("{\"searchdata\": { \"query\": \"value space\", "
+ + "\"policyType\": \"all\", " + "\"closedLooppolicyType\": \"type\", " + "\"onapName\": \"pef\", "
+ + "\"vnfType\": \"vnf\", " + "\"policyStatus\": \"active\", " + "\"vproAction\": \"reboot\", "
+ + "\"serviceType\": \"type\", " + "\"bindTextSearch\": \"pef\", " + "\"d2Service\": \"vDNS\"} }")));
+ controller.searchPolicy(request, response);
+ assertEquals(HttpServletResponse.SC_OK, response.getStatus());
+
+ PolicyRestAdapter policyData = new PolicyRestAdapter();
+ assertFalse(controller.deleteElk(policyData));
+ }
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyLocatorTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyLocatorTest.java
index 7df295382..bffdf3d79 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyLocatorTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/PolicyLocatorTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +21,7 @@
package org.onap.policy.pap.xacml.rest.elk;
import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
import org.onap.policy.pap.xacml.rest.elk.client.PolicyLocator;
@@ -35,8 +36,7 @@ public class PolicyLocatorTest {
String version = "1.0";
String testString = "[owner|scope|type|name|id|v1.0|]";
- PolicyLocator locator = new PolicyLocator(policyType, policyName, owner,
- scope, policyId, version);
+ PolicyLocator locator = new PolicyLocator(policyType, policyName, owner, scope, policyId, version);
String locatorString = locator.toString();
assertEquals(locatorString, testString);
}
diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElkConnectorImplTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/client/ElkConnectorImplTest.java
index 2f3d580f7..8eb003ca8 100644
--- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/ElkConnectorImplTest.java
+++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/elk/client/ElkConnectorImplTest.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* ONAP-PAP-REST
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,23 +18,24 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.pap.xacml.rest.elk;
+package org.onap.policy.pap.xacml.rest.elk.client;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import io.searchbox.client.JestResult;
+import io.searchbox.client.JestResult;
import java.io.IOException;
import java.lang.reflect.Method;
-
+import java.util.HashMap;
+import java.util.Map;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.onap.policy.pap.xacml.rest.elk.client.ElkConnector.PolicyIndexType;
-import org.onap.policy.pap.xacml.rest.elk.client.ElkConnectorImpl;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
public class ElkConnectorImplTest {
@@ -56,41 +57,41 @@ public class ElkConnectorImplTest {
}
@Test
- public void searchTest(){
- JestResult r1=null, r2=null, r3=null, r4=null;
+ public void searchTest() {
+ JestResult r1 = null, r2 = null, r3 = null, r4 = null;
// Should always work if the above test passes and ELK server is up
- try{
+ try {
r1 = new ElkConnectorImpl().search(PolicyIndexType.decision, "abc123");
} catch (Exception e) {
// ELK server is down. Don't continue the test
- if(e instanceof IllegalStateException){
+ if (e instanceof IllegalStateException) {
return;
}
fail();
}
// Should always work
- try{
+ try {
r2 = new ElkConnectorImpl().search(PolicyIndexType.decision, "The_quick_brown_fox_jumps_over_the_lazy_dog");
} catch (Exception e) {
fail();
}
// Should throw exception
- try{
+ try {
r3 = new ElkConnectorImpl().search(PolicyIndexType.decision, "abc123{}");
} catch (Exception e) {
- if(! (e instanceof IllegalArgumentException)){
+ if (!(e instanceof IllegalArgumentException)) {
fail();
}
}
// Should throw exception
- try{
+ try {
r4 = new ElkConnectorImpl().search(PolicyIndexType.decision, "The quick brown fox jumps over the lazy dog");
} catch (Exception e) {
- if(! (e instanceof IllegalArgumentException)){
+ if (!(e instanceof IllegalArgumentException)) {
fail();
}
}
@@ -114,7 +115,6 @@ public class ElkConnectorImplTest {
fail("Expected exception to be thrown");
}
-
@Test
public void testPut() throws IOException {
thrown.expect(NullPointerException.class);
@@ -143,4 +143,31 @@ public class ElkConnectorImplTest {
impl.search(PolicyIndexType.config, "search", null);
fail("Expected exception to be thrown");
}
+
+ @Test
+ public void testImplNegCases() throws IOException {
+ ElkConnectorImpl impl = new ElkConnectorImpl();
+ Map<String, String> filter = new HashMap<String, String>();
+ assertThatThrownBy(() -> impl.isType(PolicyIndexType.config)).isInstanceOf(IOException.class);
+ assertThatThrownBy(() -> impl.isIndex()).isInstanceOf(IOException.class);
+ assertThatThrownBy(() -> impl.search(null, null)).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> impl.search(null, "")).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> impl.search(null, ";;;")).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> impl.search(null, "foo")).isInstanceOf(IllegalStateException.class);
+ assertThatThrownBy(() -> impl.search(PolicyIndexType.all, "foo")).isInstanceOf(IllegalStateException.class);
+
+ assertThatThrownBy(() -> impl.search(null, null, null)).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> impl.search(null, null, filter)).isInstanceOf(IllegalArgumentException.class);
+ filter.put("key", "value");
+ assertThatThrownBy(() -> impl.search(null, ";;;", filter)).isInstanceOf(IllegalArgumentException.class);
+ assertThatThrownBy(() -> impl.search(null, "foo", filter)).isInstanceOf(IllegalStateException.class);
+ assertThatThrownBy(() -> impl.search(PolicyIndexType.config, "foo", filter))
+ .isInstanceOf(IllegalStateException.class);
+
+ PolicyRestAdapter adapter = new PolicyRestAdapter();
+ adapter.setNewFileName("scope.Decision_newFile");
+ adapter.setConfigPolicyType("Config");
+ assertThatThrownBy(() -> impl.put(adapter)).isInstanceOf(IOException.class);
+ assertThatThrownBy(() -> impl.delete(adapter)).isInstanceOf(IllegalStateException.class);
+ }
}