@Test public void givenNoEntriesForPackageNameWereGenerated_whenGetPackageNameWithAssociatedCertificate_thenReturnsAnAbsentOptional() { final Optional<String> optionalPackageNameWithAssociatedCertificate = testPackageNameTrie.getPackageNameWithAssociatedCertificate(TEST_PACKAGE_NAME); assertThat(optionalPackageNameWithAssociatedCertificate, equalTo(Optional.<String>absent())); }
final Optional<String> getPackageNameWithAssociatedCertificate(String packageName) { String currentPackageName = packageName; if (!packageNameToHasCertificateMap.containsKey(currentPackageName)) return Optional.absent(); while (!packageNameToHasCertificateMap.get(currentPackageName)) { currentPackageName = getUpALevel(currentPackageName); if (currentPackageName.equals("")) { Log.d(TAG_PACKAGE_NAME_TRIE, "There is no prefix associated with a certificate " + "for package name " + packageName); return Optional.absent(); } } Log.d(TAG_PACKAGE_NAME_TRIE, currentPackageName + " is the closest package name to the target " + packageName + " with an associated certificate for verification."); return Optional.of(currentPackageName); }
PackageNameTrie { final Optional<String> getPackageNameWithAssociatedCertificate(String packageName) { String currentPackageName = packageName; if (!packageNameToHasCertificateMap.containsKey(currentPackageName)) return Optional.absent(); while (!packageNameToHasCertificateMap.get(currentPackageName)) { currentPackageName = getUpALevel(currentPackageName); if (currentPackageName.equals("")) { Log.d(TAG_PACKAGE_NAME_TRIE, "There is no prefix associated with a certificate " + "for package name " + packageName); return Optional.absent(); } } Log.d(TAG_PACKAGE_NAME_TRIE, currentPackageName + " is the closest package name to the target " + packageName + " with an associated certificate for verification."); return Optional.of(currentPackageName); } }
PackageNameTrie { final Optional<String> getPackageNameWithAssociatedCertificate(String packageName) { String currentPackageName = packageName; if (!packageNameToHasCertificateMap.containsKey(currentPackageName)) return Optional.absent(); while (!packageNameToHasCertificateMap.get(currentPackageName)) { currentPackageName = getUpALevel(currentPackageName); if (currentPackageName.equals("")) { Log.d(TAG_PACKAGE_NAME_TRIE, "There is no prefix associated with a certificate " + "for package name " + packageName); return Optional.absent(); } } Log.d(TAG_PACKAGE_NAME_TRIE, currentPackageName + " is the closest package name to the target " + packageName + " with an associated certificate for verification."); return Optional.of(currentPackageName); } PackageNameTrie(); }
PackageNameTrie { final Optional<String> getPackageNameWithAssociatedCertificate(String packageName) { String currentPackageName = packageName; if (!packageNameToHasCertificateMap.containsKey(currentPackageName)) return Optional.absent(); while (!packageNameToHasCertificateMap.get(currentPackageName)) { currentPackageName = getUpALevel(currentPackageName); if (currentPackageName.equals("")) { Log.d(TAG_PACKAGE_NAME_TRIE, "There is no prefix associated with a certificate " + "for package name " + packageName); return Optional.absent(); } } Log.d(TAG_PACKAGE_NAME_TRIE, currentPackageName + " is the closest package name to the target " + packageName + " with an associated certificate for verification."); return Optional.of(currentPackageName); } PackageNameTrie();  }
PackageNameTrie { final Optional<String> getPackageNameWithAssociatedCertificate(String packageName) { String currentPackageName = packageName; if (!packageNameToHasCertificateMap.containsKey(currentPackageName)) return Optional.absent(); while (!packageNameToHasCertificateMap.get(currentPackageName)) { currentPackageName = getUpALevel(currentPackageName); if (currentPackageName.equals("")) { Log.d(TAG_PACKAGE_NAME_TRIE, "There is no prefix associated with a certificate " + "for package name " + packageName); return Optional.absent(); } } Log.d(TAG_PACKAGE_NAME_TRIE, currentPackageName + " is the closest package name to the target " + packageName + " with an associated certificate for verification."); return Optional.of(currentPackageName); } PackageNameTrie();   }