@Test
  public void testRegisterActivity() throws Exception {
    String userId = "412bac09-b9a0-46b5-a283-7442fa1eb76c";
    String token = "3f1d9898-5531-4753-80fa-2e164c5ba754";

    MvcResult result =
        mockMvc
            .perform(
                MockMvcRequestBuilders.post(
                        "/activity/register?userId=" + userId + "&token=" + token)
                    .param("type", "旅行")
                    .param("introduction", "DD活动期间晴空万里,道路通畅")
                    .param("cover", "4d51a321-f953-4623-b7ab-abd4fb858e77")
                    .param("cover", "59336875-0128-4121-862a-22d1db86fe03")
                    .param("location", "南京邮电大学")
                    .param("longitude", "118.869529")
                    .param("latitude", "32.02632")
                    .param("start", "1436494940937")
                    .param("end", "1436494955800")
                    .param("province", "江苏省")
                    .param("city", "南京")
                    .param("district", "鼓楼区")
                    .param("pay", "我请客")
                    .param("seat", "2"))
            .andExpect(MockMvcResultMatchers.status().isOk())
            .andExpect(MockMvcResultMatchers.content().encoding("UTF-8"))
            .andExpect(
                MockMvcResultMatchers.content().contentType("application/json;charset=UTF-8"))
            .andExpect(MockMvcResultMatchers.jsonPath("$.result").value(0))
            .andDo(MockMvcResultHandlers.print())
            .andReturn();
    Assert.assertNull(result.getModelAndView());
  }
 @Test
 public final void testUpdatePerson() throws Exception {
   Person person = createSamplePerson();
   Mockito.when(peopleServiceMock.updatePerson(Mockito.any(Person.class))).thenReturn(person);
   mockMvc
       .perform(
           MockMvcRequestBuilders.post("/person/update")
               .contentType(MediaType.APPLICATION_JSON)
               .content(JSONUtil.toJSonString(person).getBytes()))
       .andDo(MockMvcResultHandlers.print())
       .andExpect(MockMvcResultMatchers.status().isOk())
       .andExpect(MockMvcResultMatchers.content().string(JSONUtil.toJSonString(person)));
 }
  @Test
  public final void testAddFamily() throws Exception {
    Family family = createSampleFamily();
    Mockito.when(peopleServiceMock.addFamily(Mockito.any(Family.class))).thenReturn(family);

    mockMvc
        .perform(
            MockMvcRequestBuilders.post("/family")
                .contentType(MediaType.APPLICATION_JSON)
                .content(JSONUtil.toJSonString(family).getBytes()))
        .andDo(MockMvcResultHandlers.print())
        .andExpect(MockMvcResultMatchers.status().isOk())
        .andExpect(MockMvcResultMatchers.content().string(JSONUtil.toJSonString(family)));
  }
 @Test
 public final void testGetFamily() throws Exception {
   Family family = createSampleFamily();
   Mockito.when(peopleServiceMock.getFamily(new Long(1))).thenReturn(family);
   mockMvc
       .perform(MockMvcRequestBuilders.get("/family/1").accept(MediaType.APPLICATION_JSON))
       .andDo(MockMvcResultHandlers.print())
       .andExpect(MockMvcResultMatchers.status().isOk())
       .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_VALUE))
       .andExpect(MockMvcResultMatchers.content().string(JSONUtil.toJSonString(family)));
 }
  @Test
  public final void testFindPerson() throws Exception {
    Person person = createSamplePerson();
    List<Person> list = new ArrayList<Person>();
    list.add(person);

    Mockito.when(peopleServiceMock.findPerson("Andy")).thenReturn(list);
    mockMvc
        .perform(MockMvcRequestBuilders.get("/person/find/Andy").accept(MediaType.APPLICATION_JSON))
        .andDo(MockMvcResultHandlers.print())
        .andExpect(MockMvcResultMatchers.status().isOk())
        .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_VALUE))
        .andExpect(MockMvcResultMatchers.content().string(JSONUtil.toJSonString(list)));
  }
  @Test
  public final void testFindFamily() throws Exception {
    Family family = createSampleFamily();
    List<Family> list = new ArrayList<Family>();
    list.add(family);

    Mockito.when(peopleServiceMock.findFamily("Weber")).thenReturn(list);
    mockMvc
        .perform(
            MockMvcRequestBuilders.get("/family/find/Weber").accept(MediaType.APPLICATION_JSON))
        .andDo(MockMvcResultHandlers.print())
        .andExpect(MockMvcResultMatchers.status().isOk())
        .andExpect(MockMvcResultMatchers.content().contentType(MediaType.APPLICATION_JSON_VALUE))
        .andExpect(MockMvcResultMatchers.content().string(JSONUtil.toJSonString(list)));
  }
  @Test
  public final void testDeletePerson() throws Exception {
    Mockito.doNothing().when(peopleServiceMock).deletePerson(Mockito.any(Long.class));

    mockMvc
        .perform(
            MockMvcRequestBuilders.delete("/delPerson/200").contentType(MediaType.APPLICATION_JSON))
        .andDo(MockMvcResultHandlers.print())
        .andExpect(MockMvcResultMatchers.status().isOk())
        .andExpect(MockMvcResultMatchers.content().string(""));
  }
 @Test
 public void environmentWithLabelContainingSlash() throws Exception {
   Mockito.when(this.repository.findOne("foo", "default", "feature/puff"))
       .thenReturn(new Environment("foo", "default"));
   this.mvc
       .perform(MockMvcRequestBuilders.get("/foo/default/feature(_)puff"))
       .andExpect(MockMvcResultMatchers.status().isOk())
       .andExpect(
           MockMvcResultMatchers.content()
               .string(Matchers.containsString("\"propertySources\":")));
 }