@Override public void run() { future.complete(IdHelper.getInstallId()); } }, new Runnable() {
@Test public void idHelper() { new IdHelper(); }
/** * Overloaded constructor with limited visibility that allows for dependency injection. * * @param context The context. * @param appSecret The application secret. * @param persistence Persistence object for dependency injection. * @param ingestion Ingestion object for dependency injection. * @param appCenterHandler App Center looper thread handler. */ @VisibleForTesting DefaultChannel(@NonNull Context context, String appSecret, @NonNull Persistence persistence, @NonNull Ingestion ingestion, @NonNull Handler appCenterHandler) { mContext = context; mAppSecret = appSecret; mInstallId = IdHelper.getInstallId(); mGroupStates = new HashMap<>(); mListeners = new LinkedHashSet<>(); mPersistence = persistence; mIngestion = ingestion; mIngestions = new HashSet<>(); mIngestions.add(mIngestion); mAppCenterHandler = appCenterHandler; mEnabled = true; }
@Test public void getInstallId() { Log.i(TAG, "Testing installId-shortcut"); UUID expected = UUIDUtils.randomUUID(); SharedPreferencesManager.putString(PrefStorageConstants.KEY_INSTALL_ID, expected.toString()); UUID actual = IdHelper.getInstallId(); assertEquals(expected, actual); String wrongUUID = "1234567"; SharedPreferencesManager.putString(PrefStorageConstants.KEY_INSTALL_ID, expected.toString()); actual = IdHelper.getInstallId(); assertNotEquals(wrongUUID, actual); assertNotNull(actual); } }
mChannel.setLogUrl(mLogUrl); mChannel.addListener(new OneCollectorChannelListener(mApplication, mChannel, mLogSerializer, IdHelper.getInstallId()));