aboutsummaryrefslogtreecommitdiffstats
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/eelf/logging/format/AppMessagesTest.java65
-rw-r--r--src/test/java/org/onap/music/unittests/JsonResponseTest.java45
-rw-r--r--src/test/java/org/onap/music/unittests/jsonobjects/JsonNotificationTest.java116
-rw-r--r--src/test/java/org/onap/music/unittests/jsonobjects/JsonSelectTest.java18
-rw-r--r--src/test/java/org/onap/music/unittests/jsonobjects/MusicHealthCheckTest.java54
5 files changed, 296 insertions, 2 deletions
diff --git a/src/test/java/org/onap/music/eelf/logging/format/AppMessagesTest.java b/src/test/java/org/onap/music/eelf/logging/format/AppMessagesTest.java
new file mode 100644
index 00000000..cba9c7c2
--- /dev/null
+++ b/src/test/java/org/onap/music/eelf/logging/format/AppMessagesTest.java
@@ -0,0 +1,65 @@
+/*
+ * ============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.eelf.logging.format;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class AppMessagesTest {
+
+ private AppMessages messages;
+
+ @Before
+ public void setUp() {
+ messages= AppMessages.ALREADYEXIST;
+ }
+
+ @Test
+ public void testDetails()
+ {
+ messages.setDetails("details");
+ assertEquals("details", messages.getDetails());
+ }
+
+ @Test
+ public void testResolution()
+ {
+ messages.setResolution("Resolution");
+ assertEquals("Resolution", messages.getResolution());
+ }
+
+ @Test
+ public void testErrorCode()
+ {
+ messages.setErrorCode("ErrorCode");
+ assertEquals("ErrorCode", messages.getErrorCode());
+ }
+
+ @Test
+ public void testErrorDescription()
+ {
+ messages.setErrorDescription("ErrorDescription");
+ assertEquals("ErrorDescription", messages.getErrorDescription());
+ }
+}
diff --git a/src/test/java/org/onap/music/unittests/JsonResponseTest.java b/src/test/java/org/onap/music/unittests/JsonResponseTest.java
index 9da10638..781cdd7b 100644
--- a/src/test/java/org/onap/music/unittests/JsonResponseTest.java
+++ b/src/test/java/org/onap/music/unittests/JsonResponseTest.java
@@ -4,6 +4,8 @@
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
+ * Modifications Copyright (c) 2018-2019 IBM.
+ * ===================================================================
* 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
@@ -23,8 +25,11 @@
package org.onap.music.unittests;
import static org.junit.Assert.*;
+
+import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
+import org.onap.music.lockingservice.MusicLockState.LockStatus;
import org.onap.music.main.ResultType;
import org.onap.music.response.jsonobjects.JsonResponse;
@@ -80,4 +85,44 @@ public class JsonResponseTest {
assertEquals(ResultType.FAILURE, myMap.get("status"));
}
+ @Test
+ public void testMessage() {
+ result = new JsonResponse(ResultType.SUCCESS);
+ result.setMessage("message");
+ assertEquals("message", result.getMessage());
+
+ }
+
+ @Test
+ public void testDataResult() {
+ result = new JsonResponse(ResultType.SUCCESS);
+ Map<String, HashMap<String, Object>> dataResult= new HashMap<>();
+ result.setDataResult(dataResult);
+ assertEquals(dataResult, result.getDataResult());
+
+ }
+
+ @Test
+ public void testLock() {
+ result = new JsonResponse(ResultType.SUCCESS);
+ result.setLock("lock");
+ assertEquals("lock", result.getLock());
+
+ }
+
+ @Test
+ public void testLockStatus() {
+ result = new JsonResponse(ResultType.SUCCESS);
+ LockStatus status = LockStatus.LOCKED;
+ result.setLockStatus(status);
+ assertEquals(status, result.getLockStatus());
+
+ }
+
+ @Test
+ public void testToString() {
+ result = new JsonResponse(ResultType.SUCCESS);
+ assertTrue(result.toString() instanceof String);
+
+ }
}
diff --git a/src/test/java/org/onap/music/unittests/jsonobjects/JsonNotificationTest.java b/src/test/java/org/onap/music/unittests/jsonobjects/JsonNotificationTest.java
new file mode 100644
index 00000000..e5b13ca8
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/jsonobjects/JsonNotificationTest.java
@@ -0,0 +1,116 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2019 IBM.
+ * ===================================================================
+ * 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.assertEquals;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.music.datastore.jsonobjects.JsonNotification;
+
+public class JsonNotificationTest {
+
+ private JsonNotification jsonNotification;
+
+ @Before
+ public void setUp()
+ {
+ jsonNotification= new JsonNotification();
+ }
+
+ @Test
+ public void testGetSetNotify_field()
+ {
+ jsonNotification.setNotify_field("notify_field");
+ assertEquals("notify_field", jsonNotification.getNotify_field());
+ }
+
+ @Test
+ public void testGetSetEndpoint()
+ {
+ jsonNotification.setEndpoint("endpoint");
+ assertEquals("endpoint", jsonNotification.getEndpoint());
+ }
+
+ @Test
+ public void testGetSetUsername()
+ {
+ jsonNotification.setUsername("Username");
+ assertEquals("Username", jsonNotification.getUsername());
+ }
+
+ @Test
+ public void testGetSetPassword()
+ {
+ jsonNotification.setPassword("Password");
+ assertEquals("Password", jsonNotification.getPassword());
+ }
+
+ @Test
+ public void testGetSetResponse_body()
+ {
+ Map<String, String> ResponseBody= new HashMap<>();
+ jsonNotification.setResponse_body(ResponseBody);
+ assertEquals(ResponseBody, jsonNotification.getResponse_body());
+ }
+
+ @Test
+ public void testGetSetNotify_change()
+ {
+ jsonNotification.setNotify_change("Notify_change");
+ assertEquals("Notify_change", jsonNotification.getNotify_change());
+ }
+
+ @Test
+ public void testGetSetNotify_insert()
+ {
+ jsonNotification.setNotify_insert("Notify_insert");
+ assertEquals("Notify_insert", jsonNotification.getNotify_insert());
+ }
+
+ @Test
+ public void testGetSetNotify_delete()
+ {
+ jsonNotification.setNotify_delete("Notify_delete");
+ assertEquals("Notify_delete", jsonNotification.getNotify_delete());
+ }
+
+ @Test
+ public void testGetSetOperation_type()
+ {
+ jsonNotification.setOperation_type("Operation_type");
+ assertEquals("Operation_type", jsonNotification.getOperation_type());
+ }
+
+ @Test
+ public void testGetSetTriggerName()
+ {
+ jsonNotification.setTriggerName("TriggerName");
+ assertEquals("TriggerName", jsonNotification.getTriggerName());
+ }
+
+
+}
diff --git a/src/test/java/org/onap/music/unittests/jsonobjects/JsonSelectTest.java b/src/test/java/org/onap/music/unittests/jsonobjects/JsonSelectTest.java
index 0243232f..f776e546 100644
--- a/src/test/java/org/onap/music/unittests/jsonobjects/JsonSelectTest.java
+++ b/src/test/java/org/onap/music/unittests/jsonobjects/JsonSelectTest.java
@@ -4,6 +4,8 @@
* ===================================================================
* Copyright (c) 2017 AT&T Intellectual Property
* ===================================================================
+ * Modifications Copyright (c) 2018-2019 IBM
+ * ===================================================================
* 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
@@ -21,9 +23,12 @@
*/
package org.onap.music.unittests.jsonobjects;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+
import org.junit.Test;
import org.onap.music.datastore.jsonobjects.JsonSelect;
@@ -35,7 +40,16 @@ public class JsonSelectTest {
Map<String, String> mapSs = new HashMap<>();
mapSs.put("k1", "one");
js.setConsistencyInfo(mapSs);
- assertEquals("one",js.getConsistencyInfo().get("k1"));
+ assertEquals("one", js.getConsistencyInfo().get("k1"));
+ }
+
+ @Test
+ public void testSerialize() throws IOException {
+ JsonSelect js = new JsonSelect();
+ Map<String, String> mapSs = new HashMap<>();
+ mapSs.put("Key", "Value");
+ js.setConsistencyInfo(mapSs);
+ js.serialize();
}
}
diff --git a/src/test/java/org/onap/music/unittests/jsonobjects/MusicHealthCheckTest.java b/src/test/java/org/onap/music/unittests/jsonobjects/MusicHealthCheckTest.java
new file mode 100644
index 00000000..f48ecd40
--- /dev/null
+++ b/src/test/java/org/onap/music/unittests/jsonobjects/MusicHealthCheckTest.java
@@ -0,0 +1,54 @@
+/*
+ * ============LICENSE_START==========================================
+ * org.onap.music
+ * ===================================================================
+ * Copyright (c) 2019 IBM.
+ * ===================================================================
+ * 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.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.music.eelf.healthcheck.MusicHealthCheck;
+
+public class MusicHealthCheckTest {
+
+ private MusicHealthCheck musicHealthCheck;
+
+ @Before
+ public void setUp()
+ {
+ musicHealthCheck= new MusicHealthCheck();
+ }
+
+ @Test
+ public void testCassandraHost()
+ {
+ musicHealthCheck.setCassandrHost("9042");
+ assertEquals("9042", musicHealthCheck.getCassandrHost());
+ }
+
+ @Test
+ public void testZookeeperHost()
+ {
+ musicHealthCheck.setZookeeperHost("ZookeeperHost");
+ assertEquals("ZookeeperHost", musicHealthCheck.getZookeeperHost());
+ }
+}