VWO implements VWODownloader.DownloadResult, PreviewListener { @Nullable public static String getVariationNameForTestKey(@NonNull String testKey) { if (TextUtils.isEmpty(testKey)) { VWOLog.w(VWOLog.INITIALIZATION_LOGS, "testKey cannot be null or empty", false); return null; } Variation variation = null; String message = ""; synchronized (lock) { if (sSharedInstance != null) { if (sSharedInstance.mVWOStartState >= STARTED) { variation = sSharedInstance.getVwoData().getVariationForCampaign(testKey); } else if (sSharedInstance.mVWOStartState == OPTED_OUT) { message = "User opted out."; } else if (sSharedInstance.mVWOStartState == FAILED) { message = "SDK failed to Initialize."; } else { message = "SDK is initializing"; } } else { message = "SDK is not initialized"; } } if (variation == null) { VWOLog.w(VWOLog.DATA_LOGS, String.format(Locale.ENGLISH, "No campaign found for given test key : %s, reason: %s", testKey, !TextUtils.isEmpty(message) ? message : "Campaign does not exist."), false); return null; } else { return variation.getName(); } } private  VWO(@NonNull Context context, @NonNull VWOConfig vwoConfig); static Initializer with(@NonNull Context context, @NonNull String apiKey); @Nullable static String getVariationNameForTestKey(@NonNull String testKey); static int getIntegerForKey(@NonNull String key, int defaultValue); static String getStringForKey(@NonNull String key, @Nullable String defaultValue); static double getDoubleForKey(@NonNull String key, double defaultValue); static boolean getBooleanForKey(@NonNull String key, boolean defaultValue); @Deprecated @Nullable static Object getVariationForKey(@NonNull String key, @Nullable Object defaultValue); static Object getObjectForKey(@NonNull String key, @Nullable Object defaultValue); static void trackConversion(@NonNull String goalIdentifier); static void trackConversion(@NonNull String goalIdentifier, double value); static void setCustomVariable(@NonNull String key, @NonNull String value); static String version(); static int versionCode(); @Override void onDownloadSuccess(@Nullable String data); @Override void onDownloadError(@Nullable Exception exception, @Nullable String message); @Override void onPreviewEnabled(); @Override void onPreviewDisabled(); @NonNull Context getCurrentContext(); VWOUrlBuilder getVwoUrlBuilder(); @Nullable VWOConfig getConfig(); @Connection.State int getState(); VWOMessageQueue getMessageQueue(); VWOMessageQueue getFailureQueue(); VWOPreference getVwoPreference();  }
@Test public void variationNameForTestKeyTest() { Assert.assertEquals("third", VWO.getVariationNameForTestKey("demoapp")); Assert.assertEquals("second", VWO.getVariationNameForTestKey("default_value_test")); Assert.assertNotSame("third", VWO.getVariationNameForTestKey("default_value_test")); Assert.assertNull(VWO.getVariationNameForTestKey("demo")); }