@Test
public void queryServiceUris() throws Throwable {

    setUp(false);
    int serviceCount = 5;
    this.host.createExampleServices(this.host, serviceCount, Utils.getNowMicrosUtc());
    EnumSet<ServiceOption> options = EnumSet.of(ServiceOption.INSTRUMENTATION,
            ServiceOption.OWNER_SELECTION, ServiceOption.FACTORY_ITEM);
    Operation get = Operation.createGet(this.host.getUri());
    final ServiceDocumentQueryResult[] results = new ServiceDocumentQueryResult[1];
    get.setCompletion((o, e) -> {
        if (e != null) {
            this.host.failIteration(e);
            return;
        }
        results[0] = o.getBody(ServiceDocumentQueryResult.class);
        this.host.completeIteration();
    });
    // use path prefix match
    this.host.testStart(1);
    this.host.queryServiceUris(ExampleService.FACTORY_LINK + "/*", get.clone());
    this.host.testWait();
    assertEquals(serviceCount, results[0].documentLinks.size());
    assertEquals((long) serviceCount, (long) results[0].documentCount);
    this.host.testStart(1);
    this.host.queryServiceUris(options, true, get.clone());
    this.host.testWait();
    assertEquals(serviceCount, results[0].documentLinks.size());
    assertEquals((long) serviceCount, (long) results[0].documentCount);
    this.host.testStart(1);
    this.host.queryServiceUris(options, false, get.clone());
    this.host.testWait();
    assertTrue(results[0].documentLinks.size() >= serviceCount);
    assertEquals((long) results[0].documentLinks.size(), (long) results[0].documentCount);
}