2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Nokia. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.pnfsimulator.integration;
23 import com.google.gson.Gson;
24 import com.google.gson.JsonObject;
25 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.web.bind.annotation.PostMapping;
27 import org.springframework.web.bind.annotation.RequestBody;
28 import org.springframework.web.bind.annotation.RequestMapping;
29 import org.springframework.web.bind.annotation.RestController;
31 @RequestMapping("ves-simulator")
33 public class VesSimulatorController {
35 private final VesSimulatorService vesSimulatorService;
36 private final Gson gson;
39 public VesSimulatorController(VesSimulatorService vesSimulatorService, Gson gson) {
40 this.vesSimulatorService = vesSimulatorService;
44 @PostMapping("eventListener/v5")
45 String sendEventToDmaapV5(@RequestBody String body) {
46 System.out.println("Received event" + body);
47 JsonObject jsonObject = gson.fromJson(body, JsonObject.class);
48 vesSimulatorService.sendEventToDmaapV5(jsonObject);
49 return "MessageAccepted";
52 @PostMapping("eventListener/v7")
53 String sendEventToDmaapV7(@RequestBody String body) {
54 System.out.println("Received event" + body);
55 JsonObject jsonObject = gson.fromJson(body, JsonObject.class);
56 vesSimulatorService.sendEventToDmaapV7(jsonObject);
57 return "MessageAccepted";