use of org.alfresco.repo.rendition2.RenditionDefinition2.TIMEOUT in project hono by eclipse.
the class FuturesTest method testCreateGetsCompletedOnOriginalContext.
/**
* Verifies that the Future returned by the <em>create</em> method
* will be completed on the vert.x context it was invoked on.
*
* @param ctx The vert.x test context.
* @param vertx The vert.x instance.
*/
@Test
@Timeout(value = 5, timeUnit = TimeUnit.SECONDS)
public void testCreateGetsCompletedOnOriginalContext(final VertxTestContext ctx, final Vertx vertx) {
final Context context = vertx.getOrCreateContext();
context.runOnContext(v -> {
LOG.trace("run on context");
Futures.create(() -> CompletableFuture.runAsync(() -> {
LOG.trace("run async");
})).onComplete(r -> {
LOG.trace("after run async");
ctx.verify(() -> {
assertTrue(r.succeeded());
assertEquals(context, vertx.getOrCreateContext());
});
ctx.completeNow();
});
});
}
use of org.alfresco.repo.rendition2.RenditionDefinition2.TIMEOUT in project hono by eclipse.
the class DeviceRegistrationApiTests method testAssertRegistrationSucceedsForDeviceViaGatewayGroup.
/**
* Verifies that the registry succeeds a request to assert the registration status of a device that connects via a
* gateway that is authorized through its group membership.
*
* @param ctx The vert.x test context.
*/
@Timeout(value = 5, timeUnit = TimeUnit.SECONDS)
@Test
public void testAssertRegistrationSucceedsForDeviceViaGatewayGroup(final VertxTestContext ctx) {
final String gatewayId = getHelper().getRandomDeviceId(tenantId);
final String deviceId = getHelper().getRandomDeviceId(tenantId);
final Device device = new Device();
device.setViaGroups(List.of("group"));
final Device gateway = new Device();
gateway.setMemberOf(List.of("group"));
Future.succeededFuture().compose(ok -> getHelper().registry.registerDevice(tenantId, gatewayId, gateway)).compose(ok -> getHelper().registry.registerDevice(tenantId, deviceId, device)).compose(ok -> getClient().assertRegistration(tenantId, deviceId, gatewayId, NoopSpan.INSTANCE.context())).onComplete(ctx.succeeding(resp -> {
ctx.verify(() -> {
assertThat(resp.getDeviceId()).isEqualTo(deviceId);
assertThat(resp.getAuthorizedGateways()).containsExactly(gatewayId);
});
ctx.completeNow();
}));
}
use of org.alfresco.repo.rendition2.RenditionDefinition2.TIMEOUT in project hono by eclipse.
the class DeviceRegistrationApiTests method testAssertRegistrationFailsForDisabledGateway.
/**
* Verifies that the registry fails a disabled gateway's request to assert a device's registration status with a 403
* error code.
*
* @param ctx The vert.x test context.
*/
@Timeout(value = 5, timeUnit = TimeUnit.SECONDS)
@Test
public void testAssertRegistrationFailsForDisabledGateway(final VertxTestContext ctx) {
final String deviceId = getHelper().getRandomDeviceId(tenantId);
final String gatewayId = getHelper().getRandomDeviceId(tenantId);
final Device gateway = new Device();
gateway.setEnabled(false);
final Device device = new Device();
device.setVia(Collections.singletonList(gatewayId));
getHelper().registry.registerDevice(tenantId, gatewayId, gateway).compose(ok -> getHelper().registry.registerDevice(tenantId, deviceId, device)).compose(r -> getClient().assertRegistration(tenantId, deviceId, gatewayId, NoopSpan.INSTANCE.context())).onComplete(ctx.failing(t -> {
assertErrorCode(t, HttpURLConnection.HTTP_FORBIDDEN);
ctx.completeNow();
}));
}
use of org.alfresco.repo.rendition2.RenditionDefinition2.TIMEOUT in project hono by eclipse.
the class DeviceRegistrationApiTests method testAssertRegistrationSucceedsForDeviceViaGateway.
/**
* Verifies that the registry succeeds a request to assert the registration status of a device that connects via an
* authorized gateway.
*
* @param ctx The vert.x test context.
*/
@Timeout(value = 5, timeUnit = TimeUnit.SECONDS)
@Test
public void testAssertRegistrationSucceedsForDeviceViaGateway(final VertxTestContext ctx) {
final String gatewayId = getHelper().getRandomDeviceId(tenantId);
final String deviceId = getHelper().getRandomDeviceId(tenantId);
final List<String> via = List.of(gatewayId, "another-gateway");
final Device device = new Device();
device.setVia(via);
getHelper().registry.registerDevice(tenantId, gatewayId).compose(ok -> getHelper().registry.registerDevice(tenantId, deviceId, device)).compose(ok -> getClient().assertRegistration(tenantId, deviceId, gatewayId, NoopSpan.INSTANCE.context())).onComplete(ctx.succeeding(resp -> {
ctx.verify(() -> {
assertThat(resp.getDeviceId()).isEqualTo(deviceId);
assertThat(resp.getAuthorizedGateways()).containsExactlyElementsIn(via);
});
ctx.completeNow();
}));
}
use of org.alfresco.repo.rendition2.RenditionDefinition2.TIMEOUT in project hono by eclipse.
the class TenantJmsIT method testGetTenantFailsForUnsupportedSearchCriteria.
/**
* Verifies that a request to retrieve information for unsupported search criteria
* fails with a 400 status.
*
* @param ctx The vert.x test context.
*/
@Timeout(value = 5, timeUnit = TimeUnit.SECONDS)
@Test
public void testGetTenantFailsForUnsupportedSearchCriteria(final VertxTestContext ctx) {
final JsonObject unsupportedSearchCriteria = new JsonObject().put("color", "blue");
allTenantClient.get(unsupportedSearchCriteria.toBuffer()).onComplete(ctx.failing(t -> {
ctx.verify(() -> assertThat(((ServiceInvocationException) t).getErrorCode()).isEqualTo(HttpURLConnection.HTTP_BAD_REQUEST));
ctx.completeNow();
}));
}
Aggregations