aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java2
-rw-r--r--ms/neng/src/main/resources/db/changelog/db.changelog-master.xml11
-rw-r--r--ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/01_initial_ref_data_v1.sql6
-rw-r--r--ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/04_ref_data_extrn_int.sql14
-rw-r--r--ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_base_tables.sql6
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParametersImplTest.java66
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyPropertyMethodUtilsTest.java38
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReaderTest.java44
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java101
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParserTest.java60
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/AaiAuthorizationInterceptorTest.java90
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/PolicyManagerAuthorizationInterceptorTest.java87
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/seq/TestSequenceGenerator.java85
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/HelloTest.java53
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java221
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java108
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/TestApplicationConfig.java58
-rw-r--r--ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java200
-rw-r--r--ms/neng/src/test/resources/application-test.properties38
-rw-r--r--ms/neng/src/test/resources/h2db/changelog/h2db.changelog-master.xml16
-rw-r--r--ms/neng/src/test/resources/h2db/changelog/scripts/50_load_sim_data_dml.sql23
-rw-r--r--ms/neng/src/test/resources/h2db/changelog/scripts/51_ref_data_upd_dml.sql5
22 files changed, 1315 insertions, 17 deletions
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java
index 72aee461..24736b2f 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java
@@ -63,7 +63,7 @@ public class SpringServiceImpl implements SpringService {
@Autowired AaiServiceImpl aaiService;
@Autowired ExternalKeyValidator externalKeyValidator;
@Autowired @Qualifier("policyFinderServiceImpl") PolicyFinder policyFinder;
- @Autowired @Qualifier("policyFinderServiceDBImpl") PolicyFinder policyFinderDbImpl;
+ @Autowired @Qualifier("policyFinderServiceDbImpl") PolicyFinder policyFinderDbImpl;
@Autowired PolicyParameters policyParameters;
@Autowired SequenceGenerator sequenceGenerator;
@Autowired DbNameValidator dbNameValidator;
diff --git a/ms/neng/src/main/resources/db/changelog/db.changelog-master.xml b/ms/neng/src/main/resources/db/changelog/db.changelog-master.xml
index 9d735e64..dbbd71b6 100644
--- a/ms/neng/src/main/resources/db/changelog/db.changelog-master.xml
+++ b/ms/neng/src/main/resources/db/changelog/db.changelog-master.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-/*-
+<!--
* ============LICENSE_START=======================================================
* ONAP : CCSDK.apps
* ================================================================================
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+ -->
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
@@ -28,13 +28,6 @@
<include file="db/changelog/scripts/rel_18_10/create_base_tables.sql" />
<include file="db/changelog/scripts/rel_18_10/01_initial_ref_data_v1.sql" />
<include file="db/changelog/scripts/rel_18_10/02_create_indexes_ddl.sql" />
- <include file="db/changelog/scripts/rel_18_10/03_ref_data_upd_dml.sql" />
<include file="db/changelog/scripts/rel_18_10/04_ref_data_extrn_int.sql" />
- <include file="db/changelog/scripts/rel_18_10/05_ref_data_upd_dml.sql" />
- <include file="db/changelog/scripts/rel_18_10/06_ref_data_upd_dml.sql" />
- <include file="db/changelog/scripts/rel_18_10/07_ref_data_extrn_int_update_dml.sql" />
- <include file="db/changelog/scripts/rel_18_10/08_ref_data_extrn_int_update_dml.sql" />
- <include file="db/changelog/scripts/rel_18_10/09_table_upd_ddl.sql" />
- <include file="db/changelog/scripts/rel_18_10/10_ref_data_upd_dml.sql" />
</databaseChangeLog>
diff --git a/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/01_initial_ref_data_v1.sql b/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/01_initial_ref_data_v1.sql
index 44d86f0a..e5a4e117 100644
--- a/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/01_initial_ref_data_v1.sql
+++ b/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/01_initial_ref_data_v1.sql
@@ -5,14 +5,18 @@
--set @@autocommit:=0;
---delete all records
delete from SERVICE_PARAMETER;
INSERT INTO SERVICE_PARAMETER(NAME, VALUE, CREATED_BY) VALUES ('initial_increment','10,40,50,100','Initial');
+INSERT INTO SERVICE_PARAMETER(NAME, VALUE, CREATED_BY) VALUES ('max_gen_attempt','50','Initial');
INSERT INTO SERVICE_PARAMETER(NAME, VALUE, CREATED_BY) VALUES ('recipe_separator','|":",','Initial');
+INSERT INTO SERVICE_PARAMETER(NAME, VALUE, CREATED_BY) VALUES ('use_db_policy','N','Initial');
delete from IDENTIFIER_MAP;
+INSERT INTO IDENTIFIER_MAP(POLICY_FN_NAME, JS_FN_NAME, CREATED_BY) VALUES ('sub_str','substring', 'Initial');
INSERT INTO IDENTIFIER_MAP(POLICY_FN_NAME, JS_FN_NAME, CREATED_BY) VALUES ('substr','substring', 'Initial');
+INSERT INTO IDENTIFIER_MAP(POLICY_FN_NAME, JS_FN_NAME, CREATED_BY) VALUES ('to_lower_case','toLowerCase', 'Initial');
+INSERT INTO IDENTIFIER_MAP(POLICY_FN_NAME, JS_FN_NAME, CREATED_BY) VALUES ('to_upper_case','toUpperCase', 'Initial');
commit;
diff --git a/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/04_ref_data_extrn_int.sql b/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/04_ref_data_extrn_int.sql
index bc72a2e8..7b0973c2 100644
--- a/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/04_ref_data_extrn_int.sql
+++ b/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/04_ref_data_extrn_int.sql
@@ -1,24 +1,32 @@
--liquibase formatted sql
--changeset ref_data_update:18_10.ref_data_update.sql
--- clean up any data
delete from external_interface;
---insert the data
-
insert into external_interface(SYSTEM,PARAM,URL_SUFFIX,CREATED_TIME,CREATED_BY,LAST_UPDATED_TIME,LAST_UPDATED_BY)
values('aai','vnf-name','nodes/generic-vnfs?vnf-name=',sysdate(),'nengsys',sysdate(),'nengsys');
+insert into external_interface(SYSTEM,PARAM,URL_SUFFIX,CREATED_TIME,CREATED_BY,LAST_UPDATED_TIME,LAST_UPDATED_BY)
+values('aai','VNF','nodes/generic-vnfs?vnf-name=',sysdate(),'nengsys',sysdate(),'nengsys');
insert into external_interface(SYSTEM,PARAM,URL_SUFFIX,CREATED_TIME,CREATED_BY,LAST_UPDATED_TIME,LAST_UPDATED_BY)
values('aai','vnfc-name','nodes/vnfcs?vnfc-name=',sysdate(),'nengsys',sysdate(),'nengsys');
+insert into external_interface(SYSTEM,PARAM,URL_SUFFIX,CREATED_TIME,CREATED_BY,LAST_UPDATED_TIME,LAST_UPDATED_BY)
+values('aai','VNFC','nodes/vnfcs?vnfc-name=',sysdate(),'nengsys',sysdate(),'nengsys');
insert into external_interface(SYSTEM,PARAM,URL_SUFFIX,CREATED_TIME,CREATED_BY,LAST_UPDATED_TIME,LAST_UPDATED_BY)
values('aai','vserver-name','nodes/vservers?vserver-name=',sysdate(),'nengsys',sysdate(),'nengsys');
insert into external_interface(SYSTEM,PARAM,URL_SUFFIX,CREATED_TIME,CREATED_BY,LAST_UPDATED_TIME,LAST_UPDATED_BY)
values('aai','vf-module-name','nodes/vf-modules?vf-module-name=',sysdate(),'nengsys',sysdate(),'nengsys');
+insert into external_interface(SYSTEM,PARAM,URL_SUFFIX,CREATED_TIME,CREATED_BY,LAST_UPDATED_TIME,LAST_UPDATED_BY)
+values('aai','VFMODULE','nodes/vf-modules?vf-module-name=',sysdate(),'nengsys',sysdate(),'nengsys');
+insert into external_interface(SYSTEM,PARAM,URL_SUFFIX,CREATED_TIME,CREATED_BY,LAST_UPDATED_TIME,LAST_UPDATED_BY)
+values('aai','VF-MODULE','nodes/vf-modules?vf-module-name=',sysdate(),'nengsys',sysdate(),'nengsys');
insert into external_interface(SYSTEM,PARAM,URL_SUFFIX,CREATED_TIME,CREATED_BY,LAST_UPDATED_TIME,LAST_UPDATED_BY)
values('aai','service-instance-id','nodes/service-instances?service-instance-id=',sysdate(),'nengsys',sysdate(),'nengsys');
+insert into external_interface(SYSTEM,PARAM,URL_SUFFIX,CREATED_TIME,CREATED_BY,LAST_UPDATED_TIME,LAST_UPDATED_BY)
+values('aai','VM','nodes/vservers?vserver-name=',sysdate(),'nengsys',sysdate(),'nengsys');
+
commit;
diff --git a/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_base_tables.sql b/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_base_tables.sql
index f79dd3fc..4cfe05c8 100644
--- a/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_base_tables.sql
+++ b/ms/neng/src/main/resources/db/changelog/scripts/rel_18_10/create_base_tables.sql
@@ -10,14 +10,14 @@ NAME VARCHAR(500) COMMENT 'Generated name',
PREFIX VARCHAR(100) COMMENT 'The prefix for the name. (The part of the name before the sequence number.)',
SUFFIX VARCHAR(100) COMMENT 'The suffix for the name. (The part of the name after the sequence number.)',
IS_RELEASED CHAR(1) COMMENT 'Indicating if the entry is released/unassigned',
-CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP,
+CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
CREATED_BY VARCHAR(50),
LAST_UPDATED_TIME DATETIME,
LAST_UPDATED_BY VARCHAR(50)) AUTO_INCREMENT=100;
-- COMMENT 'TABLE TO STORE GENERATED NAMES';
CREATE TABLE SERVICE_PARAMETER (SERVICE_PARAMETER_ID INTEGER PRIMARY KEY AUTO_INCREMENT,
-NAME VARCHAR(500) COMMENT 'Parameter name' NOT NULL UNIQUE,
+NAME VARCHAR(500) NOT NULL COMMENT 'Parameter name',
VALUE VARCHAR(500) COMMENT 'Parameter value',
CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP,
CREATED_BY VARCHAR(50),
@@ -26,7 +26,7 @@ LAST_UPDATED_BY VARCHAR(50)
) AUTO_INCREMENT=100;
CREATE TABLE IDENTIFIER_MAP (IDENTIFIER_MAP_ID INTEGER PRIMARY KEY AUTO_INCREMENT,
-POLICY_FN_NAME VARCHAR(500) COMMENT 'Function name in policy manager' NOT NULL UNIQUE,
+POLICY_FN_NAME VARCHAR(500) COMMENT 'Function name in policy manager' NOT NULL,
JS_FN_NAME VARCHAR(500) COMMENT 'Equivalent name in Java or script',
CREATED_TIME DATETIME DEFAULT CURRENT_TIMESTAMP,
CREATED_BY VARCHAR(50),
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParametersImplTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParametersImplTest.java
new file mode 100644
index 00000000..e897e4fe
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParametersImplTest.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.policy;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.ccsdk.apps.ms.neng.persistence.entity.IdentifierMap;
+import org.onap.ccsdk.apps.ms.neng.persistence.entity.ServiceParameter;
+import org.onap.ccsdk.apps.ms.neng.persistence.repository.IdentifierMapRespository;
+import org.onap.ccsdk.apps.ms.neng.persistence.repository.ServiceParameterRepository;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PolicyParametersImplTest {
+ @Mock
+ IdentifierMapRespository identifierMapRepository;
+ @Mock
+ ServiceParameterRepository serviceParameterRepository;
+ @Mock
+ IdentifierMap identifierMap;
+ @InjectMocks
+ PolicyParametersImpl policyParametersImpl;
+ @Mock
+ ServiceParameter sp;
+
+ static final String RECIPE_SEPERATOR_PARAM = "recipe_separator";
+ static final String MAX_GEN_ATTEMPT_PARAM = "max_gen_attempt";
+
+ @Test
+ public void policyParameterTest() throws Exception {
+ Mockito.when(serviceParameterRepository.findByName(RECIPE_SEPERATOR_PARAM)).thenReturn(sp);
+ Mockito.when(sp.getValue()).thenReturn("value");
+ assertEquals("value", policyParametersImpl.getRecipeSeparator());
+
+ Mockito.when(identifierMapRepository.findByPolicyFnName("name")).thenReturn(identifierMap);
+ Mockito.when(identifierMap.getJsFnName()).thenReturn("jsFnName");
+ assertEquals("jsFnName", policyParametersImpl.mapFunction("name"));
+
+ Mockito.when(sp.getValue()).thenReturn("1");
+ Mockito.when(serviceParameterRepository.findByName(MAX_GEN_ATTEMPT_PARAM)).thenReturn(sp);
+ assertEquals(1, policyParametersImpl.getMaxGenAttempt());
+ }
+}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyPropertyMethodUtilsTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyPropertyMethodUtilsTest.java
new file mode 100644
index 00000000..f527b38b
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyPropertyMethodUtilsTest.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.policy;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class PolicyPropertyMethodUtilsTest {
+
+ @Test
+ public void testAll() {
+ assertEquals("TRLAK", PolicyPropertyMethodUtils.substring("TRLAKDG", "5"));
+ assertEquals("KDG", PolicyPropertyMethodUtils.substring("TRLAKDG", "-3"));
+ assertEquals("TRLAKDG", PolicyPropertyMethodUtils.substring("TRLAKDG", "8"));
+ assertEquals("TRLAKDG", PolicyPropertyMethodUtils.substring("TRLAKDG", "-11"));
+ assertEquals("XYSZ1NNN", PolicyPropertyMethodUtils.toUpperCase("XySz1NNN"));
+ assertEquals("xysz1nnn", PolicyPropertyMethodUtils.toLowerCase("XySz1NNN"));
+ }
+}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReaderTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReaderTest.java
new file mode 100644
index 00000000..30fc6e45
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReaderTest.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.policy;
+
+import static org.junit.Assert.assertEquals;
+import static org.onap.ccsdk.apps.ms.neng.core.policy.PolicyReader.namingModels;
+
+import java.util.Map;
+import org.junit.Test;
+
+public class PolicyReaderTest {
+ @Test
+ public void getPolicyFromFile() throws Exception {
+ Map<String, Object> policy = new FilePolicyReader("sample_policy.json").getPolicy();
+ assertEquals("VNF", namingModels(policy).get(0).get("naming-type"));
+ assertEquals("COMPLEX|SEQUENCE|NF_NAMING_CODE", namingModels(policy).get(0).get("naming-recipe"));
+ }
+
+ @Test
+ public void relaxedNamingType() throws Exception {
+ assertEquals("VNF", PolicyReader.relaxedNamingType("VNF_NAME"));
+ assertEquals("VNF", PolicyReader.relaxedNamingType("VNF-NAME"));
+ assertEquals("VNF", PolicyReader.relaxedNamingType("vnf-name"));
+ assertEquals("VNF", PolicyReader.relaxedNamingType("vnf_name"));
+ }
+}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java
new file mode 100644
index 00000000..9d6c3f92
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperatorTest.java
@@ -0,0 +1,101 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.policy;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PropertyOperatorTest {
+ @Mock
+ private PolicyParameters params = mock(PolicyParameters.class);
+
+ @Test
+ public void operationFunction() throws Exception {
+ assertEquals(null, PropertyOperator.operationFunction(""));
+ assertEquals(null, PropertyOperator.operationFunction(" "));
+
+ assertEquals(null, PropertyOperator.operationFunction(" (("));
+
+ assertEquals("to_lower_case", PropertyOperator.operationFunction("to_lower_case()"));
+ assertEquals("to_lower_case", PropertyOperator.operationFunction(" to_lower_case() "));
+
+ assertEquals("sub_str", PropertyOperator.operationFunction("sub_str(0,5)"));
+ assertEquals("sub_str", PropertyOperator.operationFunction("\tsub_str(0,5)"));
+ }
+
+ @Test
+ public void camelConverted() throws Exception {
+ assertEquals("", PropertyOperator.camelConverted(""));
+
+ assertEquals("toLowerCase", PropertyOperator.camelConverted("to_lower_case"));
+ }
+
+ @Test
+ public void applyToLowerCase() throws Exception {
+ Map<String, String> props = new HashMap<>();
+ props.put("property-operation", "to_lower_case()");
+ PropertyOperator op = new PropertyOperator();
+ assertEquals("asdf", op.apply("ASDF", props, params));
+ }
+
+ @Test
+ public void applyToUpperCase() throws Exception {
+ Map<String, String> props = new HashMap<>();
+ props.put("property-operation", "to_upper_case()");
+ PropertyOperator op = new PropertyOperator();
+ assertEquals("ASDF", op.apply("asdf", props, params));
+ }
+
+ @Test
+ public void applySubstr() throws Exception {
+ when(params.mapFunction("sub_str")).thenReturn("substring");
+ PropertyOperator op = new PropertyOperator();
+
+ Map<String, String> props = new HashMap<>();
+
+ props.put("property-operation", "sub_str(0,5)");
+ assertEquals("01234", op.apply("0123456789", props, params));
+
+ props.put("property-operation", " sub_str(0,4)");
+ assertEquals("0123", op.apply("0123456789", props, params));
+
+ props.put("property-operation", "sub_str(1,5)");
+ assertEquals("1234", op.apply("0123456789", props, params));
+
+ props.put("property-operation", "sub_str(1)");
+ assertEquals("0", op.apply("0", props, params));
+
+ props.put("property-operation", "sub_str(-2)");
+ assertEquals("89", op.apply("0123456789", props, params));
+
+ props.put("property-operation", "sub_str(-3)");
+ assertEquals("789", op.apply("0123456789", props, params));
+ }
+}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParserTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParserTest.java
new file mode 100644
index 00000000..744d967d
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParserTest.java
@@ -0,0 +1,60 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.policy;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class RecipeParserTest {
+ @Mock
+ private PolicyParameters params = mock(PolicyParameters.class);
+
+ @Test
+ public void parseRecipe() throws Exception {
+ assertEquals(0, RecipeParser.parseRecipe(params, "").size());
+ assertEquals("[]", RecipeParser.parseRecipe(params, "").toString());
+
+ assertEquals(1, RecipeParser.parseRecipe(params, "a").size());
+ assertEquals("[a]", RecipeParser.parseRecipe(params, "a").toString());
+
+ assertEquals(2, RecipeParser.parseRecipe(params, "a,b").size());
+ assertEquals(2, RecipeParser.parseRecipe(params, "a|b").size());
+ assertEquals(2, RecipeParser.parseRecipe(params, "a:b").size());
+
+ assertEquals("[a, b]", RecipeParser.parseRecipe(params, "a,b").toString());
+ assertEquals("[a, b]", RecipeParser.parseRecipe(params, "a|b").toString());
+ assertEquals("[a, b]", RecipeParser.parseRecipe(params, "a:b").toString());
+
+ assertEquals(3, RecipeParser.parseRecipe(params, "a,b,c").size());
+ assertEquals(3, RecipeParser.parseRecipe(params, "a|b|c").size());
+ assertEquals(3, RecipeParser.parseRecipe(params, "a:b:c").size());
+
+ assertEquals("[a, b, c]", RecipeParser.parseRecipe(params, "a,b,c").toString());
+ assertEquals("[a, b, c]", RecipeParser.parseRecipe(params, "a|b|c").toString());
+ assertEquals("[a, b, c]", RecipeParser.parseRecipe(params, "a:b:c").toString());
+ }
+}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/AaiAuthorizationInterceptorTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/AaiAuthorizationInterceptorTest.java
new file mode 100644
index 00000000..40e507ea
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/AaiAuthorizationInterceptorTest.java
@@ -0,0 +1,90 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.rs.interceptors;
+
+import static org.junit.Assert.assertNotNull;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.header;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
+
+import java.net.URI;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Spy;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigRequest;
+import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigResponse;
+import org.onap.ccsdk.apps.ms.neng.extinf.props.AaiProps;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.http.RequestEntity;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.web.client.ExpectedCount;
+import org.springframework.test.web.client.MockRestServiceServer;
+import org.springframework.web.client.RestTemplate;
+
+@RunWith(MockitoJUnitRunner.class)
+public class AaiAuthorizationInterceptorTest {
+ MockRestServiceServer mockServer;
+ RestTemplate restTemplate;
+ String aaiHostName = "http://0.0.0.1:8080/";
+ String aaiPath = "services/service/networkInfrastructureResourcesSample/v1";
+
+ @InjectMocks
+ AaiAuthorizationInterceptor aaiAuthorizationInterceptor;
+ @Spy
+ AaiProps props = new AaiProps();
+
+ /**
+ * Does the setup.
+ */
+ @Before
+ public void setUp() {
+ if (restTemplate == null) {
+ restTemplate = new RestTemplate();
+ }
+ props.setAccept("application/json");
+ props.setCert("c:/certs");
+ props.setCertPassword("password");
+ props.setFromAppId("namegen-ms");
+ props.setUriBase("https://localhost:8080/aai/v13/");
+ props.setTransactionId("X12345YV");
+ restTemplate.getInterceptors().add(aaiAuthorizationInterceptor);
+ mockServer = MockRestServiceServer.bindTo(restTemplate).build();
+ }
+
+ @Test
+ public void testAuth() throws Exception {
+
+ mockServer.expect(ExpectedCount.once(), requestTo(aaiHostName + aaiPath)).andExpect(method(HttpMethod.POST))
+ .andExpect(header("x-FromAppId", new String[] {"namegen-ms"}))
+ .andRespond(withSuccess("", MediaType.APPLICATION_JSON));
+ GetConfigRequest req = new GetConfigRequest();
+ RequestEntity<GetConfigRequest> re = RequestEntity.post(new URI(aaiHostName + aaiPath))
+ .accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON).body(req);
+ ResponseEntity<GetConfigResponse> resp = restTemplate.exchange(re, GetConfigResponse.class);
+ mockServer.verify();
+ assertNotNull(resp);
+ }
+}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/PolicyManagerAuthorizationInterceptorTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/PolicyManagerAuthorizationInterceptorTest.java
new file mode 100644
index 00000000..d814c253
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/rs/interceptors/PolicyManagerAuthorizationInterceptorTest.java
@@ -0,0 +1,87 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.rs.interceptors;
+
+import static org.junit.Assert.assertNotNull;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.header;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
+
+import java.net.URI;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Spy;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigRequest;
+import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigResponse;
+import org.onap.ccsdk.apps.ms.neng.extinf.props.PolicyManagerProps;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.http.RequestEntity;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.web.client.ExpectedCount;
+import org.springframework.test.web.client.MockRestServiceServer;
+import org.springframework.web.client.RestTemplate;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PolicyManagerAuthorizationInterceptorTest {
+ MockRestServiceServer mockServer;
+ RestTemplate restTemplate;
+ String policyManagerHostname = "http://0.0.0.1:8080/";
+ String policyManagerResPath = "services/service/networkInfrastructureResourcesSample/v1";
+ @InjectMocks
+ PolicyManagerAuthorizationInterceptor policyManagerInterceptor;
+ @Spy
+ PolicyManagerProps props = new PolicyManagerProps();
+
+ /**
+ * Does the setup for tests.
+ */
+ @Before
+ public void setUp() {
+ if (restTemplate == null) {
+ restTemplate = new RestTemplate();
+ }
+ props.setBasicAuth("Basic bnVsbDpudWxs");
+ props.setClientAuth("Basic bnVsbDpudWxs");
+ props.setEcompRequestId("xxuv");
+ props.setEnvironment("TEST");
+ restTemplate.getInterceptors().add(policyManagerInterceptor);
+ mockServer = MockRestServiceServer.bindTo(restTemplate).build();
+ }
+
+ @Test
+ public void testAuth() throws Exception {
+ mockServer.expect(ExpectedCount.once(), requestTo(policyManagerHostname + policyManagerResPath))
+ .andExpect(method(HttpMethod.POST))
+ .andExpect(header("Authorization", new String[] {"Basic bnVsbDpudWxs"}))
+ .andRespond(withSuccess("", MediaType.APPLICATION_JSON));
+ GetConfigRequest req = new GetConfigRequest();
+ RequestEntity<GetConfigRequest> re = RequestEntity.post(new URI(policyManagerHostname + policyManagerResPath))
+ .accept(MediaType.APPLICATION_JSON).contentType(MediaType.APPLICATION_JSON).body(req);
+ ResponseEntity<GetConfigResponse> resp = restTemplate.exchange(re, GetConfigResponse.class);
+ mockServer.verify();
+ assertNotNull(resp);
+ }
+}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/seq/TestSequenceGenerator.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/seq/TestSequenceGenerator.java
new file mode 100644
index 00000000..fcee4da0
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/seq/TestSequenceGenerator.java
@@ -0,0 +1,85 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.seq;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.ccsdk.apps.ms.neng.core.policy.PolicySequence;
+import org.onap.ccsdk.apps.ms.neng.persistence.entity.ServiceParameter;
+import org.onap.ccsdk.apps.ms.neng.persistence.repository.GeneratedNameRespository;
+import org.onap.ccsdk.apps.ms.neng.persistence.repository.ServiceParameterRepository;
+
+
+@RunWith(MockitoJUnitRunner.class)
+public class TestSequenceGenerator {
+ @Mock
+ private GeneratedNameRespository genNameRepo = mock(GeneratedNameRespository.class);
+ @Mock
+ private ServiceParameterRepository servParamRepo = mock(ServiceParameterRepository.class);
+ @Mock
+ private PolicySequence params = mock(PolicySequence.class);
+ @Mock
+ private ServiceParameter sp = mock(ServiceParameter.class);
+ @InjectMocks
+ SequenceGenerator sg;
+
+ @Test
+ public void testGenerate() throws Exception {
+ assertEquals(0, sg.generate("zSSRX1234", null, params, null, 1));
+
+ Mockito.when(params.getLastReleaseSeqNumTried()).thenReturn(null);
+ Mockito.when(genNameRepo.findMaxByPrefixAndSuffix("zSSRX1234", null)).thenReturn("4");
+
+ assertEquals(0, sg.generate("zSSRX1234", null, params, null, 1));
+
+ Mockito.when(genNameRepo.findMaxByPrefixAndSuffix("zSSRX1234", null)).thenReturn("2");
+ Mockito.when(genNameRepo.findMaxByPrefixAndSuffix("zSSRX1234", null)).thenReturn(null);
+ Mockito.when(servParamRepo.findByName("initial_increment")).thenReturn(sp);
+ Mockito.when(sp.getValue()).thenReturn("1");
+
+ assertEquals(0, sg.generate("zSSRX1234", null, params, 1L, 2));
+
+ Mockito.when(genNameRepo.findNextReleasedSeq(0L, "zSSRX1234", null)).thenReturn(null);
+ assertEquals(0, sg.generate("zSSRX1234", null, params, null, 1));
+ }
+
+ @Test(expected = Exception.class)
+ public void exceltionTest() throws Exception {
+ Mockito.when(genNameRepo.findNextReleasedSeq(1L, "zSSRX1234", null)).thenReturn(null);
+ Mockito.when(params.getLastReleaseSeqNumTried()).thenReturn(1L);
+ sg.generate("zSSRX1234", null, params, null, 1);
+ }
+
+ @Test
+ public void testAlreadyUsedSequesnce() throws Exception {
+ Mockito.when(genNameRepo.findMaxByPrefixAndSuffix("zSSRX1234", null)).thenReturn("1");
+ Mockito.when(sp.getValue()).thenReturn("4");
+ Mockito.when(params.getIncrement()).thenReturn(2L);
+ assertEquals(0L, sg.generate("zSSRX1234", null, params, 2L, 0));
+ }
+}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/HelloTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/HelloTest.java
new file mode 100644
index 00000000..1c5fa81f
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/HelloTest.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.service;
+
+import static org.junit.Assert.assertEquals;
+
+import javax.ws.rs.core.Response;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.ccsdk.apps.ms.neng.core.service.rs.RestService;
+import org.onap.ccsdk.apps.ms.neng.persistence.repository.GeneratedNameRespository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@EnableAutoConfiguration
+@WebAppConfiguration
+@SpringBootTest
+@ActiveProfiles("test")
+public class HelloTest {
+ @Autowired
+ RestService service;
+ @Autowired
+ GeneratedNameRespository repo;
+
+ @Test
+ public void testQuickHello() throws Exception {
+ Response response = service.getQuickHello("test");
+ assertEquals("message = Hello test!", response.getEntity().toString());
+ }
+}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java
new file mode 100644
index 00000000..a1873692
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceIntTest.java
@@ -0,0 +1,221 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.service;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.when;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.onap.ccsdk.apps.ms.neng.core.exceptions.NengException;
+import org.onap.ccsdk.apps.ms.neng.core.persistence.NamePersister;
+import org.onap.ccsdk.apps.ms.neng.core.resource.model.NameGenRequest;
+import org.onap.ccsdk.apps.ms.neng.core.resource.model.NameGenResponse;
+import org.onap.ccsdk.apps.ms.neng.core.service.rs.RestServiceImpl;
+import org.onap.ccsdk.apps.ms.neng.persistence.entity.GeneratedName;
+import org.onap.ccsdk.apps.ms.neng.persistence.entity.PolicyDetails;
+import org.onap.ccsdk.apps.ms.neng.persistence.repository.PolicyDetailsRepository;
+import org.onap.ccsdk.apps.ms.neng.persistence.repository.ServiceParameterRepository;
+import org.onap.ccsdk.apps.ms.neng.service.extinf.impl.AaiServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager;
+import org.springframework.boot.test.mock.mockito.SpyBean;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.RequestEntity;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.web.client.RestTemplate;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@DataJpaTest
+@ActiveProfiles("test")
+public class SpringServiceIntTest {
+ @Autowired
+ TestEntityManager entityManager;
+ @SpyBean
+ SpringService springService;
+ @Autowired
+ NamePersister namePersister;
+ @Autowired
+ @Qualifier("policyMgrRestTempBuilder")
+ RestTemplateBuilder policyMgrRestTempBuilder;
+ @Mock
+ RestTemplate restTemplate;
+ @Autowired
+ PolicyDetailsRepository policyDetailsRepo;
+ @Autowired
+ ServiceParameterRepository serviceParamRepo;
+ @Autowired
+ AaiServiceImpl aaiServiceImpl;
+ @Autowired
+ RestServiceImpl restServiceImpl;
+
+ @Before
+ public void setup() {
+ doReturn(restTemplate).when(policyMgrRestTempBuilder).build();
+ }
+
+ @Test
+ public void testObjects() {
+ assertNotNull(entityManager);
+ assertNotNull(namePersister);
+ assertNotNull(springService);
+ }
+
+ @Test
+ public void testNamePersiser() throws Exception {
+ GeneratedName name = new GeneratedName();
+ name.setName("abcd6ytx");
+ name.setPrefix("dlpv");
+ name.setSuffix("ytx");
+ name.setSequenceNumber(006L);
+ name.setElementType("VNF");
+ name.setGeneratedNameId(1000);
+ name.setExternalId("EXT-11");
+
+ namePersister.persist(name);
+ name = namePersister.findBy("VNF", "abcd6ytx", null);
+ assertNotNull(name);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testGenName_1() throws Exception {
+ ResponseEntity<Object> resp = new ResponseEntity<Object>(
+ getConfigResponse("JQINSRIOV.Config_MS_SriovBigJson.1.xml"), HttpStatus.OK);
+ when(restTemplate.exchange(Matchers.any(RequestEntity.class), Matchers.any(Class.class))).thenReturn(resp);
+ when(aaiServiceImpl.validate(Matchers.anyString(), Matchers.anyString())).thenReturn(true);
+ NameGenRequest request = nameGenRequest_1();
+ NameGenResponse genresp = springService.genNetworkElementName(request);
+ assertTrue("vnf-name".equals(genresp.getElements().get(0).get("resource-name")));
+ }
+
+ NameGenRequest nameGenRequest_1() {
+ Map<String, String> vnfMap = new HashMap<>();
+ vnfMap.put("external-key", "VQA-UN8");
+ vnfMap.put("policy-instance-name", "JQINSRIOV.Config_MS_SriovBigJson.1.xml");
+ vnfMap.put("complex", "vnfunfc");
+ vnfMap.put("NF_NAMING_CODE", "xyFg12");
+ vnfMap.put("resource-name", "vnf-name");
+ vnfMap.put("naming-type", "VNF");
+ vnfMap.put("nf-role", "vPE");
+
+ List<Map<String, String>> elements = new ArrayList<>();
+ elements.add(vnfMap);
+ NameGenRequest request = new NameGenRequest();
+ request.setElements(elements);
+
+ return request;
+ }
+
+ NameGenRequest nameGenRequestRelease() {
+ NameGenRequest request = new NameGenRequest();
+ Map<String, String> vnfMap = new HashMap<>();
+ vnfMap.put("external-key", "VQA-UN8");
+ List<Map<String, String>> elements = new ArrayList<>();
+ elements.add(vnfMap);
+ request.setElements(elements);
+
+ return request;
+ }
+
+ Object getConfigResponse(String policyName) throws Exception {
+ ObjectMapper objectmapper = new ObjectMapper();
+ objectmapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
+ PolicyDetails policyDetails = policyDetailsRepo.findPolicyResponseByName(policyName);
+ List<Map<Object, Object>> respObj = objectmapper.readValue(policyDetails.getPolicyResponse(),
+ new TypeReference<List<Map<Object, Object>>>() {});
+ return respObj;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testRestGenerateNetworkElementName() throws Exception {
+ NameGenRequest request = nameGenRequest_1();
+ ResponseEntity<Object> resp = new ResponseEntity<Object>(
+ getConfigResponse("JQINSRIOV.Config_MS_SriovBigJson.1.xml"), HttpStatus.OK);
+ when(restTemplate.exchange(Matchers.any(RequestEntity.class), Matchers.any(Class.class))).thenReturn(resp);
+ when(aaiServiceImpl.validate(Matchers.anyString(), Matchers.anyString())).thenReturn(true);
+ restServiceImpl.generateNetworkElementName(request);
+ }
+
+ @Test
+ public void testRestGenerateNetworkElementName_exp() throws Exception {
+ NameGenRequest request = nameGenRequest_1();
+ doThrow(new NengException("")).when(springService).genNetworkElementName(request);
+ restServiceImpl.generateNetworkElementName(request);
+ }
+
+ @Test
+ public void testRestReleaseNetworkElementName() throws Exception {
+ NameGenRequest request = nameGenRequestRelease();
+ restServiceImpl.releaseNetworkElementName(request);
+ }
+
+ @Test
+ public void testRestReleaseNetworkElementName_exp() throws Exception {
+ NameGenRequest request = nameGenRequestRelease();
+ doThrow(new NengException("")).when(springService).releaseNetworkElementName(request);
+ restServiceImpl.releaseNetworkElementName(request);
+ }
+
+ @Test
+ public void testRestGetPolicyResponse() throws Exception {
+ List<Map<String, Object>> policyResponse =
+ restServiceImpl.getPolicyResponse("JQINSRIOV.Config_MS_SriovBigJson.1.xml");
+ assertNotNull(policyResponse);
+ }
+
+ @Test
+ public void testRestAddPolicyToDb() throws Exception {
+ Map<String, Object> policy = new HashMap<>();
+ policy.put("policyName", "policyname");
+ policy.put("policyValue", "policyname");
+ restServiceImpl.addPolicyToDb(policy);
+ }
+
+ @Test
+ public void testRestAddPolicyToDB_exp() throws Exception {
+ Map<String, Object> policy = new HashMap<>();
+ policy.put("policyName", "policyname");
+ policy.put("policyValue", "policyname");
+
+ doThrow(new NengException("")).when(springService).addPolicy(policy);
+ restServiceImpl.addPolicyToDb(policy);
+ }
+}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java
new file mode 100644
index 00000000..303692c5
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceTest.java
@@ -0,0 +1,108 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.ccsdk.apps.ms.neng.core.resource.model.NameGenRequest;
+import org.onap.ccsdk.apps.ms.neng.core.validator.ExternalKeyValidator;
+import org.onap.ccsdk.apps.ms.neng.persistence.entity.GeneratedName;
+import org.onap.ccsdk.apps.ms.neng.persistence.entity.PolicyDetails;
+import org.onap.ccsdk.apps.ms.neng.persistence.entity.ServiceParameter;
+import org.onap.ccsdk.apps.ms.neng.persistence.repository.GeneratedNameRespository;
+import org.onap.ccsdk.apps.ms.neng.persistence.repository.PolicyDetailsRepository;
+import org.onap.ccsdk.apps.ms.neng.persistence.repository.ServiceParameterRepository;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SpringServiceTest {
+
+ @Mock
+ ExternalKeyValidator externalKeyValidator;
+ @Mock
+ ServiceParameter param;
+ @Mock
+ ServiceParameterRepository serviceParamRepo;
+ @Mock
+ PolicyDetails policyDetails;
+ @Mock
+ PolicyDetailsRepository policyDetailsRepository;
+ @Mock
+ GeneratedNameRespository generatedNameRepository;
+
+ @InjectMocks
+ SpringServiceImpl springserviceImpl;
+
+ Map<String, String> req = new HashMap<>();
+ List<Map<String, String>> rsp = new ArrayList<>();
+ NameGenRequest request = new NameGenRequest();
+
+ {
+ req.put("external-key", "Xyx-zzk");
+ req.put("policy-instance-name", "testDbPolicy66");
+ req.put("COMPLEX", "TRLAKDG");
+ req.put("NFC-NAMING-CODE", "ESP");
+ req.put("CLOUD_REGION_ID", "SSR");
+ req.put("NF_CODE", "X1234");
+ req.put("resource-name", "vm-name");
+ req.put("naming-type", "VM");
+ req.put("nf-role", "vPE");
+ rsp.add(req);
+ request.setElements(rsp);
+ }
+
+ @Test(expected = Exception.class)
+ public void genNetworkElementNameTest() throws Exception {
+ Mockito.when(externalKeyValidator.isPresent(req.get("external-key"))).thenReturn(false);
+ Mockito.when(serviceParamRepo.findByName("use_db_policy")).thenReturn(param);
+ springserviceImpl.genNetworkElementName(request);
+
+ }
+
+ @Test
+ public void getPolicyDetailsTest() {
+ Mockito.when(policyDetailsRepository.findPolicyResponseByName("testDbPolicy66")).thenReturn(policyDetails);
+ org.junit.Assert.assertNotNull(springserviceImpl.getPolicyDetails("testDbPolicy66"));
+ }
+
+ @Test
+ public void addPolicy() throws Exception {
+ springserviceImpl.addPolicy(req);
+ }
+
+ @Test
+ public void releaseNetworkElementNameTest() throws Exception {
+ GeneratedName gn = new GeneratedName();
+ List<GeneratedName> generatedNameList = new ArrayList<>();
+ generatedNameList.add(gn);
+
+ Mockito.when(generatedNameRepository.findByExternalId(req.get("external-key"))).thenReturn(generatedNameList);
+ Assert.assertNotNull(springserviceImpl.releaseNetworkElementName(request));
+ }
+}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/TestApplicationConfig.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/TestApplicationConfig.java
new file mode 100644
index 00000000..5e30bac9
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/core/service/TestApplicationConfig.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.service;
+
+import static org.mockito.Mockito.spy;
+
+import org.mockito.Mockito;
+import org.onap.ccsdk.apps.ms.neng.core.rs.interceptors.PolicyManagerAuthorizationInterceptor;
+import org.onap.ccsdk.apps.ms.neng.service.extinf.impl.AaiServiceImpl;
+import org.springframework.boot.SpringBootConfiguration;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@SpringBootConfiguration
+@ActiveProfiles("test")
+@ComponentScan(basePackages = {"org.onap.ccsdk.apps.ms.neng"})
+@EnableJpaRepositories(basePackages = "org.onap.ccsdk.apps.ms.neng.persistence.repository")
+@EntityScan(basePackages = {"org.onap.ccsdk.apps.ms.neng.persistence.entity"})
+@EnableTransactionManagement
+public class TestApplicationConfig {
+
+ @Bean
+ @Primary
+ public RestTemplateBuilder policyMgrRestTempBuilder(PolicyManagerAuthorizationInterceptor auth) {
+ RestTemplateBuilder restTemplateBuiler = new RestTemplateBuilder();
+ return spy(restTemplateBuiler.additionalInterceptors(auth));
+ }
+
+ @Bean
+ @Primary
+ AaiServiceImpl aaiServiceImpl() {
+ return Mockito.mock(AaiServiceImpl.class);
+ }
+}
diff --git a/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java
new file mode 100644
index 00000000..17dddd4e
--- /dev/null
+++ b/ms/neng/src/test/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImplTest.java
@@ -0,0 +1,200 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 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.ccsdk.apps.ms.neng.service.extinf.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.when;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Spy;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.ccsdk.apps.ms.neng.core.exceptions.NengException;
+import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigRequest;
+import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigResponse;
+import org.onap.ccsdk.apps.ms.neng.core.rs.interceptors.PolicyManagerAuthorizationInterceptor;
+import org.onap.ccsdk.apps.ms.neng.extinf.props.PolicyManagerProps;
+import org.springframework.boot.web.client.RestTemplateBuilder;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.RequestEntity;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PolicyFinderServiceImplTest {
+ @InjectMocks
+ @Spy
+ PolicyFinderServiceImpl policyFinder;
+ @Spy
+ PolicyManagerProps policManProps;
+ @Mock
+ RestTemplateBuilder policyMgrRestTempBuilder;
+ @Mock
+ PolicyManagerAuthorizationInterceptor authInt;
+ @Mock
+ RestTemplate restTemplate;
+
+ @Test
+ public void testConfig() throws Exception {
+ doReturn(new GetConfigResponse()).when(policyFinder).makeOutboundCall(Matchers.any(), Matchers.any());
+ assertNotNull(policyFinder.getConfig("policy"));
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testmakeOutboundCall() throws Exception {
+ Map<String, Object> configMap = buildPolicyResponse();
+ Object resp = Arrays.asList(new Object[] {configMap});
+ ResponseEntity<Object> respEn = new ResponseEntity<>(resp, HttpStatus.OK);
+ when(restTemplate.exchange(Matchers.any(RequestEntity.class), Matchers.any(Class.class))).thenReturn(respEn);
+
+ policManProps.setUrl("http://policyManager.onap.org");
+
+ GetConfigRequest request = new GetConfigRequest();
+ request.setPolicyName("policy");
+ GetConfigResponse configResp = policyFinder.makeOutboundCall(request, GetConfigResponse.class);
+ assertNotNull(configResp);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test(expected = NengException.class)
+ public void testmakeOutboundCall_500() throws Exception {
+ Map<String, Object> configMap = buildPolicyResponse();
+ Object resp = Arrays.asList(new Object[] {configMap});
+ ResponseEntity<Object> respEn = new ResponseEntity<>(resp, HttpStatus.INTERNAL_SERVER_ERROR);
+ when(restTemplate.exchange(Matchers.any(RequestEntity.class), Matchers.any(Class.class))).thenReturn(respEn);
+
+ policManProps.setUrl("http://policyManager.onap.org");
+
+ GetConfigRequest request = new GetConfigRequest();
+ request.setPolicyName("policy");
+ policyFinder.makeOutboundCall(request, GetConfigResponse.class);
+ }
+
+ @Test
+ public void testGetRestTemplate() throws Exception {
+ PolicyFinderServiceImpl service = new PolicyFinderServiceImpl();
+ RestTemplateBuilder policyRestTemplateBuilder = new RestTemplateBuilder();
+ service.setPolicyMgrRestTempBuilder(policyRestTemplateBuilder);
+ service.setAuthInt(new PolicyManagerAuthorizationInterceptor());
+
+ assertNotNull(service.getPolicyMgrRestTempBuilder());
+ assertNotNull(service.getAuthInt());
+ assertNotNull(service.getRestTemplate());
+ }
+
+ @Test
+ public void testTransformConfigObject() throws Exception {
+ String config = "{\"riskLevel\":\"4\",\"riskType\":\"test\","
+ + "\"policyName\":\"1806SriovBigJson\",\"service\":\"SDNC-GenerateName\","
+ + "\"guard\":\"False\",\"description\":\"1806SriovBigJson\","
+ + "\"templateVersion\":\"1607\",\"priority\":\"4\",\"version\":\"pannny_nnnn\","
+ + "\"content\":{\"policy-instance-name\":\"1806NameGenerationPolicyForSRIOV\","
+ + "\"naming-models\":[{\"naming-properties\":[{\"property-operation\":\"substr(5)\","
+ + "\"property-name\":\"COMPLEX\"},{\"property-name\":\"SEQUENCE\","
+ + "\"increment-sequence\":{\"max\":\"zzz\",\"scope\":\"ENTIRETY\","
+ + "\"start-value\":\"001\",\"length\":\"3\",\"increment\":\"1\","
+ + "\"sequence-type\":\"alpha-numeric\"}},{\"property-name\":\"NF_NAMING_CODE\"}],"
+ + "\"naming-type\":\"VNF\",\"nfRole\":\"vPE\","
+ + "\"naming-recipe\":\"COMPLEX|SEQUENCE|NF_NAMING_CODE\"},"
+ + "{\"naming-properties\":[{\"property-name\":\"VNF_NAME\"},"
+ + "{\"property-name\":\"SEQUENCE\",\"increment-sequence\":"
+ + "{\"max\":\"999\",\"scope\":\"ENTIRETY\",\"start-value\":\"001\",\"length\":\"3\","
+ + "\"increment\":\"1\",\"sequence-type\":\"numeric\"}},"
+ + "{\"property-operation\":\"substr(-3)\",\"property-name\":\"NFC_NAMING_CODE\"}],"
+ + "\"naming-type\":\"VM\",\"nfRole\":\"vPE\","
+ + "\"naming-recipe\":\"VNF_NAME|SEQUENCE|NFC_NAMING_CODE\"},"
+ + "{\"naming-properties\":[{\"property-name\":\"VNF_NAME\"},"
+ + "{\"property-value\":\"-\",\"property-name\":\"DELIMITER\"},"
+ + "{\"property-name\":\"VF_MODULE_LABEL\"},{\"property-name\":\"VF_MODULE_TYPE\"},"
+ + "{\"property-name\":\"SEQUENCE\",\"increment-sequence\":"
+ + "{\"max\":\"99\",\"scope\":\"PRECEEDING\",\"start-value\":\"01\",\"length\":\"2\","
+ + "\"increment\":\"1\",\"sequence-type\":\"numeric\"}}],"
+ + "\"naming-type\":\"VF-MODULE\",\"nfRole\":\"vPE\","
+ + "\"naming-recipe\":\"VNF_NAME|DELIMITER|VF_MODULE_LABEL|DELIMITER"
+ + "|VF_MODULE_TYPE|DELIMITER|SEQUENCE\"},"
+ + "{\"naming-properties\":[{\"property-name\":\"VF-MODULE_NAME\"},"
+ + "{\"property-value\":\"-\",\"property-name\":\"DELIMITER\"},"
+ + "{\"property-value\":\"volumegroup\",\"property-name\":\"CONSTANT\"}],"
+ + "\"naming-type\":\"VOLUME_GROUP\",\"nfRole\":\"vPE\","
+ + "\"naming-recipe\":\"VF-MODULE_NAME|DELIMITER|CONSTANT\"},"
+ + "{\"naming-properties\":[{\"property-name\":\"VOLUME_GROUP_NAME\"},"
+ + "{\"property-value\":\"-\",\"property-name\":\"DELIMITER\"},"
+ + "{\"property-value\":\"volume\",\"property-name\":\"CONSTANT\"},"
+ + "{\"property-name\":\"SEQUENCE\",\"increment-sequence\":"
+ + "{\"max\":\"99\",\"scope\":\"PRECEEDING\",\"start-value\":\"01\","
+ + "\"length\":\"2\",\"increment\":\"1\",\"sequence-type\":\"numeric\"}}],"
+ + "\"naming-type\":\"VOLUME\",\"nfRole\":\"vPE\","
+ + "\"naming-recipe\":\"VOLUME_GROUP_NAME|DELIMITER|CONSTANT|DELIMITER|SEQUENCE\"},"
+ + "{\"naming-properties\":[{\"property-name\":\"VNF_NAME\"},"
+ + "{\"property-value\":\"-\",\"property-name\":\"DELIMITER\"},"
+ + "{\"property-value\":\"affinity\",\"property-name\":\"CONSTANT\"}],"
+ + "\"naming-type\":\"AFFINITY\",\"nfRole\":\"vPE\","
+ + "\"naming-recipe\":\"VNF_NAME|DELIMITER|CONSTANT\"},"
+ + "{\"naming-properties\":[{\"property-name\":\"VNF_NAME\"},"
+ + "{\"property-value\":\"-\",\"property-name\":\"DELIMITER\"},"
+ + "{\"property-value\":\"INT\",\"property-name\":\"CONSTANT\"},"
+ + "{\"property-name\":\"SEQUENCE\",\"increment-sequence\":"
+ + "{\"max\":\"99\",\"scope\":\"PRECEEDING\",\"start-value\":\"01\","
+ + "\"length\":\"2\",\"increment\":\"1\",\"sequence-type\":\"numeric\"}}],"
+ + "\"naming-type\":\"INTERNAL_NETWORK\",\"nfRole\":\"vPE\","
+ + "\"naming-recipe\":\"VNF_NAME|DELIMITER|CONSTANT|SEQUENCE\"}]}}";
+ Map<Object, Object> configMap = new HashMap<>();
+ configMap.put("config", config);
+ ObjectMapper objectmapper = new ObjectMapper();
+ List<Map<Object, Object>> respList = new ArrayList<>();
+ respList.add(configMap);
+ policyFinder.transformConfigObject(objectmapper, respList);
+ assertNotNull(respList.get(0).get("config"));
+ }
+
+ Map<String, Object> buildPolicyResponse() {
+ Map<String, Object> policyDataMap = new HashMap<>();
+ policyDataMap.put("policy-instance-name", "SDNC_Policy.Config_MS_VNFCNamingPolicy");
+ Map<String, Object> namingModelMap = new HashMap<>();
+ namingModelMap.put("nf-role", "vPE");
+ namingModelMap.put("naming-type", "VNF");
+ namingModelMap.put("naming-recipe", "COMPLEX|NF-NAMING-CODE|Field2|Field3|Field4");
+ Map<String, Object> namingPropertyMap = new HashMap<>();
+ Map<String, Object> propertyMap1 = new HashMap<>();
+ propertyMap1.put("property-name", "COMPLEX");
+ Map<String, Object> propertyMap2 = new HashMap<>();
+ propertyMap2.put("property-name", "NF-NAMING-CODE");
+ namingPropertyMap.put("", Arrays.asList(new Object[] {propertyMap1, propertyMap2}));
+ namingModelMap.put("naming-properties", namingPropertyMap);
+ policyDataMap.put("naming-models", Arrays.asList(new Object[] {namingModelMap}));
+ Map<String, Object> configMap = new HashMap<>();
+ Map<String, Object> contentMap = new HashMap<>();
+ contentMap.put("content", policyDataMap);
+ configMap.put("config", contentMap);
+ return configMap;
+ }
+}
diff --git a/ms/neng/src/test/resources/application-test.properties b/ms/neng/src/test/resources/application-test.properties
new file mode 100644
index 00000000..ca8ac129
--- /dev/null
+++ b/ms/neng/src/test/resources/application-test.properties
@@ -0,0 +1,38 @@
+info.build.artifact=@project.artifactId@
+info.build.name=@project.name@
+info.build.description=@project.description@
+info.build.version=@project.version@
+
+spring.jersey.type=filter
+
+logging.level.root=info
+logging.level.org.glassfish=info
+logging.level.org.glassfish.jersey=info
+
+spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
+
+logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex
+
+liquibase.changeLog=classpath:/h2db/changelog/h2db.changelog-master.xml
+logging.level.liquibase: DEBUG
+
+spring.jersey.type=filter
+spring.mvc.urls=swagger,docs,prometheus,auditevents,info,heapdump,autoconfig,beans,loggers,dump,env,trace,health,configprops,mappings
+
+server.contextPath=/web
+
+spring.datasource.driver-class-name=org.h2.Driver
+spring.datasource.username=sa
+spring.datasource.password=sa
+spring.jpa.hibernate.ddl-auto=none
+spring.jpa.show-sql=true
+spring.datasource.url=jdbc:h2:mem:tests;DB_CLOSE_DELAY=-1;
+
+datasource.db.driver-class-name=org.h2.Driver
+datasource.db.url=jdbc:h2:mem:tests;DB_CLOSE_DELAY=-1;
+datasource.db.username=sa
+datasource.db.password=sa
+jpa.hibernate.ddl-auto=none
+jpa.show-sql=true
+
+entitymanager.packagesToScan=org.onap.ccsdk.apps.ms.neng.persistence.entity
diff --git a/ms/neng/src/test/resources/h2db/changelog/h2db.changelog-master.xml b/ms/neng/src/test/resources/h2db/changelog/h2db.changelog-master.xml
new file mode 100644
index 00000000..496a2e9d
--- /dev/null
+++ b/ms/neng/src/test/resources/h2db/changelog/h2db.changelog-master.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<databaseChangeLog
+ xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
+ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
+
+ <include file="db/changelog/scripts/rel_18_10/create_base_tables.sql" />
+ <include file="db/changelog/scripts/rel_18_10/01_initial_ref_data_v1.sql" />
+ <include file="db/changelog/scripts/rel_18_10/02_create_indexes_ddl.sql" />
+ <include file="db/changelog/scripts/rel_18_10/04_ref_data_extrn_int.sql" />
+
+ <include file="h2db/changelog/scripts/50_load_sim_data_dml.sql" />
+ <include file="h2db/changelog/scripts/51_ref_data_upd_dml.sql" />
+</databaseChangeLog> \ No newline at end of file
diff --git a/ms/neng/src/test/resources/h2db/changelog/scripts/50_load_sim_data_dml.sql b/ms/neng/src/test/resources/h2db/changelog/scripts/50_load_sim_data_dml.sql
new file mode 100644
index 00000000..5c750bd2
--- /dev/null
+++ b/ms/neng/src/test/resources/h2db/changelog/scripts/50_load_sim_data_dml.sql
@@ -0,0 +1,23 @@
+--liquibase formatted sql
+--changeset policy_man_sim:18_06.table_load.sql
+
+insert into policy_man_sim(policy_name, policy_response) values ('JQINSRIOV.Config_MS_SriovBigJson.1.xml', '[
+ {
+ "policyConfigMessage": "Config Retrieved! ",
+ "policyConfigStatus": "CONFIG_RETRIEVED",
+ "type": "JSON",
+ "config": {"riskLevel":"4","riskType":"test","policyName":"SriovBigJson","service":"SDNC-GenerateName","guard":"False","description":"SriovBigJson","templateVersion":"1607","priority":"4","version":"pannny_nnnn","content":{"policy-instance-name":"NameGenerationPolicyForSRIOV","naming-models":[{"naming-properties":[{"property-operation":"substr(5)","property-name":"COMPLEX"},{"property-name":"SEQUENCE","increment-sequence":{"max":"zzz","scope":"ENTIRETY","start-value":"001","length":"3","increment":"1","sequence-type":"alpha-numeric"}},{"property-name":"NF_NAMING_CODE"}],"naming-type":"VNF","nfRole":"vPE","naming-recipe":"COMPLEX|SEQUENCE|NF_NAMING_CODE"},{"naming-properties":[{"property-name":"VNF_NAME"},{"property-name":"SEQUENCE","increment-sequence":{"max":"999","scope":"ENTIRETY","start-value":"001","length":"3","increment":"1","sequence-type":"numeric"}},{"property-operation":"substr(-3)","property-name":"NFC_NAMING_CODE"}],"naming-type":"VM","nfRole":"vPE","naming-recipe":"VNF_NAME|SEQUENCE|NFC_NAMING_CODE"},{"naming-properties":[{"property-name":"VNF_NAME"},{"property-value":"-","property-name":"DELIMITER"},{"property-name":"VF_MODULE_LABEL"},{"property-name":"VF_MODULE_TYPE"},{"property-name":"SEQUENCE","increment-sequence":{"max":"99","scope":"PRECEEDING","start-value":"01","length":"2","increment":"1","sequence-type":"numeric"}}],"naming-type":"VF-MODULE","nfRole":"vPE","naming-recipe":"VNF_NAME|DELIMITER|VF_MODULE_LABEL|DELIMITER|VF_MODULE_TYPE|DELIMITER|SEQUENCE"},{"naming-properties":[{"property-name":"VF-MODULE_NAME"},{"property-value":"-","property-name":"DELIMITER"},{"property-value":"volumegroup","property-name":"CONSTANT"}],"naming-type":"VOLUME_GROUP","nfRole":"vPE","naming-recipe":"VF-MODULE_NAME|DELIMITER|CONSTANT"},{"naming-properties":[{"property-name":"VOLUME_GROUP_NAME"},{"property-value":"-","property-name":"DELIMITER"},{"property-value":"volume","property-name":"CONSTANT"},{"property-name":"SEQUENCE","increment-sequence":{"max":"99","scope":"PRECEEDING","start-value":"01","length":"2","increment":"1","sequence-type":"numeric"}}],"naming-type":"VOLUME","nfRole":"vPE","naming-recipe":"VOLUME_GROUP_NAME|DELIMITER|CONSTANT|DELIMITER|SEQUENCE"},{"naming-properties":[{"property-name":"VNF_NAME"},{"property-value":"-","property-name":"DELIMITER"},{"property-value":"affinity","property-name":"CONSTANT"}],"naming-type":"AFFINITY","nfRole":"vPE","naming-recipe":"VNF_NAME|DELIMITER|CONSTANT"},{"naming-properties":[{"property-name":"VNF_NAME"},{"property-value":"-","property-name":"DELIMITER"},{"property-value":"INT","property-name":"CONSTANT"},{"property-name":"SEQUENCE","increment-sequence":{"max":"99","scope":"PRECEEDING","start-value":"01","length":"2","increment":"1","sequence-type":"numeric"}}],"naming-type":"INTERNAL_NETWORK","nfRole":"vPE","naming-recipe":"VNF_NAME|DELIMITER|CONSTANT|SEQUENCE"}]}},
+ "policyName": "JQINSRIOV.Config_MS_SriovBigJson.1.xml",
+ "policyType": "MicroService",
+ "policyVersion": "1",
+ "matchingConditions": {
+ "ECOMPName": "SDNC",
+ "ONAPName": "SDNC",
+ "service": "SDNC-GenerateName"
+ },
+ "responseAttributes": {},
+ "property": null
+ }
+]');
+
+commit; \ No newline at end of file
diff --git a/ms/neng/src/test/resources/h2db/changelog/scripts/51_ref_data_upd_dml.sql b/ms/neng/src/test/resources/h2db/changelog/scripts/51_ref_data_upd_dml.sql
new file mode 100644
index 00000000..2114a624
--- /dev/null
+++ b/ms/neng/src/test/resources/h2db/changelog/scripts/51_ref_data_upd_dml.sql
@@ -0,0 +1,5 @@
+--liquibase formatted sql
+--changeset ref_data_update:18_10.ref_data_update.sql
+
+DELETE FROM SERVICE_PARAMETER where NAME='use_db_policy';
+INSERT INTO SERVICE_PARAMETER(NAME, VALUE, CREATED_BY) VALUES ('use_db_policy','Y','Initial');