### Question:
IotivityRepository { public Observable<Device> scanOwnedDevices() { return Completable.create(emitter -> { Timber.d("Discovering owned devices"); ownedDevices.clear(); OCObtDiscoveryHandler handler = (uuid, endpoints) -> { String deviceId = OCUuidUtil.uuidToString(uuid); Timber.d("Discovered owned device: "+ deviceId); DeviceEntity device = deviceDao.findById(deviceId).blockingGet(); if (device == null) { deviceDao.insert(new DeviceEntity(deviceId, "", endpoints, DeviceType.OWNED_BY_SELF, Device.FULL_PERMITS)); } else { deviceDao.insert(new DeviceEntity(deviceId, device.getName(), endpoints, DeviceType.OWNED_BY_SELF, Device.FULL_PERMITS)); } Device device1 = new Device(DeviceType.OWNED_BY_SELF, deviceId, new OcDeviceInfo(), endpoints, Device.FULL_PERMITS); if (!ownedDevices.contains(device1)) { ownedDevices.add(device1); } }; int ret; String scope = preferencesRepository.getDiscoveryScope(); if (scope.equals(DiscoveryScope.DISCOVERY_SCOPE_SITE)) { ret = OCObt.discoverOwnedDevicesSiteLocalIPv6(handler); } else if (scope.equals(DiscoveryScope.DISCOVERY_SCOPE_REALM)) { ret = OCObt.discoverOwnedDevicesRealmLocalIPv6(handler); } else { ret = OCObt.discoverOwnedDevices(handler); } if (ret < 0) { String error = "ERROR discovering owned Devices."; Timber.e(error); emitter.onError(new Exception(error)); } }).timeout(getDiscoveryTimeout(), TimeUnit.SECONDS) .onErrorComplete() .andThen(Observable.fromIterable(ownedDevices)); } @Inject  IotivityRepository(Context ctx, DeviceDao deviceDao, PreferencesRepository prefRepository); Completable initOICStack(); Single<String> getDeviceId(); Completable setFactoryResetHandler(OCFactoryPresetsHandler handler); Observable<Device> scanUnownedDevices(); Observable<Device> scanOwnedDevices(); Completable scanHosts(); Observable<Device> scanOwnedByOtherDevices(); Single<String> getNonSecureEndpoint(Device device); Single<String> getSecureEndpoint(Device device); Single<String> getNonSecureEndpoint(List<String> endpoints); Single<String> getSecureEndpoint(List<String> endpoints); Single<OcDeviceInfo> getDeviceInfo(String endpoint); Single<OcPlatformInfo> getPlatformInfo(String endpoint); Single<String> getDeviceName(String deviceId); Completable setDeviceName(String deviceId, String deviceName); Completable updateDeviceType(String deviceId, DeviceType type, int permits); Maybe<DeviceEntity> getDeviceFromDatabase(String deviceId); int getDiscoveryTimeout(); Single<List<OcResource>> findVerticalResources(String host); Single<OcRes> findResources(String host); Observable<OcResource> discoverAllResources(String deviceId); Single<List<OcResource>> discoverVerticalResources(String deviceId); Single<OcRes> findResource(String host, String resourceType); Single<OCRepresentation> get(String host, String uri, String deviceId); Completable post(String host, String uri, String deviceId, OCRepresentation rep, Object valueArray); Completable post(String host, String uri, String deviceId, Map<String, Object> values); void close();  }### Answer:
@Test public void scanOwnedDevices() { }