@Test
public void thirdPartyClientPost() throws Throwable {

    setUp(false);
    this.host.waitForServiceAvailable(ExampleService.FACTORY_LINK);
    String name = UUID.randomUUID().toString();
    ExampleServiceState s = new ExampleServiceState();
    s.name = name;
    Consumer<Operation> bodySetter = (o) -> {
        o.setBody(s);
    };
    URI factoryURI = UriUtils.buildFactoryUri(this.host, ExampleService.class);
    long c = 1;
    Map<URI, ExampleServiceState> states = this.host.doFactoryChildServiceStart(null, c,
            ExampleServiceState.class, bodySetter, factoryURI);
    String contentType = Operation.MEDIA_TYPE_APPLICATION_JSON;
    for (ExampleServiceState initialState : states.values()) {
        String json = this.host.sendWithJavaClient(
                UriUtils.buildUri(this.host, initialState.documentSelfLink), contentType, null);
        ExampleServiceState javaClientRsp = Utils.fromJson(json, ExampleServiceState.class);
        assertTrue(javaClientRsp.name.equals(initialState.name));
    }
    // Now issue POST with third party client
    s.name = UUID.randomUUID().toString();
    String body = Utils.toJson(s);
    // first use proper content type
    String json = this.host.sendWithJavaClient(factoryURI,
            Operation.MEDIA_TYPE_APPLICATION_JSON, body);
    ExampleServiceState javaClientRsp = Utils.fromJson(json, ExampleServiceState.class);
    assertTrue(javaClientRsp.name.equals(s.name));
    // POST to a service we know does not exist and verify our request did not get implicitly
    // queued, but failed instantly instead
    json = this.host.sendWithJavaClient(
            UriUtils.extendUri(factoryURI, UUID.randomUUID().toString()),
            Operation.MEDIA_TYPE_APPLICATION_JSON, null);
    ServiceErrorResponse r = Utils.fromJson(json, ServiceErrorResponse.class);
    assertEquals(Operation.STATUS_CODE_NOT_FOUND, r.statusCode);
}