diff options
author | Lasse Kaihlavirta <l.kaihlavirt@partner.samsung.com> | 2021-03-24 08:56:10 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2021-03-24 08:56:10 +0000 |
commit | 29e0ba3179409458b96089dd37452d4a11cc32d3 (patch) | |
tree | 615dfa2bb37b0cc6a1c5605b15b5253a2404d224 /src/test | |
parent | 14433f2704a39d737e79543fe66db53d6d288697 (diff) | |
parent | 5ea372baed3b743dbf3ddeffb8fe1a0acdf376d6 (diff) |
Merge changes Idbdec7b3,I643dadac,I2f54e1d5,I2ead5203
* changes:
Provide initial a1-pe-sim docs
Initial code check-in for A1 Policy Enforcement Simulator
Add basic .gitignore
Add linters setup
Diffstat (limited to 'src/test')
18 files changed, 1322 insertions, 0 deletions
diff --git a/src/test/java/org/onap/a1pesimulator/TestHelpers.java b/src/test/java/org/onap/a1pesimulator/TestHelpers.java new file mode 100644 index 0000000..449318d --- /dev/null +++ b/src/test/java/org/onap/a1pesimulator/TestHelpers.java @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2021 Samsung Electronics + * 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 + */ + +package org.onap.a1pesimulator; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import org.onap.a1pesimulator.data.cell.CellDetails; +import org.onap.a1pesimulator.data.cell.CellWithStatus; +import org.onap.a1pesimulator.data.ue.UserEquipment; + +public class TestHelpers { + + public static final int CELL_ARRAY_SIZE = 5; + public static final int UE_ARRAY_SIZE = 3; + + public static final String CELL_PREFIX = "Chn00"; + + public static final String FIRST_CELL_ID = "Chn0000"; + public static final double FIRST_CELL_LATITUDE = 50.11; + public static final double FIRST_CELL_LONGITUDE = 19.98; + public static final int FIRST_CELL_CONNECTED_UE_SIZE = 1; + public static final String FIRST_CELL_CONNECTED_UE_ID = "mobile_samsung_s10"; + + public static final String FIRST_UE_ID = "emergency_police_111"; + public static final double FIRST_UE_LATITUDE = 50.035; + public static final double FIRST_UE_LONGITUDE = 19.97; + public static final String FIRST_UE_CELL_ID = "Chn0002"; + + public static final String FIRST_UE_HANDOVER_CELL = "Chn0004"; + + public static void checkFirstCell(CellDetails cellDetails) { + assertNotNull(cellDetails); + + assertEquals(FIRST_CELL_ID, cellDetails.getId()); + assertEquals(FIRST_CELL_LATITUDE, cellDetails.getLatitude()); + assertEquals(FIRST_CELL_LONGITUDE, cellDetails.getLongitude()); + assertEquals(FIRST_CELL_CONNECTED_UE_SIZE, cellDetails.getConnectedUserEquipments().size()); + assertEquals(FIRST_CELL_CONNECTED_UE_ID, cellDetails.getConnectedUserEquipments().iterator().next()); + } + + public static void checkFirstUserEquipment(UserEquipment userEquipment) { + assertNotNull(userEquipment); + + assertEquals(FIRST_UE_ID, userEquipment.getId()); + assertEquals(FIRST_UE_LATITUDE, userEquipment.getLatitude()); + assertEquals(FIRST_UE_LONGITUDE, userEquipment.getLongitude()); + assertEquals(FIRST_UE_CELL_ID, userEquipment.getCellId()); + } + + public static void checkFirstCellWithStatus(CellWithStatus cellWithStatus) { + assertNotNull(cellWithStatus); + + assertEquals(FIRST_CELL_ID, cellWithStatus.getCell().getIdentifier()); + assertFalse(cellWithStatus.isFailureMode()); + assertFalse(cellWithStatus.isVesEnabled()); + } + + private TestHelpers() { + } +} diff --git a/src/test/java/org/onap/a1pesimulator/controller/RanA1ControllerTest.java b/src/test/java/org/onap/a1pesimulator/controller/RanA1ControllerTest.java new file mode 100644 index 0000000..5b846c4 --- /dev/null +++ b/src/test/java/org/onap/a1pesimulator/controller/RanA1ControllerTest.java @@ -0,0 +1,209 @@ +/* + * Copyright (C) 2021 Samsung Electronics + * 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 + */ + +package org.onap.a1pesimulator.controller; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.onap.a1pesimulator.TestHelpers.FIRST_UE_CELL_ID; +import static org.onap.a1pesimulator.TestHelpers.FIRST_UE_HANDOVER_CELL; +import static org.onap.a1pesimulator.TestHelpers.FIRST_UE_ID; +import static org.onap.a1pesimulator.controller.URLHelper.getHealthCheckEndpoint; +import static org.onap.a1pesimulator.controller.URLHelper.getPolicyPath; +import static org.onap.a1pesimulator.controller.URLHelper.getPolicyTypePath; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.google.common.collect.Lists; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.a1pesimulator.data.ue.UserEquipment; +import org.onap.a1pesimulator.service.ue.RanUeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; + +@SpringBootTest +@AutoConfigureMockMvc +@RunWith(SpringRunner.class) +public class RanA1ControllerTest { + + private static final String FIRST_POLICY_TYPE_ID = "1000"; + private static final Policy.Preference FIRST_POLICY_PREFERENCE = Policy.Preference.AVOID; + private static final String FIRST_POLICY_ORIGINAL_ID = "ue1"; + private static final String TEST_POLICY_SCHEMA = + "{\n" + " \"name\": \"samsung_policy_type\",\n" + " \"description\": \"samsung policy type;\",\n" + + " \"policy_type_id\": 1000,\n" + " \"create_schema\": {\n" + + " \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n" + + " \"title\": \"Samsung_demo\",\n" + " \"description\": \"Samsung demo policy type\",\n" + + " \"type\": \"object\",\n" + " \"additionalProperties\": false,\n" + " \"required\": [\n" + + " \"scope\",\n" + " \"resources\"\n" + " ]\n" + " }\n" + "}"; + + @Autowired + private MockMvc mvc; + + @Autowired + private ObjectMapper mapper; + + @Autowired + RanUeService ranUeService; + + @Test + public void testHealthcheck() throws Exception { + this.mvc.perform(get(getHealthCheckEndpoint())); + } + + @Test + public void testGetPolicyTypes() throws Exception { + String firstPolicyURL = URLHelper.getPolicyTypePath("1000"); + mvc.perform(put(firstPolicyURL).content(TEST_POLICY_SCHEMA)).andExpect(status().isCreated()); + + String[] policyTypes = mapper.readValue(getFromController(getPolicyTypePath()), String[].class); + + assertEquals(FIRST_POLICY_TYPE_ID, policyTypes[0]); + } + + @Test + public void testGetPolicy() throws Exception { + // Remove escaping + Policy policy = mapper.readValue(getFromController(getPolicyPath("3", "1")), Policy.class); + + assertEquals(FIRST_POLICY_ORIGINAL_ID, policy.getScope().getUeId()); + assertEquals(FIRST_POLICY_PREFERENCE, policy.getResources().get(0).getPreference()); + } + + @Test + public void testPutPolicyAndTriggerHandover() throws Exception { + String policyURL = getPolicyPath("3", "1"); + + mvc.perform(put(policyURL).content(getHandoverPolicy())).andExpect(status().isAccepted()); + + // Remove escaping + Policy policy = mapper.readValue(getFromController(policyURL), Policy.class); + + assertEquals(FIRST_UE_ID, policy.getScope().getUeId()); + + assertEquals(FIRST_POLICY_PREFERENCE, policy.getResources().get(0).getPreference()); + assertEquals(FIRST_UE_CELL_ID, policy.getResources().get(0).getCellIdList().get(0)); + + UserEquipment userEquipment = ranUeService.getUserEquipment(FIRST_UE_ID).orElse(null); + + assertNotNull(userEquipment); + assertEquals(FIRST_UE_HANDOVER_CELL, userEquipment.getCellId()); + + mvc.perform(put(policyURL).content(getOriginalPolicy())).andExpect(status().isAccepted()); + } + + @Test + public void testPutPolicyAndCantHandover() throws Exception { + String policyURL = getPolicyPath("3", "1"); + + // trigger cellId==null in the onPolicy + mvc.perform(put(policyURL).content(getHandoverPolicyWithoutCellId())).andExpect(status().isAccepted()); + + // trigger canHandover==false in the onPolicy + mvc.perform(put(policyURL).content(getOriginalPolicy())).andExpect(status().isAccepted()); + } + + @Test + public void shouldDeletePolicyInstanceAndReturn200() throws Exception { + String url = getPolicyPath("3", "1"); + mvc.perform(delete(url)).andExpect(status().isAccepted()); + } + + @Test + public void shouldReturn404WhenPolicyInstanceNotExists() throws Exception { + String url = getPolicyPath("10", "321123"); + mvc.perform(delete(url)).andExpect(status().isNotFound()); + } + + private String getFromController(String url) throws Exception { + return this.mvc.perform(get(url)).andExpect(status().isOk()).andReturn().getResponse().getContentAsString(); + } + + private String getOriginalPolicy() throws JsonProcessingException { + return mapper.writeValueAsString( + Policy.builder().scope(Policy.Scope.builder().ueId(FIRST_POLICY_ORIGINAL_ID).build()).resources( + Lists.newArrayList(Policy.Resources.builder().cellIdList(Lists.newArrayList(FIRST_UE_CELL_ID)) + .preference(Policy.Preference.AVOID).build())).build()); + } + + private String getHandoverPolicy() throws JsonProcessingException { + return mapper.writeValueAsString(Policy.builder().scope(Policy.Scope.builder().ueId(FIRST_UE_ID).build()) + .resources(Lists.newArrayList(Policy.Resources.builder().cellIdList( + Lists.newArrayList(FIRST_UE_CELL_ID)).preference( + Policy.Preference.AVOID).build())).build()); + } + + private String getHandoverPolicyWithoutCellId() throws JsonProcessingException { + return mapper.writeValueAsString(Policy.builder().scope(Policy.Scope.builder().ueId(FIRST_UE_ID).build()) + .resources(Lists.newArrayList( + Policy.Resources.builder().cellIdList(Lists.newArrayList()) + .preference(Policy.Preference.AVOID).build())) + .build()); + } + + @Data + @Builder + @JsonSerialize + @NoArgsConstructor + @AllArgsConstructor + private static class Policy { + + private Scope scope; + private List<Resources> resources; + + @Data + @Builder + @JsonSerialize + @NoArgsConstructor + @AllArgsConstructor + private static class Scope { + + private String ueId; + } + + @Data + @Builder + @JsonSerialize + @NoArgsConstructor + @AllArgsConstructor + private static class Resources { + + private List<String> cellIdList; + private Preference preference; + } + + public enum Preference { + SHALL("SHALL"), PREFER("PREFER"), AVOID("AVOID"), FORBID("FORBID"); + public final String value; + + Preference(String stateName) { + this.value = stateName; + } + } + + } +} diff --git a/src/test/java/org/onap/a1pesimulator/controller/RanCellControllerTest.java b/src/test/java/org/onap/a1pesimulator/controller/RanCellControllerTest.java new file mode 100644 index 0000000..ebc93fb --- /dev/null +++ b/src/test/java/org/onap/a1pesimulator/controller/RanCellControllerTest.java @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2021 Samsung Electronics + * 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 + */ + +package org.onap.a1pesimulator.controller; + +import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.onap.a1pesimulator.controller.URLHelper.getRanCellControllerEndpoint; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.a1pesimulator.data.cell.CellDetails; +import org.onap.a1pesimulator.data.cell.RanCell; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultHandlers; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +@SpringBootTest +@AutoConfigureMockMvc +@RunWith(SpringRunner.class) +@ActiveProfiles(value = {"localStore"}) +public class RanCellControllerTest { + + @Autowired + private MockMvc mvc; + + @Autowired + private ObjectMapper mapper; + + protected String mapToJson(Object obj) throws JsonProcessingException { + mapper = new ObjectMapper(); + return mapper.writeValueAsString(obj); + } + + protected <T> T mapFromJson(String json, Class<T> clazz) + throws JsonParseException, JsonMappingException, IOException { + mapper = new ObjectMapper(); + return mapper.readValue(json, clazz); + } + + @Test(expected = IllegalArgumentException.class) + public void testGetCells() throws Exception { + MvcResult mvcResult = this.mvc.perform( + MockMvcRequestBuilders.get(getRanCellControllerEndpoint()).accept(MediaType.APPLICATION_JSON_VALUE)) + .andDo(MockMvcResultHandlers.print()).andReturn(); + + int status = mvcResult.getResponse().getStatus(); + assertEquals(200, status); + String content = mvcResult.getResponse().getContentAsString(); + + RanCell[] ranCell = this.mapFromJson(content, RanCell[].class); + + assertTrue(ranCell.length > 0); + } + + @Test(expected = IllegalArgumentException.class) + public void testGetCellById() throws Exception { + MvcResult mvcResult = this.mvc.perform( + MockMvcRequestBuilders.get(getRanCellControllerEndpoint() + "/{identifier}", 1) + .accept(MediaType.APPLICATION_JSON_VALUE)).andReturn(); + + int status = mvcResult.getResponse().getStatus(); + assertEquals(200, status); + String content = mvcResult.getResponse().getContentAsString(); + + CellDetails cell = this.mapFromJson(content, CellDetails.class); + assertEquals(cell.getId(), "1"); + } + + @Test(expected = IllegalArgumentException.class) + public void testStartSendingFailureVesEvents() throws Exception { + this.mvc.perform(MockMvcRequestBuilders.get(getRanCellControllerEndpoint() + "/1/startFailure") + .accept(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(MockMvcResultMatchers.status().isOk()).andDo(MockMvcResultHandlers.print()); + } + + @Test(expected = IllegalArgumentException.class) + public void testStopSendingFailureVesEvents() throws Exception { + this.mvc.perform(MockMvcRequestBuilders.get(getRanCellControllerEndpoint() + "/1/stopFailure") + .accept(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(MockMvcResultMatchers.status().isOk()).andDo(MockMvcResultHandlers.print()); + } + + @Test(expected = IllegalArgumentException.class) + public void testStartSendingVesEvents() throws Exception { + this.mvc.perform(MockMvcRequestBuilders.get(getRanCellControllerEndpoint() + "/1/start") + .accept(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(MockMvcResultMatchers.status().isOk()).andDo(MockMvcResultHandlers.print()); + } + + @Test(expected = IllegalArgumentException.class) + public void testStopSendingVesEvents() throws Exception { + this.mvc.perform(MockMvcRequestBuilders.get(getRanCellControllerEndpoint() + "/1/stop") + .accept(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(MockMvcResultMatchers.status().isOk()).andDo(MockMvcResultHandlers.print()); + } + + @Test(expected = IllegalArgumentException.class) + public void testGetVesEventStructure() throws Exception { + this.mvc.perform(MockMvcRequestBuilders.get(getRanCellControllerEndpoint() + "/1/structure") + .accept(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(MockMvcResultMatchers.status().isOk()).andDo(MockMvcResultHandlers.print()); + } +} diff --git a/src/test/java/org/onap/a1pesimulator/controller/RanControllerTest.java b/src/test/java/org/onap/a1pesimulator/controller/RanControllerTest.java new file mode 100644 index 0000000..3c2602f --- /dev/null +++ b/src/test/java/org/onap/a1pesimulator/controller/RanControllerTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2021 Samsung Electronics + * 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 + */ + +package org.onap.a1pesimulator.controller; + +import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.onap.a1pesimulator.controller.URLHelper.getRanCellControllerEndpoint; +import static org.onap.a1pesimulator.controller.URLHelper.getRanControllerEndpoint; + +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.a1pesimulator.data.Topology; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultHandlers; +import org.springframework.test.web.servlet.result.MockMvcResultMatchers; + +@SpringBootTest +@AutoConfigureMockMvc +@RunWith(SpringRunner.class) +@ActiveProfiles(value = {"localStore"}) +public class RanControllerTest { + + @Autowired + private MockMvc mvc; + + @Autowired + private ObjectMapper mapper; + + protected <T> T mapFromJson(String json, Class<T> clazz) throws IOException { + mapper = new ObjectMapper(); + return mapper.readValue(json, clazz); + } + + @Test(expected = IllegalArgumentException.class) + public void testGetRan() throws Exception { + MvcResult mvcResult = this.mvc.perform( + MockMvcRequestBuilders.get(getRanControllerEndpoint()).accept(MediaType.APPLICATION_JSON_VALUE)) + .andDo(MockMvcResultHandlers.print()).andReturn(); + + int status = mvcResult.getResponse().getStatus(); + assertEquals(200, status); + String content = mvcResult.getResponse().getContentAsString(); + + Topology topology = this.mapFromJson(content, Topology.class); + + assertTrue(topology.getCells().size() > 0); + assertTrue(topology.getUserEquipments().size() > 0); + } + + @Test(expected = IllegalArgumentException.class) + public void testRefreshRan() throws Exception { + this.mvc.perform(MockMvcRequestBuilders.get(getRanCellControllerEndpoint() + "/refresh") + .accept(MediaType.APPLICATION_JSON_VALUE)) + .andExpect(MockMvcResultMatchers.status().isOk()).andDo(MockMvcResultHandlers.print()); + } +} diff --git a/src/test/java/org/onap/a1pesimulator/controller/RanUeControllerTest.java b/src/test/java/org/onap/a1pesimulator/controller/RanUeControllerTest.java new file mode 100644 index 0000000..f474102 --- /dev/null +++ b/src/test/java/org/onap/a1pesimulator/controller/RanUeControllerTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2021 Samsung Electronics + * 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 + */ + +package org.onap.a1pesimulator.controller; + +import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.onap.a1pesimulator.controller.URLHelper.getRanUeControllerEndpoint; + +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.a1pesimulator.data.ue.UserEquipment; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.servlet.MockMvc; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.test.web.servlet.result.MockMvcResultHandlers; + +@SpringBootTest +@AutoConfigureMockMvc +@RunWith(SpringRunner.class) +@ActiveProfiles(value = {"localStore"}) +public class RanUeControllerTest { + + @Autowired + private MockMvc mvc; + + @Autowired + private ObjectMapper mapper; + + protected String mapToJson(Object obj) throws JsonProcessingException { + mapper = new ObjectMapper(); + return mapper.writeValueAsString(obj); + } + + protected <T> T mapFromJson(String json, Class<T> clazz) + throws JsonParseException, JsonMappingException, IOException { + mapper = new ObjectMapper(); + return mapper.readValue(json, clazz); + } + + @Test(expected = IllegalArgumentException.class) + public void testGetUes() throws Exception { + MvcResult mvcResult = this.mvc.perform( + MockMvcRequestBuilders.get(getRanUeControllerEndpoint()).accept(MediaType.APPLICATION_JSON_VALUE)) + .andDo(MockMvcResultHandlers.print()).andReturn(); + + int status = mvcResult.getResponse().getStatus(); + assertEquals(200, status); + String content = mvcResult.getResponse().getContentAsString(); + + UserEquipment[] ues = this.mapFromJson(content, UserEquipment[].class); + + assertTrue(ues.length > 0); + } + + @Test(expected = IllegalArgumentException.class) + public void testGetUeById() throws Exception { + MvcResult mvcResult = this.mvc.perform( + MockMvcRequestBuilders.get(getRanUeControllerEndpoint() + "/{identifier}", 1) + .accept(MediaType.APPLICATION_JSON_VALUE)).andReturn(); + + int status = mvcResult.getResponse().getStatus(); + assertEquals(200, status); + String content = mvcResult.getResponse().getContentAsString(); + + UserEquipment ue = this.mapFromJson(content, UserEquipment.class); + assertEquals(ue.getId(), "1"); + } +} diff --git a/src/test/java/org/onap/a1pesimulator/controller/URLHelper.java b/src/test/java/org/onap/a1pesimulator/controller/URLHelper.java new file mode 100644 index 0000000..41b55dc --- /dev/null +++ b/src/test/java/org/onap/a1pesimulator/controller/URLHelper.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2021 Samsung Electronics + * 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 + */ + +package org.onap.a1pesimulator.controller; + +import org.springframework.stereotype.Component; + +@Component +public class URLHelper { + + private static final String A1_CONTROLLER_PREFIX = "/v1/a1-p"; + + private static final String POLICY_FORMAT = "%s/%s/policies/%s"; + + private static final String RAN_CELL_CONTROLLER_PREFIX = "${restapi.version}/ran/cells"; + + private static final String RAN_CONTROLLER_PREFIX = "${restapi.version}/ran"; + + private static final String RAN_UE_CONTROLLER_PREFIX = "${restapi.version}/ran/ues"; + + public static String getHealthCheckEndpoint() { + return A1_CONTROLLER_PREFIX + "/healthcheck"; + } + + public static String getPolicyTypePath() { + return A1_CONTROLLER_PREFIX + "/policytypes"; + } + + public static String getPolicyTypePath(String policyType) { + return getPolicyTypePath() + "/" + policyType; + } + + public static String getPolicyPath(String policyType, String policy) { + return String.format(POLICY_FORMAT, getPolicyTypePath(), policyType, policy); + } + + public static String getRanCellControllerEndpoint() { + return RAN_CELL_CONTROLLER_PREFIX; + } + + public static String getRanControllerEndpoint() { + return RAN_CONTROLLER_PREFIX; + } + + public static String getRanUeControllerEndpoint() { + return RAN_UE_CONTROLLER_PREFIX; + } +} diff --git a/src/test/java/org/onap/a1pesimulator/service/CellServiceTest.java b/src/test/java/org/onap/a1pesimulator/service/CellServiceTest.java new file mode 100644 index 0000000..5e9dc05 --- /dev/null +++ b/src/test/java/org/onap/a1pesimulator/service/CellServiceTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2021 Samsung Electronics + * 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 + */ + +package org.onap.a1pesimulator.service; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.onap.a1pesimulator.TestHelpers.CELL_ARRAY_SIZE; +import static org.onap.a1pesimulator.TestHelpers.CELL_PREFIX; +import static org.onap.a1pesimulator.TestHelpers.FIRST_CELL_ID; +import static org.onap.a1pesimulator.TestHelpers.UE_ARRAY_SIZE; +import static org.onap.a1pesimulator.TestHelpers.checkFirstCell; +import static org.onap.a1pesimulator.TestHelpers.checkFirstCellWithStatus; +import static org.onap.a1pesimulator.TestHelpers.checkFirstUserEquipment; + +import java.util.Collection; +import java.util.Set; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.a1pesimulator.data.Topology; +import org.onap.a1pesimulator.data.cell.CellDetails; +import org.onap.a1pesimulator.data.cell.CellWithStatus; +import org.onap.a1pesimulator.service.cell.RanCellService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@SpringBootTest +@RunWith(SpringRunner.class) +public class CellServiceTest { + + @Autowired + private RanCellService cellService; + + @Test + public void testGetTopology() { + Topology topology = cellService.getTopology(); + + assertNotNull(topology); + + assertEquals(CELL_ARRAY_SIZE, topology.getCells().size()); + assertEquals(UE_ARRAY_SIZE, topology.getUserEquipments().size()); + + checkFirstCell(topology.getCells().iterator().next()); + checkFirstUserEquipment(topology.getUserEquipments().iterator().next()); + } + + @Test + public void testGetCellById() { + CellDetails cellDetails = cellService.getCellById(FIRST_CELL_ID); + checkFirstCell(cellDetails); + } + + @Test + public void testGetCellIds() { + Set<String> ids = cellService.getCellIds(); + assertEquals(CELL_ARRAY_SIZE, ids.size()); + ids.forEach(id -> assertTrue(id.startsWith(CELL_PREFIX))); + } + + @Test + public void testGetCellWithStatus() { + Collection<CellWithStatus> cells = cellService.getAllCellsWithStatus(); + + assertEquals(CELL_ARRAY_SIZE, cells.size()); + checkFirstCellWithStatus(cells.iterator().next()); + } +} diff --git a/src/test/java/org/onap/a1pesimulator/service/RanUeServiceImplTest.java b/src/test/java/org/onap/a1pesimulator/service/RanUeServiceImplTest.java new file mode 100644 index 0000000..6409700 --- /dev/null +++ b/src/test/java/org/onap/a1pesimulator/service/RanUeServiceImplTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2021 Samsung Electronics + * 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 + */ + +package org.onap.a1pesimulator.service; + +import static org.onap.a1pesimulator.TestHelpers.FIRST_CELL_CONNECTED_UE_ID; +import static org.onap.a1pesimulator.TestHelpers.FIRST_CELL_ID; +import static org.onap.a1pesimulator.TestHelpers.FIRST_UE_HANDOVER_CELL; + +import java.util.Optional; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.a1pesimulator.data.ue.UserEquipment; +import org.onap.a1pesimulator.service.ue.RanUeServiceImpl; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class RanUeServiceImplTest { + + @Autowired + private RanUeServiceImpl ranUeService; + + @Test + public void testHandover() { + // when + ranUeService.handover(FIRST_CELL_CONNECTED_UE_ID, FIRST_UE_HANDOVER_CELL); + + // then + Optional<UserEquipment> optUserEquipment = ranUeService.getUserEquipment(FIRST_CELL_CONNECTED_UE_ID); + + Assert.assertTrue(optUserEquipment.isPresent()); + UserEquipment userEquipment = optUserEquipment.get(); + Assert.assertEquals(FIRST_UE_HANDOVER_CELL, userEquipment.getCellId()); + + // cleanup + userEquipment.setCellId(FIRST_CELL_ID); + } +} diff --git a/src/test/java/org/onap/a1pesimulator/service/UeServiceTest.java b/src/test/java/org/onap/a1pesimulator/service/UeServiceTest.java new file mode 100644 index 0000000..53c63ce --- /dev/null +++ b/src/test/java/org/onap/a1pesimulator/service/UeServiceTest.java @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2021 Samsung Electronics + * 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 + */ + +package org.onap.a1pesimulator.service; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.onap.a1pesimulator.TestHelpers.FIRST_CELL_CONNECTED_UE_ID; +import static org.onap.a1pesimulator.TestHelpers.FIRST_CELL_ID; +import static org.onap.a1pesimulator.TestHelpers.FIRST_UE_CELL_ID; +import static org.onap.a1pesimulator.TestHelpers.FIRST_UE_HANDOVER_CELL; +import static org.onap.a1pesimulator.TestHelpers.FIRST_UE_ID; +import static org.onap.a1pesimulator.TestHelpers.UE_ARRAY_SIZE; +import static org.onap.a1pesimulator.TestHelpers.checkFirstUserEquipment; + +import java.util.Collection; +import java.util.Optional; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.a1pesimulator.data.ue.UserEquipment; +import org.onap.a1pesimulator.service.ue.RanUeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@SpringBootTest +@RunWith(SpringRunner.class) +public class UeServiceTest { + + @Autowired + private RanUeService ueService; + + @Test + public void testGetUes() { + Collection<UserEquipment> userEquipments = ueService.getUserEquipments(); + + assertNotNull(userEquipments); + assertEquals(UE_ARRAY_SIZE, userEquipments.size()); + + UserEquipment userEquipment = userEquipments.iterator().next(); + checkFirstUserEquipment(userEquipment); + } + + @Test + public void testGetUeConnectedToCell() { + Collection<UserEquipment> userEquipments = ueService.getUserEquipmentsConnectedToCell(FIRST_CELL_ID); + + assertNotNull(userEquipments); + assertEquals(1, userEquipments.size()); + + UserEquipment userEquipment = userEquipments.iterator().next(); + assertEquals(FIRST_CELL_CONNECTED_UE_ID, userEquipment.getId()); + } + + @Test + public void testGetUeByID() { + Optional<UserEquipment> userEquipmentOpt = ueService.getUserEquipment(FIRST_UE_ID); + + assertNotNull(userEquipmentOpt); + assertTrue(userEquipmentOpt.isPresent()); + + UserEquipment userEquipment = userEquipmentOpt.get(); + checkFirstUserEquipment(userEquipment); + } + + @Test + public void testGetUeByNotCorrectID() { + Optional<UserEquipment> userEquipmentOpt = ueService.getUserEquipment("BAD_ID"); + + assertFalse(userEquipmentOpt.isPresent()); + assertNull(userEquipmentOpt.orElse(null)); + } + + @Test + public void testHandoverFlow() { + boolean canHandover = ueService.canHandover(FIRST_UE_ID, FIRST_UE_HANDOVER_CELL); + assertTrue(canHandover); + + ueService.handover(FIRST_UE_ID, FIRST_UE_HANDOVER_CELL); + + UserEquipment userEquipment = ueService.getUserEquipment(FIRST_UE_ID).orElse(null); + assertNotNull(userEquipment); + assertEquals(FIRST_UE_HANDOVER_CELL, userEquipment.getCellId()); + + ueService.handover(FIRST_UE_ID, FIRST_UE_CELL_ID); + } + + @Test + public void testCantHandoverFlow() { + boolean canHandover = ueService.canHandover(FIRST_UE_ID, "BAD_CELL_ID"); + assertFalse(canHandover); + } +} diff --git a/src/test/java/org/onap/a1pesimulator/service/VesBrokerServiceImplTest.java b/src/test/java/org/onap/a1pesimulator/service/VesBrokerServiceImplTest.java new file mode 100644 index 0000000..5b27529 --- /dev/null +++ b/src/test/java/org/onap/a1pesimulator/service/VesBrokerServiceImplTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2021 Samsung Electronics + * 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 + */ + +package org.onap.a1pesimulator.service; + +import static org.mockito.Mockito.when; + +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentMatchers; +import org.mockito.Mock; +import org.onap.a1pesimulator.data.ves.Event; +import org.onap.a1pesimulator.service.ves.RanVesBrokerService; +import org.onap.a1pesimulator.service.ves.RanVesSender; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.util.ReflectionTestUtils; +import org.springframework.web.client.RestTemplate; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class VesBrokerServiceImplTest { + + private static final String VES_COLLECTOR_URL = "someProtocol://someVesCollectorIP:someVesCollectorPort/somePath"; + + @Autowired + private RanVesBrokerService vesBrokerService; + @Autowired + private RanVesSender vesSender; + @Autowired + private ObjectMapper mapper; + @Mock + private RestTemplate restTemplate; + + @Before + public void before() { + ReflectionTestUtils.setField(vesSender, "restTemplate", restTemplate); + } + + @Test + public void testStartSendingVes() throws Exception { + ResponseEntity<String> responseEntity = new ResponseEntity<>(HttpStatus.OK); + + when(restTemplate.exchange(ArgumentMatchers.eq(VES_COLLECTOR_URL), ArgumentMatchers.eq(HttpMethod.POST), + ArgumentMatchers.any(HttpEntity.class), ArgumentMatchers.eq(String.class))).thenReturn(responseEntity); + + ResponseEntity<String> response = vesBrokerService.startSendingVesEvents("CustomIdentifier", + loadEventFromFile("VesBrokerControllerTest_pm_ves.json"), 10); + + Assert.assertEquals(HttpStatus.ACCEPTED, response.getStatusCode()); + } + + private Event loadEventFromFile(String fileName) throws Exception { + return mapper.readValue(loadFileContent(fileName), Event.class); + } + + private String loadFileContent(String fileName) throws IOException, URISyntaxException { + Path path = Paths.get(VesBrokerServiceImplTest.class.getResource(fileName).toURI()); + return new String(Files.readAllBytes(path)); + } +} diff --git a/src/test/java/org/onap/a1pesimulator/util/ItemsRefresherTest.java b/src/test/java/org/onap/a1pesimulator/util/ItemsRefresherTest.java new file mode 100644 index 0000000..25bdacf --- /dev/null +++ b/src/test/java/org/onap/a1pesimulator/util/ItemsRefresherTest.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2021 Samsung Electronics + * 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 + */ + +package org.onap.a1pesimulator.util; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.junit.Test; +import org.onap.a1pesimulator.service.cell.RanCellsHolder; +import org.onap.a1pesimulator.service.ue.RanUeHolder; + +public class ItemsRefresherTest { + + private final RanCellsHolder cellsHolder = mock(RanCellsHolder.class); + private final RanUeHolder ueHolder = mock(RanUeHolder.class); + private final ItemsRefresher refresher = new ItemsRefresher(cellsHolder, ueHolder); + + @Test + public void testHaveNotChanged() { + // given + when(cellsHolder.hasChanged()).thenReturn(false); + when(ueHolder.hasChanged()).thenReturn(false); + + // when + refresher.refresh(); + + // then + verify(cellsHolder).hasChanged(); + verify(cellsHolder, never()).refresh(); + verify(ueHolder).hasChanged(); + verify(ueHolder, never()).refresh(); + } + + @Test + public void testOneHasChanged() { + // given + when(cellsHolder.hasChanged()).thenReturn(false); + when(ueHolder.hasChanged()).thenReturn(true); + + // when + refresher.refresh(); + + // then + verify(cellsHolder).hasChanged(); + verify(cellsHolder, never()).refresh(); + verify(ueHolder).hasChanged(); + verify(ueHolder).refresh(); + } + + @Test + public void testBothHaveChanged() { + // given + when(cellsHolder.hasChanged()).thenReturn(true); + when(ueHolder.hasChanged()).thenReturn(true); + + // when + refresher.refresh(); + + // then + verify(cellsHolder).hasChanged(); + verify(cellsHolder).refresh(); + verify(ueHolder).hasChanged(); + verify(ueHolder).refresh(); + } +} diff --git a/src/test/java/org/onap/a1pesimulator/util/VnfConfigReaderTest.java b/src/test/java/org/onap/a1pesimulator/util/VnfConfigReaderTest.java new file mode 100644 index 0000000..b921755 --- /dev/null +++ b/src/test/java/org/onap/a1pesimulator/util/VnfConfigReaderTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2021 Samsung Electronics + * 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 + */ + +package org.onap.a1pesimulator.util; + +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.a1pesimulator.data.VnfConfig; +import org.onap.a1pesimulator.exception.LackOfConfigException; +import org.onap.a1pesimulator.exception.VesBrokerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class VnfConfigReaderTest { + + @Autowired + private VnfConfigReader vnfConfigReader; + + @Test + public void testGettingVnfConfig() throws LackOfConfigException, VesBrokerException { + VnfConfig vnfConfig = vnfConfigReader.getVnfConfig(); + Assert.assertEquals("someVesCollectorIP", vnfConfig.getVesHost()); + Assert.assertEquals("someVesCollectorPort", vnfConfig.getVesPort()); + Assert.assertEquals("someVesUser", vnfConfig.getVesUser()); + Assert.assertEquals("someVesPassword", vnfConfig.getVesPassword()); + Assert.assertEquals("someVnfId", vnfConfig.getVnfId()); + Assert.assertEquals("someVnfName", vnfConfig.getVnfName()); + } +} diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties new file mode 100644 index 0000000..97c855b --- /dev/null +++ b/src/test/resources/application.properties @@ -0,0 +1,32 @@ +# +# Copyright (C) 2021 Samsung Electronics +# 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 +# + +vnf.config.file=src/test/resources/vnf.config +ves.collector.protocol=someProtocol +ves.collector.endpoint=/somePath +ves.pm.maxPoolSize=10 +ves.defaultInterval=10 +ves.defaultFailureDuration=120 + +ves.failing.throughput=1 +ves.failing.latency=500 +# in sec +ves.failing.checkout.delay=15 + +topology.cell.config.file=src/test/resources/cells.json +topology.cell.range=5 +topology.ue.config.file=src/test/resources/ue.json + +refresher.fixed.rate.ms=60000 + +restapi.version=v1
\ No newline at end of file diff --git a/src/test/resources/cells.json b/src/test/resources/cells.json new file mode 100644 index 0000000..bd44bb7 --- /dev/null +++ b/src/test/resources/cells.json @@ -0,0 +1,125 @@ +{ + "cellList": [ + { + "Cell": { + "networkId": "RAN001", + "nodeId": "Chn0000", + "physicalCellId": 0, + "pnfName": "ncserver1", + "sectorNumber": 0, + "latitude": "50.11", + "longitude": "19.98" + }, + "neighbor": [ + { + "nodeId": "Chn0002", + "blacklisted": "false" + }, + { + "nodeId": "Chn0003", + "blacklisted": "false" + }, + { + "nodeId": "Chn0001", + "blacklisted": "false" + } + ] + }, + { + "Cell": { + "networkId": "RAN001", + "nodeId": "Chn0001", + "physicalCellId": 1, + "pnfName": "ncserver1", + "sectorNumber": 0, + "latitude": "50.06", + "longitude": "20.03" + }, + "neighbor": [ + { + "nodeId": "Chn0004", + "blacklisted": "false" + }, + { + "nodeId": "Chn0000", + "blacklisted": "false" + }, + { + "nodeId": "Chn0002", + "blacklisted": "false" + } + ] + }, + { + "Cell": { + "networkId": "RAN001", + "nodeId": "Chn0002", + "physicalCellId": 3, + "pnfName": "ncserver1", + "sectorNumber": 0, + "latitude": "50.06", + "longitude": "19.94" + }, + "neighbor": [ + { + "nodeId": "Chn0004", + "blacklisted": "false" + }, + { + "nodeId": "Chn0000", + "blacklisted": "false" + }, + { + "nodeId": "Chn0003", + "blacklisted": "false" + }, + { + "nodeId": "Chn0001", + "blacklisted": "false" + } + ] + }, + { + "Cell": { + "networkId": "RAN001", + "nodeId": "Chn0003", + "physicalCellId": 4, + "pnfName": "ncserver1", + "sectorNumber": 0, + "latitude": "50.11", + "longitude": "19.88" + }, + "neighbor": [ + { + "nodeId": "Chn0002", + "blacklisted": "false" + }, + { + "nodeId": "Chn0000", + "blacklisted": "false" + } + ] + }, + { + "Cell": { + "networkId": "RAN001", + "nodeId": "Chn0004", + "physicalCellId": 6, + "pnfName": "ncserver1", + "sectorNumber": 0, + "latitude": "50.01", + "longitude": "19.99" + }, + "neighbor": [ + { + "nodeId": "Chn0002", + "blacklisted": "false" + }, + { + "nodeId": "Chn0001", + "blacklisted": "false" + } + ] + } + ] +} diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml new file mode 100644 index 0000000..1a162e3 --- /dev/null +++ b/src/test/resources/logback.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Copyright (C) 2021 Samsung Electronics + ~ 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 + --> + +<configuration> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <layout class="ch.qos.logback.classic.PatternLayout"> + <Pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n</Pattern> + </layout> + </appender> + + <root level="INFO"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/src/test/resources/org/onap/a1pesimulator/service/VesBrokerControllerTest_pm_ves.json b/src/test/resources/org/onap/a1pesimulator/service/VesBrokerControllerTest_pm_ves.json new file mode 100644 index 0000000..8c59897 --- /dev/null +++ b/src/test/resources/org/onap/a1pesimulator/service/VesBrokerControllerTest_pm_ves.json @@ -0,0 +1,35 @@ +{ + "event": { + "commonEventHeader": { + "version": "4.0.1", + "vesEventListenerVersion": "7.0.1", + "domain": "measurement", + "eventName": "Measurement_vIsbcMmc", + "eventId": "measurement0000259", + "sequence": 3, + "priority": "Normal", + "reportingEntityId": "cc305d54-75b4-431b-adb2-eb6b9e541234", + "reportingEntityName": "ibcx0001vm002oam001", + "sourceId": "de305d54-75b4-431b-adb2-eb6b9e546014", + "sourceName": "ibcx0001vm002ssc001", + "nfVendorName": "Samsung", + "nfNamingCode": "ibcx", + "nfcNamingCode": "ssc", + "startEpochMicrosec": 1413378172000000, + "lastEpochMicrosec": 1413378172000000, + "timeZoneOffset": "UTC-05:30" + }, + "measurementFields": { + "additionalMeasurements": [ + { + "name": "latency", + "hashMap": { + "value": "[[100-150]]" + } + } + ], + "measurementInterval": 5, + "measurementFieldsVersion": "4.0" + } + } +} diff --git a/src/test/resources/ue.json b/src/test/resources/ue.json new file mode 100644 index 0000000..437df08 --- /dev/null +++ b/src/test/resources/ue.json @@ -0,0 +1,20 @@ +[ + { + "id": "mobile_samsung_s10", + "latitude": "50.09", + "longitude": "19.94", + "cellId": "Chn0000" + }, + { + "id": "mobile_samsung_s20", + "latitude": "50.05", + "longitude": "19.95", + "cellId": "Chn0002" + }, + { + "id": "emergency_police_111", + "latitude": "50.035", + "longitude": "19.97", + "cellId": "Chn0002" + } +] diff --git a/src/test/resources/vnf.config b/src/test/resources/vnf.config new file mode 100644 index 0000000..09a2553 --- /dev/null +++ b/src/test/resources/vnf.config @@ -0,0 +1,7 @@ +vesHost=someVesCollectorIP +vesPort=someVesCollectorPort +vesUser=someVesUser +vesPassword=someVesPassword +vnfId=someVnfId +vnfName=someVnfName +unknownProperty=doNotFail |