コード例 #1
0
  @Test(dependsOnMethods = "testListSensors")
  public void testTriggerSampleEffector() throws InterruptedException, IOException {
    ClientResponse response =
        client()
            .resource(
                "/v1/applications/simple-app/entities/simple-ent/effectors/"
                    + RestMockSimpleEntity.SAMPLE_EFFECTOR.getName())
            .type(MediaType.APPLICATION_JSON_TYPE)
            .post(ClientResponse.class, ImmutableMap.of("param1", "foo", "param2", 4));

    assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());

    String result = response.getEntity(String.class);
    assertEquals(result, "foo4");
  }
コード例 #2
0
  @Test(dependsOnMethods = "testListSensors")
  public void testTriggerSampleEffectorWithFormData() throws InterruptedException, IOException {
    MultivaluedMap<String, String> data = new MultivaluedMapImpl();
    data.add("param1", "foo");
    data.add("param2", "4");
    ClientResponse response =
        client()
            .resource(
                "/v1/applications/simple-app/entities/simple-ent/effectors/"
                    + RestMockSimpleEntity.SAMPLE_EFFECTOR.getName())
            .type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
            .post(ClientResponse.class, data);

    assertEquals(response.getStatus(), Response.Status.ACCEPTED.getStatusCode());

    String result = response.getEntity(String.class);
    assertEquals(result, "foo4");
  }