use of org.eclipse.hono.service.management.SearchResult in project hono by eclipse.
the class AbstractTenantManagementSearchTenantsTest method testSearchTenantsWithWildCardToMatchMultipleCharacters.
/**
* Verifies that a request to search tenants with filters containing the wildcard character '*'
* succeeds and matching tenants are found.
*
* @param ctx The vert.x test context.
*/
@Test
default void testSearchTenantsWithWildCardToMatchMultipleCharacters(final VertxTestContext ctx) {
final String tenantId1 = DeviceRegistryUtils.getUniqueIdentifier();
final String tenantId2 = DeviceRegistryUtils.getUniqueIdentifier();
final String tenantId3 = DeviceRegistryUtils.getUniqueIdentifier();
final int pageSize = 10;
final int pageOffset = 0;
final Filter filter1 = new Filter("/ext/id", "tenant*-*");
final Filter filter2 = new Filter("/ext/value", "test$2*e");
final Sort sortOption = new Sort("/id");
createTenants(Map.of(tenantId1, new Tenant().setEnabled(false).setExtensions(Map.of("id", "tenant1-id")), tenantId2, new Tenant().setEnabled(true).setExtensions(Map.of("id", "tenant2-id", "value", "test$2Value")), tenantId3, new Tenant().setEnabled(true).setExtensions(Map.of("id", "tenant3-id", "value", "test$3Value")))).onFailure(ctx::failNow).compose(ok -> getTenantManagementService().searchTenants(pageSize, pageOffset, List.of(filter1, filter2), List.of(sortOption), NoopSpan.INSTANCE)).onComplete(ctx.succeeding(s -> {
ctx.verify(() -> {
assertThat(s.getStatus()).isEqualTo(HttpURLConnection.HTTP_OK);
final SearchResult<TenantWithId> searchResult = s.getPayload();
assertThat(searchResult.getTotal()).isEqualTo(1);
assertThat(searchResult.getResult()).hasSize(1);
assertThat(searchResult.getResult().get(0).getId()).isEqualTo(tenantId2);
});
ctx.completeNow();
}));
}
use of org.eclipse.hono.service.management.SearchResult in project hono by eclipse.
the class AbstractTenantManagementSearchTenantsTest method testSearchTenantsWithPageOffset.
/**
* Verifies that a request to search tenants with valid page offset succeeds and the result is in accordance with
* the specified page offset.
*
* @param ctx The vert.x test context.
*/
@Test
default void testSearchTenantsWithPageOffset(final VertxTestContext ctx) {
final String tenantId1 = DeviceRegistryUtils.getUniqueIdentifier();
final String tenantId2 = DeviceRegistryUtils.getUniqueIdentifier();
final int pageSize = 1;
final int pageOffset = 1;
final Filter filter = new Filter("/enabled", true);
final Sort sortOption = new Sort("/ext/id");
sortOption.setDirection(Sort.Direction.DESC);
createTenants(Map.of(tenantId1, new Tenant().setEnabled(true).setExtensions(Map.of("id", "1")), tenantId2, new Tenant().setEnabled(true).setExtensions(Map.of("id", "2")))).onFailure(ctx::failNow).compose(ok -> getTenantManagementService().searchTenants(pageSize, pageOffset, List.of(filter), List.of(sortOption), NoopSpan.INSTANCE)).onComplete(ctx.succeeding(s -> {
ctx.verify(() -> {
assertThat(s.getStatus()).isEqualTo(HttpURLConnection.HTTP_OK);
final SearchResult<TenantWithId> searchResult = s.getPayload();
assertThat(searchResult.getTotal()).isEqualTo(2);
assertThat(searchResult.getResult()).hasSize(1);
assertThat(searchResult.getResult().get(0).getId()).isEqualTo(tenantId1);
});
ctx.completeNow();
}));
}
Aggregations