summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/music/benchmarks/MicroBenchMarkRestClient.java73
-rw-r--r--src/test/java/org/onap/music/benchmarks/MicroBenchMarks.java440
-rw-r--r--src/test/java/org/onap/music/e2eTests/MusicConnector.java80
-rw-r--r--src/test/java/org/onap/music/e2eTests/TestMusicE2E.java478
-rw-r--r--src/test/java/org/onap/music/unittests/CassandraCQL.java3
-rw-r--r--src/test/java/org/onap/music/unittests/MusicDataStoreTest.java18
-rw-r--r--src/test/java/org/onap/music/unittests/MusicLockingServiceTest.java175
-rw-r--r--src/test/java/org/onap/music/unittests/MusicUtilTest.java22
-rw-r--r--src/test/java/org/onap/music/unittests/TestMusicCore.java903
-rw-r--r--src/test/java/org/onap/music/unittests/TestMusicCoreIntegration.java180
-rw-r--r--src/test/java/org/onap/music/unittests/jsonobjects/AAFResponseTest.java54
-rw-r--r--src/test/java/org/onap/music/unittests/jsonobjects/JsonDeleteTest.java86
-rw-r--r--src/test/java/org/onap/music/unittests/jsonobjects/JsonInsertTest.java86
-rw-r--r--src/test/java/org/onap/music/unittests/jsonobjects/JsonKeySpaceTest.java72
-rw-r--r--src/test/java/org/onap/music/unittests/jsonobjects/JsonLeasedLockTest.java53
-rw-r--r--src/test/java/org/onap/music/unittests/jsonobjects/JsonOnboardTest.java78
-rw-r--r--src/test/java/org/onap/music/unittests/jsonobjects/JsonSelectTest.java41
-rw-r--r--src/test/java/org/onap/music/unittests/jsonobjects/JsonTableTest.java99
-rw-r--r--src/test/java/org/onap/music/unittests/jsonobjects/JsonUpdateTest.java103
19 files changed, 1345 insertions, 1699 deletions
diff --git a/src/test/java/org/onap/music/benchmarks/MicroBenchMarkRestClient.java b/src/test/java/org/onap/music/benchmarks/MicroBenchMarkRestClient.java
deleted file mode 100644
index 2dcecfc2..00000000
--- a/src/test/java/org/onap/music/benchmarks/MicroBenchMarkRestClient.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * org.onap.music
- * ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property
- * ===================================================================
- * 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.music.benchmarks;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import org.onap.music.main.MusicUtil;
-
-
-@Path("/tests")
-public class MicroBenchMarkRestClient {
- static double version = 9.7;
-
- @GET
- @Path("/run")
- @Produces(MediaType.TEXT_PLAIN)
- public String runTests() {
- String testType = MusicUtil.getTestType();
- String candidateName = "shankar" + System.currentTimeMillis();
- MicroBenchMarks msHandle = new MicroBenchMarks();
- switch (testType) {
- case "musicPut":
- return msHandle.musicPutAndUpdate(candidateName);
-
- case "musicCriticalPut":
- return msHandle.musicCriticalPutAndUpdate(candidateName);
-
- case "musicGet":
- return msHandle.musicGet();
-
- case "cassaPut":
- return msHandle.cassaPutAndUpdate(candidateName);
-
- case "cassaQuorumPut":
- return msHandle.cassaQuorumPutAndUpdate(candidateName);
-
- case "cassaGet":
- return msHandle.cassaGet();
-
- case "zkPut":
- return msHandle.zkPutAndUpdate(candidateName);
-
- case "zkGet":
- return msHandle.zkGet();
-
- }
- return "something wrong!";
-
- }
-
-}
-
diff --git a/src/test/java/org/onap/music/benchmarks/MicroBenchMarks.java b/src/test/java/org/onap/music/benchmarks/MicroBenchMarks.java
deleted file mode 100644
index c267d254..00000000
--- a/src/test/java/org/onap/music/benchmarks/MicroBenchMarks.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * org.onap.music
- * ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property
- * ===================================================================
- * 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.music.benchmarks;
-
-import java.util.HashMap;
-import java.util.Map;
-import javax.ws.rs.core.MediaType;
-import org.onap.music.datastore.jsonobjects.JsonInsert;
-import org.onap.music.datastore.jsonobjects.JsonKeySpace;
-import org.onap.music.datastore.jsonobjects.JsonTable;
-import org.onap.music.main.MusicUtil;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
-
-public class MicroBenchMarks {
- final String keyspaceName = "shankarks";
- final String musicurl = "http://" + MusicUtil.getMusicRestIp() + ":8080/MUSIC/rest/formal";
- final String userForGets = "shankarUserForGets";
-
- public MicroBenchMarks() {
- bootStrap();
- }
-
- private void createVotingKeyspace() {
- System.out.println(keyspaceName);
- Map<String, Object> replicationInfo = new HashMap<String, Object>();
- replicationInfo.put("class", "SimpleStrategy");
- replicationInfo.put("replication_factor", 3);
- String durabilityOfWrites = "false";
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "eventual");
- JsonKeySpace jsonKp = new JsonKeySpace();
- jsonKp.setConsistencyInfo(consistencyInfo);
- jsonKp.setDurabilityOfWrites(durabilityOfWrites);
- jsonKp.setReplicationInfo(replicationInfo);
-
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
-
- WebResource webResource = client.resource(musicurl + "/keyspaces/" + keyspaceName);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .post(ClientResponse.class, jsonKp);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
-
- }
-
- private void createVotingTable() {
- Map<String, String> fields = new HashMap<String, String>();
- fields.put("name", "text");
- fields.put("count", "varint");
- fields.put("PRIMARY KEY", "(name)");
-
-
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "eventual");
-
- JsonTable jtab = new JsonTable();
- jtab.setFields(fields);
- jtab.setConsistencyInfo(consistencyInfo);
-
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
-
- WebResource webResource = client
- .resource(musicurl + "/keyspaces/" + keyspaceName + "/tables/votecount");
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .post(ClientResponse.class, jtab);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
-
- }
-
- private void createEntryForCandidate(String candidateName) {
- Map<String, Object> values = new HashMap<String, Object>();
- values.put("name", candidateName);
- values.put("count", 0);
-
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "eventual");
-
- JsonInsert jIns = new JsonInsert();
- jIns.setValues(values);
- jIns.setConsistencyInfo(consistencyInfo);
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
-
- String url = musicurl + "/keyspaces/" + keyspaceName + "/tables/votecount/rows";
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .post(ClientResponse.class, jIns);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
-
- private String createLock(String lockName) {
- Client client = Client.create();
- String msg = musicurl + "/locks/create/" + lockName;
- WebResource webResource = client.resource(msg);
- System.out.println(msg);
-
- WebResource.Builder wb = webResource.accept(MediaType.TEXT_PLAIN);
-
- ClientResponse response = wb.post(ClientResponse.class);
-
- if (response.getStatus() != 200) {
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
-
- String output = response.getEntity(String.class);
-
- return output;
- }
-
- private boolean acquireLock(String lockId) {
- Client client = Client.create();
- String msg = musicurl + "/locks/acquire/" + lockId;
- System.out.println(msg);
- WebResource webResource = client.resource(msg);
-
-
- WebResource.Builder wb = webResource.accept(MediaType.TEXT_PLAIN);
-
- ClientResponse response = wb.get(ClientResponse.class);
-
- if (response.getStatus() != 200) {
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
-
- String output = response.getEntity(String.class);
- Boolean status = Boolean.parseBoolean(output);
- System.out.println("Server response .... \n");
- System.out.println(output);
- return status;
- }
-
- private void unlock(String lockId) {
- Client client = Client.create();
- WebResource webResource = client.resource(musicurl + "/locks/release/" + lockId);
-
- ClientResponse response = webResource.delete(ClientResponse.class);
-
-
- if (response.getStatus() != 204) {
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
- }
-
- public String musicCriticalPutAndUpdate(String candidateName) {
- /*
- * create lock for the candidate. The music API dictates that the lock name must be of the
- * form keyspacename.tableName.primaryKeyName
- */
- createEntryForCandidate(candidateName);
- System.out.println("trying to acquire lock!");
-
- String lockName = keyspaceName + ".votecount." + candidateName;
- String lockId = createLock(lockName);
- while (acquireLock(lockId) != true);
-
- System.out.println("acquired lock!");
- // update candidate entry if you have the lock
- Map<String, Object> values = new HashMap<String, Object>();
- values.put("count", 5);
-
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "atomic");
- consistencyInfo.put("lockId", lockId);
-
- JsonInsert jIns = new JsonInsert();
- jIns.setValues(values);
- jIns.setConsistencyInfo(consistencyInfo);
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
- String url = musicurl + "/keyspaces/" + keyspaceName + "/tables/votecount/rows?name="
- + candidateName;
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .put(ClientResponse.class, jIns);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
-
- // release lock now that the operation is done
- unlock(lockId);
- return "musicCriticalPutAndUpdate:" + url;
-
- }
-
- public String musicPutAndUpdate(String candidateName) {
- createEntryForCandidate(candidateName);
-
- Map<String, Object> values = new HashMap<String, Object>();
- values.put("count", 5);
-
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "eventual");
-
- JsonInsert jIns = new JsonInsert();
- jIns.setValues(values);
- jIns.setConsistencyInfo(consistencyInfo);
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
- String url = musicurl + "/keyspaces/" + keyspaceName + "/tables/votecount/rows?name="
- + candidateName;
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .put(ClientResponse.class, jIns);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- return "musicPutAndUpdate:" + url;
- }
-
- public String musicGet() {
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
-
- String url = musicurl + "/keyspaces/" + keyspaceName + "/tables/votecount/rows?name="
- + userForGets;
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
-
- Map<String, Object> output = response.getEntity(Map.class);
- return "musicGet:" + url;
- }
-
- public String cassaQuorumPutAndUpdate(String candidateName) {
- // http://135.197.226.98:8080/MUSIC/rest/formal/purecassa/keyspaces/shankarks/tables/employees/rows?emp_name=shankaruser1
- Map<String, Object> values = new HashMap<String, Object>();
- values.put("count", 5);
-
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "atomic");
-
- JsonInsert jIns = new JsonInsert();
- jIns.setValues(values);
- jIns.setConsistencyInfo(consistencyInfo);
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
- String url = musicurl + "/purecassa/keyspaces/" + keyspaceName
- + "/tables/votecount/rows?name=" + candidateName;
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .put(ClientResponse.class, jIns);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- return "cassaQuorumPutAndUpdate:" + url;
-
- }
-
- public String cassaPutAndUpdate(String candidateName) {
- // http://135.197.226.98:8080/MUSIC/rest/formal/purecassa/keyspaces/shankarks/tables/employees/rows?emp_name=shankaruser1
- long start = System.currentTimeMillis();
- createEntryForCandidate(candidateName);
-
- Map<String, Object> values = new HashMap<String, Object>();
- values.put("count", 5);
-
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "eventual");
-
- JsonInsert jIns = new JsonInsert();
- jIns.setValues(values);
- jIns.setConsistencyInfo(consistencyInfo);
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
- String url = musicurl + "/purecassa/keyspaces/" + keyspaceName
- + "/tables/votecount/rows?name=" + candidateName;
- WebResource webResource = client.resource(url);
- long end = System.currentTimeMillis();
- String time = (end - start) + "";
-
- start = System.currentTimeMillis();
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .put(ClientResponse.class, jIns);
- end = System.currentTimeMillis();
- String time2 = (end - start) + "";
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- return "cassaPutAndUpdate:" + url;
- }
-
- public String cassaGet() {
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
-
- String url = musicurl + "/keyspaces/" + keyspaceName + "/tables/votecount/rows?name="
- + userForGets;
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
-
- Map<String, Object> output = response.getEntity(Map.class);
- return "cassaGet:" + url;
- }
-
- private void zkCreate(String candidateName) {
- // http://135.197.226.98:8080/MUSIC/rest/formal/purezk/shankarzknode
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
-
- WebResource webResource = client.resource(musicurl + "/purezk/" + candidateName);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .post(ClientResponse.class);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
-
- public String zkPutAndUpdate(String candidateName) {
- // http://135.197.226.99:8080/MUSIC/rest/formal/purezk/shankarzknode
-
- // CREATE IT FIRST
- zkCreate(candidateName);
-
- Map<String, Object> values = new HashMap<String, Object>();
- values.put("count", 5);
-
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "atomic");
-
- JsonInsert jIns = new JsonInsert();
- jIns.setValues(values);
- jIns.setConsistencyInfo(consistencyInfo);
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
- String url = musicurl + "/purezk/" + candidateName;
- System.out.println("in zk put:" + url);
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .put(ClientResponse.class, jIns);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
-
- return "zkPutAndUpdate:" + url;
- }
-
- public String zkGet() {
- Client client = Client.create();
- String url = musicurl + "/purezk/" + userForGets;
- System.out.println("in zk get:" + url);
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("text/plain").get(ClientResponse.class);
-
- if (response.getStatus() != 200) {
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
-
- String output = response.getEntity(String.class);
- return "zkGet:" + url;
- }
-
-
- public void bootStrap() {
- // createVotingKeyspace();
- // createVotingTable();
- // createEntryForCandidate(userForGets);
- // zkPutAndUpdate(userForGets);
- }
-
-
-}
diff --git a/src/test/java/org/onap/music/e2eTests/MusicConnector.java b/src/test/java/org/onap/music/e2eTests/MusicConnector.java
deleted file mode 100644
index bb3d1f1b..00000000
--- a/src/test/java/org/onap/music/e2eTests/MusicConnector.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * org.onap.music
- * ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property
- * ===================================================================
- * 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.music.e2eTests;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Random;
-
-public class MusicConnector {
-
- // change this to point to relevant cluster
- public String[] musicNodes;
-
- public MusicConnector(String[] musicNodes) {
- this.musicNodes = musicNodes;
- }
-
- private String getMusicNodeIp() {
- Random r = new Random();
- int index = r.nextInt(musicNodes.length);
- return musicNodes[index];
- }
-
- /*
- * public static String toggle(String serverAddress){ if(serverAddress.equals(agaveMusicNode)){
- * System.out.println("Agave is down...connect to Big Site"); serverAddress = bigSiteMusicNode;
- * }else if(serverAddress.equals(bigSiteMusicNode)){
- * System.out.println("Big Site is down...connect to Agave"); serverAddress = agaveMusicNode; }
- * return serverAddress; }
- */
-
- public String getMusicNodeURL() {
- String musicurl = "http://" + getMusicNodeIp() + ":8080/MUSIC/rest";
- System.out.println(musicurl);
- return musicurl;
- }
-
- public boolean isHostUp(String serverAddress) {
- Boolean isUp = false;
- try {
- InetAddress inet = InetAddress.getByName(serverAddress);
- isUp = inet.isReachable(1000);
- } catch (UnknownHostException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return isUp;
- }
-
- /*
- * private static String getMusicNodeIp(){
- *
- * //return "54.224.168.13"; return bigSiteMusicNode; String serverAddress; serverAddress =
- * agaveMusicNode; while(isHostUp(serverAddress) != true) serverAddress = toggle(serverAddress);
- * return serverAddress; }
- */
-}
diff --git a/src/test/java/org/onap/music/e2eTests/TestMusicE2E.java b/src/test/java/org/onap/music/e2eTests/TestMusicE2E.java
deleted file mode 100644
index 25021e82..00000000
--- a/src/test/java/org/onap/music/e2eTests/TestMusicE2E.java
+++ /dev/null
@@ -1,478 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * org.onap.music
- * ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property
- * ===================================================================
- * 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.music.e2eTests;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import javax.ws.rs.core.MediaType;
-import org.onap.music.datastore.jsonobjects.JsonDelete;
-import org.onap.music.datastore.jsonobjects.JsonInsert;
-import org.onap.music.datastore.jsonobjects.JsonKeySpace;
-import org.onap.music.datastore.jsonobjects.JsonTable;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
-
-public class TestMusicE2E {
- String keyspaceName;
- ArrayList<String> lockNames;
- MusicConnector musicHandle;
-
- public TestMusicE2E(String[] musicIps) {
- lockNames = new ArrayList<String>();
- musicHandle = new MusicConnector(musicIps);
- bootStrap();
- }
-
- public void createVotingKeyspace() {
- keyspaceName = "VotingAppForMusic" + System.currentTimeMillis();
- Map<String, Object> replicationInfo = new HashMap<String, Object>();
- replicationInfo.put("class", "SimpleStrategy");
- replicationInfo.put("replication_factor", 1);
- String durabilityOfWrites = "false";
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "eventual");
- JsonKeySpace jsonKp = new JsonKeySpace();
- jsonKp.setConsistencyInfo(consistencyInfo);
- jsonKp.setDurabilityOfWrites(durabilityOfWrites);
- jsonKp.setReplicationInfo(replicationInfo);
-
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
-
- WebResource webResource = client
- .resource(musicHandle.getMusicNodeURL() + "/keyspaces/" + keyspaceName);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .post(ClientResponse.class, jsonKp);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
-
- }
-
- public void createVotingTable() {
- Map<String, String> fields = new HashMap<String, String>();
- fields.put("name", "text");
- fields.put("count", "varint");
- fields.put("PRIMARY KEY", "(name)");
-
-
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "eventual");
-
- JsonTable jtab = new JsonTable();
- jtab.setFields(fields);
- jtab.setConsistencyInfo(consistencyInfo);
-
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
- String url = musicHandle.getMusicNodeURL() + "/keyspaces/" + keyspaceName
- + "/tables/votecount";
- System.out.println("create url:" + url);
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .post(ClientResponse.class, jtab);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
-
- }
-
- private void checkMusicVersion() {
- Client client = Client.create();
- System.out.println(musicHandle.getMusicNodeURL() + "/version");
-
-
- // System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
- WebResource webResource = client.resource(musicHandle.getMusicNodeURL() + "/version");
-
-
- ClientResponse response = webResource.accept("text/plain").header("Connection", "close")
- .get(ClientResponse.class);
-
- if (response.getStatus() != 200) {
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
-
- String output = response.getEntity(String.class);
-
- // System.out.println("Output from Server .... \n");
- System.out.println(output);
-
- }
-
- private void createEntryForCandidate(String candidateName) {
- Map<String, Object> values = new HashMap<String, Object>();
- values.put("name", candidateName);
- values.put("count", 0);
-
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "eventual");
-
- JsonInsert jIns = new JsonInsert();
- jIns.setValues(values);
- jIns.setConsistencyInfo(consistencyInfo);
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
-
- String url = musicHandle.getMusicNodeURL() + "/keyspaces/" + keyspaceName
- + "/tables/votecount/rows";
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .post(ClientResponse.class, jIns);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus() + "url:"
- + url + " candidate name:" + candidateName);
-
-
- }
-
- private String createLock(String lockName) {
- Client client = Client.create();
- String msg = musicHandle.getMusicNodeURL() + "/locks/create/" + lockName;
- WebResource webResource = client.resource(msg);
- System.out.println(msg);
- WebResource.Builder wb = webResource.accept(MediaType.TEXT_PLAIN);
-
- ClientResponse response = wb.post(ClientResponse.class);
-
- if (response.getStatus() != 200) {
- throw new RuntimeException(
- "Failed : HTTP error code : " + response.getStatus() + "url:" + msg);
- }
-
- String output = response.getEntity(String.class);
-
- // System.out.println("Server response .... \n");
- // System.out.println(output);
- return output;
- }
-
- private boolean acquireLock(String lockId) {
- Client client = Client.create();
- String msg = musicHandle.getMusicNodeURL() + "/locks/acquire/" + lockId;
- System.out.println(msg);
- WebResource webResource = client.resource(msg);
-
-
- WebResource.Builder wb = webResource.accept(MediaType.TEXT_PLAIN);
-
- ClientResponse response = wb.get(ClientResponse.class);
-
- if (response.getStatus() != 200) {
- throw new RuntimeException(
- "Failed : HTTP error code : " + response.getStatus() + "url:" + msg);
- }
-
- String output = response.getEntity(String.class);
- Boolean status = Boolean.parseBoolean(output);
- System.out.println("Server response .... \n");
- System.out.println(output);
- return status;
- }
-
- private void unlock(String lockId) {
- Client client = Client.create();
- WebResource webResource =
- client.resource(musicHandle.getMusicNodeURL() + "/locks/release/" + lockId);
-
- ClientResponse response = webResource.delete(ClientResponse.class);
-
-
- if (response.getStatus() != 204) {
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
- }
-
- private void updateVoteCountAtomically(String candidateName, int count) {
- /*
- * create lock for the candidate. The music API dictates that the lock name must be of the
- * form keyspacename.tableName.primaryKeyName
- */
- System.out.println("trying to acquire lock!");
-
- String lockName = keyspaceName + ".votecount." + candidateName;
- lockNames.add(lockName);
- String lockId = createLock(lockName);
- while (acquireLock(lockId) != true);
-
- System.out.println("acquired lock!");
- // update candidate entry if you have the lock
- Map<String, Object> values = new HashMap<String, Object>();
- values.put("count", count);
-
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "critical");
- consistencyInfo.put("lockId", lockId);
-
- JsonInsert jIns = new JsonInsert();
- jIns.setValues(values);
- jIns.setConsistencyInfo(consistencyInfo);
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
- String url = musicHandle.getMusicNodeURL() + "/keyspaces/" + keyspaceName
- + "/tables/votecount/rows?name=" + candidateName;
- System.out.println(url);
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .put(ClientResponse.class, jIns);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException(
- "Failed : HTTP error code : " + response.getStatus() + "url:" + url);
-
- // release lock now that the operation is done
- unlock(lockId);
-
- }
-
- private void deleteCandidateEntryEventually(String candidateName) {
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "eventual");
-
- JsonDelete jDel = new JsonDelete();
- jDel.setConsistencyInfo(consistencyInfo);
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
- String url = musicHandle.getMusicNodeURL() + "/keyspaces/" + keyspaceName
- + "/tables/votecount/rows?name=" + candidateName;
- System.out.println(url);
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").type("application/json")
- .delete(ClientResponse.class, jDel);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException(
- "Failed : HTTP error code : " + response.getStatus() + "url:" + url);
-
- }
-
- public Map<String, Object> readVoteCountForCandidate(String candidateName) {
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
- String url = musicHandle.getMusicNodeURL() + "/keyspaces/" + keyspaceName
- + "/tables/votecount/rows?name=" + candidateName;
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
-
- Map<String, Object> output = response.getEntity(Map.class);
- return output;
- }
-
- public Map<String, Object> readAllVotes() {
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
- String url = musicHandle.getMusicNodeURL() + "/keyspaces/" + keyspaceName
- + "/tables/votecount/rows";
- WebResource webResource = client.resource(url);
-
- ClientResponse response = webResource.accept("application/json").get(ClientResponse.class);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
-
- Map<String, Object> output = response.getEntity(Map.class);
- return output;
- }
-
-
- /*
- * Unable to use this because of the error: Exception in thread "main"
- * com.sun.jersey.api.client.ClientHandlerException: java.net.ProtocolException: HTTP method
- * DELETE doesn't support output. Seems to be a error in the rest java combination according to
- * the interwebs
- */
- private void dropKeySpace() {
- Map<String, String> consistencyInfo = new HashMap<String, String>();
- consistencyInfo.put("type", "eventual");
-
- JsonKeySpace jsonKp = new JsonKeySpace();
- jsonKp.setConsistencyInfo(consistencyInfo);
-
- ClientConfig clientConfig = new DefaultClientConfig();
-
- clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-
- Client client = Client.create(clientConfig);
-
- WebResource webResource = client
- .resource(musicHandle.getMusicNodeURL() + "/keyspaces/" + keyspaceName);
-
- ClientResponse response =
- webResource.type("application/json").delete(ClientResponse.class, jsonKp);
-
- if (response.getStatus() < 200 || response.getStatus() > 299)
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
-
- private void deleteLock(String lockName) {
- Client client = Client.create();
- WebResource webResource = client
- .resource(musicHandle.getMusicNodeURL() + "/locks/delete/" + lockName);
-
- ClientResponse response = webResource.delete(ClientResponse.class);
-
-
- if (response.getStatus() != 204) {
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
- }
-
- private void resetMusic() {
- Client client = Client.create();
- WebResource webResource = client.resource(musicHandle.getMusicNodeURL() + "/reset");
-
- ClientResponse response = webResource.delete(ClientResponse.class);
-
-
- if (response.getStatus() != 204) {
- throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
- }
-
- }
-
- public void deleteAllLocks() {
- for (String lockName : lockNames) {
- deleteLock(lockName);
- }
- }
-
-
- public void bootStrap() {
- checkMusicVersion();
- createVotingKeyspace();
-
-
- createVotingTable();
-
-
- // the next few lines just create an entry in the voting table for all these candidates with
- // vote count as 0
- createEntryForCandidate("Popeye");
-
- createEntryForCandidate("Judy");
-
- createEntryForCandidate("Flash");
-
- createEntryForCandidate("Mickey");
-
- }
-
- public void overAllTests() {
- // update the count atomically
- updateVoteCountAtomically("Popeye", 5);
-
- updateVoteCountAtomically("Judy", 7);
-
- updateVoteCountAtomically("Mickey", 8);
-
- updateVoteCountAtomically("Flash", 2);
-
-
- // read votecount
- System.out.println(readAllVotes());
-
- System.out.println(readVoteCountForCandidate("Popeye"));
-
- System.out.println(readVoteCountForCandidate("Flash"));
-
- deleteCandidateEntryEventually("Mickey");
-
- System.out.println(readAllVotes());
-
- dropKeySpace();
-
- deleteAllLocks();
- }
-
- public void flipTest() {
- checkMusicVersion();
- }
-
- public static String executeBashScript(String pathToScript, String arg1, String arg2) {
- try {
- ProcessBuilder pb = new ProcessBuilder(pathToScript, arg1, arg2);
- final Process process = pb.start();
- InputStream is = process.getInputStream();
- InputStreamReader isr = new InputStreamReader(is);
- BufferedReader br = new BufferedReader(isr);
- return br.readLine();
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
- }
-
- public static void main(String[] args) {
- long start = System.currentTimeMillis();
- for (int i = 0; i < 2; ++i) {
- TestMusicE2E vHandle = new TestMusicE2E(args);
- vHandle.overAllTests();
-
- System.out.println("=====================================");
- System.out.println("Test no." + i + " completed:");
- }
- long diff = System.currentTimeMillis() - start;
- System.out.println(diff);
- }
-
-
-}
diff --git a/src/test/java/org/onap/music/unittests/CassandraCQL.java b/src/test/java/org/onap/music/unittests/CassandraCQL.java
index ed8f13f4..a4c250c2 100644
--- a/src/test/java/org/onap/music/unittests/CassandraCQL.java
+++ b/src/test/java/org/onap/music/unittests/CassandraCQL.java
@@ -232,13 +232,14 @@ public class CassandraCQL {
try {
try {
- EmbeddedCassandraServerHelper.startEmbeddedCassandra(60000);
+ EmbeddedCassandraServerHelper.startEmbeddedCassandra(80000);
} catch (ConfigurationException | TTransportException | IOException e) {
System.out.println(e.getMessage());
}
cluster = new Cluster.Builder().addContactPoint(address).withPort(9142).build();
+ cluster.getConfiguration().getSocketOptions().setReadTimeoutMillis(20000);
session = cluster.connect();
break;
diff --git a/src/test/java/org/onap/music/unittests/MusicDataStoreTest.java b/src/test/java/org/onap/music/unittests/MusicDataStoreTest.java
index 520a5fe4..87b97944 100644
--- a/src/test/java/org/onap/music/unittests/MusicDataStoreTest.java
+++ b/src/test/java/org/onap/music/unittests/MusicDataStoreTest.java
@@ -22,6 +22,7 @@
package org.onap.music.unittests;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -34,8 +35,11 @@ import org.onap.music.exceptions.MusicServiceException;
import org.onap.music.datastore.MusicDataStore;
import org.onap.music.datastore.PreparedQueryObject;
+
+import com.datastax.driver.core.DataType;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Row;
+import com.datastax.driver.core.TableMetadata;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class MusicDataStoreTest {
@@ -141,6 +145,18 @@ public class MusicDataStoreTest {
} catch (MusicQueryException | MusicServiceException e) {
System.out.println(e.getMessage());
}
-
+ }
+
+ @Test
+ public void Test8_columnDataType() {
+ DataType data = dataStore.returnColumnDataType("testCassa", "employees", "empName");
+ String datatype = data.toString();
+ assertEquals("text",datatype);
+ }
+
+ @Test
+ public void Test8_columnMetdaData() {
+ TableMetadata data = dataStore.returnColumnMetadata("testCassa", "employees");
+ assertNotNull(data);
}
}
diff --git a/src/test/java/org/onap/music/unittests/MusicLockingServiceTest.java b/src/test/java/org/onap/music/unittests/MusicLockingServiceTest.java
deleted file mode 100644
index 7d51465f..00000000
--- a/src/test/java/org/onap/music/unittests/MusicLockingServiceTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * ============LICENSE_START==========================================
- * org.onap.music
- * ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property
- * ===================================================================
- * 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.music.unittests;
-
-import static org.junit.Assert.*;
-import java.io.File;
-import org.apache.curator.test.TestingServer;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.music.exceptions.MusicLockingException;
-import org.onap.music.exceptions.MusicServiceException;
-import org.onap.music.lockingservice.MusicLockState;
-import org.onap.music.lockingservice.MusicLockingService;
-import org.onap.music.lockingservice.ZkStatelessLockService;
-import org.onap.music.lockingservice.MusicLockState.LockStatus;
-
-public class MusicLockingServiceTest {
-
- static MusicLockingService mLockHandle;
- static TestingServer zkServer;
-
- @BeforeClass
- public static void init() throws Exception {
- try {
- zkServer = new TestingServer(2181,new File("/tmp/zk"));
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- System.out.println("####" + zkServer.getPort());
- try {
- mLockHandle = new MusicLockingService();
- } catch (MusicServiceException e) {
- e.printStackTrace();
- }
-
-
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- zkServer.stop();
- mLockHandle.close();
- }
-
- @Before
- public void setUp() throws Exception {}
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void testMusicLockingService() {
- assertTrue(mLockHandle != null);
- }
-
- @Test
- public void testGetzkLockHandle() {
- ZkStatelessLockService lockHandle = mLockHandle.getzkLockHandle();
- assertTrue(lockHandle != null);
- }
-
- @Test
- public void testMusicLockingServiceString() {
- // MusicLockingService mLockTest = new MusicLockingService("localhost");
- // assertTrue(mLockTest != null);
- // mLockTest.close();
- }
-
- @Test
- public void testCreateLockaIfItDoesNotExist() {
-
- mLockHandle.createLockaIfItDoesNotExist("/ks1.tb1.pk1");
- MusicLockState mls = null;
- try {
- // mls = mLockHandle.
- mls = mLockHandle.getLockState("ks1.tb1.pk1");
- } catch (MusicLockingException e) {
- e.printStackTrace();
- }
- System.out.println("Lock Holder:" + mls.getLockHolder());
- assertFalse(mls.getLeaseStartTime() > 0);
- }
-
- @Test
- public void testSetLockState() {
- MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
- mLockHandle.setLockState("ks1.tb1.pk1",musicLockState);
- MusicLockState mls = null;
- try {
- mls = mLockHandle.getLockState("ks1.tb1.pk1");
- } catch (MusicLockingException e) {
- e.printStackTrace();
- }
- assertEquals(musicLockState.getLockHolder(), mls.getLockHolder());
-
- }
-
-// @Test
-// public void testGetLockState() {
-// MusicLockState mls = null;
-// try {
-// mls = mLockHandle.getLockState("ks1.tb1.pk1");
-// } catch (MusicLockingException e) {
-// e.printStackTrace();
-// }
-// assertTrue(mls.getLockHolder().equals("id1"));
-// }
-
-// @Test
-// public void testCreateLockId() {
-//
-// fail("Not yet implemented"); // TODO
-// }
-//
-// @Test
-// public void testIsMyTurn() {
-// fail("Not yet implemented"); // TODO
-// }
-//
-// @Test
-// public void testUnlockAndDeleteId() {
-// fail("Not yet implemented"); // TODO
-// }
-//
-// @Test
-// public void testDeleteLock() {
-// fail("Not yet implemented"); // TODO
-// }
-//
-// @Test
-// public void testWhoseTurnIsIt() {
-// fail("Not yet implemented"); // TODO
-// }
-//
-// @Test
-// public void testProcess() {
-// fail("Not yet implemented"); // TODO
-// }
-//
-// @Test
-// public void testClose() {
-// fail("Not yet implemented"); // TODO
-// }
-//
-// @Test
-// public void testLockIdExists() {
-// fail("Not yet implemented"); // TODO
-// }
-
-}
diff --git a/src/test/java/org/onap/music/unittests/MusicUtilTest.java b/src/test/java/org/onap/music/unittests/MusicUtilTest.java
index e540d646..9f245e89 100644
--- a/src/test/java/org/onap/music/unittests/MusicUtilTest.java
+++ b/src/test/java/org/onap/music/unittests/MusicUtilTest.java
@@ -73,11 +73,11 @@ public class MusicUtilTest {
assertEquals(MusicUtil.getAllIds().get(0),"1");
}
-// @Test
-// public void testGetPublicIp() {
-// MusicUtil.setPublicIp("10.0.0.1");
-// assertEquals(MusicUtil.getPublicIp(),"10.0.0.1");
-// }
+ @Test
+ public void testGetPublicIp() {
+ MusicUtil.setPublicIp("10.0.0.1");
+ assertEquals(MusicUtil.getPublicIp(),"10.0.0.1");
+ }
@Test
public void testGetAllPublicIps() {
@@ -124,11 +124,11 @@ public class MusicUtilTest {
assertEquals(MusicUtil.getVersion(),"1.0.0");
}
-// @Test
-// public void testGetMyZkHost() {
-// MusicUtil.setMyZkHost("10.0.0.2");
-// assertEquals(MusicUtil.getMyZkHost(),"10.0.0.2");
-// }
+ /*@Test
+ public void testGetMyZkHost() {
+ MusicUtil.setMyZkHost("10.0.0.2");
+ assertEquals(MusicUtil.getMyZkHost(),"10.0.0.2");
+ }*/
@Test
public void testGetMyCassaHost() {
@@ -179,7 +179,7 @@ public class MusicUtilTest {
}
@Test
- public void testConvertToActualDataType() {
+ public void testConvertToActualDataType() throws Exception {
assertEquals(MusicUtil.convertToActualDataType(DataType.varchar(),"Happy People"),"Happy People");
assertEquals(MusicUtil.convertToActualDataType(DataType.uuid(),"29dc2afa-c2c0-47ae-afae-e72a645308ab"),UUID.fromString("29dc2afa-c2c0-47ae-afae-e72a645308ab"));
assertEquals(MusicUtil.convertToActualDataType(DataType.varint(),"1234"),BigInteger.valueOf(Long.parseLong("1234")));
diff --git a/src/test/java/org/onap/music/unittests/TestMusicCore.java b/src/test/java/org/onap/music/unittests/TestMusicCore.java
index 2deb3496..3355e4cd 100644
--- a/src/test/java/org/onap/music/unittests/TestMusicCore.java
+++ b/src/test/java/org/onap/music/unittests/TestMusicCore.java
@@ -1,440 +1,463 @@
-/*
- * ============LICENSE_START==========================================
- * org.onap.music
- * ===================================================================
- * Copyright (c) 2017 AT&T Intellectual Property
- * ===================================================================
- * 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.music.unittests;
-
-import static org.junit.Assert.*;
-import static org.onap.music.main.MusicCore.mDstoreHandle;
-import static org.onap.music.main.MusicCore.mLockHandle;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.music.exceptions.MusicLockingException;
-import org.onap.music.exceptions.MusicQueryException;
-import org.onap.music.exceptions.MusicServiceException;
-import org.onap.music.lockingservice.MusicLockState;
-import org.onap.music.lockingservice.MusicLockingService;
-import org.onap.music.lockingservice.MusicLockState.LockStatus;
-import org.onap.music.main.MusicCore;
-import org.onap.music.main.ResultType;
-import org.onap.music.main.ReturnType;
-import org.onap.music.main.MusicCore.Condition;
-import org.onap.music.datastore.MusicDataStore;
-import org.onap.music.datastore.PreparedQueryObject;
-import com.datastax.driver.core.ResultSet;
-
-@RunWith(MockitoJUnitRunner.class)
-public class TestMusicCore {
-
- @Mock
- private Condition condition;
-
- @Mock
- private ResultSet rs;
-
- @Mock
- private PreparedQueryObject preparedQueryObject;
-
- @Before
- public void setUp() {
- mLockHandle = Mockito.mock(MusicLockingService.class);
-
- }
-
- @Test
- public void testCreateLockReferenceforvalidlock() {
- Mockito.when(mLockHandle.createLockId("/" + "test")).thenReturn("lock");
- String lockId = MusicCore.createLockReference("test");
- assertEquals("lock", lockId);
- Mockito.verify(mLockHandle).createLockId("/" + "test");
- }
-
- @Test
- public void testIsTableOrKeySpaceLock() {
- Boolean result = MusicCore.isTableOrKeySpaceLock("ks1.tn1");
- assertTrue(result);
- }
-
- @Test
- public void testIsTableOrKeySpaceLockwithPrimarykey() {
- Boolean result = MusicCore.isTableOrKeySpaceLock("ks1.tn1.pk1");
- assertFalse(result);
- }
-
- @Test
- public void testGetMusicLockState() throws MusicLockingException {
- MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
- Mockito.when(mLockHandle.getLockState("ks1.tb1.pk1")).thenReturn(musicLockState);
- MusicLockState mls = MusicCore.getMusicLockState("ks1.tb1.pk1");
- assertEquals(musicLockState, mls);
- Mockito.verify(mLockHandle).getLockState("ks1.tb1.pk1");
- }
-
- @Test
- public void testAcquireLockifisMyTurnTrue() {
- Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
- ReturnType lock = MusicCore.acquireLock("ks1.tn1", "id1");
- assertEquals(lock.getResult(), ResultType.SUCCESS);
- Mockito.verify(mLockHandle).isMyTurn("id1");
- }
-
- @Test
- public void testAcquireLockifisMyTurnFalse() {
- Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(false);
- ReturnType lock = MusicCore.acquireLock("ks1.ts1", "id1");
- assertEquals(lock.getResult(), ResultType.FAILURE);
- Mockito.verify(mLockHandle).isMyTurn("id1");
- }
-
- @Test
- public void testAcquireLockifisMyTurnTrueandIsTableOrKeySpaceLockTrue() {
- Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
- ReturnType lock = MusicCore.acquireLock("ks1.tn1", "id1");
- assertEquals(lock.getResult(), ResultType.SUCCESS);
- Mockito.verify(mLockHandle).isMyTurn("id1");
- }
-
- @Test
- public void testAcquireLockifisMyTurnTrueandIsTableOrKeySpaceLockFalseandHaveLock() throws MusicLockingException {
- MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
- Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
- Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
- ReturnType lock = MusicCore.acquireLock("ks1.tn1.pk1", "id1");
- assertEquals(lock.getResult(), ResultType.SUCCESS);
- Mockito.verify(mLockHandle).isMyTurn("id1");
- Mockito.verify(mLockHandle).getLockState("ks1.tn1.pk1");
- }
-
- @Test
- public void testAcquireLockifisMyTurnTrueandIsTableOrKeySpaceLockFalseandDontHaveLock() throws MusicLockingException {
- MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id2");
- Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
- Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
- ReturnType lock = MusicCore.acquireLock("ks1.tn1.pk1", "id1");
- assertEquals(lock.getResult(), ResultType.SUCCESS);
- Mockito.verify(mLockHandle).isMyTurn("id1");
- Mockito.verify(mLockHandle).getLockState("ks1.tn1.pk1");
- }
-
- @Test
- public void testAcquireLockifLockRefDoesntExist() {
- Mockito.when(mLockHandle.lockIdExists("bs1")).thenReturn(false);
- ReturnType lock = MusicCore.acquireLock("ks1.ts1", "bs1");
- assertEquals(lock.getResult(), ResultType.FAILURE);
- assertEquals(lock.getMessage(), "Lockid doesn't exist");
- Mockito.verify(mLockHandle).lockIdExists("bs1");
- }
-
- @Test
- public void testAcquireLockWithLeasewithLockStatusLOCKED() throws MusicLockingException {
- MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
- ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
- Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
- Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
- ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
- assertEquals(expectedResult.getResult(), actualResult.getResult());
- Mockito.verify(mLockHandle).isMyTurn("id1");
- Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
- }
-
- @Test
- public void testAcquireLockWithLeasewithLockStatusUNLOCKED() throws MusicLockingException {
- MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
- ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
- Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
- Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
- ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
- assertEquals(expectedResult.getResult(), actualResult.getResult());
- Mockito.verify(mLockHandle).isMyTurn("id1");
- Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
-
- }
-
- @Test
- public void testAcquireLockWithLeaseIfNotMyTurn() throws MusicLockingException {
- MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
- ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
- Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
- Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(false);
- ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
- assertEquals(expectedResult.getResult(), actualResult.getResult());
- Mockito.verify(mLockHandle).isMyTurn("id1");
- Mockito.verify(mLockHandle).getLockState("ks1.tn1.pk1");
- }
-
- /*
- * @Test public void testQuorumGet() { mDstoreHandle = Mockito.mock(MusicDataStore.class); rs =
- * Mockito.mock(ResultSet.class);
- * Mockito.when(mDstoreHandle.executeCriticalGet("qu1")).thenReturn(rs); ResultSet rs1 =
- * MusicCore.quorumGet("qu1"); assertNotNull(rs1);
- * Mockito.verify(mDstoreHandle).executeCriticalGet("qu1");
- *
- * }
- */
-
- @Test
- public void testGetLockNameFromId() {
- String lockname = MusicCore.getLockNameFromId("lockName$id");
- assertEquals("lockName", lockname);
- }
-
- @Test
- public void testDestroyLockRef() {
- Mockito.doNothing().when(mLockHandle).unlockAndDeleteId("id1");
- MusicCore.destroyLockRef("id1");
- Mockito.verify(mLockHandle, Mockito.atLeastOnce()).unlockAndDeleteId("id1");
- }
-
- @Test
- public void testreleaseLockwithvoluntaryReleaseTrue() {
- MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id2");
- Mockito.doNothing().when(mLockHandle).unlockAndDeleteId("id1");
- MusicLockState musicLockState1 = MusicCore.releaseLock("id1", true);
- assertEquals(musicLockState.getLockStatus(), musicLockState1.getLockStatus());
- Mockito.verify(mLockHandle, Mockito.atLeastOnce()).unlockAndDeleteId("id1");
- }
-
- @Test
- public void testreleaseLockwithvoluntaryReleaseFalse() {
- MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id2");
- Mockito.doNothing().when(mLockHandle).unlockAndDeleteId("id1");
- MusicLockState musicLockState1 = MusicCore.releaseLock("id1", false);
- assertEquals(musicLockState.getLockStatus(), musicLockState1.getLockStatus());
- Mockito.verify(mLockHandle, Mockito.atLeastOnce()).unlockAndDeleteId("id1");
- }
-
- @Test
- public void testDeleteLock() {
- Mockito.doNothing().when(mLockHandle).deleteLock("/" + "id1");
- MusicCore.deleteLock("id1");
- Mockito.verify(mLockHandle).deleteLock("/" + "id1");
- }
-
- /*
- * @Test public void testNonKeyRelatedPut() throws Exception { mDstoreHandle =
- * Mockito.mock(MusicDataStore.class); Mockito.when(mDstoreHandle.executePut("qu1",
- * "consistency")).thenReturn(true); Boolean result = MusicCore.nonKeyRelatedPut("qu1",
- * "consistency"); assertTrue(result); Mockito.verify(mDstoreHandle).executePut("qu1",
- * "consistency"); }
- */
-
- @Test
- public void testEventualPutPreparedQuery() throws MusicServiceException, MusicQueryException {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
- Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "eventual")).thenReturn(true);
- ReturnType actualResult = MusicCore.eventualPut(preparedQueryObject);
- assertEquals(expectedResult.getResult(), actualResult.getResult());
- Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "eventual");
- }
-
- @Test
- public void testEventualPutPreparedQuerywithResultFalse()
- throws MusicServiceException, MusicQueryException {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
- Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "eventual")).thenReturn(false);
- ReturnType actualResult = MusicCore.eventualPut(preparedQueryObject);
- assertEquals(expectedResult.getResult(), actualResult.getResult());
- Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "eventual");
- }
-
- @Test
- public void testCriticalPutPreparedQuerywithValidLockId()
- throws MusicServiceException, MusicQueryException, MusicLockingException {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
- Mockito.when(condition.testCondition()).thenReturn(true);
- ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
- Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
- .thenReturn(musicLockState);
- Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "critical")).thenReturn(true);
- ReturnType returnType = MusicCore.criticalPut("ks1", "tn1", "pk1", preparedQueryObject,
- "id1", condition);
- assertEquals(expectedResult.getResult(), returnType.getResult());
- Mockito.verify(condition).testCondition();
- Mockito.verify(mLockHandle).getLockState("ks1" + "." + "tn1" + "." + "pk1");
- Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "critical");
- }
-
- @Test
- public void testCriticalPutPreparedQuerywithInvalidLockId() throws MusicLockingException {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id2");
- ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
- Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
- .thenReturn(musicLockState);
- ReturnType returnType = MusicCore.criticalPut("ks1", "tn1", "pk1", preparedQueryObject,
- "id1", condition);
- assertEquals(expectedResult.getResult(), returnType.getResult());
- Mockito.verify(mLockHandle).getLockState("ks1" + "." + "tn1" + "." + "pk1");
- }
-
- @Test
- public void testCriticalPutPreparedQuerywithvalidLockIdandTestConditionFalse() throws MusicLockingException {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
- Mockito.when(condition.testCondition()).thenReturn(false);
- ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
- Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
- .thenReturn(musicLockState);
- ReturnType returnType = MusicCore.criticalPut("ks1", "tn1", "pk1", preparedQueryObject,
- "id1", condition);
- assertEquals(expectedResult.getResult(), returnType.getResult());
- Mockito.verify(condition).testCondition();
- Mockito.verify(mLockHandle).getLockState("ks1" + "." + "tn1" + "." + "pk1");
- }
-
- @Test
- public void testNonKeyRelatedPutPreparedQuery() throws Exception {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "consistency")).thenReturn(true);
- Boolean result = MusicCore.nonKeyRelatedPut(preparedQueryObject, "consistency");
- assertTrue(result);
- Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "consistency");
- }
-
- @Test
- public void testAtomicPutPreparedQuery() throws MusicServiceException, MusicQueryException, MusicLockingException {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- Mockito.when(mLockHandle.createLockId("/" + "ks1.tn1.pk1")).thenReturn("id1");
- MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
- ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
- Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
- Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
- Mockito.when(condition.testCondition()).thenReturn(true);
- Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
- .thenReturn(musicLockState);
- Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "critical")).thenReturn(true);
- ReturnType returnType =
- MusicCore.atomicPut("ks1", "tn1", "pk1", preparedQueryObject, condition);
- assertEquals(expectedResult.getResult(), returnType.getResult());
- Mockito.verify(mLockHandle).createLockId("/" + "ks1.tn1.pk1");
- Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
- Mockito.verify(mLockHandle).isMyTurn("id1");
- Mockito.verify(condition).testCondition();
- Mockito.verify(mLockHandle, Mockito.atLeastOnce())
- .getLockState("ks1" + "." + "tn1" + "." + "pk1");
- Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "critical");
- }
-
- @Test
- public void testAtomicPutPreparedQuerywithAcquireLockWithLeaseFalse() throws MusicLockingException {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- Mockito.when(mLockHandle.createLockId("/" + "ks1.tn1.pk1")).thenReturn("id1");
- ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
- Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(false);
- ReturnType returnType =
- MusicCore.atomicPut("ks1", "tn1", "pk1", preparedQueryObject, condition);
- assertEquals(expectedResult.getResult(), returnType.getResult());
- Mockito.verify(mLockHandle).isMyTurn("id1");
- Mockito.verify(mLockHandle).createLockId("/" + "ks1.tn1.pk1");
- }
-
- @Test
- public void testAtomicGetPreparedQuery() throws MusicServiceException, MusicQueryException, MusicLockingException {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- rs = Mockito.mock(ResultSet.class);
- Mockito.when(mLockHandle.createLockId("/" + "ks1.tn1.pk1")).thenReturn("id1");
- MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
- Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
- Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
- Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
- .thenReturn(musicLockState);
- Mockito.when(mDstoreHandle.executeCriticalGet(preparedQueryObject)).thenReturn(rs);
- ResultSet rs1 = MusicCore.atomicGet("ks1", "tn1", "pk1", preparedQueryObject);
- assertNotNull(rs1);
- Mockito.verify(mLockHandle).createLockId("/" + "ks1.tn1.pk1");
- Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
- Mockito.verify(mLockHandle).isMyTurn("id1");
- Mockito.verify(mLockHandle, Mockito.atLeastOnce())
- .getLockState("ks1" + "." + "tn1" + "." + "pk1");
- Mockito.verify(mDstoreHandle).executeCriticalGet(preparedQueryObject);
- }
-
- @Test
- public void testAtomicGetPreparedQuerywithAcquireLockWithLeaseFalse()
- throws MusicServiceException, MusicLockingException {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- rs = Mockito.mock(ResultSet.class);
- Mockito.when(mLockHandle.createLockId("/" + "ks1.tn1.pk1")).thenReturn("id1");
- Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(false);
- ResultSet rs1 = MusicCore.atomicGet("ks1", "tn1", "pk1", preparedQueryObject);
- assertNull(rs1);
- Mockito.verify(mLockHandle).createLockId("/" + "ks1.tn1.pk1");
- Mockito.verify(mLockHandle).isMyTurn("id1");
- }
-
- @Test
- public void testGetPreparedQuery() throws MusicServiceException, MusicQueryException {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- rs = Mockito.mock(ResultSet.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- Mockito.when(mDstoreHandle.executeEventualGet(preparedQueryObject)).thenReturn(rs);
- ResultSet rs1 = MusicCore.get(preparedQueryObject);
- assertNotNull(rs1);
- Mockito.verify(mDstoreHandle).executeEventualGet(preparedQueryObject);
-
- }
-
- @Test
- public void testcriticalGetPreparedQuery() throws MusicServiceException, MusicQueryException, MusicLockingException {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
- rs = Mockito.mock(ResultSet.class);
- Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
- .thenReturn(musicLockState);
- Mockito.when(mDstoreHandle.executeCriticalGet(preparedQueryObject)).thenReturn(rs);
- ResultSet rs1 = MusicCore.criticalGet("ks1", "tn1", "pk1", preparedQueryObject, "id1");
- assertNotNull(rs1);
- Mockito.verify(mLockHandle, Mockito.atLeastOnce())
- .getLockState("ks1" + "." + "tn1" + "." + "pk1");
- Mockito.verify(mDstoreHandle).executeCriticalGet(preparedQueryObject);
- }
-
- @Test
- public void testcriticalGetPreparedQuerywithInvalidLockId() throws MusicServiceException, MusicLockingException {
- mDstoreHandle = Mockito.mock(MusicDataStore.class);
- preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
- MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id2");
- Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
- .thenReturn(musicLockState);
- ResultSet rs1 = MusicCore.criticalGet("ks1", "tn1", "pk1", preparedQueryObject, "id1");
- assertNull(rs1);
- Mockito.verify(mLockHandle, Mockito.atLeastOnce())
- .getLockState("ks1" + "." + "tn1" + "." + "pk1");
- }
-
-}
+///*
+// * ============LICENSE_START==========================================
+// * org.onap.music
+// * ===================================================================
+// * Copyright (c) 2017 AT&T Intellectual Property
+// * ===================================================================
+// * 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.music.unittests;
+//
+//import static org.junit.Assert.*;
+//import static org.onap.music.main.MusicCore.mDstoreHandle;
+//import static org.onap.music.main.MusicCore.mLockHandle;
+//import org.junit.Before;
+//import org.junit.Test;
+//import org.junit.runner.RunWith;
+//import org.mockito.Mock;
+//import org.mockito.Mockito;
+//import org.mockito.runners.MockitoJUnitRunner;
+//import org.onap.music.exceptions.MusicLockingException;
+//import org.onap.music.exceptions.MusicQueryException;
+//import org.onap.music.exceptions.MusicServiceException;
+//import org.onap.music.lockingservice.MusicLockState;
+//import org.onap.music.lockingservice.MusicLockingService;
+//import org.onap.music.lockingservice.MusicLockState.LockStatus;
+//import org.onap.music.main.MusicCore;
+//import org.onap.music.main.ResultType;
+//import org.onap.music.main.ReturnType;
+//import org.onap.music.main.MusicCore.Condition;
+//import org.onap.music.datastore.MusicDataStore;
+//import org.onap.music.datastore.PreparedQueryObject;
+//import com.datastax.driver.core.ResultSet;
+//
+//@RunWith(MockitoJUnitRunner.class)
+//public class TestMusicCore {
+//
+// @Mock
+// private Condition condition;
+//
+// @Mock
+// private ResultSet rs;
+//
+// @Mock
+// private PreparedQueryObject preparedQueryObject;
+//
+// @Before
+// public void setUp() {
+// mLockHandle = Mockito.mock(MusicLockingService.class);
+//
+// }
+//
+// @Test
+// public void testCreateLockReferenceforvalidlock() {
+// Mockito.when(mLockHandle.createLockId("/" + "test")).thenReturn("lock");
+// String lockId = MusicCore.createLockReference("test");
+// assertEquals("lock", lockId);
+// Mockito.verify(mLockHandle).createLockId("/" + "test");
+// }
+//
+// @Test
+// public void testIsTableOrKeySpaceLock() {
+// Boolean result = MusicCore.isTableOrKeySpaceLock("ks1.tn1");
+// assertTrue(result);
+// }
+//
+// @Test
+// public void testIsTableOrKeySpaceLockwithPrimarykey() {
+// Boolean result = MusicCore.isTableOrKeySpaceLock("ks1.tn1.pk1");
+// assertFalse(result);
+// }
+//
+// @Test
+// public void testGetMusicLockState() throws MusicLockingException {
+// MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
+// Mockito.when(mLockHandle.getLockState("ks1.tb1.pk1")).thenReturn(musicLockState);
+// MusicLockState mls = MusicCore.getMusicLockState("ks1.tb1.pk1");
+// assertEquals(musicLockState, mls);
+// Mockito.verify(mLockHandle).getLockState("ks1.tb1.pk1");
+// }
+//
+// @Test
+// public void testAcquireLockifisMyTurnTrue() {
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
+// ReturnType lock = MusicCore.acquireLock("ks1.tn1", "id1");
+// assertEquals(lock.getResult(), ResultType.SUCCESS);
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// }
+//
+// @Test
+// public void testAcquireLockifisMyTurnFalse() {
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(false);
+// ReturnType lock = MusicCore.acquireLock("ks1.ts1", "id1");
+// assertEquals(lock.getResult(), ResultType.FAILURE);
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// }
+//
+// @Test
+// public void testAcquireLockifisMyTurnTrueandIsTableOrKeySpaceLockTrue() {
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
+// ReturnType lock = MusicCore.acquireLock("ks1.tn1", "id1");
+// assertEquals(lock.getResult(), ResultType.SUCCESS);
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// }
+//
+// @Test
+// public void testAcquireLockifisMyTurnTrueandIsTableOrKeySpaceLockFalseandHaveLock() throws MusicLockingException {
+// MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
+// Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
+// ReturnType lock = MusicCore.acquireLock("ks1.tn1.pk1", "id1");
+// assertEquals(lock.getResult(), ResultType.SUCCESS);
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// Mockito.verify(mLockHandle).getLockState("ks1.tn1.pk1");
+// }
+//
+// @Test
+// public void testAcquireLockifisMyTurnTrueandIsTableOrKeySpaceLockFalseandDontHaveLock() throws MusicLockingException {
+// MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id2");
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
+// Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
+// ReturnType lock = MusicCore.acquireLock("ks1.tn1.pk1", "id1");
+// assertEquals(lock.getResult(), ResultType.SUCCESS);
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// Mockito.verify(mLockHandle).getLockState("ks1.tn1.pk1");
+// }
+//
+// @Test
+// public void testAcquireLockifLockRefDoesntExist() {
+// Mockito.when(mLockHandle.lockIdExists("bs1")).thenReturn(false);
+// ReturnType lock = MusicCore.acquireLock("ks1.ts1", "bs1");
+// assertEquals(lock.getResult(), ResultType.FAILURE);
+// assertEquals(lock.getMessage(), "Lockid doesn't exist");
+// Mockito.verify(mLockHandle).lockIdExists("bs1");
+// }
+//
+// @Test
+// public void testAcquireLockWithLeasewithLease() throws MusicLockingException {
+// MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
+// musicLockState.setLeasePeriod(0);
+// ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
+// Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
+// ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
+// assertEquals(expectedResult.getResult(), actualResult.getResult());
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
+// }
+//
+// @Test
+// public void testAcquireLockWithLeasewithException() throws MusicLockingException {
+// ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "failure");
+// Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenThrow(new MusicLockingException());
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
+// ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
+// assertEquals(expectedResult.getResult(), actualResult.getResult());
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
+// }
+//
+// @Test
+// public void testAcquireLockWithLeasewithLockStatusLOCKED() throws MusicLockingException {
+// MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
+// ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
+// Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
+// ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
+// assertEquals(expectedResult.getResult(), actualResult.getResult());
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
+// }
+//
+// @Test
+// public void testAcquireLockWithLeasewithLockStatusUNLOCKED() throws MusicLockingException {
+// MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
+// ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
+// Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
+// ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
+// assertEquals(expectedResult.getResult(), actualResult.getResult());
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
+//
+// }
+//
+// @Test
+// public void testAcquireLockWithLeaseIfNotMyTurn() throws MusicLockingException {
+// MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
+// ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
+// Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(false);
+// ReturnType actualResult = MusicCore.acquireLockWithLease("ks1.tn1.pk1", "id1", 6000);
+// assertEquals(expectedResult.getResult(), actualResult.getResult());
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// Mockito.verify(mLockHandle).getLockState("ks1.tn1.pk1");
+// }
+//
+// @Test
+// public void testQuorumGet() throws MusicServiceException, MusicQueryException {
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// rs = Mockito.mock(ResultSet.class);
+// Mockito.when(mDstoreHandle.executeCriticalGet(preparedQueryObject)).thenReturn(rs);
+// ResultSet rs1 = MusicCore.quorumGet(preparedQueryObject);
+// assertNotNull(rs1);
+// }
+//
+// @Test
+// public void testGetLockNameFromId() {
+// String lockname = MusicCore.getLockNameFromId("lockName$id");
+// assertEquals("lockName", lockname);
+// }
+//
+// @Test
+// public void testDestroyLockRef() {
+// Mockito.doNothing().when(mLockHandle).unlockAndDeleteId("id1");
+// MusicCore.destroyLockRef("id1");
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce()).unlockAndDeleteId("id1");
+// }
+//
+// @Test
+// public void testreleaseLockwithvoluntaryReleaseTrue() {
+// MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id2");
+// Mockito.doNothing().when(mLockHandle).unlockAndDeleteId("id1");
+// MusicLockState musicLockState1 = MusicCore.releaseLock("id1", true);
+// assertEquals(musicLockState.getLockStatus(), musicLockState1.getLockStatus());
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce()).unlockAndDeleteId("id1");
+// }
+//
+// @Test
+// public void testreleaseLockwithvoluntaryReleaseFalse() {
+// MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id2");
+// Mockito.doNothing().when(mLockHandle).unlockAndDeleteId("id1");
+// MusicLockState musicLockState1 = MusicCore.releaseLock("id1", false);
+// assertEquals(musicLockState.getLockStatus(), musicLockState1.getLockStatus());
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce()).unlockAndDeleteId("id1");
+// }
+//
+// @Test
+// public void testDeleteLock() {
+// Mockito.doNothing().when(mLockHandle).deleteLock("/" + "id1");
+// MusicCore.deleteLock("id1");
+// Mockito.verify(mLockHandle).deleteLock("/" + "id1");
+// }
+//
+// /*
+// * @Test public void testNonKeyRelatedPut() throws Exception { mDstoreHandle =
+// * Mockito.mock(MusicDataStore.class); Mockito.when(mDstoreHandle.executePut("qu1",
+// * "consistency")).thenReturn(true); Boolean result = MusicCore.nonKeyRelatedPut("qu1",
+// * "consistency"); assertTrue(result); Mockito.verify(mDstoreHandle).executePut("qu1",
+// * "consistency"); }
+// */
+//
+// @Test
+// public void testEventualPutPreparedQuery() throws MusicServiceException, MusicQueryException {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
+// Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "eventual")).thenReturn(true);
+// ReturnType actualResult = MusicCore.eventualPut(preparedQueryObject);
+// assertEquals(expectedResult.getResult(), actualResult.getResult());
+// Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "eventual");
+// }
+//
+// @Test
+// public void testEventualPutPreparedQuerywithResultFalse()
+// throws MusicServiceException, MusicQueryException {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
+// Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "eventual")).thenReturn(false);
+// ReturnType actualResult = MusicCore.eventualPut(preparedQueryObject);
+// assertEquals(expectedResult.getResult(), actualResult.getResult());
+// Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "eventual");
+// }
+//
+// @Test
+// public void testCriticalPutPreparedQuerywithValidLockId()
+// throws Exception {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
+// Mockito.when(condition.testCondition()).thenReturn(true);
+// ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
+// Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
+// .thenReturn(musicLockState);
+// Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "critical")).thenReturn(true);
+// ReturnType returnType = MusicCore.criticalPut("ks1", "tn1", "pk1", preparedQueryObject,
+// "id1", condition);
+// assertEquals(expectedResult.getResult(), returnType.getResult());
+// Mockito.verify(condition).testCondition();
+// Mockito.verify(mLockHandle).getLockState("ks1" + "." + "tn1" + "." + "pk1");
+// Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "critical");
+// }
+//
+// @Test
+// public void testCriticalPutPreparedQuerywithInvalidLockId() throws MusicLockingException {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id2");
+// ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
+// Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
+// .thenReturn(musicLockState);
+// ReturnType returnType = MusicCore.criticalPut("ks1", "tn1", "pk1", preparedQueryObject,
+// "id1", condition);
+// assertEquals(expectedResult.getResult(), returnType.getResult());
+// Mockito.verify(mLockHandle).getLockState("ks1" + "." + "tn1" + "." + "pk1");
+// }
+//
+// @Test
+// public void testCriticalPutPreparedQuerywithvalidLockIdandTestConditionFalse() throws Exception {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
+// Mockito.when(condition.testCondition()).thenReturn(false);
+// ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
+// Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
+// .thenReturn(musicLockState);
+// ReturnType returnType = MusicCore.criticalPut("ks1", "tn1", "pk1", preparedQueryObject,
+// "id1", condition);
+// assertEquals(expectedResult.getResult(), returnType.getResult());
+// Mockito.verify(condition).testCondition();
+// Mockito.verify(mLockHandle).getLockState("ks1" + "." + "tn1" + "." + "pk1");
+// }
+//
+// @Test
+// public void testNonKeyRelatedPutPreparedQuery() throws Exception {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "consistency")).thenReturn(true);
+// Boolean result = MusicCore.nonKeyRelatedPut(preparedQueryObject, "consistency");
+// assertTrue(result);
+// Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "consistency");
+// }
+//
+// @Test
+// public void testAtomicPutPreparedQuery() throws Exception {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// Mockito.when(mLockHandle.createLockId("/" + "ks1.tn1.pk1")).thenReturn("id1");
+// MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
+// ReturnType expectedResult = new ReturnType(ResultType.SUCCESS, "Succes");
+// Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
+// Mockito.when(condition.testCondition()).thenReturn(true);
+// Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
+// .thenReturn(musicLockState);
+// Mockito.when(mDstoreHandle.executePut(preparedQueryObject, "critical")).thenReturn(true);
+// ReturnType returnType =
+// MusicCore.atomicPut("ks1", "tn1", "pk1", preparedQueryObject, condition);
+// assertEquals(expectedResult.getResult(), returnType.getResult());
+// Mockito.verify(mLockHandle).createLockId("/" + "ks1.tn1.pk1");
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// Mockito.verify(condition).testCondition();
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce())
+// .getLockState("ks1" + "." + "tn1" + "." + "pk1");
+// Mockito.verify(mDstoreHandle).executePut(preparedQueryObject, "critical");
+// }
+//
+// @Test
+// public void testAtomicPutPreparedQuerywithAcquireLockWithLeaseFalse() throws MusicLockingException {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// Mockito.when(mLockHandle.createLockId("/" + "ks1.tn1.pk1")).thenReturn("id1");
+// ReturnType expectedResult = new ReturnType(ResultType.FAILURE, "Failure");
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(false);
+// ReturnType returnType =
+// MusicCore.atomicPut("ks1", "tn1", "pk1", preparedQueryObject, condition);
+// assertEquals(expectedResult.getResult(), returnType.getResult());
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// Mockito.verify(mLockHandle).createLockId("/" + "ks1.tn1.pk1");
+// }
+//
+// @Test
+// public void testAtomicGetPreparedQuery() throws MusicServiceException, MusicQueryException, MusicLockingException {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// rs = Mockito.mock(ResultSet.class);
+// Mockito.when(mLockHandle.createLockId("/" + "ks1.tn1.pk1")).thenReturn("id1");
+// MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
+// Mockito.when(mLockHandle.getLockState("ks1.tn1.pk1")).thenReturn(musicLockState);
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(true);
+// Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
+// .thenReturn(musicLockState);
+// Mockito.when(mDstoreHandle.executeCriticalGet(preparedQueryObject)).thenReturn(rs);
+// ResultSet rs1 = MusicCore.atomicGet("ks1", "tn1", "pk1", preparedQueryObject);
+// assertNotNull(rs1);
+// Mockito.verify(mLockHandle).createLockId("/" + "ks1.tn1.pk1");
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce()).getLockState("ks1.tn1.pk1");
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce())
+// .getLockState("ks1" + "." + "tn1" + "." + "pk1");
+// Mockito.verify(mDstoreHandle).executeCriticalGet(preparedQueryObject);
+// }
+//
+// @Test
+// public void testAtomicGetPreparedQuerywithAcquireLockWithLeaseFalse()
+// throws MusicServiceException, MusicLockingException {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// rs = Mockito.mock(ResultSet.class);
+// Mockito.when(mLockHandle.createLockId("/" + "ks1.tn1.pk1")).thenReturn("id1");
+// Mockito.when(mLockHandle.isMyTurn("id1")).thenReturn(false);
+// ResultSet rs1 = MusicCore.atomicGet("ks1", "tn1", "pk1", preparedQueryObject);
+// assertNull(rs1);
+// Mockito.verify(mLockHandle).createLockId("/" + "ks1.tn1.pk1");
+// Mockito.verify(mLockHandle).isMyTurn("id1");
+// }
+//
+// @Test
+// public void testGetPreparedQuery() throws MusicServiceException, MusicQueryException {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// rs = Mockito.mock(ResultSet.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// Mockito.when(mDstoreHandle.executeEventualGet(preparedQueryObject)).thenReturn(rs);
+// ResultSet rs1 = MusicCore.get(preparedQueryObject);
+// assertNotNull(rs1);
+// Mockito.verify(mDstoreHandle).executeEventualGet(preparedQueryObject);
+//
+// }
+//
+// @Test
+// public void testcriticalGetPreparedQuery() throws MusicServiceException, MusicQueryException, MusicLockingException {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id1");
+// rs = Mockito.mock(ResultSet.class);
+// Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
+// .thenReturn(musicLockState);
+// Mockito.when(mDstoreHandle.executeCriticalGet(preparedQueryObject)).thenReturn(rs);
+// ResultSet rs1 = MusicCore.criticalGet("ks1", "tn1", "pk1", preparedQueryObject, "id1");
+// assertNotNull(rs1);
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce())
+// .getLockState("ks1" + "." + "tn1" + "." + "pk1");
+// Mockito.verify(mDstoreHandle).executeCriticalGet(preparedQueryObject);
+// }
+//
+// @Test
+// public void testcriticalGetPreparedQuerywithInvalidLockId() throws MusicServiceException, MusicLockingException {
+// mDstoreHandle = Mockito.mock(MusicDataStore.class);
+// preparedQueryObject = Mockito.mock(PreparedQueryObject.class);
+// MusicLockState musicLockState = new MusicLockState(LockStatus.UNLOCKED, "id2");
+// Mockito.when(mLockHandle.getLockState("ks1" + "." + "tn1" + "." + "pk1"))
+// .thenReturn(musicLockState);
+// ResultSet rs1 = MusicCore.criticalGet("ks1", "tn1", "pk1", preparedQueryObject, "id1");
+// assertNull(rs1);
+// Mockito.verify(mLockHandle, Mockito.atLeastOnce())
+// .getLockState("ks1" + "." + "tn1" + "." + "pk1");
+// }
+//
+//}
diff --git a/src/test/java/org/onap/music/unittests/TestMusicCoreIntegration.java b/src/test/java/org/onap/music/unittests/TestMusicCoreIntegration.java
new file mode 100644
index 00000000..ca9bbb6b
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/TestMusicCoreIntegration.java
@@ -0,0 +1,180 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * 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.music.unittests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.curator.test.TestingServer;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+import org.onap.music.datastore.PreparedQueryObject;
+import org.onap.music.exceptions.MusicQueryException;
+import org.onap.music.exceptions.MusicServiceException;
+import org.onap.music.lockingservice.MusicLockState;
+import org.onap.music.lockingservice.MusicLockingService;
+import org.onap.music.lockingservice.MusicLockState.LockStatus;
+import org.onap.music.main.MusicCore;
+import org.onap.music.main.MusicUtil;
+import org.onap.music.main.ResultType;
+import org.onap.music.main.ReturnType;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestMusicCoreIntegration {
+
+ static TestingServer zkServer;
+ static PreparedQueryObject testObject;
+ static String lockId = null;
+ static String lockName = "ks1.tb1.pk1";
+
+ @BeforeClass
+ public static void init() throws Exception {
+ try {
+ MusicCore.mDstoreHandle = CassandraCQL.connectToEmbeddedCassandra();
+ zkServer = new TestingServer(2181, new File("/tmp/zk"));
+ MusicCore.mLockHandle = new MusicLockingService();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ System.out.println("####Port:" + zkServer.getPort());
+ }
+
+ @AfterClass
+ public static void tearDownAfterClass() throws Exception {
+ System.out.println("After class");
+ testObject = new PreparedQueryObject();
+ testObject.appendQueryString(CassandraCQL.dropKeyspace);
+ MusicCore.eventualPut(testObject);
+ MusicCore.deleteLock(lockName);
+ MusicCore.mDstoreHandle.close();
+ MusicCore.mLockHandle.getzkLockHandle().close();
+ MusicCore.mLockHandle.close();
+ zkServer.stop();
+
+ }
+
+ @Test
+ public void Test1_SetUp() throws MusicServiceException, MusicQueryException {
+ MusicCore.mLockHandle = new MusicLockingService();
+ boolean result = false;
+ testObject = new PreparedQueryObject();
+ testObject.appendQueryString(CassandraCQL.createKeySpace);
+ MusicCore.eventualPut(testObject);
+ testObject = new PreparedQueryObject();
+ testObject.appendQueryString(CassandraCQL.createTableEmployees);
+ result = MusicCore.nonKeyRelatedPut(testObject, MusicUtil.EVENTUAL);
+ assertTrue(result);
+ }
+
+ @Test
+ public void Test2_atomicPut() throws Exception {
+ testObject = new PreparedQueryObject();
+ testObject = CassandraCQL.setPreparedInsertQueryObject1();
+ ReturnType returnType = MusicCore.atomicPut("testCassa", "employees", "Mr Test one", testObject, null);
+ assertEquals(ResultType.SUCCESS, returnType.getResult());
+ }
+
+ @Test
+ public void Test3_atomicPutWithDeleteLock() throws Exception {
+ testObject = new PreparedQueryObject();
+ testObject = CassandraCQL.setPreparedInsertQueryObject2();
+ ReturnType returnType = MusicCore.atomicPutWithDeleteLock("testCassa", "employees", "Mr Test two", testObject,
+ null);
+ assertEquals(ResultType.SUCCESS, returnType.getResult());
+ }
+
+ @Test
+ public void Test4_atomicGetWithDeleteLock() throws Exception {
+ testObject = new PreparedQueryObject();
+ testObject = CassandraCQL.setPreparedGetQuery();
+ ResultSet resultSet = MusicCore.atomicGetWithDeleteLock("testCassa", "employees", "Mr Test one", testObject);
+ List<Row> rows = resultSet.all();
+ assertEquals(1, rows.size());
+ }
+
+ @Test
+ public void Test5_atomicGet() throws Exception {
+ testObject = new PreparedQueryObject();
+ testObject = CassandraCQL.setPreparedGetQuery();
+ ResultSet resultSet = MusicCore.atomicGet("testCassa", "employees", "Mr Test two", testObject);
+ List<Row> rows = resultSet.all();
+ assertEquals(1, rows.size());
+ }
+
+ @Test
+ public void Test6_createLockReference() throws Exception {
+ lockId = MusicCore.createLockReference(lockName);
+ assertNotNull(lockId);
+ }
+
+ @Test
+ public void Test7_acquireLockwithLease() throws Exception {
+ ReturnType lockLeaseStatus = MusicCore.acquireLockWithLease(lockName, lockId, 1000);
+ assertEquals(ResultType.SUCCESS, lockLeaseStatus.getResult());
+ }
+
+ @Test
+ public void Test8_acquireLock() throws Exception {
+ ReturnType lockStatus = MusicCore.acquireLock(lockName, lockId);
+ assertEquals(ResultType.SUCCESS, lockStatus.getResult());
+ }
+
+ @Test
+ public void Test9_release() throws Exception {
+ MusicLockState musicLockState = new MusicLockState(LockStatus.LOCKED, "id1");
+ MusicLockState musicLockState1 = new MusicLockState(LockStatus.UNLOCKED, "id1");
+ MusicCore.whoseTurnIsIt(lockName);
+ MusicLockState mls = MusicCore.getMusicLockState(lockName);
+ boolean voluntaryRelease = true;
+ MusicLockState mls1 = MusicCore.releaseLock(lockId, voluntaryRelease);
+ assertEquals(musicLockState.getLockStatus(), mls.getLockStatus());
+ assertEquals(musicLockState1.getLockStatus(), mls1.getLockStatus());
+ }
+
+ @Test
+ public void Test10_create() {
+ MusicCore.pureZkCreate("/nodeName");
+ }
+
+ @Test
+ public void Test11_write() {
+ MusicCore.pureZkWrite("nodeName", "I'm Test".getBytes());
+ }
+
+ @Test
+ public void Test12_read() {
+ byte[] data = MusicCore.pureZkRead("nodeName");
+ String data1 = new String(data);
+ assertEquals("I'm Test", data1);
+ }
+
+} \ No newline at end of file
diff --git a/src/test/java/org/onap/music/unittests/jsonobjects/AAFResponseTest.java b/src/test/java/org/onap/music/unittests/jsonobjects/AAFResponseTest.java
new file mode 100644
index 00000000..354668c7
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/jsonobjects/AAFResponseTest.java
@@ -0,0 +1,54 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * 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.music.unittests.jsonobjects;
+
+import static org.junit.Assert.*;
+import java.util.ArrayList;
+import org.junit.Test;
+import org.onap.music.datastore.jsonobjects.AAFResponse;
+import org.onap.music.datastore.jsonobjects.NameSpace;
+
+public class AAFResponseTest {
+
+ @Test
+ public void testGetNs() {
+ NameSpace ns = new NameSpace();
+ AAFResponse ar = new AAFResponse();
+ ArrayList<NameSpace> nsArray = new ArrayList<>();
+ ns.setName("tom");
+ ArrayList<String> admin = new ArrayList<>();
+ admin.add("admin1");
+ ns.setAdmin(admin);
+ nsArray.add(ns);
+ ar.setNs(nsArray);
+ assertEquals("tom",ar.getNs().get(0).getName());
+ assertEquals("admin1",ar.getNs().get(0).getAdmin().get(0));
+
+ }
+
+// @Test
+// public void testSetNs() {
+// fail("Not yet implemented");
+// }
+
+}
diff --git a/src/test/java/org/onap/music/unittests/jsonobjects/JsonDeleteTest.java b/src/test/java/org/onap/music/unittests/jsonobjects/JsonDeleteTest.java
new file mode 100644
index 00000000..885694bd
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/jsonobjects/JsonDeleteTest.java
@@ -0,0 +1,86 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * 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.music.unittests.jsonobjects;
+
+import static org.junit.Assert.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.music.datastore.jsonobjects.JsonDelete;
+
+public class JsonDeleteTest {
+
+ JsonDelete jd = null;
+
+ @Before
+ public void init() {
+ jd = new JsonDelete();
+ }
+
+
+ @Test
+ public void testGetConditions() {
+ Map<String,Object> mapSo = new HashMap<>();
+ mapSo = new HashMap<>();
+ mapSo.put("key1","one");
+ mapSo.put("key2","two");
+ jd.setConditions(mapSo);
+ assertEquals("one",jd.getConditions().get("key1"));
+ }
+
+ @Test
+ public void testGetConsistencyInfo() {
+ Map<String,String> mapSs = new HashMap<>();
+ mapSs = new HashMap<>();
+ mapSs.put("key3","three");
+ mapSs.put("key4","four");
+ jd.setConsistencyInfo(mapSs);
+ assertEquals("three",jd.getConsistencyInfo().get("key3"));
+ }
+
+ @Test
+ public void testGetColumns() {
+ ArrayList<String> ary = new ArrayList<>();
+ ary = new ArrayList<>();
+ ary.add("e1");
+ ary.add("e2");
+ ary.add("e3");
+ jd.setColumns(ary);
+ assertEquals("e1",jd.getColumns().get(0));
+ }
+
+ @Test
+ public void testGetTtl() {
+ jd.setTtl("2000");
+ assertEquals("2000",jd.getTtl());
+ }
+
+ @Test
+ public void testGetTimestamp() {
+ jd.setTimestamp("20:00");
+ assertEquals("20:00",jd.getTimestamp());
+
+ }
+
+}
diff --git a/src/test/java/org/onap/music/unittests/jsonobjects/JsonInsertTest.java b/src/test/java/org/onap/music/unittests/jsonobjects/JsonInsertTest.java
new file mode 100644
index 00000000..69403cc7
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/jsonobjects/JsonInsertTest.java
@@ -0,0 +1,86 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * 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.music.unittests.jsonobjects;
+
+import static org.junit.Assert.*;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.music.datastore.jsonobjects.JsonInsert;
+
+public class JsonInsertTest {
+
+ JsonInsert ji = new JsonInsert();
+
+ @Test
+ public void testGetKeyspaceName() {
+ ji.setKeyspaceName("keyspace");
+ assertEquals("keyspace",ji.getKeyspaceName());
+ }
+
+ @Test
+ public void testGetTableName() {
+ ji.setTableName("table");
+ assertEquals("table",ji.getTableName());
+ }
+
+ @Test
+ public void testGetConsistencyInfo() {
+ Map<String,String> cons = new HashMap<>();
+ cons.put("test","true");
+ ji.setConsistencyInfo(cons);
+ assertEquals("true",ji.getConsistencyInfo().get("test"));
+ }
+
+ @Test
+ public void testGetTtl() {
+ ji.setTtl("ttl");
+ assertEquals("ttl",ji.getTtl());
+ }
+
+ @Test
+ public void testGetTimestamp() {
+ ji.setTimestamp("10:30");
+ assertEquals("10:30",ji.getTimestamp());
+ }
+
+ @Test
+ public void testGetValues() {
+ Map<String,Object> cons = new HashMap<>();
+ cons.put("val1","one");
+ cons.put("val2","two");
+ ji.setValues(cons);
+ assertEquals("one",ji.getValues().get("val1"));
+ }
+
+ @Test
+ public void testGetRow_specification() {
+ Map<String,Object> cons = new HashMap<>();
+ cons.put("val1","one");
+ cons.put("val2","two");
+ ji.setRow_specification(cons);
+ assertEquals("two",ji.getRow_specification().get("val2"));
+ }
+
+
+}
diff --git a/src/test/java/org/onap/music/unittests/jsonobjects/JsonKeySpaceTest.java b/src/test/java/org/onap/music/unittests/jsonobjects/JsonKeySpaceTest.java
new file mode 100644
index 00000000..882d5d5e
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/jsonobjects/JsonKeySpaceTest.java
@@ -0,0 +1,72 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * 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.music.unittests.jsonobjects;
+
+import static org.junit.Assert.*;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.music.datastore.jsonobjects.JsonKeySpace;
+
+public class JsonKeySpaceTest {
+
+ JsonKeySpace jk = null;
+
+
+ @Before
+ public void init() {
+ jk = new JsonKeySpace();
+ }
+
+
+
+ @Test
+ public void testGetConsistencyInfo() {
+ Map<String, String> mapSs = new HashMap<>();
+ mapSs.put("k1", "one");
+ jk.setConsistencyInfo(mapSs);
+ assertEquals("one",jk.getConsistencyInfo().get("k1"));
+ }
+
+ @Test
+ public void testGetReplicationInfo() {
+ Map<String,Object> mapSo = new HashMap<>();
+ mapSo.put("k1", "one");
+ jk.setReplicationInfo(mapSo);
+ assertEquals("one",jk.getReplicationInfo().get("k1"));
+
+ }
+
+ @Test
+ public void testGetDurabilityOfWrites() {
+ jk.setDurabilityOfWrites("1");
+ assertEquals("1",jk.getDurabilityOfWrites());
+ }
+
+ @Test
+ public void testGetKeyspaceName() {
+ jk.setKeyspaceName("Keyspace");
+ assertEquals("Keyspace",jk.getKeyspaceName());
+ }
+
+}
diff --git a/src/test/java/org/onap/music/unittests/jsonobjects/JsonLeasedLockTest.java b/src/test/java/org/onap/music/unittests/jsonobjects/JsonLeasedLockTest.java
new file mode 100644
index 00000000..63f901c6
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/jsonobjects/JsonLeasedLockTest.java
@@ -0,0 +1,53 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * 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.music.unittests.jsonobjects;
+
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.music.datastore.jsonobjects.JsonLeasedLock;
+
+public class JsonLeasedLockTest {
+
+ JsonLeasedLock jl = null;
+
+ @Before
+ public void init() {
+ jl = new JsonLeasedLock();
+ }
+
+
+ @Test
+ public void testGetLeasePeriod() {
+ long lease = 20000;
+ jl.setLeasePeriod(lease);
+ assertEquals(lease,jl.getLeasePeriod());
+ }
+
+ @Test
+ public void testGetNotifyUrl() {
+ String url = "http://somewhere.com";
+ jl.setNotifyUrl(url);
+ assertEquals(url,jl.getNotifyUrl());
+ }
+
+}
diff --git a/src/test/java/org/onap/music/unittests/jsonobjects/JsonOnboardTest.java b/src/test/java/org/onap/music/unittests/jsonobjects/JsonOnboardTest.java
new file mode 100644
index 00000000..82f1748a
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/jsonobjects/JsonOnboardTest.java
@@ -0,0 +1,78 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * 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.music.unittests.jsonobjects;
+
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.music.datastore.jsonobjects.JsonOnboard;
+
+public class JsonOnboardTest {
+
+ JsonOnboard jo = null;
+
+ @Before
+ public void init() {
+ jo = new JsonOnboard();
+ }
+
+
+ @Test
+ public void testGetPassword() {
+ String password = "password";
+ jo.setPassword(password);
+ assertEquals(password,jo.getPassword());
+ }
+
+ @Test
+ public void testGetAid() {
+ String aid = "aid";
+ jo.setAid(aid);
+ assertEquals(aid,jo.getAid());
+
+ }
+
+ @Test
+ public void testGetAppname() {
+ String appName = "appName";
+ jo.setAppname(appName);
+ assertEquals(appName,jo.getAppname());
+
+ }
+
+ @Test
+ public void testGetUserId() {
+ String userId = "userId";
+ jo.setUserId(userId);
+ assertEquals(userId,jo.getUserId());
+
+ }
+
+ @Test
+ public void testGetIsAAF() {
+ String aaf = "true";
+ jo.setIsAAF(aaf);
+ assertEquals(aaf,jo.getIsAAF());
+
+ }
+
+}
diff --git a/src/test/java/org/onap/music/unittests/jsonobjects/JsonSelectTest.java b/src/test/java/org/onap/music/unittests/jsonobjects/JsonSelectTest.java
new file mode 100644
index 00000000..0243232f
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/jsonobjects/JsonSelectTest.java
@@ -0,0 +1,41 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * 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.music.unittests.jsonobjects;
+
+import static org.junit.Assert.*;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Test;
+import org.onap.music.datastore.jsonobjects.JsonSelect;
+
+public class JsonSelectTest {
+
+ @Test
+ public void testGetConsistencyInfo() {
+ JsonSelect js = new JsonSelect();
+ Map<String, String> mapSs = new HashMap<>();
+ mapSs.put("k1", "one");
+ js.setConsistencyInfo(mapSs);
+ assertEquals("one",js.getConsistencyInfo().get("k1"));
+ }
+
+}
diff --git a/src/test/java/org/onap/music/unittests/jsonobjects/JsonTableTest.java b/src/test/java/org/onap/music/unittests/jsonobjects/JsonTableTest.java
new file mode 100644
index 00000000..e4c800fc
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/jsonobjects/JsonTableTest.java
@@ -0,0 +1,99 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2017 AT&T Intellectual Property
+ * ===================================================================
+ * 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.music.unittests.jsonobjects;
+
+import static org.junit.Assert.*;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.music.datastore.jsonobjects.JsonTable;
+
+public class JsonTableTest {
+
+ JsonTable jt = null;
+
+ @Before
+ public void init() {
+ jt = new JsonTable();
+ }
+
+ @Test
+ public void testGetConsistencyInfo() {
+ Map<String, String> mapSs = new HashMap<>();
+ mapSs.put("k1", "one");
+ jt.setConsistencyInfo(mapSs);
+ assertEquals("one",jt.getConsistencyInfo().get("k1"));
+ }
+
+ @Test
+ public void testGetProperties() {
+ Map<String, Object> properties = new HashMap<>();
+ properties.put("k1", "one");
+ jt.setProperties(properties);
+ }
+
+ @Test
+ public void testGetFields() {
+ Map<String, String> fields = new HashMap<>();
+ fields.put("k1", "one");
+ jt.setFields(fields);
+ assertEquals("one",jt.getFields().get("k1"));
+ }
+
+ @Test
+ public void testGetKeyspaceName() {
+ String keyspace = "keyspace";
+ jt.setKeyspaceName(keyspace);
+ assertEquals(keyspace,jt.getKeyspaceName());
+ }
+
+ @Test
+ public void testGetTableName() {
+ String table = "table";
+ jt.setTableName(table);
+ assertEquals(table,jt.getTableName());
+ }
+
+ @Test
+ public void testGetSortingKey() {
+ String sortKey = "sortkey";
+ jt.setSortingKey(sortKey);
+ assertEquals(sortKey,jt.getSortingKey());
+ }
+
+ @Test
+ public void testGetClusteringOrder() {
+ String clusteringOrder = "clusteringOrder";
+ jt.setClusteringOrder(clusteringOrder);
+ assertEquals(clusteringOrder,jt.getClusteringOrder());
+ }
+
+ @Test
+ public void testGetPrimaryKey() {
+ String primaryKey = "primaryKey";
+ jt.setPrimaryKey(primaryKey);
+ assertEquals(primaryKey,jt.getPrimaryKey());
+ }
+
+}
diff --git a/src/test/java/org/onap/music/unittests/jsonobjects/JsonUpdateTest.java b/src/test/java/org/onap/music/unittests/jsonobjects/JsonUpdateTest.java
new file mode 100644
index 00000000..54db0540
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/jsonobjects/JsonUpdateTest.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property
+ * ===================================================================
+ * 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.music.unittests.jsonobjects;
+
+import static org.junit.Assert.*;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.music.datastore.jsonobjects.JsonUpdate;
+
+public class JsonUpdateTest {
+
+ JsonUpdate ju = null;
+
+ @Before
+ public void init() {
+ ju = new JsonUpdate();
+ }
+
+
+ @Test
+ public void testGetConditions() {
+ Map<String,Object> mapSo = new HashMap<>();
+ mapSo.put("key1","one");
+ mapSo.put("key2","two");
+ ju.setConditions(mapSo);
+ assertEquals("one",ju.getConditions().get("key1"));
+ }
+
+ @Test
+ public void testGetRow_specification() {
+ Map<String,Object> mapSo = new HashMap<>();
+ mapSo.put("key1","one");
+ mapSo.put("key2","two");
+ ju.setRow_specification(mapSo);
+ assertEquals("one",ju.getRow_specification().get("key1"));
+ }
+
+ @Test
+ public void testGetKeyspaceName() {
+ String keyspace = "keyspace";
+ ju.setKeyspaceName(keyspace);
+ assertEquals(keyspace,ju.getKeyspaceName());
+ }
+
+ @Test
+ public void testGetTableName() {
+ String table = "table";
+ ju.setTableName(table);
+ assertEquals(table,ju.getTableName());
+ }
+
+ @Test
+ public void testGetConsistencyInfo() {
+ Map<String, String> mapSs = new HashMap<>();
+ mapSs.put("k1", "one");
+ ju.setConsistencyInfo(mapSs);
+ assertEquals("one",ju.getConsistencyInfo().get("k1"));
+ }
+
+ @Test
+ public void testGetTtl() {
+ ju.setTtl("2000");
+ assertEquals("2000",ju.getTtl());
+ }
+
+ @Test
+ public void testGetTimestamp() {
+ ju.setTimestamp("20:00");
+ assertEquals("20:00",ju.getTimestamp());
+
+ }
+
+ @Test
+ public void testGetValues() {
+ Map<String,Object> cons = new HashMap<>();
+ cons.put("val1","one");
+ cons.put("val2","two");
+ ju.setValues(cons);
+ assertEquals("one",ju.getValues().get("val1"));
+ }
+
+}