@Test
  public void testCreateCustomer() throws Exception {

    long now = System.currentTimeMillis();
    String f = "Joe", l = "Doe";

    String jsonOfJoeDoe =
        "{ \"signupDate\":" + now + ",\"firstName\":\"" + f + "\",\"lastName\":\"" + l + "\"}";

    MvcResult mvcResult =
        mockMvc
            .perform(
                post("/users/{userId}/customers", userId)
                    .accept(applicationJsonMediaType)
                    .content(jsonOfJoeDoe)
                    .contentType(this.applicationJsonMediaType))
            .andExpect(status().isCreated())
            .andExpect(content().contentType(this.applicationJsonMediaType))
            .andReturn();

    mockServer.verify();

    String locationUri = mvcResult.getResponse().getHeader("Location");
    Assert.assertTrue(locationUri.contains("/users/" + userId + "/customers/"));
  }
Exemplo n.º 2
0
 private Service makeService(String name, String url, String message, ServiceStatus status) {
   Service s = new Service();
   s.setId(ObjectId.get());
   s.setDashboardId(ObjectId.get());
   s.setApplicationName("appName");
   s.setLastUpdated(System.currentTimeMillis());
   s.setName(name);
   s.setMessage(message);
   s.setStatus(status);
   s.setUrl(url);
   return s;
 }