2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright 2018 TechMahindra
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=========================================================
20 package org.onap.universalvesadapter.controller;
22 import static org.junit.Assert.assertEquals;
23 import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
24 import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
25 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
26 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.onap.universalvesadapter.Application;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
33 import org.springframework.boot.test.context.SpringBootTest;
34 import org.springframework.test.context.junit4.SpringRunner;
35 import org.springframework.test.web.servlet.MockMvc;
36 import org.springframework.test.web.servlet.MvcResult;
37 import org.springframework.test.web.servlet.ResultActions;
39 @RunWith(SpringRunner.class)
40 @SpringBootTest(classes=Application.class)
42 public class VesControllerTest {
45 private MockMvc mockMvc;
48 public void startShouldReturnApplicationStartedMessage() throws Exception {
50 MvcResult mvcResult = this.mockMvc.perform(get("/start")).andDo(print()).andExpect(status().isOk())
51 .andReturn();//Expect(jsonPath("$.content").value("Application started"));
52 assertEquals("Application started", mvcResult.getResponse().getContentAsString());
56 public void stopShouldReturnApplicationStoppingMessage() throws Exception {
58 MvcResult mvcResult = this.mockMvc.perform(get("/stop")).andDo(print()).andExpect(status().isOk())
59 .andReturn();//.andExpect(jsonPath("$.content").value("Application will be stopped soon"));
60 assertEquals("Application will be stopped soon", mvcResult.getResponse().getContentAsString());