use of org.eclipse.hono.service.management.Filter in project hono by eclipse.
the class AbstractDeviceManagementSearchDevicesTest method testSearchDevicesWithWildCardToMatchMultipleCharacters.
/**
* Verifies that a request to search devices with filters containing the wildcard character '*'
* succeeds and matching devices are found.
*
* @param ctx The vert.x test context.
*/
@Test
default void testSearchDevicesWithWildCardToMatchMultipleCharacters(final VertxTestContext ctx) {
final String tenantId = DeviceRegistryUtils.getUniqueIdentifier();
final int pageSize = 10;
final int pageOffset = 0;
final Filter filter1 = new Filter("/id", "test*-*");
final Filter filter2 = new Filter("/ext/value", "test$1*e");
final Sort sortOption = new Sort("/id");
createDevices(tenantId, Map.of("testDevice", new Device(), "testDevice-1", new Device().setExtensions(Map.of("value", "test$1Value")), "testDevice-2", new Device().setExtensions(Map.of("value", "test$2Value")))).compose(ok -> getDeviceManagementService().searchDevices(tenantId, 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<DeviceWithId> searchResult = s.getPayload();
assertThat(searchResult.getTotal()).isEqualTo(1);
assertThat(searchResult.getResult()).hasSize(1);
assertThat(searchResult.getResult().get(0).getId()).isEqualTo("testDevice-1");
});
ctx.completeNow();
})));
}
Aggregations