Add unit tests to increase sonar coverage
[aai/esr-server.git] / esr-mgr / src / test / java / org / onap / aai / esr / externalservice / msb / MsbHelperTest.java
diff --git a/esr-mgr/src/test/java/org/onap/aai/esr/externalservice/msb/MsbHelperTest.java b/esr-mgr/src/test/java/org/onap/aai/esr/externalservice/msb/MsbHelperTest.java
new file mode 100644 (file)
index 0000000..28a22c5
--- /dev/null
@@ -0,0 +1,51 @@
+/**\r
+ * Copyright 2016-2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+package org.onap.aai.esr.externalservice.msb;\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+import org.mockito.Mockito;\r
+import org.mockito.MockitoAnnotations;\r
+import org.onap.msb.sdk.discovery.entity.MicroServiceFullInfo;\r
+import org.onap.msb.sdk.discovery.entity.MicroServiceInfo;\r
+import org.onap.msb.sdk.httpclient.msb.MSBServiceClient;\r
+\r
+public class MsbHelperTest {\r
+\r
+    MsbHelper helper;\r
+\r
+    @Mock\r
+    MSBServiceClient client;\r
+\r
+    @Mock\r
+    MicroServiceFullInfo serviceInfo;\r
+\r
+    @Before\r
+    public void init(){\r
+        MockitoAnnotations.initMocks(this);\r
+        helper = new MsbHelper(client);\r
+    }\r
+\r
+    @Test\r
+    public void testRegisterMsb() throws Exception {\r
+        Mockito.when(client.registerMicroServiceInfo(Mockito.any(MicroServiceInfo.class),\r
+                Mockito.anyBoolean())).thenReturn(serviceInfo);\r
+        helper.registerMsb();\r
+        Mockito.verify(client, Mockito.times(1)).\r
+                registerMicroServiceInfo(Mockito.any(MicroServiceInfo.class), Mockito.anyBoolean());\r
+    }\r
+}\r