Added UniversalVesAdapter TestCases in the Mapper
[dcaegen2/services/mapper.git] / UniversalVesAdapter / src / test / java / org / onap / universalvesadapter / controller / VesControllerTest.java
1 /*
2 * ============LICENSE_START=======================================================
3 * ONAP : DCAE
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
10 *
11 *     http://www.apache.org/licenses/LICENSE-2.0
12 *
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=========================================================
19 */
20 package org.onap.universalvesadapter.controller;
21
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;
27
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;
38
39 @RunWith(SpringRunner.class)
40 @SpringBootTest(classes=Application.class)
41 @AutoConfigureMockMvc
42 public class VesControllerTest {
43
44     @Autowired
45     private MockMvc mockMvc;
46
47     @Test
48     public void startShouldReturnApplicationStartedMessage() throws Exception {
49
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());
53     }
54
55     @Test
56     public void stopShouldReturnApplicationStoppingMessage() throws Exception {
57         
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());
61     }
62
63
64
65 }