Initial source code
[oam/tr069-adapter.git] / acs / application-booter / src / test / java / org / commscope / tr069adapter / acs / cpe / test / acsnbi / InvokeRPCTest.java
diff --git a/acs/application-booter/src/test/java/org/commscope/tr069adapter/acs/cpe/test/acsnbi/InvokeRPCTest.java b/acs/application-booter/src/test/java/org/commscope/tr069adapter/acs/cpe/test/acsnbi/InvokeRPCTest.java
new file mode 100644 (file)
index 0000000..2ea1800
--- /dev/null
@@ -0,0 +1,92 @@
+/*\r
+ * ============LICENSE_START========================================================================\r
+ * ONAP : tr-069-adapter\r
+ * =================================================================================================\r
+ * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
+ * =================================================================================================\r
+ * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
+ * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
+ * may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
+ * either express or implied. See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ===============LICENSE_END=======================================================================\r
+ */\r
+\r
+package org.commscope.tr069adapter.acs.cpe.test.acsnbi;\r
+\r
+import static org.junit.Assert.assertNotNull;\r
+import static org.junit.Assert.fail;\r
+\r
+import org.apache.activemq.broker.BrokerService;\r
+import org.commscope.tr069adapter.acs.booter.ACSServiceBooter;\r
+import org.commscope.tr069adapter.acs.common.DeviceRPCRequest;\r
+import org.commscope.tr069adapter.acs.common.dto.TR069OperationCode;\r
+import org.commscope.tr069adapter.acs.cpe.test.RequestProcessorTestsUtils;\r
+import org.commscope.tr069adapter.acs.nbi.mapper.service.MapperRequestRESTService;\r
+import org.junit.After;\r
+import org.junit.Test;\r
+import org.junit.runner.RunWith;\r
+import org.mockito.Mockito;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;\r
+import org.springframework.boot.test.context.SpringBootTest;\r
+import org.springframework.boot.test.mock.mockito.MockBean;\r
+import org.springframework.jms.core.JmsTemplate;\r
+import org.springframework.test.context.ContextConfiguration;\r
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;\r
+\r
+@SpringBootTest(classes = {ACSServiceBooter.class})\r
+@RunWith(SpringJUnit4ClassRunner.class)\r
+@AutoConfigureMockMvc\r
+@ContextConfiguration\r
+public class InvokeRPCTest {\r
+\r
+\r
+  @MockBean\r
+  private JmsTemplate jmsTemplate;\r
+\r
+  @Autowired\r
+  private MapperRequestRESTService mapperRequestRestService;\r
+\r
+  @Autowired\r
+  BrokerService broker;\r
+\r
+  @Test\r
+  public void processInformPnPTest() throws Exception {\r
+\r
+\r
+    try {\r
+      Mockito.doNothing().when(jmsTemplate).convertAndSend(Mockito.anyString(),\r
+          Mockito.any(Object.class));\r
+\r
+      DeviceRPCRequest deviceRPCRequest = new DeviceRPCRequest();\r
+      deviceRPCRequest.setOperationId(10L);\r
+      deviceRPCRequest.setDeviceDetails(RequestProcessorTestsUtils.getDeviceDetails());\r
+      deviceRPCRequest.setOpDetails(\r
+          RequestProcessorTestsUtils.getOperationDetails(TR069OperationCode.SET_PARAMETER_VALUES));\r
+      deviceRPCRequest.setOptions(RequestProcessorTestsUtils.getOperationOptions(60000L));\r
+      Long operationId = mapperRequestRestService.initiateDeviceOperation(deviceRPCRequest);\r
+\r
+      assertNotNull(operationId);\r
+    } catch (Exception e) {\r
+      fail(e.getMessage());\r
+    }\r
+  }\r
+\r
+  @After\r
+  public void stopBroker() throws Exception {\r
+    try {\r
+      System.out.println("Tearing down the broker");\r
+      broker.stop();\r
+      broker.waitUntilStopped();\r
+      broker = null;\r
+    } catch (Exception e) {\r
+      e.printStackTrace();\r
+    }\r
+  }\r
+\r
+}\r