diff options
author | herbert <herbert.eiselt@highstreet-technologies.com> | 2020-02-28 13:51:00 +0100 |
---|---|---|
committer | herbert <herbert.eiselt@highstreet-technologies.com> | 2020-02-28 13:51:34 +0100 |
commit | 4eed58ba1a434261510c996316d2d201a40eb760 (patch) | |
tree | 3a1983f02a0311fc97710943eff336a49db43681 /sdnr/wt/common/src/test | |
parent | ac2749ef5c0de23a9874c049e043eb7eda2b1168 (diff) |
Update command and dataprovider components
Adjust license and changes
Issue-ID: SDNC-1092
Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com>
Change-Id: I8a0a339e4ecee828ae402f67d9dfc4dff7c3e59a
Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/common/src/test')
14 files changed, 321 insertions, 205 deletions
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java index 47fe9d4f6..57ae0e3bc 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java @@ -1,20 +1,24 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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 +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH 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 + * 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========================================================================== - ******************************************************************************/ + * 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.ccsdk.features.sdnr.wt.common.test; import static org.junit.Assert.assertEquals; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseServlet.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseServlet.java index ee602ce28..02a82a70d 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseServlet.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseServlet.java @@ -1,20 +1,24 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH 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 +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH 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 + * 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========================================================================== - ******************************************************************************/ + * 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.ccsdk.features.sdnr.wt.common.test; import java.io.IOException; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java index fd0c255dd..3b19f5c4b 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java @@ -1,20 +1,24 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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 +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH 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 + * 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========================================================================== - ******************************************************************************/ + * 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.ccsdk.features.sdnr.wt.common.test; import static org.junit.Assert.*; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDatabaseFilterConversion.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDatabaseFilterConversion.java index 2dd74bbec..fc244f6b6 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDatabaseFilterConversion.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDatabaseFilterConversion.java @@ -1,20 +1,24 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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 +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH 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 + * 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========================================================================== - ******************************************************************************/ + * 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.ccsdk.features.sdnr.wt.common.test; import static org.junit.Assert.assertEquals; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java index e39998008..d04aac678 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java @@ -1,20 +1,24 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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 +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH 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 + * 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========================================================================== - ******************************************************************************/ + * 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.ccsdk.features.sdnr.wt.common.test; import static org.junit.Assert.*; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java index 40c2cfe9a..21c68b3ae 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java @@ -1,20 +1,24 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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 +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH 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 + * 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========================================================================== - ******************************************************************************/ + * 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.ccsdk.features.sdnr.wt.common.test; import static org.junit.Assert.fail; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java index 9fdfeb2d2..d876f6609 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java @@ -1,20 +1,24 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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 +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH 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 + * 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========================================================================== - ******************************************************************************/ + * 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.ccsdk.features.sdnr.wt.common.test; import org.junit.AfterClass; @@ -24,6 +28,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterHealthRequest; +import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.CreateAliasRequest; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.CreateIndexRequest; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteAliasRequest; @@ -38,6 +43,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.requests.SearchRequest; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.UpdateByQueryRequest; import org.onap.ccsdk.features.sdnr.wt.common.database.requests.UpdateRequest; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterHealthResponse; +import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.CreateAliasResponse; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.CreateIndexResponse; import org.onap.ccsdk.features.sdnr.wt.common.database.responses.DeleteByQueryResponse; @@ -54,6 +60,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.responses.UpdateResponse; import static org.junit.Assert.assertEquals; 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 java.io.IOException; @@ -453,6 +460,49 @@ public class TestDbRequests { System.out.println(stats.getNodesInfo()); System.out.println(stats.getNodeStatistics()); } + + //@Test + public void testPreventAutoCreateIndex() { + final String IDX1="acidx1"; + final String ID1="acid1"; + final String IDX2="acidx2"; + final String ID2="acid2"; + final String OBJ="{\"test\":5}"; + + ClusterSettingsResponse settingsResponse=null; + String esId=null; + //set setting to allow autocreate + try { + settingsResponse = dbClient.setupClusterSettings(new ClusterSettingsRequest(true)); + } catch (IOException e) { + fail(e.getMessage()); + } + assertNotNull(settingsResponse); + assertTrue(settingsResponse.isAcknowledged()); + //test if something new can be created + esId = dbClient.doWriteRaw(IDX1, IDX1, ID1, OBJ); + assertEquals(ID1, esId); + //set setting to deny autocreate + try { + settingsResponse = dbClient.setupClusterSettings(new ClusterSettingsRequest(false)); + } catch (IOException e) { + fail(e.getMessage()); + } + assertNotNull(settingsResponse); + assertTrue(settingsResponse.isAcknowledged()); + //test if something new cannot be created + esId = dbClient.doWriteRaw(IDX2, IDX2, ID2, OBJ); + assertNull(esId); + //set setting to allow autocreate + try { + settingsResponse = dbClient.setupClusterSettings(new ClusterSettingsRequest(true)); + } catch (IOException e) { + fail(e.getMessage()); + } + assertNotNull(settingsResponse); + assertTrue(settingsResponse.isAcknowledged()); + + } private void deleteAlias(String idx,String alias) { try { dbClient.deleteAlias( new DeleteAliasRequest(idx,alias)); @@ -467,5 +517,6 @@ public class TestDbRequests { } } + } diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java index d88df96a0..32177d8df 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java @@ -1,20 +1,24 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2020 highstreet technologies GmbH 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 +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH 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 + * 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========================================================================== - ******************************************************************************/ + * 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.ccsdk.features.sdnr.wt.common.test; import static org.junit.Assert.assertEquals; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java index e4e8f9477..d927ed750 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java @@ -1,26 +1,32 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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 +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH 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 + * 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========================================================================== - ******************************************************************************/ + * 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.ccsdk.features.sdnr.wt.common.test; import static org.junit.Assert.*; +import org.json.JSONArray; import org.json.JSONException; import org.junit.Test; +import org.onap.ccsdk.features.sdnr.wt.common.HtAssert; import org.onap.ccsdk.features.sdnr.wt.common.test.JSONAssert; public class TestJsonAssert { @@ -28,117 +34,139 @@ public class TestJsonAssert { @Test public void testGenericTypes() { try { - JSONAssert.assertEquals("test boolean","{ \"test\":true}","{ \"test\":true}",true); + JSONAssert.assertEquals("test boolean", "{ \"test\":true}", "{ \"test\":true}", true); } catch (JSONException e) { fail(e.getMessage()); } try { - JSONAssert.assertEquals("test int","{ \"test\":2}","{ \"test\":2}",true); + JSONAssert.assertEquals("test int", "{ \"test\":2}", "{ \"test\":2}", true); } catch (JSONException e) { fail(e.getMessage()); } try { - JSONAssert.assertEquals("test string","{ \"test\":\"abc\"}","{ \"test\":\"abc\"}",true); + JSONAssert.assertEquals("test string", "{ \"test\":\"abc\"}", "{ \"test\":\"abc\"}", true); } catch (JSONException e) { fail(e.getMessage()); } - + } + @Test public void testGenericTypesFails() { try { - JSONAssert.assertEquals("test boolean","{ \"test\":true}","{ \"test\":false}",true); + JSONAssert.assertEquals("test boolean", "{ \"test\":true}", "{ \"test\":false}", true); fail("test boolean not failed, but has to"); } catch (JSONException e) { fail("problem with json"); - }catch(AssertionError e) { - + } catch (AssertionError e) { + } try { - JSONAssert.assertEquals("test int","{ \"test\":2}","{ \"test\":3}",true); + JSONAssert.assertEquals("test int", "{ \"test\":2}", "{ \"test\":3}", true); fail("test int not failed, but has to"); } catch (JSONException e) { fail("problem with json"); - } catch(AssertionError e) { - + } catch (AssertionError e) { + } try { - JSONAssert.assertEquals("test string","{ \"test\":\"abc\"}","{ \"test\":\"abcd\"}",true); + JSONAssert.assertEquals("test string", "{ \"test\":\"abc\"}", "{ \"test\":\"abcd\"}", true); fail("test string not failed, but has to"); } catch (JSONException e) { fail("problem with json"); - }catch(AssertionError e) { - + } catch (AssertionError e) { + } - + } + @Test public void testObject() { try { - JSONAssert.assertEquals("test object","{ \"test\":{\"more\":{\"x\":1,\"y\":\"2\",\"z\":{}}}}","{ \"test\":{\"more\":{\"x\":1,\"z\":{},\"y\":\"2\"}}}",true); + JSONAssert.assertEquals("test object", "{ \"test\":{\"more\":{\"x\":1,\"y\":\"2\",\"z\":{}}}}", + "{ \"test\":{\"more\":{\"x\":1,\"z\":{},\"y\":\"2\"}}}", true); } catch (JSONException e) { fail(e.getMessage()); } - } + } + @Test public void testObjectFails() { try { - JSONAssert.assertEquals("test object","{ \"test\":{\"more\":{\"x\":1,\"y\":\"2\",\"z\":{}}}}","{ \"test\":{\"more\":{\"x\":1,\"z\":{}}}}",true); + JSONAssert.assertEquals("test object", "{ \"test\":{\"more\":{\"x\":1,\"y\":\"2\",\"z\":{}}}}", + "{ \"test\":{\"more\":{\"x\":1,\"z\":{}}}}", true); fail("test object not failed, but has to"); } catch (JSONException e) { fail("problem with json"); - } - catch(AssertionError e) { - + } catch (AssertionError e) { + } } + @Test public void testArrayStrict() { try { - JSONAssert.assertEquals("test array strict","{ \"test\":[\"a\",\"b\",\"c\"]}","{ \"test\":[\"a\",\"b\",\"c\"]}",true); + JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}", + "{ \"test\":[\"a\",\"b\",\"c\"]}", true); } catch (JSONException e) { fail(e.getMessage()); } - } + } + @Test public void testArrayStrictFails() { try { - JSONAssert.assertEquals("test array strict","{ \"test\":[\"a\",\"b\",\"c\"]}","{ \"test\":[\"a\",\"c\",\"b\"]}",true); + JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}", + "{ \"test\":[\"a\",\"c\",\"b\"]}", true); fail("test object not failed, but has to"); } catch (JSONException e) { fail("problem with json"); - } - catch(AssertionError e) { - + } catch (AssertionError e) { + } } + @Test public void testArrayNonStrict() { try { - JSONAssert.assertEquals("test array strict","{ \"test\":[\"a\",\"b\",\"c\"]}","{ \"test\":[\"a\",\"c\",\"b\"]}",false); + JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}", + "{ \"test\":[\"a\",\"c\",\"b\"]}", false); } catch (JSONException e) { fail(e.getMessage()); } - } + } + @Test public void testArrayNonStrictFails() { try { - JSONAssert.assertEquals("test array strict","{ \"test\":[\"a\",\"b\",\"c\"]}","{ \"test\":[\"a\",\"c\",\"b\",\"d\"]}",false); + JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}", + "{ \"test\":[\"a\",\"c\",\"b\",\"d\"]}", false); fail("test object not failed, but has to"); } catch (JSONException e) { fail("problem with json"); - } - catch(AssertionError e) { - + } catch (AssertionError e) { + } try { - JSONAssert.assertEquals("test array strict","{ \"test\":[\"a\",\"b\",\"c\"]}","{ \"test\":[\"a\",\"b\",\"d\"]}",false); + JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}", + "{ \"test\":[\"a\",\"b\",\"d\"]}", false); fail("test object not failed, but has to"); } catch (JSONException e) { fail("problem with json"); + } catch (AssertionError e) { + } - catch(AssertionError e) { - + } + + @Test + public void testNullParamCheck() { + + try { + + HtAssert.nonnull("test", new JSONArray(), null); + fail("exception not thrown"); + } catch (Exception e) { + assertTrue(e.getMessage().contains("org.onap.ccsdk.features.sdnr.wt.common.test.TestJsonAssert") && e.getMessage().contains("testNullParamCheck")); } } } diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPageHashMap.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPageHashMap.java index 9c2ade992..292856940 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPageHashMap.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPageHashMap.java @@ -1,20 +1,24 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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 +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH 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 + * 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========================================================================== - ******************************************************************************/ + * 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.ccsdk.features.sdnr.wt.common.test; import org.junit.Test; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java index 02233aff4..a6f1b51b3 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java @@ -1,20 +1,24 @@ -/******************************************************************************* - * ============LICENSE_START======================================================================== - * ONAP : ccsdk feature sdnr wt - * ================================================================================================= - * Copyright (C) 2019 highstreet technologies GmbH 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 +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2019 highstreet technologies GmbH 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 + * 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========================================================================== - ******************************************************************************/ + * 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.ccsdk.features.sdnr.wt.common.test; import static org.junit.Assert.assertEquals; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java index 2e8cda0ef..6ec47c230 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * ONAP : CCSDK.apps.sdnr.wt.apigateway + * ONAP : ccsdk features * ================================================================================ * Copyright (C) 2018 highstreet technologies GmbH Intellectual Property. * All rights reserved. @@ -9,7 +9,7 @@ * 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 + * 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, @@ -17,6 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * */ package org.onap.ccsdk.features.sdnr.wt.common.test.helper; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java index b0db4f0e6..8144e6eb7 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java @@ -1,6 +1,6 @@ /* * ============LICENSE_START======================================================= - * ONAP : CCSDK.apps.sdnr.wt.apigateway + * ONAP : ccsdk features * ================================================================================ * Copyright (C) 2018 highstreet technologies GmbH Intellectual Property. * All rights reserved. @@ -9,7 +9,7 @@ * 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 + * 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, @@ -17,6 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * */ package org.onap.ccsdk.features.sdnr.wt.common.test.helper; diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/IPublicServlet.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/IPublicServlet.java index 9d5ac4fc0..e6634d6a1 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/IPublicServlet.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/IPublicServlet.java @@ -18,7 +18,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.onap.ccsdk.features.sdnr.wt.common.test.helper; import java.io.IOException; |