aboutsummaryrefslogtreecommitdiffstats
path: root/plans/so/integration-etsi-testing/so-simulators/sdc-simulator
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2019-07-09 16:14:17 +0000
committerwaqas.ikram <waqas.ikram@est.tech>2019-07-09 16:14:17 +0000
commitb01df8be03edfbea5e6185d763496bd8cfa833ff (patch)
treef23ea7558b8767fc432ca31cae0ed9dc7273403b /plans/so/integration-etsi-testing/so-simulators/sdc-simulator
parent1e0cd76fa5fb5f43d2b404083a0622eaf1e7b9f5 (diff)
Adding Infrastructure for Simulate Request for SDC
Change-Id: Icf1100f180201735b4862cb0b9762d4a30750817 Issue-ID: SO-1949 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'plans/so/integration-etsi-testing/so-simulators/sdc-simulator')
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/pom.xml36
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/Constant.java26
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorApplication.java35
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorController.java49
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml5
-rw-r--r--plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/SdcSimulatorControllerTest.java66
6 files changed, 217 insertions, 0 deletions
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/pom.xml b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/pom.xml
new file mode 100644
index 00000000..6a1baccf
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/pom.xml
@@ -0,0 +1,36 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>so-simulators</artifactId>
+ <groupId>org.onap.so.simulators</groupId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>sdc-simulator</artifactId>
+ <name>${project.artifactId}</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+ <mainClass>org.onap.so.sdc.simulator.SdcSimulatorApplication</mainClass>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/Constant.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/Constant.java
new file mode 100644
index 00000000..c4e9c468
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/Constant.java
@@ -0,0 +1,26 @@
+/*
+ * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix
+ * Foundation. ================================================================================ 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.sdc.simulator;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ */
+public class Constant {
+
+ public static final String BASE_URL = "/sdc/simulator/v1";
+
+ private Constant() {}
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorApplication.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorApplication.java
new file mode 100644
index 00000000..6bcd04d8
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorApplication.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.sdc.simulator;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ */
+@SpringBootApplication
+public class SdcSimulatorApplication extends SpringBootServletInitializer {
+ public static void main(final String[] args) {
+ SpringApplication.run(SdcSimulatorApplication.class, args);
+ }
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorController.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorController.java
new file mode 100644
index 00000000..12e179f8
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/java/org/onap/so/sdc/simulator/SdcSimulatorController.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.sdc.simulator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+import javax.ws.rs.core.MediaType;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ */
+@RestController
+@RequestMapping(path = Constant.BASE_URL, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
+public class SdcSimulatorController {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(SdcSimulatorController.class);
+
+ @GetMapping(value = "/healthcheck")
+ @ResponseStatus(code = HttpStatus.OK)
+ public String healthCheck() {
+ LOGGER.info("Running health check ...");
+ return "healthy";
+ }
+
+
+}
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml
new file mode 100644
index 00000000..f1e63b10
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/main/resources/application.yaml
@@ -0,0 +1,5 @@
+server:
+ port: 9991
+ tomcat:
+ max-threads: 50
+ssl-enable: false
diff --git a/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/SdcSimulatorControllerTest.java b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/SdcSimulatorControllerTest.java
new file mode 100644
index 00000000..e0d44e93
--- /dev/null
+++ b/plans/so/integration-etsi-testing/so-simulators/sdc-simulator/src/test/java/org/onap/so/sdc/simulator/SdcSimulatorControllerTest.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2019 Nordix Foundation.
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.sdc.simulator;
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@ActiveProfiles("test")
+@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
+public class SdcSimulatorControllerTest {
+
+ @LocalServerPort
+ private int port;
+
+ @Autowired
+ private TestRestTemplate restTemplate;
+
+ @Test
+ public void testHealthCheck() {
+ final HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+
+ final HttpEntity<?> request = new HttpEntity<>(headers);
+ final String url = "http://localhost:" + port + Constant.BASE_URL + "/healthcheck";
+ final ResponseEntity<String> object = restTemplate.exchange(url, HttpMethod.GET, request, String.class);
+
+ assertEquals("healthy", object.getBody());
+
+ }
+
+}