Device Software version management
[oam/tr069-adapter.git] / config-data / src / test / java / org / commscope / tr069adapter / config / ConfugurationDataControllerTests.java
index 58bfea8..38634d0 100644 (file)
@@ -21,9 +21,6 @@ package org.commscope.tr069adapter.config;
 import static org.junit.Assert.assertEquals;\r
 import static org.junit.Assert.assertThat;\r
 import static org.junit.jupiter.api.Assertions.fail;\r
-\r
-import java.util.Optional;\r
-\r
 import org.commscope.tr069adapter.config.repository.ConfigurationDataRepository;\r
 import org.hamcrest.CoreMatchers;\r
 import org.junit.Test;\r
@@ -33,6 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 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.http.HttpStatus;\r
 import org.springframework.http.MediaType;\r
 import org.springframework.mock.web.MockHttpServletResponse;\r
 import org.springframework.mock.web.MockMultipartFile;\r
@@ -96,49 +94,22 @@ public class ConfugurationDataControllerTests {
     assertEquals(expectedResult, resultString);\r
   }\r
 \r
-  @Test\r
-  public void viewFileContentTest() {\r
-    Mockito.when(configDataRepository.findById(ConfigDataTestsUtils.macId))\r
-        .thenReturn(Optional.of(ConfigDataTestsUtils.getConfigFileContent()));\r
-\r
-    MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders\r
-        .get("/getFileContent/" + ConfigDataTestsUtils.macId).accept(MediaType.APPLICATION_JSON);\r
-\r
-    MvcResult result = null;\r
-    String resultString = null;\r
-    try {\r
-      result = mockMvc.perform(requestBuilder).andReturn();\r
-      MockHttpServletResponse response = result.getResponse();\r
-      resultString = response.getContentAsString();\r
-    } catch (Exception e) {\r
-      fail(e.getMessage());\r
-    }\r
-\r
-    String expectedResult =\r
-        "{\"macId\":\"testMacId\",\"fileContent\":\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\r\\n<configDataFile>\\r\\n  <fileHeader fileFormatVersion=\\\"32.594 V14.0.0\\\" vendorName=\\\"Commscope\\\"/>\\r\\n  <configData>\\r\\n    <managedElement swVersion=\\\"4.3.00.038\\\" localDn=\\\"0005B95196D0\\\" hwVersion=\\\"750742.00.04\\\" ProductClass=\\\"LTE_Enterprise_C-RANSC_Cntrl\\\" OUI=\\\"0005B9\\\"/>\\r\\n    <Device>\\r\\n      <FAP>\\r\\n        <GPS>\\r\\n          <AGPSServerConfig>\\r\\n            <Enable>1</Enable>\\r\\n            <Password>dmsuser</Password>\\r\\n            <ServerPort>7001</ServerPort>\\r\\n            <ServerURL>NONE</ServerURL>\\r\\n            <Username>dmsuser</Username>\\r\\n          </AGPSServerConfig>\\r\\n          <GPSReset>0</GPSReset>\\r\\n        </GPS>\\r\\n\\t\\t</FAP>\\r\\n    </Device>\\r\\n  </configData>\\r\\n  <fileFooter dateTime=\\\"2019-07-16T17:32:35+05:30\\\"/>\\r\\n</configDataFile>\"}";\r
-    assertEquals(expectedResult, resultString);\r
-  }\r
-\r
-\r
   @Test\r
   public void viewConfigurationDataTest() {\r
-    Mockito.when(configDataRepository.findById(ConfigDataTestsUtils.macId))\r
-        .thenReturn(Optional.of(ConfigDataTestsUtils.getConfigFileContent()));\r
+    Mockito.when(configDataRepository.findByMacId(ConfigDataTestsUtils.macId))\r
+        .thenReturn(ConfigDataTestsUtils.getConfigFileContent());\r
 \r
-    MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders\r
-        .get("/getConfig/" + ConfigDataTestsUtils.macId).accept(MediaType.APPLICATION_JSON);\r
+    MockHttpServletRequestBuilder requestBuilder =\r
+        MockMvcRequestBuilders.post("/getConfig").param("macId", "0005B95196D0")\r
+            .param("swVersion", "4.5").param("hwVersion", "1.1").accept(MediaType.APPLICATION_JSON);\r
 \r
     MvcResult result = null;\r
-    String resultString = null;\r
     try {\r
       result = mockMvc.perform(requestBuilder).andReturn();\r
       MockHttpServletResponse response = result.getResponse();\r
-      resultString = response.getContentAsString();\r
+      assertEquals(200, response.getStatus());\r
     } catch (Exception e) {\r
       fail(e.getMessage());\r
     }\r
-\r
-    String expectedSubString = "\"localDn\":\"0005B95196D0\"";\r
-    assertThat(resultString, CoreMatchers.containsString(expectedSubString));\r
   }\r
 }\r