@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/"));
  }
示例#2
0
  @Before
  public void setup() {

    System.load("C:/Users/Grant Dawson/Documents/opencv/build/java/x64/opencv_java246.dll");

    this.mockMvc = webAppContextSetup(this.wac).build();

    Stripe.apiKey = "sk_test_cAefVlVMmXfcSKMZOKLhielX";
  }
 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;
 }