summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core')
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/pom.xml60
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/CassandraBaseDao.java50
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueCassandraDaoImpl.java65
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueDaoFactoryImpl.java33
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraNoSqlDbFactoryImpl.java43
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraNoSqlDbImpl.java104
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java124
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java92
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java234
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml253
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/NoSqlDbTest.java48
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/utilities/Yaml/YamlUtilTest.java47
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/utilities/json/JsonUtilTest.java13
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/testobjects/yaml/InnerP.java25
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/testobjects/yaml/Parameter.java68
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/testobjects/yaml/YamlFile.java37
16 files changed, 1296 insertions, 0 deletions
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/pom.xml b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/pom.xml
new file mode 100644
index 0000000000..d799edb961
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/pom.xml
@@ -0,0 +1,60 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <groupId>org.openecomp.sdc</groupId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../../..</relativePath>
+ </parent>
+
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-nosqldb-core</artifactId>
+ <name>openecomp-nosqldb-core</name>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-nosqldb-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ <version>1.14</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>2.3.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <scope>test</scope>
+ <version>1.10.19</version>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ <version>6.8.5</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>snakeyaml</artifactId>
+ <groupId>org.yaml</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ <version>RELEASE</version>
+ </dependency>
+ </dependencies>
+</project> \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/CassandraBaseDao.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/CassandraBaseDao.java
new file mode 100644
index 0000000000..1b3dbc4c6f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/CassandraBaseDao.java
@@ -0,0 +1,50 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.core.dao.impl;
+
+import com.datastax.driver.mapping.Mapper;
+import org.openecomp.core.dao.BaseDao;
+
+public abstract class CassandraBaseDao<T> implements BaseDao<T> {
+ protected abstract Mapper<T> getMapper();
+
+ protected abstract Object[] getKeys(T entity);
+
+ @Override
+ public void create(T entity) {
+ getMapper().save(entity);
+ }
+
+ @Override
+ public void update(T entity) {
+ getMapper().save(entity);
+ }
+
+ @Override
+ public T get(T entity) {
+ return getMapper().get(getKeys(entity));
+ }
+
+ @Override
+ public void delete(T entity) {
+ getMapper().delete(entity);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueCassandraDaoImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueCassandraDaoImpl.java
new file mode 100644
index 0000000000..31dd602400
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueCassandraDaoImpl.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.core.dao.impl;
+
+import com.datastax.driver.mapping.Mapper;
+import com.datastax.driver.mapping.Result;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.dao.UniqueValueDao;
+import org.openecomp.core.dao.types.UniqueValueEntity;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+
+import java.util.Collection;
+
+public class UniqueValueCassandraDaoImpl extends CassandraBaseDao<UniqueValueEntity>
+ implements UniqueValueDao {
+
+ private static NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static Mapper<UniqueValueEntity> mapper =
+ noSqlDb.getMappingManager().mapper(UniqueValueEntity.class);
+ private static UniqueValueAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(UniqueValueAccessor.class);
+
+
+ @Override
+ protected Mapper<UniqueValueEntity> getMapper() {
+ return mapper;
+ }
+
+ @Override
+ protected Object[] getKeys(UniqueValueEntity entity) {
+ return new Object[]{entity.getType(), entity.getValue()};
+ }
+
+ @Override
+ public Collection<UniqueValueEntity> list(UniqueValueEntity entity) {
+ return accessor.listAll().all();
+ }
+
+ @Accessor
+ interface UniqueValueAccessor {
+
+ @Query("select * from unique_value")
+ Result<UniqueValueEntity> listAll();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueDaoFactoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueDaoFactoryImpl.java
new file mode 100644
index 0000000000..b717fcbee1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/dao/impl/UniqueValueDaoFactoryImpl.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.core.dao.impl;
+
+import org.openecomp.core.dao.UniqueValueDao;
+import org.openecomp.core.dao.UniqueValueDaoFactory;
+
+public class UniqueValueDaoFactoryImpl extends UniqueValueDaoFactory {
+ private static UniqueValueDao INSTANCE = new UniqueValueCassandraDaoImpl();
+
+ @Override
+ public UniqueValueDao createInterface() {
+ return INSTANCE;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraNoSqlDbFactoryImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraNoSqlDbFactoryImpl.java
new file mode 100644
index 0000000000..2922925171
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraNoSqlDbFactoryImpl.java
@@ -0,0 +1,43 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.core.nosqldb.impl.cassandra;
+
+import com.datastax.driver.core.Session;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+
+public class CassandraNoSqlDbFactoryImpl extends NoSqlDbFactory {
+
+ @Override
+ public NoSqlDb createInterface() {
+
+
+ return new CassandraNoSqlDbImpl(ReferenceHolder.CASSANDRA);
+ }
+
+ protected void stop() {
+ ReferenceHolder.CASSANDRA.close();
+ }
+
+ private static class ReferenceHolder {
+ private static final Session CASSANDRA = CassandraSessionFactory.getSession();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraNoSqlDbImpl.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraNoSqlDbImpl.java
new file mode 100644
index 0000000000..bcac5f8d79
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraNoSqlDbImpl.java
@@ -0,0 +1,104 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.core.nosqldb.impl.cassandra;
+
+import com.datastax.driver.core.BoundStatement;
+import com.datastax.driver.core.PreparedStatement;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Session;
+import com.datastax.driver.mapping.MappingManager;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.util.CassandraUtils;
+import org.openecomp.core.utilities.CommonMethods;
+import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
+import org.openecomp.sdc.common.errors.ErrorCode;
+
+class CassandraNoSqlDbImpl implements NoSqlDb {
+
+ private final Session session;
+ private final String keySpace;
+ private final MappingManager mappingManager;
+
+
+ public CassandraNoSqlDbImpl(Session session) {
+ this.session = session;
+ this.keySpace = this.session.getLoggedKeyspace();
+ this.mappingManager = new MappingManager(this.session);
+
+ }
+
+ @Override
+ public void insert(String tableName, String[] colNames, Object[] values) {
+ if (colNames.length != values.length) {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder()).withMessage(
+ "number of colmuns[" + colNames.length + "] is not equal to the number of values["
+ + values.length + "].").withId("E0005").withCategory(ErrorCategory.APPLICATION)
+ .build());
+ }
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("insert into ")
+ .append(tableName)
+ .append(" (")
+ .append(CommonMethods.arrayToCommaSeparatedString(colNames))
+ .append(") values (")
+ .append(CommonMethods.duplicateStringWithDelimiter("?", ',', values.length))
+ .append(")");
+ System.out.println(sb.toString());
+ PreparedStatement prepared = session.prepare(sb.toString());
+
+ BoundStatement bound;
+ bound = prepared.bind(values);
+ session.execute(bound);
+
+ }
+
+ @Override
+ public ResultSet execute(String statement) {
+ return session.execute(statement);
+ }
+
+ @Override
+ public ResultSet execute(String statementName, Object... values) {
+
+ String statement = CassandraUtils.getStatement(statementName);
+ if (statement == null) {
+ statement = statementName;
+ }
+ if (values != null) {
+ PreparedStatement prepared = session.prepare(statement);
+
+ BoundStatement bound;
+ bound = prepared.bind(values);
+ return session.execute(bound);
+ } else {
+ return session.execute(statement);
+ }
+
+ }
+
+ @Override
+ public MappingManager getMappingManager() {
+ return mappingManager;
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java
new file mode 100644
index 0000000000..1b98f095b5
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/impl/cassandra/CassandraSessionFactory.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.core.nosqldb.impl.cassandra;
+
+import com.google.common.base.Optional;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.SSLOptions;
+import com.datastax.driver.core.Session;
+
+import org.openecomp.core.nosqldb.util.CassandraUtils;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.security.KeyManagementException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManagerFactory;
+
+public class CassandraSessionFactory {
+ public static Session getSession() {
+ return ReferenceHolder.CASSANDRA;
+ }
+
+ /**
+ * New cassandra session session.
+ *
+ * @return the session
+ */
+ public static Session newCassandraSession() {
+ Cluster.Builder builder = Cluster.builder();
+ String[] addresses = CassandraUtils.getAddresses();
+ for (String address : addresses) {
+ builder.addContactPoint(address);
+ }
+ Boolean isSsl = CassandraUtils.isSsl();
+ if (isSsl) {
+ builder.withSSL(getSslOptions().get());
+ }
+ int port = CassandraUtils.getCassandraPort();
+ if (port > 0) {
+ builder.withPort(port);
+ }
+ //Check if user/pass
+ Boolean isAuthenticate = CassandraUtils.isAuthenticate();
+ if (isAuthenticate) {
+ builder.withCredentials(CassandraUtils.getUser(), CassandraUtils.getPassword());
+ }
+
+ Cluster cluster = builder.build();
+ String keyStore = CassandraUtils.getKeySpace();
+ return cluster.connect(keyStore);
+ }
+
+ private static Optional<SSLOptions> getSslOptions() {
+ Optional<String> truststorePath = Optional.of(CassandraUtils.getTruststore());
+ Optional<String> truststorePassword = Optional.of(CassandraUtils.getTruststorePassword());
+
+ if (truststorePath.isPresent() && truststorePassword.isPresent()) {
+ SSLContext context;
+ try {
+ context = getSslContext(truststorePath.get(), truststorePassword.get());
+ } catch (UnrecoverableKeyException | KeyManagementException
+ | NoSuchAlgorithmException | KeyStoreException | CertificateException | IOException e0) {
+ throw new RuntimeException(e0);
+ }
+ String[] css = new String[]{"TLS_RSA_WITH_AES_128_CBC_SHA"};
+ return Optional.of(new SSLOptions(context, css));
+ }
+ return Optional.absent();
+ }
+
+ private static SSLContext getSslContext(String truststorePath, String truststorePassword)
+ throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException,
+ UnrecoverableKeyException, KeyManagementException {
+ FileInputStream tsf = null;
+ SSLContext ctx = null;
+ try {
+ tsf = new FileInputStream(truststorePath);
+ ctx = SSLContext.getInstance("SSL");
+
+ KeyStore ts = KeyStore.getInstance("JKS");
+ ts.load(tsf, truststorePassword.toCharArray());
+ TrustManagerFactory tmf =
+ TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ tmf.init(ts);
+
+ ctx.init(null, tmf.getTrustManagers(), new SecureRandom());
+ } catch (Exception e0) {
+ e0.printStackTrace();
+ } finally {
+ tsf.close();
+
+ }
+ return ctx;
+ }
+
+ private static class ReferenceHolder {
+ private static final Session CASSANDRA = newCassandraSession();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java
new file mode 100644
index 0000000000..2a88d0e521
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/CassandraUtils.java
@@ -0,0 +1,92 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.core.nosqldb.util;
+
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.core.utilities.json.JsonUtil;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+public class CassandraUtils {
+
+
+ private static final String CASSANDRA_STATEMENT_DEFINITION_FILE = "cassandraStatements.json";
+ private static Map<String, String> statementMap = new HashMap<>();
+
+ public static String[] getAddresses() {
+ return ConfigurationManager.getInstance().getAddresses();
+
+ }
+
+ public static String getKeySpace() {
+ return ConfigurationManager.getInstance().getKeySpace();
+ }
+
+ /**
+ * Gets statement.
+ *
+ * @param statementName the statement name
+ * @return the statement
+ */
+ public static String getStatement(String statementName) {
+ if (statementMap.size() == 0) {
+ InputStream statementJson = FileUtils.getFileInputStream(CASSANDRA_STATEMENT_DEFINITION_FILE);
+ statementMap = JsonUtil.json2Object(statementJson, Map.class);
+ }
+ return statementMap.get(statementName);
+ }
+
+ public static String getUser() {
+
+ return ConfigurationManager.getInstance().getUsername();
+ }
+
+ public static String getPassword() {
+ return ConfigurationManager.getInstance().getPassword();
+
+ }
+
+ public static String getTruststore() {
+ return ConfigurationManager.getInstance().getTruststorePath();
+
+ }
+
+ public static String getTruststorePassword() {
+ return ConfigurationManager.getInstance().getTruststorePassword();
+
+ }
+
+ public static int getCassandraPort() {
+ return ConfigurationManager.getInstance().getSslPort();
+
+ }
+
+ public static boolean isSsl() {
+ return ConfigurationManager.getInstance().isSsl();
+
+ }
+
+ public static boolean isAuthenticate() {
+ return ConfigurationManager.getInstance().isAuthenticate();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java
new file mode 100644
index 0000000000..a1c0b528fb
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/java/org/openecomp/core/nosqldb/util/ConfigurationManager.java
@@ -0,0 +1,234 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 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.openecomp.core.nosqldb.util;
+
+import org.openecomp.core.utilities.yaml.YamlUtil;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * The type Configuration manager.
+ */
+public class ConfigurationManager {
+
+ private static final String CONFIGURATION_YAML_FILE = "configuration.yaml";
+ private static final String cassandraKey = "cassandraConfig";
+ private static final String DEFAULT_KEYSPACE_NAME = "dox";
+ private static final String CASSANDRA_ADDRESSES = "cassandra.addresses";
+ private static final String CASSANDRA_DOX_KEY_STORE = "cassandra.dox.keystore";
+ private static final String CASSANDRA_AUTHENTICATE = "cassandra.authenticate";
+ private static final String CASSANDRA_USER = "cassandra.user";
+ private static final String CASSANDRA_PASSWORD = "cassandra.password";
+ private static final String CASSANDRA_PORT = "cassandra.port";
+ private static final String CASSANDRA_SSL = "cassandra.ssl";
+ private static final String CASSANDRA_TRUSTSTORE = "cassandra.Truststore";
+ private static final String CASSANDRA_TRUSTSTORE_PASSWORD = "cassandra.TruststorePassword";
+ private static final String cassandraHostsKey = "cassandraHosts";
+ private static final String cassandraPortKey = "port";
+ private static final String cassandraUsernameKey = "username";
+ private static final String cassandraPasswordKey = "password";
+ private static final String cassandraAuthenticateKey = "authenticate";
+ private static final String cassandraSSLKey = "ssl";
+ private static final String cassandraTruststorePathKey = "truststorePath";
+ private static final String cassandraTruststorePasswordKey = "truststorePassword";
+ private static ConfigurationManager instance = null;
+ private final LinkedHashMap<String, Object> cassandraConfiguration;
+
+
+ private ConfigurationManager() {
+ YamlUtil yamlUtil = new YamlUtil();
+ String configurationYamlFile = System.getProperty(CONFIGURATION_YAML_FILE);
+ InputStream yamlAsString;
+ if (configurationYamlFile != null) {
+ yamlAsString = getConfigFileIs(configurationYamlFile);
+ } else {
+ //Load from resources
+ yamlAsString = yamlUtil.loadYamlFileIs("/" + CONFIGURATION_YAML_FILE);
+ }
+ Map<String, LinkedHashMap<String, Object>> configurationMap = yamlUtil.yamlToMap(yamlAsString);
+ cassandraConfiguration = configurationMap.get(cassandraKey);
+
+ }
+
+ /**
+ * Gets instance.
+ *
+ * @return the instance
+ */
+ public static ConfigurationManager getInstance() {
+ if (instance == null) {
+ instance = new ConfigurationManager();
+ }
+ return instance;
+ }
+
+ /**
+ * Get addresses string [ ].
+ *
+ * @return the string [ ]
+ */
+ public String[] getAddresses() {
+
+ String addresses = System.getProperty(CASSANDRA_ADDRESSES);
+ if (addresses != null) {
+ return addresses.split(",");
+ }
+ List locAddresses = (ArrayList) cassandraConfiguration.get(cassandraHostsKey);
+ String[] addressesArray;
+ addressesArray = (String[]) locAddresses.toArray(new String[locAddresses.size()]);
+ return addressesArray;
+
+ }
+
+ /**
+ * Gets key space.
+ *
+ * @return the key space
+ */
+ public String getKeySpace() {
+ String keySpace = System.getProperty(CASSANDRA_DOX_KEY_STORE);
+ if (keySpace == null) {
+ //keySpace = cassandraConfiguration.get(cassandraKeySpaceKey);
+ //if (keySpace == null)
+ keySpace = DEFAULT_KEYSPACE_NAME;
+ }
+ return keySpace;
+ }
+
+ /**
+ * Gets username.
+ *
+ * @return the username
+ */
+ public String getUsername() {
+ String username = System.getProperty(CASSANDRA_USER);
+ if (username == null) {
+ username = (String) cassandraConfiguration.get(cassandraUsernameKey);
+ }
+ return username;
+ }
+
+ /**
+ * Gets password.
+ *
+ * @return the password
+ */
+ public String getPassword() {
+ String password = System.getProperty(CASSANDRA_PASSWORD);
+ if (password == null) {
+ password = (String) cassandraConfiguration.get(cassandraPasswordKey);
+ }
+ return password;
+ }
+
+ /**
+ * Gets truststore path.
+ *
+ * @return the truststore path
+ */
+ public String getTruststorePath() {
+ String truststorePath = System.getProperty(CASSANDRA_TRUSTSTORE);
+ if (truststorePath == null) {
+ truststorePath = (String) cassandraConfiguration.get(cassandraTruststorePathKey);
+ }
+ return truststorePath;
+ }
+
+ /**
+ * Gets truststore password.
+ *
+ * @return the truststore password
+ */
+ public String getTruststorePassword() {
+ String truststorePassword = System.getProperty(CASSANDRA_TRUSTSTORE_PASSWORD);
+ if (truststorePassword == null) {
+ truststorePassword = (String) cassandraConfiguration.get(cassandraTruststorePasswordKey);
+ }
+ return truststorePassword;
+ }
+
+ /**
+ * Gets ssl port.
+ *
+ * @return the ssl port
+ */
+ public int getSslPort() {
+ int port;
+ String sslPort = System.getProperty(CASSANDRA_PORT);
+ if (sslPort == null) {
+ sslPort = (String) cassandraConfiguration.get(cassandraPortKey);
+ if (sslPort == null) {
+ sslPort = "0";
+ }
+ }
+ port = Integer.valueOf(sslPort);
+ return port;
+ }
+
+
+ /**
+ * Is ssl boolean.
+ *
+ * @return the boolean
+ */
+ public boolean isSsl() {
+ return getBooleanResult(CASSANDRA_SSL, cassandraSSLKey);
+ }
+
+ /**
+ * Is authenticate boolean.
+ *
+ * @return the boolean
+ */
+ public boolean isAuthenticate() {
+ return getBooleanResult(CASSANDRA_AUTHENTICATE, cassandraAuthenticateKey);
+ }
+
+ private Boolean getBooleanResult(String property, String key) {
+ Boolean res;
+ String value;
+ if (System.getProperty(property) == null) {
+ value = String.valueOf(cassandraConfiguration.get(key));
+ } else {
+ value = System.getProperty(property);
+ }
+
+ res = Boolean.valueOf(value);
+
+ return res;
+ }
+
+ private InputStream getConfigFileIs(String file) {
+ InputStream is = null;
+ try {
+ is = new FileInputStream(file);
+ } catch (FileNotFoundException e0) {
+ e0.printStackTrace();
+ }
+ return is;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml
new file mode 100644
index 0000000000..0988f50237
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/main/resources/configuration.yaml
@@ -0,0 +1,253 @@
+identificationHeaderFields:
+ - HTTP_IV_USER
+ - HTTP_CSP_FIRSTNAME
+ - HTTP_CSP_LASTNAME
+ - HTTP_IV_REMOTE_ADDRESS
+ - HTTP_CSP_WSTYPE
+
+
+
+# catalog backend hostname
+beFqdn: sdccatalog.att.com
+
+# catalog backend http port
+beHttpPort: 8080
+
+# catalog backend http context
+beContext: /sdc/rest/config/get
+
+# catalog backend protocol
+beProtocol: http
+
+# catalog backend ssl port
+beSslPort: 8443
+
+version: 1.0
+released: 2012-11-30
+
+titanCfgFile: /home/vagrant/catalog-be/config/catalog-be/titan.properties
+titanInMemoryGraph: false
+titanLockTimeout: 30
+titanReconnectIntervalInSeconds: 3
+titanHealthCheckReadTimeout: 1
+esReconnectIntervalInSeconds: 3
+uebHealthCheckReconnectIntervalInSeconds: 15
+uebHealthCheckReadTimeout: 4
+
+# Protocols
+protocols:
+ - http
+ - https
+
+# Users
+users:
+ tom: passwd
+ bob: passwd
+
+neo4j:
+ host: neo4jhost
+ port: 7474
+ user: neo4j
+ password: "12345"
+
+cassandraConfig:
+ cassandraHosts: ['127.0.0.1']
+ reconnectTimeout : 30000
+ authenticate: false
+ username: sdc_user
+ password: Aa1234%^!
+ ssl: false
+ truststorePath : /path/path
+ truststorePassword : Aa123456
+ keySpaces:
+ - { name: dox, replicationStrategy: SimpleStrategy, replicationInfo: ['1']}
+ - { name: sdcartifact, replicationStrategy: SimpleStrategy, replicationInfo: ['1']}
+
+#Application-specific settings of ES
+elasticSearch:
+ # Mapping of index prefix to time-based frame. For example, if below is configured:
+ #
+ # - indexPrefix: auditingevents
+ # creationPeriod: minute
+ #
+ # then ES object of type which is mapped to "auditingevents-*" template, and created on 2015-12-23 13:24:54, will enter "auditingevents-2015-12-23-13-24" index.
+ # Another object created on 2015-12-23 13:25:54, will enter "auditingevents-2015-12-23-13-25" index.
+ # If creationPeriod: month, both of the above will enter "auditingevents-2015-12" index.
+ #
+ # PLEASE NOTE: the timestamps are created in UTC/GMT timezone! This is needed so that timestamps will be correctly presented in Kibana.
+ #
+ # Legal values for creationPeriod - year, month, day, hour, minute, none (meaning no time-based behaviour).
+ #
+ # If no creationPeriod is configured for indexPrefix, default behavour is creationPeriod: month.
+
+ indicesTimeFrequency:
+ - indexPrefix: auditingevents
+ creationPeriod: month
+ - indexPrefix: monitoring_events
+ creationPeriod: month
+
+artifactTypes:
+ - CHEF
+ - PUPPET
+ - SHELL
+ - YANG
+ - YANG_XML
+ - HEAT
+ - BPEL
+ - DG_XML
+ - MURANO_PKG
+ - OTHER
+
+licenseTypes:
+ - User
+ - Installation
+ - CPU
+
+#Deployment artifacts placeHolder
+deploymentResourceArtifacts:
+ heat:
+ displayName: "HEAT Template"
+ type: HEAT
+
+deploymentResourceInstanceArtifacts:
+ heatEnv:
+ displayName: "HEAT ENV"
+ type: HEAT_ENV
+ description: "Auto-generated HEAT Environment deployment artifact"
+ fileExtension: "env"
+
+#Informational artifacts placeHolder
+excludeResourceCategory:
+ - Generic
+informationalResourceArtifacts:
+ features:
+ displayName: Features
+ type: OTHER
+ capacity:
+ displayName: Capacity
+ type: OTHER
+ vendorTestResult:
+ displayName: Vendor Test Result
+ type: OTHER
+ testScripts:
+ displayName: Test Scripts
+ type: OTHER
+ cloudQuestionnaire:
+ displayName: Cloud Questionnaire (completed)
+ type: OTHER
+ HEATTemplateFromVendor:
+ displayName: HEAT Template from Vendor
+ type: HEAT
+
+excludeServiceCategory:
+
+informationalServiceArtifacts:
+ messageFlows:
+ displayName: Message Flows
+ type: OTHER
+ instantiationFlows:
+ displayName: Management Flows
+ type: OTHER
+ serviceArtifactPlan:
+ displayName: Service Artifact Plan
+ type: OTHER
+ summaryOfImpactsToECOMPElements:
+ displayName: Summary of impacts to ECOMP elements,OSSs, BSSs
+ type: OTHER
+ controlLoopFunctions:
+ displayName: Control Loop Functions
+ type: OTHER
+ dimensioningInfo:
+ displayName: Dimensioning Info
+ type: OTHER
+ affinityRules:
+ displayName: Affinity Rules
+ type: OTHER
+ operationalPolicies:
+ displayName: Operational Policies
+ type: OTHER
+ serviceSpecificPolicies:
+ displayName: Service-specific Policies
+ type: OTHER
+ engineeringRules:
+ displayName: Engineering Rules (ERD)
+ type: OTHER
+ distributionInstructions:
+ displayName: Distribution Instructions
+ type: OTHER
+ certificationTestResults:
+ displayName: TD Certification Test Results
+ type: OTHER
+ deploymentVotingRecord:
+ displayName: Deployment Voting Record
+ type: OTHER
+ serviceQuestionnaire:
+ displayName: Service Questionnaire
+ type: OTHER
+
+serviceApiArtifacts:
+ configuration:
+ displayName: Configuration
+ type: OTHER
+ instantiation:
+ displayName: Instantiation
+ type: OTHER
+ monitoring:
+ displayName: Monitoring
+ type: OTHER
+ reporting:
+ displayName: Reporting
+ type: OTHER
+ logging:
+ displayName: Logging
+ type: OTHER
+ testing:
+ displayName: Testing
+ type: OTHER
+
+
+additionalInformationMaxNumberOfKeys: 50
+
+systemMonitoring:
+ enabled: false
+ isProxy: false
+ probeIntervalInSeconds: 15
+
+defaultHeatArtifactTimeoutMinutes: 60
+
+serviceDeploymentArtifacts:
+
+resourceDeploymentArtifacts:
+ HEAT:
+ acceptedTypes:
+ - yaml
+ - yml
+
+resourceInformationalDeployedArtifacts:
+ YANG_XML:
+ acceptedTypes:
+ - xml
+
+
+unLoggedUrls:
+ - /sdc2/rest/healthCheck
+
+cleanComponentsConfiguration:
+ cleanIntervalInMinutes: 1440
+ componentsToClean:
+ - Resource
+
+artifactsIndex: resources
+
+heatEnvArtifactHeader:
+ " # _______________________________________________________________________________________________________________________________________\n
+ #| AT&T Proprietary (Restricted) |\n
+ #| Only for use by authorized individuals or any above-designated team(s) |\n
+ #| within the AT&T companies and not for general distribution |\n
+ #|_______________________________________________________________________________________________________________________________________|\n"
+heatEnvArtifactFooter:
+ " # _______________________________________________________________________________________________________________________________________\n
+ #| AT&T Proprietary (Restricted) |\n
+ #| Only for use by authorized individuals or any above-designated team(s) |\n
+ #| within the AT&T companies and not for general distribution |\n
+ #|_______________________________________________________________________________________________________________________________________|\n"
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/NoSqlDbTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/NoSqlDbTest.java
new file mode 100644
index 0000000000..e53c482b86
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/nosqldb/NoSqlDbTest.java
@@ -0,0 +1,48 @@
+package org.openecomp.core.nosqldb;
+
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+public class NoSqlDbTest {
+
+ private static NoSqlDb noSqlDb;
+
+
+// @Test
+ public void testNoSqlDbFactoryFactoryInit(){
+ this.noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ Assert.assertNotNull(this.noSqlDb);
+ Assert.assertEquals(this.noSqlDb.getClass().getName(),"org.openecomp.core.nosqldb.impl.cassandra.CassandraNoSqlDbImpl");
+ }
+
+// @Test(dependsOnMethods = {"testNoSqlDbFactoryFactoryInit"})
+ public void testCreateTable(){
+ this.noSqlDb.execute("test.drop",null);
+ this.noSqlDb.execute("test.create",null);
+ }
+
+// @Test(dependsOnMethods = {"testCreateTable"})
+ public void testInsertTable(){
+ this.noSqlDb.insert("test",new String[]{"name","value"},new String[]{"TestName","testValue"});
+ this.noSqlDb.execute("test.insert",new String[]{"TestName2","testValue2"});
+ }
+
+// @Test(dependsOnMethod`s = {"testInsertTable"})
+ public void gettestSelectTable(){
+ ResultSet result = this.noSqlDb.execute("test.select.all",null);
+ List<Row> rows = result.all();
+ Assert.assertEquals(rows.size(),2);
+ for (Row row:rows){
+ System.out.format("%s %s\n", row.getString("name"), row.getString("value"));
+ }
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/utilities/Yaml/YamlUtilTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/utilities/Yaml/YamlUtilTest.java
new file mode 100644
index 0000000000..baf9bfb350
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/utilities/Yaml/YamlUtilTest.java
@@ -0,0 +1,47 @@
+package org.openecomp.core.utilities.Yaml;
+
+import org.openecomp.core.utilities.yaml.YamlUtil;
+import org.junit.Before;
+import org.junit.Test;
+import testobjects.yaml.YamlFile;
+
+
+public class YamlUtilTest {
+
+ String yamlContent;
+
+ @Before
+ public void setup() {
+ initYamlFileContent();
+ }
+
+ void initYamlFileContent() {
+ yamlContent = "heat_template_version: ss\n" +
+ "description: ab\n" +
+ "parameters:\n" +
+ " jsa_net_name: \n" +
+ " description: network name of jsa log network\n" +
+ " hidden: true\n" +
+ " inner:\n" +
+ " inner1:\n" +
+ " name: shiri\n" +
+ " inner2:\n" +
+ " name: avi";
+ }
+
+ @Test
+ public void shouldConvertSimpleYamlToObject() {
+ new YamlUtil().yamlToObject(yamlContent, YamlFile.class);
+ }
+
+
+ /*public void loadCassandraParameters(){
+ YamlUtil yamlutil = new YamlUtil();
+ String cassandraKey = "cassandraConfig";
+ String configurationFile = "/configuration.yaml";
+ InputStream yamlAsIS = yamlutil.loadYamlFileIs(configurationFile);
+ Map<String, LinkedHashMap<String, Object>> configurationMap = yamlutil.yamlToMap(yamlAsIS);
+ LinkedHashMap<String, Object> cassandraConfiguration = configurationMap.get(cassandraKey);
+ System.out.println(cassandraConfiguration.entrySet());
+ }*/
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/utilities/json/JsonUtilTest.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/utilities/json/JsonUtilTest.java
new file mode 100644
index 0000000000..5cf8988c06
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/org/openecomp/core/utilities/json/JsonUtilTest.java
@@ -0,0 +1,13 @@
+package org.openecomp.core.utilities.json;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class JsonUtilTest {
+ @Test
+ public void abc() {
+ System.out.println("as");
+ }
+
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/testobjects/yaml/InnerP.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/testobjects/yaml/InnerP.java
new file mode 100644
index 0000000000..eda4143e3e
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/testobjects/yaml/InnerP.java
@@ -0,0 +1,25 @@
+package testobjects.yaml;
+
+public class InnerP {
+ String name;
+ String label;
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/testobjects/yaml/Parameter.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/testobjects/yaml/Parameter.java
new file mode 100644
index 0000000000..febcef9c40
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/testobjects/yaml/Parameter.java
@@ -0,0 +1,68 @@
+package testobjects.yaml;
+
+import java.util.Map;
+
+public class Parameter {
+ String name;
+ String label;
+ String description;
+ String paramDefault;
+ boolean hidden;
+ Map<String, InnerP> inner;
+
+ public Map<String, InnerP> getInner() {
+ return inner;
+ }
+
+ public void setInner(Map<String, InnerP> inner) {
+ this.inner = inner;
+ }
+
+ public String getParamDefault() {
+ return paramDefault;
+ }
+
+ public void setParamDefault(String paramDefault) {
+ this.paramDefault = paramDefault;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getDefault() {
+ return paramDefault;
+ }
+
+ public void setDefault(String paramDefault) {
+ this.paramDefault = paramDefault;
+ }
+
+ public boolean isHidden() {
+ return hidden;
+ }
+
+ public void setHidden(boolean hidden) {
+ this.hidden = hidden;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/testobjects/yaml/YamlFile.java b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/testobjects/yaml/YamlFile.java
new file mode 100644
index 0000000000..1c4989da37
--- /dev/null
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-nosqldb-lib/openecomp-nosqldb-core/src/test/java/testobjects/yaml/YamlFile.java
@@ -0,0 +1,37 @@
+package testobjects.yaml;
+
+import java.util.Map;
+
+public class YamlFile {
+ String heat_template_version;
+ String description;
+ Map<String, Parameter> parameters;
+
+
+ public YamlFile() {
+ }
+
+ public String getHeat_template_version() {
+ return heat_template_version;
+ }
+
+ public void setHeat_template_version(String heat_template_version) {
+ this.heat_template_version = heat_template_version;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Map<String, Parameter> getParameters() {
+ return parameters;
+ }
+
+ public void setParameters(Map<String, Parameter> parameters) {
+ this.parameters = parameters;
+ }
+}