MapBasedDeviceConnectionService implements DeviceConnectionService { @Override public final Future<DeviceConnectionResult> getLastKnownGatewayForDevice(final String tenantId, final String deviceId, final Span span) { Objects.requireNonNull(tenantId); Objects.requireNonNull(deviceId); final Map<String, JsonObject> lastKnownGatewaysForTenantMap = lastKnownGatewaysMap.get(tenantId); final DeviceConnectionResult result; if (lastKnownGatewaysForTenantMap != null) { final JsonObject lastKnownGatewayJson = lastKnownGatewaysForTenantMap.get(deviceId); if (lastKnownGatewayJson != null) { result = DeviceConnectionResult.from(HttpURLConnection.HTTP_OK, lastKnownGatewayJson); } else { result = DeviceConnectionResult.from(HttpURLConnection.HTTP_NOT_FOUND); } } else { result = DeviceConnectionResult.from(HttpURLConnection.HTTP_NOT_FOUND); } return Future.succeededFuture(result); }  @Autowired void setConfig(final MapBasedDeviceConnectionsConfigProperties configuration); MapBasedDeviceConnectionsConfigProperties getConfig(); @Override final Future<DeviceConnectionResult> setLastKnownGatewayForDevice(final String tenantId, final String deviceId,
            final String gatewayId, final Span span); @Override final Future<DeviceConnectionResult> getLastKnownGatewayForDevice(final String tenantId, final String deviceId,
            final Span span); @Override final Future<DeviceConnectionResult> setCommandHandlingAdapterInstance(final String tenantId,
            final String deviceId, final String protocolAdapterInstanceId, final Duration lifespan, final Span span); @Override final Future<DeviceConnectionResult> removeCommandHandlingAdapterInstance(
            final String tenantId,
            final String deviceId,
            final String adapterInstanceId,
            final Span span); @Override final Future<DeviceConnectionResult> getCommandHandlingAdapterInstances(final String tenantId,
            final String deviceId, final List<String> viaGateways, final Span span);  }
@Test public void testGetLastKnownGatewayForDeviceNotFound(final VertxTestContext ctx) { final String deviceId = "testDevice"; svc.getLastKnownGatewayForDevice(Constants.DEFAULT_TENANT, deviceId, span) .onComplete(ctx.succeeding(deviceConnectionResult -> ctx.verify(() -> { assertEquals(HttpURLConnection.HTTP_NOT_FOUND, deviceConnectionResult.getStatus()); assertNull(deviceConnectionResult.getPayload()); ctx.completeNow(); }))); }