aboutsummaryrefslogtreecommitdiffstats
path: root/music-core/src/test/java/org/onap/music/main
diff options
context:
space:
mode:
Diffstat (limited to 'music-core/src/test/java/org/onap/music/main')
-rw-r--r--music-core/src/test/java/org/onap/music/main/CipherUtilTest.java55
-rw-r--r--music-core/src/test/java/org/onap/music/main/DeadlockDetectionUtilTest.java87
-rw-r--r--music-core/src/test/java/org/onap/music/main/MusicCoreTest.java391
-rw-r--r--music-core/src/test/java/org/onap/music/main/ResultTypeTest.java42
-rw-r--r--music-core/src/test/java/org/onap/music/main/ReturnTypeTest.java82
5 files changed, 657 insertions, 0 deletions
diff --git a/music-core/src/test/java/org/onap/music/main/CipherUtilTest.java b/music-core/src/test/java/org/onap/music/main/CipherUtilTest.java
new file mode 100644
index 00000000..ff187ffd
--- /dev/null
+++ b/music-core/src/test/java/org/onap/music/main/CipherUtilTest.java
@@ -0,0 +1,55 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2019 IBM 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.main;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class CipherUtilTest {
+
+ private CipherUtil cipherUtil;
+
+ @Before
+ public void setup() {
+ cipherUtil = new CipherUtil();
+ }
+
+ @Test
+ public void testEncryptPKC() {
+ String encryptedText = CipherUtil.encryptPKC("This is another string to be encrypted",
+ "4BFF9DCCD774F3650E20C4D3F69F8C99");
+ System.out.println("*************************" + encryptedText);
+ assertEquals(88, encryptedText.length());
+ }
+
+ @Test
+ public void testDecryptPKC() {
+ String encryptedText = CipherUtil.encryptPKC("This is another string to be encrypted",
+ "4BFF9DCCD774F3650E20C4D3F69F8C99");
+ assertEquals("This is another string to be encrypted",
+ CipherUtil.decryptPKC(encryptedText, "4BFF9DCCD774F3650E20C4D3F69F8C99"));
+ }
+
+}
diff --git a/music-core/src/test/java/org/onap/music/main/DeadlockDetectionUtilTest.java b/music-core/src/test/java/org/onap/music/main/DeadlockDetectionUtilTest.java
new file mode 100644
index 00000000..ab767e17
--- /dev/null
+++ b/music-core/src/test/java/org/onap/music/main/DeadlockDetectionUtilTest.java
@@ -0,0 +1,87 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2019 IBM 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.main;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import org.junit.Before;
+import org.junit.Test;
+//import org.junit.experimental.runners.Enclosed;
+//import org.junit.runner.RunWith;
+import org.onap.music.main.DeadlockDetectionUtil.OwnershipType;
+
+//@RunWith(Enclosed.class)
+public class DeadlockDetectionUtilTest {
+ private DeadlockDetectionUtil ddu;
+
+ @Before
+ public void setup() {
+ ddu = new DeadlockDetectionUtil();
+ }
+
+ @Test
+ public void testListAllNodes() {
+ ddu = new DeadlockDetectionUtil();
+ ddu.setExisting("r1", "o2", OwnershipType.ACQUIRED);
+ ddu.setExisting("r3", "o2", OwnershipType.ACQUIRED);
+
+ ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ System.setOut(new PrintStream(outContent));
+ ddu.listAllNodes();
+
+ /*
+ * String expectedOutput = "In DeadlockDetectionUtil: \n" +
+ * " o2 : Node [id=o2, links=r3, visited=false, onStack=false]\n" +
+ * " r3 : Node [id=r3, links=, visited=false, onStack=false]\n" +
+ * " r1 : Node [id=r1, links=o2, visited=false, onStack=false]\n";
+ * assertEquals(expectedOutput, outContent.toString());
+ *
+ * ddu = new DeadlockDetectionUtil(); ddu.setExisting("111", "222",
+ * OwnershipType.CREATED); ddu.setExisting("333", "222", OwnershipType.CREATED);
+ * outContent = new ByteArrayOutputStream(); System.setOut(new
+ * PrintStream(outContent)); ddu.listAllNodes(); expectedOutput =
+ * "In DeadlockDetectionUtil: \n" +
+ * " o222 : Node [id=o222, links=r111r333, visited=false, onStack=false]\n" +
+ * " r333 : Node [id=r333, links=, visited=false, onStack=false]\n" +
+ * " r111 : Node [id=r111, links=, visited=false, onStack=false]";
+ * assertEquals(expectedOutput, outContent.toString());
+ */
+ }
+
+ @Test
+ public void testcheckForDeadlock() {
+ ddu = new DeadlockDetectionUtil();
+ ddu.setExisting("111", "222", DeadlockDetectionUtil.OwnershipType.ACQUIRED);
+ ddu.setExisting("333", "444", DeadlockDetectionUtil.OwnershipType.ACQUIRED);
+ assertEquals(false, ddu.checkForDeadlock("111", "444", DeadlockDetectionUtil.OwnershipType.CREATED));
+
+ ddu = new DeadlockDetectionUtil();
+ ddu.setExisting("111", "222", DeadlockDetectionUtil.OwnershipType.ACQUIRED);
+ ddu.setExisting("333", "444", DeadlockDetectionUtil.OwnershipType.ACQUIRED);
+ ddu.setExisting("333", "222", DeadlockDetectionUtil.OwnershipType.CREATED);
+ assertEquals(true, ddu.checkForDeadlock("111", "444", DeadlockDetectionUtil.OwnershipType.CREATED));
+ }
+}
diff --git a/music-core/src/test/java/org/onap/music/main/MusicCoreTest.java b/music-core/src/test/java/org/onap/music/main/MusicCoreTest.java
new file mode 100644
index 00000000..4714778b
--- /dev/null
+++ b/music-core/src/test/java/org/onap/music/main/MusicCoreTest.java
@@ -0,0 +1,391 @@
+/*******************************************************************************
+ * ============LICENSE_START========================================== org.onap.music
+ * =================================================================== Copyright (c) 2019 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.main;
+
+import static org.junit.Assert.assertEquals;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.core.MultivaluedMap;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.internal.util.reflection.FieldSetter;
+import org.onap.music.datastore.Condition;
+import org.onap.music.datastore.PreparedQueryObject;
+import org.onap.music.datastore.jsonobjects.JsonDelete;
+import org.onap.music.datastore.jsonobjects.JsonIndex;
+import org.onap.music.datastore.jsonobjects.JsonInsert;
+import org.onap.music.datastore.jsonobjects.JsonKeySpace;
+import org.onap.music.datastore.jsonobjects.JsonSelect;
+import org.onap.music.datastore.jsonobjects.JsonTable;
+import org.onap.music.datastore.jsonobjects.JsonUpdate;
+import org.onap.music.exceptions.MusicLockingException;
+import org.onap.music.exceptions.MusicQueryException;
+import org.onap.music.exceptions.MusicServiceException;
+import org.onap.music.lockingservice.cassandra.CassaLockStore;
+import org.onap.music.lockingservice.cassandra.LockType;
+import org.onap.music.lockingservice.cassandra.MusicLockState;
+import org.onap.music.service.MusicCoreService;
+import com.datastax.driver.core.ResultSet;
+
+public class MusicCoreTest {
+
+ MusicCore mCore;
+ MusicCoreService musicCore;
+ CassaLockStore mLockHandle;
+
+ @Before
+ public void setup() {
+ mCore = new MusicCore();
+ musicCore = Mockito.mock(MusicCoreService.class);
+ mLockHandle = Mockito.mock(CassaLockStore.class);
+ try {
+ FieldSetter.setField(mCore, mCore.getClass().getDeclaredField("musicCore"), musicCore);
+ } catch (NoSuchFieldException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (SecurityException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testAcquireLock() throws MusicLockingException, MusicQueryException, MusicServiceException {
+ ReturnType returnType = Mockito.mock(ReturnType.class);
+ ReturnType result = null;
+ Mockito.when(musicCore.acquireLock(Mockito.any(), Mockito.any())).thenReturn(returnType);
+ result = MusicCore.acquireLock("key1", "lockid1");
+ assertEquals(returnType, result);
+ }
+
+ @Test
+ public void testacquireLockWithLease() throws MusicLockingException, MusicQueryException, MusicServiceException {
+ ReturnType returnType = Mockito.mock(ReturnType.class);
+ ReturnType result = null;
+ Mockito.when(musicCore.acquireLockWithLease(Mockito.anyString(), Mockito.anyString(), Mockito.anyLong()))
+ .thenReturn(returnType);
+ result = MusicCore.acquireLockWithLease("key1", "lockid1", 100L);
+ assertEquals(returnType, result);
+ }
+
+ @Test
+ public void testCreateLockReferenceAtomic() throws MusicLockingException {
+ String result = null;
+ Mockito.when(musicCore.createLockReferenceAtomic(Mockito.any())).thenReturn("lockreference1");
+ result = MusicCore.createLockReferenceAtomic("key2");
+ assertEquals("lockreference1", result);
+ }
+
+ @Test
+ public void testCreateLockReference() throws MusicLockingException {
+ String result = null;
+ Mockito.when(musicCore.createLockReference(Mockito.any(), Mockito.any())).thenReturn("lockreference2");
+ result = MusicCore.createLockReference("key3", "owner3");
+ assertEquals("lockreference2", result);
+ }
+
+ @Test
+ public void testCreateLockReferenceAtomic2() throws MusicLockingException {
+ String result = null;
+ Mockito.when(musicCore.createLockReferenceAtomic(Mockito.any(), Mockito.any())).thenReturn("lockreference3");
+ result = MusicCore.createLockReferenceAtomic("key4", LockType.READ);
+ assertEquals("lockreference3", result);
+ }
+
+ @Test
+ public void testCreateLockReference2() throws MusicLockingException {
+ String result = null;
+ Mockito.when(musicCore.createLockReference(Mockito.any(), Mockito.any(), Mockito.any()))
+ .thenReturn("lockreference4");
+ result = MusicCore.createLockReference("key4", LockType.READ, "owner4");
+ assertEquals("lockreference4", result);
+ }
+
+ @Test
+ public void testCreateTable() throws MusicServiceException {
+ ResultType resultType = Mockito.mock(ResultType.class);
+ ResultType result = null;
+ Mockito.when(musicCore.createTable(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
+ .thenReturn(resultType);
+ result = MusicCore.createTable("keyspace1", "table1", new PreparedQueryObject(), "consistency");
+ assertEquals(resultType, result);
+ }
+
+ @Test
+ public void testQuorumGet() {
+ ResultSet rs = Mockito.mock(ResultSet.class);
+ Mockito.when(musicCore.quorumGet(Mockito.any())).thenReturn(rs);
+ assertEquals(rs, MusicCore.quorumGet(new PreparedQueryObject()));
+ }
+
+ @Test
+ public void testWhoseTurnIsIt() {
+ Mockito.when(musicCore.whoseTurnIsIt(Mockito.any())).thenReturn("turn");
+ assertEquals("turn", MusicCore.whoseTurnIsIt("key5"));
+ }
+
+ @Test
+ public void testGetCurrentLockHolders() {
+ List<String> result = Mockito.mock(List.class);
+ Mockito.when(musicCore.getCurrentLockHolders(Mockito.any())).thenReturn(result);
+ assertEquals(result, MusicCore.getCurrentLockHolders("key6"));
+ }
+
+ @Test
+ public void testPromoteLock() throws MusicLockingException {
+ ReturnType returnType = Mockito.mock(ReturnType.class);
+ ReturnType result = null;
+ Mockito.when(musicCore.promoteLock(Mockito.any())).thenReturn(returnType);
+ result = MusicCore.promoteLock("lockid2");
+ assertEquals(returnType, result);
+ }
+
+ @Test
+ public void testEventualPut() {
+ ReturnType returnType = Mockito.mock(ReturnType.class);
+ Mockito.when(musicCore.eventualPut(Mockito.any())).thenReturn(returnType);
+ assertEquals(returnType, MusicCore.eventualPut(new PreparedQueryObject()));
+ }
+
+ @Test
+ public void testEventualPut_nb() {
+ ReturnType returnType = Mockito.mock(ReturnType.class);
+ Mockito.when(musicCore.eventualPut_nb(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
+ .thenReturn(returnType);
+ assertEquals(returnType,
+ MusicCore.eventualPut_nb(new PreparedQueryObject(), "keyspace2", "table2", "primarykey1"));
+ }
+
+ @Test
+ public void testCriticalPut() {
+ ReturnType returnType = Mockito.mock(ReturnType.class);
+ Mockito.when(musicCore.criticalPut(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(),
+ Mockito.any())).thenReturn(returnType);
+ assertEquals(returnType, MusicCore.criticalPut("keyspace3", "table3", "primarykey2", new PreparedQueryObject(),
+ "lockreference2", new Condition(new HashMap(), new PreparedQueryObject())));
+ }
+
+ @Test
+ public void testNonKeyRelatedPut() throws MusicServiceException, MusicQueryException {
+ ResultType resultType = Mockito.mock(ResultType.class);
+ ResultType result = null;
+ Mockito.when(musicCore.nonKeyRelatedPut(Mockito.any(), Mockito.any())).thenReturn(resultType);
+ result = MusicCore.nonKeyRelatedPut(new PreparedQueryObject(), "consistency2");
+ assertEquals(resultType, result);
+ }
+
+ @Test
+ public void testGet() throws MusicServiceException {
+ ResultSet rs = Mockito.mock(ResultSet.class);
+ ResultSet result = null;
+ Mockito.when(musicCore.get(Mockito.any())).thenReturn(rs);
+ result = MusicCore.get(new PreparedQueryObject());
+ assertEquals(rs, result);
+ }
+
+ @Test
+ public void testCriticalGet() throws MusicServiceException {
+ ResultSet rs = Mockito.mock(ResultSet.class);
+ ResultSet result = null;
+ Mockito.when(musicCore.criticalGet(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
+ .thenReturn(rs);
+ result = MusicCore.criticalGet("keyspace4", "table4", "primarykey3", new PreparedQueryObject(),
+ "lockreference3");
+ assertEquals(rs, result);
+ }
+
+ @Test
+ public void testAtomicPut() throws MusicLockingException, MusicQueryException, MusicServiceException {
+ ReturnType returnType = Mockito.mock(ReturnType.class);
+ ReturnType result = null;
+ Mockito.when(musicCore.atomicPut(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
+ .thenReturn(returnType);
+ result = MusicCore.atomicPut("keyspace5", "table5", "primarykey4", new PreparedQueryObject(),
+ new Condition(new HashMap(), new PreparedQueryObject()));
+ assertEquals(returnType, result);
+ }
+
+ @Test
+ public void testAtomicGet() throws MusicServiceException, MusicLockingException, MusicQueryException {
+ ResultSet rs = Mockito.mock(ResultSet.class);
+ ResultSet result = null;
+ Mockito.when(musicCore.atomicGet(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(rs);
+ result = MusicCore.atomicGet("keyspace5", "table5", "primarykey4", new PreparedQueryObject());
+ assertEquals(rs, result);
+ }
+
+ @Test
+ public void testGetLockQueue() throws MusicServiceException, MusicQueryException, MusicLockingException {
+ List<String> result = Mockito.mock(List.class);
+ List<String> rst = null;
+ Mockito.when(musicCore.getLockQueue(Mockito.any())).thenReturn(result);
+ rst = MusicCore.getLockQueue("key5");
+ assertEquals(result, rst);
+ }
+
+ @Test
+ public void testGetLockQueueSize() throws MusicServiceException, MusicQueryException, MusicLockingException {
+ long result = 0L;
+ Mockito.when(musicCore.getLockQueueSize(Mockito.any())).thenReturn(100L);
+ result = MusicCore.getLockQueueSize("key6");
+ assertEquals(100L, result);
+ }
+
+ @Test
+ public void testatomicPutWithDeleteLock() throws MusicLockingException {
+ ReturnType returnType = Mockito.mock(ReturnType.class);
+ ReturnType result = null;
+ Mockito.when(musicCore.atomicPutWithDeleteLock(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any(),
+ Mockito.any())).thenReturn(returnType);
+ result = MusicCore.atomicPutWithDeleteLock("keyspace5", "table5", "primarykey4", new PreparedQueryObject(),
+ new Condition(new HashMap(), new PreparedQueryObject()));
+ assertEquals(returnType, result);
+ }
+
+ @Test
+ public void testAtomicGetWithDeleteLock() throws MusicServiceException, MusicLockingException {
+ ResultSet rs = Mockito.mock(ResultSet.class);
+ ResultSet result = null;
+ Mockito.when(musicCore.atomicGetWithDeleteLock(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()))
+ .thenReturn(rs);
+ result = MusicCore.atomicGetWithDeleteLock("keyspace5", "table5", "primarykey4", new PreparedQueryObject());
+ assertEquals(rs, result);
+ }
+
+ @Test
+ public void testValidateLock() {
+ Map<String, Object> map = Mockito.mock(Map.class);
+ Mockito.when(musicCore.validateLock(Mockito.any())).thenReturn(map);
+ assertEquals(map, MusicCore.validateLock("lockname"));
+ }
+
+ @Test
+ public void testReleaseLock() throws MusicLockingException {
+ MusicLockState musicLockState = Mockito.mock(MusicLockState.class);
+ MusicLockState result = null;
+ Mockito.when(musicCore.releaseLock(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(musicLockState);
+ result = MusicCore.releaseLock("lockid", true);
+ assertEquals(musicLockState, result);
+ }
+
+ @Test
+ public void testReleaseAllLocksForOwner() throws MusicLockingException, MusicServiceException, MusicQueryException {
+ List<String> result = Mockito.mock(List.class);
+ List<String> rst = null;
+ Mockito.when(musicCore.releaseAllLocksForOwner(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(result);
+ rst = MusicCore.releaseAllLocksForOwner("owner2", "keyspace6", "table6");
+ assertEquals(result, rst);
+ }
+
+ @Test
+ public void testCreateKeyspace() throws MusicServiceException, MusicQueryException {
+ ResultType resultType = Mockito.mock(ResultType.class);
+ ResultType result = null;
+ Mockito.when(musicCore.createKeyspace(Mockito.any(), Mockito.any())).thenReturn(resultType);
+ result = MusicCore.createKeyspace(new JsonKeySpace(), "consistency3");
+ assertEquals(resultType, result);
+ }
+
+ @Test
+ public void testDropKeyspace() throws MusicServiceException, MusicQueryException {
+ ResultType resultType = Mockito.mock(ResultType.class);
+ ResultType result = null;
+ Mockito.when(musicCore.dropKeyspace(Mockito.any(), Mockito.any())).thenReturn(resultType);
+ result = MusicCore.dropKeyspace(new JsonKeySpace(), "consistency4");
+ assertEquals(resultType, result);
+ }
+
+ @Test
+ public void testCreateTable2() throws MusicServiceException, MusicQueryException {
+ ResultType resultType = Mockito.mock(ResultType.class);
+ ResultType result = null;
+ Mockito.when(musicCore.createTable(Mockito.any(), Mockito.any())).thenReturn(resultType);
+ result = MusicCore.createTable(new JsonTable(), "consistency5");
+ assertEquals(resultType, result);
+ }
+
+ @Test
+ public void testDropTable() throws MusicServiceException, MusicQueryException {
+ ResultType resultType = Mockito.mock(ResultType.class);
+ ResultType result = null;
+ Mockito.when(musicCore.dropTable(Mockito.any(), Mockito.any())).thenReturn(resultType);
+ result = MusicCore.dropTable(new JsonTable(), "consistency5");
+ assertEquals(resultType, result);
+ }
+
+ @Test
+ public void testCreateIndex() throws MusicServiceException, MusicQueryException {
+ ResultType resultType = Mockito.mock(ResultType.class);
+ ResultType result = null;
+ Mockito.when(musicCore.createIndex(Mockito.any(), Mockito.any())).thenReturn(resultType);
+ result = MusicCore.createIndex(new JsonIndex("indexName", "keyspace7", "table7", "field"), "consistency6");
+ assertEquals(resultType, result);
+ }
+
+ @Test
+ public void testSelect() throws MusicServiceException, MusicQueryException {
+ ResultSet rs = Mockito.mock(ResultSet.class);
+ ResultSet result = null;
+ Mockito.when(musicCore.select(Mockito.any(), Mockito.any())).thenReturn(rs);
+ MultivaluedMap<String, String> map = Mockito.mock(MultivaluedMap.class);
+ result = MusicCore.select(new JsonSelect(), map);
+ assertEquals(rs, result);
+ }
+
+ @Test
+ public void testSelectCritical() throws MusicLockingException, MusicQueryException, MusicServiceException {
+ ResultSet rs = Mockito.mock(ResultSet.class);
+ ResultSet result = null;
+ Mockito.when(musicCore.selectCritical(Mockito.any(), Mockito.any())).thenReturn(rs);
+ MultivaluedMap<String, String> map = Mockito.mock(MultivaluedMap.class);
+ result = MusicCore.selectCritical(new JsonInsert(), map);
+ assertEquals(rs, result);
+ }
+
+ @Test
+ public void testInsertIntoTable() throws MusicLockingException, MusicQueryException, MusicServiceException {
+ ReturnType returnType = Mockito.mock(ReturnType.class);
+ ReturnType result = null;
+ Mockito.when(musicCore.insertIntoTable(Mockito.any())).thenReturn(returnType);
+ result = MusicCore.insertIntoTable(new JsonInsert());
+ assertEquals(returnType, result);
+ }
+
+ @Test
+ public void testUpdateTable() throws MusicLockingException, MusicQueryException, MusicServiceException {
+ ReturnType returnType = Mockito.mock(ReturnType.class);
+ ReturnType result = null;
+ Mockito.when(musicCore.updateTable(Mockito.any(), Mockito.any())).thenReturn(returnType);
+ MultivaluedMap<String, String> map = Mockito.mock(MultivaluedMap.class);
+ result = MusicCore.updateTable(new JsonUpdate(), map);
+ assertEquals(returnType, result);
+ }
+
+ @Test
+ public void testDeleteFromTable() throws MusicLockingException, MusicQueryException, MusicServiceException {
+ ReturnType returnType = Mockito.mock(ReturnType.class);
+ ReturnType result = null;
+ MultivaluedMap<String, String> map = Mockito.mock(MultivaluedMap.class);
+ Mockito.when(musicCore.deleteFromTable(Mockito.any(), Mockito.any())).thenReturn(returnType);
+ result = MusicCore.deleteFromTable(new JsonDelete(), map);
+ assertEquals(returnType, result);
+ }
+}
diff --git a/music-core/src/test/java/org/onap/music/main/ResultTypeTest.java b/music-core/src/test/java/org/onap/music/main/ResultTypeTest.java
new file mode 100644
index 00000000..d6ccc1f1
--- /dev/null
+++ b/music-core/src/test/java/org/onap/music/main/ResultTypeTest.java
@@ -0,0 +1,42 @@
+/*
+ * ============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.main;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+public class ResultTypeTest {
+
+ @Test
+ public void testResultType() {
+ assertEquals("SUCCESS",ResultType.SUCCESS.name());
+ assertEquals("FAILURE",ResultType.FAILURE.name());
+ }
+
+ @Test
+ public void testGetResult() {
+ assertEquals("Success",ResultType.SUCCESS.getResult());
+ assertEquals("Failure",ResultType.FAILURE.getResult());
+ }
+
+}
diff --git a/music-core/src/test/java/org/onap/music/main/ReturnTypeTest.java b/music-core/src/test/java/org/onap/music/main/ReturnTypeTest.java
new file mode 100644
index 00000000..fbb5f84d
--- /dev/null
+++ b/music-core/src/test/java/org/onap/music/main/ReturnTypeTest.java
@@ -0,0 +1,82 @@
+/*
+ * ============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.main;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+
+import org.junit.Test;
+
+public class ReturnTypeTest {
+
+ @Test
+ public void testReturnType() {
+ ReturnType result = new ReturnType(ResultType.SUCCESS,"message");
+ assertEquals(result.getMessage(),"message");
+ assertEquals(result.getResult(),ResultType.SUCCESS);
+ }
+
+ @Test
+ public void testTimingInfo() {
+ ReturnType result = new ReturnType(ResultType.SUCCESS,"message");
+ result.setTimingInfo("123");
+ assertEquals(result.getTimingInfo(),"123");
+ }
+
+ @Test
+ public void testGetResult() {
+ ReturnType result = new ReturnType(ResultType.FAILURE,"message");
+ assertEquals(result.getResult(),ResultType.FAILURE);
+ }
+
+ @Test
+ public void testGetMessage() {
+ ReturnType result = new ReturnType(ResultType.SUCCESS,"message");
+ result.setMessage("NewMessage");
+ assertEquals(result.getMessage(),"NewMessage");
+ }
+
+ @Test
+ public void testToJson() {
+ ReturnType result = new ReturnType(ResultType.SUCCESS,"message");
+ String myJson = result.toJson();
+ assertTrue(myJson.contains("message"));
+ }
+
+ @Test
+ public void testToString() {
+ ReturnType result = new ReturnType(ResultType.SUCCESS,"message");
+ String test = result.toString();
+ assertTrue(test.contains("message"));
+ }
+
+ @Test
+ public void testToMap() {
+ ReturnType result = new ReturnType(ResultType.SUCCESS,"message");
+ Map<String, Object> myMap = result.toMap();
+ assertTrue(myMap.containsKey("message"));
+ }
+
+}