@Test public void testUnrecognizedInstallSourceIsParsedCorrectly() { final String unrecognizedInstallerPackageName = "com.unrecognized"; final InstallSource installSource = InstallSource.fromInstallerPackageName(unrecognizedInstallerPackageName); assertTrue( "Non-null package name is correctly identified as an unrecognized install source", installSource instanceof UnrecognizedInstallSource); assertEquals( "Unrecognized install source returns raw package name as description", unrecognizedInstallerPackageName, installSource.toString()); }
@NonNull static InstallSource fromInstallerPackageName(@Nullable final String installerPackageName) { if (GOOGLE_PLAY_STORE_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new GooglePlayStoreInstallSource(); } else if (AMAZON_APP_STORE_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new AmazonAppStoreInstallSource(); } else if (AMAZON_UNDERGROUND_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new AmazonUndergroundInstallSource(); } else if (PACKAGE_INSTALLER_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new PackageInstallerInstallSource(); } else if (installerPackageName != null) { return new UnrecognizedInstallSource(installerPackageName); } else { return new UnknownInstallSource(); } }
InstallSource { @NonNull static InstallSource fromInstallerPackageName(@Nullable final String installerPackageName) { if (GOOGLE_PLAY_STORE_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new GooglePlayStoreInstallSource(); } else if (AMAZON_APP_STORE_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new AmazonAppStoreInstallSource(); } else if (AMAZON_UNDERGROUND_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new AmazonUndergroundInstallSource(); } else if (PACKAGE_INSTALLER_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new PackageInstallerInstallSource(); } else if (installerPackageName != null) { return new UnrecognizedInstallSource(installerPackageName); } else { return new UnknownInstallSource(); } } }
InstallSource { @NonNull static InstallSource fromInstallerPackageName(@Nullable final String installerPackageName) { if (GOOGLE_PLAY_STORE_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new GooglePlayStoreInstallSource(); } else if (AMAZON_APP_STORE_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new AmazonAppStoreInstallSource(); } else if (AMAZON_UNDERGROUND_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new AmazonUndergroundInstallSource(); } else if (PACKAGE_INSTALLER_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new PackageInstallerInstallSource(); } else if (installerPackageName != null) { return new UnrecognizedInstallSource(installerPackageName); } else { return new UnknownInstallSource(); } } private  InstallSource(); }
InstallSource { @NonNull static InstallSource fromInstallerPackageName(@Nullable final String installerPackageName) { if (GOOGLE_PLAY_STORE_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new GooglePlayStoreInstallSource(); } else if (AMAZON_APP_STORE_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new AmazonAppStoreInstallSource(); } else if (AMAZON_UNDERGROUND_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new AmazonUndergroundInstallSource(); } else if (PACKAGE_INSTALLER_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new PackageInstallerInstallSource(); } else if (installerPackageName != null) { return new UnrecognizedInstallSource(installerPackageName); } else { return new UnknownInstallSource(); } } private  InstallSource();  }
InstallSource { @NonNull static InstallSource fromInstallerPackageName(@Nullable final String installerPackageName) { if (GOOGLE_PLAY_STORE_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new GooglePlayStoreInstallSource(); } else if (AMAZON_APP_STORE_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new AmazonAppStoreInstallSource(); } else if (AMAZON_UNDERGROUND_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new AmazonUndergroundInstallSource(); } else if (PACKAGE_INSTALLER_PACKAGE_NAME.equalsIgnoreCase(installerPackageName)) { return new PackageInstallerInstallSource(); } else if (installerPackageName != null) { return new UnrecognizedInstallSource(installerPackageName); } else { return new UnknownInstallSource(); } } private  InstallSource();   }