summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/music/conf
diff options
context:
space:
mode:
authorsa282w <sa282w@att.com>2018-06-15 12:45:37 -0400
committersa282w <sa282w@att.com>2018-06-21 10:59:42 -0400
commita68c7de8ca9d38fbdf0801252a4185c8fd94cea6 (patch)
treee44fd8286a51a684c6bfd6540c0c380014c2bc03 /ecomp-portal-BE-common/src/test/java/org/onap/portalapp/music/conf
parent4072269d9f6b452aaff41fc02b09bfca40356dd5 (diff)
Music health check apis
Issue-ID: PORTAL-291, PORTAL-307 Included the music changes, other changes from 2.3 branch to be included in master, added JUnits to the new classes and updated the document with the API version changes. Change-Id: I7b4c54be49317264afbdcb8d8ae3f20395bf0e1f Signed-off-by: sa282w <sa282w@att.com>
Diffstat (limited to 'ecomp-portal-BE-common/src/test/java/org/onap/portalapp/music/conf')
-rw-r--r--ecomp-portal-BE-common/src/test/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandlerTest.java103
1 files changed, 103 insertions, 0 deletions
diff --git a/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandlerTest.java b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandlerTest.java
new file mode 100644
index 00000000..3b622f2e
--- /dev/null
+++ b/ecomp-portal-BE-common/src/test/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandlerTest.java
@@ -0,0 +1,103 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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.portalapp.music.conf;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.onap.music.datastore.PreparedQueryObject;
+import org.onap.music.main.MusicCore;
+import org.onap.portalapp.music.service.MusicService;
+import org.onap.portalapp.music.util.MusicUtil;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.springframework.session.Session;
+
+import com.datastax.driver.core.ResultSet;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({MusicUtil.class, MusicCore.class})
+public class MusicSessionRepositoryHandlerTest {
+
+ @Mock
+ private MusicService musicService;
+
+ @Mock
+ ResultSet resultSet;
+
+ @Before
+ public void setUp() {
+ PowerMockito.mockStatic(MusicUtil.class);
+ PowerMockito.mockStatic(MusicCore.class);
+ Mockito.when(MusicUtil.isCached()).thenReturn(true);
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @InjectMocks
+ MusicSessionRepositoryHandler musicSessionRepositoryHandler = new MusicSessionRepositoryHandler();
+
+ MusicSession ms = new MusicSession();
+
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getTest() throws Exception {
+ Mockito.when(MusicCore.get(Matchers.any(PreparedQueryObject.class))).thenReturn(resultSet);
+ Mockito.when(musicService.getMetaAttribute("test_id")).thenReturn(ms);
+ Session session = musicSessionRepositoryHandler.get("test_id");
+ assertNotNull(session);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getFailWithIdTest() throws Exception {
+ Mockito.when(MusicCore.get(Matchers.any(PreparedQueryObject.class))).thenReturn(resultSet);
+ Mockito.when((musicService).getMetaAttribute("test_id")).thenThrow(new NullPointerException());
+ Session session = musicSessionRepositoryHandler.get("test_id");
+ assertNull(session);
+ }
+}