target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void urlsMatchExceptForTrailingSlash() throws Exception { assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertTrue(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertFalse(UrlUtils.urlsMatchExceptForTrailingSlash("http: assertFalse(...
public static boolean urlsMatchExceptForTrailingSlash(final @NonNull String url1, final @NonNull String url2) { int lengthDifference = url1.length() - url2.length(); if (lengthDifference == 0) { return url1.equalsIgnoreCase(url2); } else if (lengthDifference == 1) { return url1.charAt(url1.length() - 1) == '/' && url1....
UrlUtils { public static boolean urlsMatchExceptForTrailingSlash(final @NonNull String url1, final @NonNull String url2) { int lengthDifference = url1.length() - url2.length(); if (lengthDifference == 0) { return url1.equalsIgnoreCase(url2); } else if (lengthDifference == 1) { return url1.charAt(url1.length() - 1) == '...
UrlUtils { public static boolean urlsMatchExceptForTrailingSlash(final @NonNull String url1, final @NonNull String url2) { int lengthDifference = url1.length() - url2.length(); if (lengthDifference == 0) { return url1.equalsIgnoreCase(url2); } else if (lengthDifference == 1) { return url1.charAt(url1.length() - 1) == '...
UrlUtils { public static boolean urlsMatchExceptForTrailingSlash(final @NonNull String url1, final @NonNull String url2) { int lengthDifference = url1.length() - url2.length(); if (lengthDifference == 0) { return url1.equalsIgnoreCase(url2); } else if (lengthDifference == 1) { return url1.charAt(url1.length() - 1) == '...
UrlUtils { public static boolean urlsMatchExceptForTrailingSlash(final @NonNull String url1, final @NonNull String url2) { int lengthDifference = url1.length() - url2.length(); if (lengthDifference == 0) { return url1.equalsIgnoreCase(url2); } else if (lengthDifference == 1) { return url1.charAt(url1.length() - 1) == '...
@Test public void testLanguage() { assertEquals("en", Locales.getLanguage(Locale.ENGLISH)); }
public static String getLanguage(final Locale locale) { final String language = locale.getLanguage(); if (language.equals("iw")) { return "he"; } if (language.equals("in")) { return "id"; } if (language.equals("ji")) { return "yi"; } return language; }
Locales { public static String getLanguage(final Locale locale) { final String language = locale.getLanguage(); if (language.equals("iw")) { return "he"; } if (language.equals("in")) { return "id"; } if (language.equals("ji")) { return "yi"; } return language; } }
Locales { public static String getLanguage(final Locale locale) { final String language = locale.getLanguage(); if (language.equals("iw")) { return "he"; } if (language.equals("in")) { return "id"; } if (language.equals("ji")) { return "yi"; } return language; } }
Locales { public static String getLanguage(final Locale locale) { final String language = locale.getLanguage(); if (language.equals("iw")) { return "he"; } if (language.equals("in")) { return "id"; } if (language.equals("ji")) { return "yi"; } return language; } static void initializeLocale(Context context); static St...
Locales { public static String getLanguage(final Locale locale) { final String language = locale.getLanguage(); if (language.equals("iw")) { return "he"; } if (language.equals("in")) { return "id"; } if (language.equals("ji")) { return "yi"; } return language; } static void initializeLocale(Context context); static St...
@Test public void testNormalize() { assertEquals("http: assertEquals("https: assertEquals("https: assertEquals("file: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: assertEquals("http: for (final String supported : SupportUtils.SUPPORTED_URLS) { assertEquals(supported, SupportUtils.norm...
public static String normalize(@NonNull String input) { String trimmedInput = input.trim(); Uri uri = Uri.parse(trimmedInput); for (final String s : SupportUtils.SUPPORTED_URLS) { if (s.equals(input)) { return input; } } if (TextUtils.isEmpty(uri.getScheme())) { uri = Uri.parse("http: } return uri.toString(); }
SupportUtils { public static String normalize(@NonNull String input) { String trimmedInput = input.trim(); Uri uri = Uri.parse(trimmedInput); for (final String s : SupportUtils.SUPPORTED_URLS) { if (s.equals(input)) { return input; } } if (TextUtils.isEmpty(uri.getScheme())) { uri = Uri.parse("http: } return uri.toStri...
SupportUtils { public static String normalize(@NonNull String input) { String trimmedInput = input.trim(); Uri uri = Uri.parse(trimmedInput); for (final String s : SupportUtils.SUPPORTED_URLS) { if (s.equals(input)) { return input; } } if (TextUtils.isEmpty(uri.getScheme())) { uri = Uri.parse("http: } return uri.toStri...
SupportUtils { public static String normalize(@NonNull String input) { String trimmedInput = input.trim(); Uri uri = Uri.parse(trimmedInput); for (final String s : SupportUtils.SUPPORTED_URLS) { if (s.equals(input)) { return input; } } if (TextUtils.isEmpty(uri.getScheme())) { uri = Uri.parse("http: } return uri.toStri...
SupportUtils { public static String normalize(@NonNull String input) { String trimmedInput = input.trim(); Uri uri = Uri.parse(trimmedInput); for (final String s : SupportUtils.SUPPORTED_URLS) { if (s.equals(input)) { return input; } } if (TextUtils.isEmpty(uri.getScheme())) { uri = Uri.parse("http: } return uri.toStri...
@Test public void testIsUrl() { assertTrue(SupportUtils.isUrl("http: assertTrue(SupportUtils.isUrl("https: assertTrue(SupportUtils.isUrl("https: assertTrue(SupportUtils.isUrl(" https: assertTrue(SupportUtils.isUrl(" https: assertTrue(SupportUtils.isUrl("https: assertTrue(SupportUtils.isUrl("file: assertTrue(SupportUtil...
public static boolean isUrl(@Nullable String url) { if (TextUtils.isEmpty(url)) { return false; } final String trimmedUrl = url.trim().toLowerCase(Locale.getDefault()); if (trimmedUrl.contains(" ")) { return false; } for (final String s : SupportUtils.SUPPORTED_URLS) { if (s.equals(trimmedUrl)) { return true; } } Uri u...
SupportUtils { public static boolean isUrl(@Nullable String url) { if (TextUtils.isEmpty(url)) { return false; } final String trimmedUrl = url.trim().toLowerCase(Locale.getDefault()); if (trimmedUrl.contains(" ")) { return false; } for (final String s : SupportUtils.SUPPORTED_URLS) { if (s.equals(trimmedUrl)) { return ...
SupportUtils { public static boolean isUrl(@Nullable String url) { if (TextUtils.isEmpty(url)) { return false; } final String trimmedUrl = url.trim().toLowerCase(Locale.getDefault()); if (trimmedUrl.contains(" ")) { return false; } for (final String s : SupportUtils.SUPPORTED_URLS) { if (s.equals(trimmedUrl)) { return ...
SupportUtils { public static boolean isUrl(@Nullable String url) { if (TextUtils.isEmpty(url)) { return false; } final String trimmedUrl = url.trim().toLowerCase(Locale.getDefault()); if (trimmedUrl.contains(" ")) { return false; } for (final String s : SupportUtils.SUPPORTED_URLS) { if (s.equals(trimmedUrl)) { return ...
SupportUtils { public static boolean isUrl(@Nullable String url) { if (TextUtils.isEmpty(url)) { return false; } final String trimmedUrl = url.trim().toLowerCase(Locale.getDefault()); if (trimmedUrl.contains(" ")) { return false; } for (final String s : SupportUtils.SUPPORTED_URLS) { if (s.equals(trimmedUrl)) { return ...
@Test public void getSumoURLForTopic() throws Exception { final String appVersion; try { appVersion = ApplicationProvider.getApplicationContext().getPackageManager().getPackageInfo(ApplicationProvider.getApplicationContext().getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { throw new ...
public static String getSumoURLForTopic(final Context context, final String topic) { String escapedTopic; try { escapedTopic = URLEncoder.encode(topic, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("utf-8 should always be available", e); } final String appVersion; try { appVersion...
SupportUtils { public static String getSumoURLForTopic(final Context context, final String topic) { String escapedTopic; try { escapedTopic = URLEncoder.encode(topic, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("utf-8 should always be available", e); } final String appVersion; t...
SupportUtils { public static String getSumoURLForTopic(final Context context, final String topic) { String escapedTopic; try { escapedTopic = URLEncoder.encode(topic, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("utf-8 should always be available", e); } final String appVersion; t...
SupportUtils { public static String getSumoURLForTopic(final Context context, final String topic) { String escapedTopic; try { escapedTopic = URLEncoder.encode(topic, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("utf-8 should always be available", e); } final String appVersion; t...
SupportUtils { public static String getSumoURLForTopic(final Context context, final String topic) { String escapedTopic; try { escapedTopic = URLEncoder.encode(topic, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new IllegalStateException("utf-8 should always be available", e); } final String appVersion; t...
@Test public void getManifestoURL() throws Exception { Locale.setDefault(Locale.UK); assertEquals("https: SupportUtils.getManifestoURL()); Locale.setDefault(Locale.KOREA); assertEquals("https: SupportUtils.getManifestoURL()); }
public static String getManifestoURL() { final String langTag = Locales.getLanguageTag(Locale.getDefault()); return "https: }
SupportUtils { public static String getManifestoURL() { final String langTag = Locales.getLanguageTag(Locale.getDefault()); return "https: } }
SupportUtils { public static String getManifestoURL() { final String langTag = Locales.getLanguageTag(Locale.getDefault()); return "https: } }
SupportUtils { public static String getManifestoURL() { final String langTag = Locales.getLanguageTag(Locale.getDefault()); return "https: } static String normalize(@NonNull String input); static boolean isUrl(@Nullable String url); static boolean isTemplateSupportPages(String url); static String getSumoURLForTopic(fi...
SupportUtils { public static String getManifestoURL() { final String langTag = Locales.getLanguageTag(Locale.getDefault()); return "https: } static String normalize(@NonNull String input); static boolean isUrl(@Nullable String url); static boolean isTemplateSupportPages(String url); static String getSumoURLForTopic(fi...
@Test public void testGetReadableTextColor() { assertEquals(Color.BLACK, ColorUtils.getReadableTextColor(Color.WHITE)); assertEquals(Color.WHITE, ColorUtils.getReadableTextColor(Color.BLACK)); assertEquals(Color.BLACK, ColorUtils.getReadableTextColor(0xfff6f4ec)); assertEquals(Color.WHITE, ColorUtils.getReadableTextCol...
public static int getReadableTextColor(final int backgroundColor) { final int greyValue = grayscaleFromRGB(backgroundColor); if (greyValue < 186) { return Color.WHITE; } else { return Color.BLACK; } }
ColorUtils { public static int getReadableTextColor(final int backgroundColor) { final int greyValue = grayscaleFromRGB(backgroundColor); if (greyValue < 186) { return Color.WHITE; } else { return Color.BLACK; } } }
ColorUtils { public static int getReadableTextColor(final int backgroundColor) { final int greyValue = grayscaleFromRGB(backgroundColor); if (greyValue < 186) { return Color.WHITE; } else { return Color.BLACK; } } }
ColorUtils { public static int getReadableTextColor(final int backgroundColor) { final int greyValue = grayscaleFromRGB(backgroundColor); if (greyValue < 186) { return Color.WHITE; } else { return Color.BLACK; } } static int getReadableTextColor(final int backgroundColor); }
ColorUtils { public static int getReadableTextColor(final int backgroundColor) { final int greyValue = grayscaleFromRGB(backgroundColor); if (greyValue < 186) { return Color.WHITE; } else { return Color.BLACK; } } static int getReadableTextColor(final int backgroundColor); }
@Test public void testText() { assertTrue(MimeUtils.isText("text")); assertFalse(MimeUtils.isText("text/plain/")); assertFalse(MimeUtils.isText("text/plain*")); }
public static boolean isText(@Nullable String type) { return !TextUtils.isEmpty(type) && textPattern.matcher(type).find(); }
MimeUtils { public static boolean isText(@Nullable String type) { return !TextUtils.isEmpty(type) && textPattern.matcher(type).find(); } }
MimeUtils { public static boolean isText(@Nullable String type) { return !TextUtils.isEmpty(type) && textPattern.matcher(type).find(); } private MimeUtils(); }
MimeUtils { public static boolean isText(@Nullable String type) { return !TextUtils.isEmpty(type) && textPattern.matcher(type).find(); } private MimeUtils(); static boolean isText(@Nullable String type); static boolean isImage(@Nullable String type); static boolean isAudio(@Nullable String type); static boolean isVide...
MimeUtils { public static boolean isText(@Nullable String type) { return !TextUtils.isEmpty(type) && textPattern.matcher(type).find(); } private MimeUtils(); static boolean isText(@Nullable String type); static boolean isImage(@Nullable String type); static boolean isAudio(@Nullable String type); static boolean isVide...
@Test public void testImage() { assertTrue(MimeUtils.isImage("image")); assertFalse(MimeUtils.isImage("image/png/")); assertFalse(MimeUtils.isImage("image/png*")); }
public static boolean isImage(@Nullable String type) { return !TextUtils.isEmpty(type) && imgPattern.matcher(type).find(); }
MimeUtils { public static boolean isImage(@Nullable String type) { return !TextUtils.isEmpty(type) && imgPattern.matcher(type).find(); } }
MimeUtils { public static boolean isImage(@Nullable String type) { return !TextUtils.isEmpty(type) && imgPattern.matcher(type).find(); } private MimeUtils(); }
MimeUtils { public static boolean isImage(@Nullable String type) { return !TextUtils.isEmpty(type) && imgPattern.matcher(type).find(); } private MimeUtils(); static boolean isText(@Nullable String type); static boolean isImage(@Nullable String type); static boolean isAudio(@Nullable String type); static boolean isVide...
MimeUtils { public static boolean isImage(@Nullable String type) { return !TextUtils.isEmpty(type) && imgPattern.matcher(type).find(); } private MimeUtils(); static boolean isText(@Nullable String type); static boolean isImage(@Nullable String type); static boolean isAudio(@Nullable String type); static boolean isVide...
@Test public void testAudio() { assertTrue(MimeUtils.isAudio("audio")); assertFalse(MimeUtils.isAudio("audio/mp3/")); assertFalse(MimeUtils.isAudio("audio/mp3*")); }
public static boolean isAudio(@Nullable String type) { return !TextUtils.isEmpty(type) && audioPattern.matcher(type).find(); }
MimeUtils { public static boolean isAudio(@Nullable String type) { return !TextUtils.isEmpty(type) && audioPattern.matcher(type).find(); } }
MimeUtils { public static boolean isAudio(@Nullable String type) { return !TextUtils.isEmpty(type) && audioPattern.matcher(type).find(); } private MimeUtils(); }
MimeUtils { public static boolean isAudio(@Nullable String type) { return !TextUtils.isEmpty(type) && audioPattern.matcher(type).find(); } private MimeUtils(); static boolean isText(@Nullable String type); static boolean isImage(@Nullable String type); static boolean isAudio(@Nullable String type); static boolean isVi...
MimeUtils { public static boolean isAudio(@Nullable String type) { return !TextUtils.isEmpty(type) && audioPattern.matcher(type).find(); } private MimeUtils(); static boolean isText(@Nullable String type); static boolean isImage(@Nullable String type); static boolean isAudio(@Nullable String type); static boolean isVi...
@Test public void testVideo() { assertTrue(MimeUtils.isVideo("video")); assertFalse(MimeUtils.isVideo("video/mp4/")); assertFalse(MimeUtils.isVideo("video/mp4*")); }
public static boolean isVideo(@Nullable String type) { return !TextUtils.isEmpty(type) && videoPattern.matcher(type).find(); }
MimeUtils { public static boolean isVideo(@Nullable String type) { return !TextUtils.isEmpty(type) && videoPattern.matcher(type).find(); } }
MimeUtils { public static boolean isVideo(@Nullable String type) { return !TextUtils.isEmpty(type) && videoPattern.matcher(type).find(); } private MimeUtils(); }
MimeUtils { public static boolean isVideo(@Nullable String type) { return !TextUtils.isEmpty(type) && videoPattern.matcher(type).find(); } private MimeUtils(); static boolean isText(@Nullable String type); static boolean isImage(@Nullable String type); static boolean isAudio(@Nullable String type); static boolean isVi...
MimeUtils { public static boolean isVideo(@Nullable String type) { return !TextUtils.isEmpty(type) && videoPattern.matcher(type).find(); } private MimeUtils(); static boolean isText(@Nullable String type); static boolean isImage(@Nullable String type); static boolean isAudio(@Nullable String type); static boolean isVi...
@Test public void isPermittedResourceProtocol() { assertTrue(UrlUtils.isPermittedResourceProtocol("http")); assertTrue(UrlUtils.isPermittedResourceProtocol("https")); assertTrue(UrlUtils.isPermittedResourceProtocol("data")); assertTrue(UrlUtils.isPermittedResourceProtocol("file")); assertFalse(UrlUtils.isPermittedResou...
public static boolean isPermittedResourceProtocol(@NonNull final String scheme) { if (TextUtils.isEmpty(scheme)) { return false; } return scheme.startsWith("http") || scheme.startsWith("https") || scheme.startsWith("file") || scheme.startsWith("data"); }
UrlUtils { public static boolean isPermittedResourceProtocol(@NonNull final String scheme) { if (TextUtils.isEmpty(scheme)) { return false; } return scheme.startsWith("http") || scheme.startsWith("https") || scheme.startsWith("file") || scheme.startsWith("data"); } }
UrlUtils { public static boolean isPermittedResourceProtocol(@NonNull final String scheme) { if (TextUtils.isEmpty(scheme)) { return false; } return scheme.startsWith("http") || scheme.startsWith("https") || scheme.startsWith("file") || scheme.startsWith("data"); } }
UrlUtils { public static boolean isPermittedResourceProtocol(@NonNull final String scheme) { if (TextUtils.isEmpty(scheme)) { return false; } return scheme.startsWith("http") || scheme.startsWith("https") || scheme.startsWith("file") || scheme.startsWith("data"); } static boolean isHttpOrHttps(String url); static bool...
UrlUtils { public static boolean isPermittedResourceProtocol(@NonNull final String scheme) { if (TextUtils.isEmpty(scheme)) { return false; } return scheme.startsWith("http") || scheme.startsWith("https") || scheme.startsWith("file") || scheme.startsWith("data"); } static boolean isHttpOrHttps(String url); static bool...
@Test public void testSanity() { Assert.assertFalse(new TabEntity(null, null).isValid()); Assert.assertFalse(new TabEntity(null, null, "title", "").isValid()); Assert.assertFalse(new TabEntity(null, null, null, "url").isValid()); Assert.assertFalse(new TabEntity("id", null, null, null).isValid()); Assert.assertTrue(new...
public boolean isValid() { final boolean hasId = !TextUtils.isEmpty(this.getId()); final boolean hasUrl = !TextUtils.isEmpty(this.getUrl()); return hasId && hasUrl; }
TabEntity { public boolean isValid() { final boolean hasId = !TextUtils.isEmpty(this.getId()); final boolean hasUrl = !TextUtils.isEmpty(this.getUrl()); return hasId && hasUrl; } }
TabEntity { public boolean isValid() { final boolean hasId = !TextUtils.isEmpty(this.getId()); final boolean hasUrl = !TextUtils.isEmpty(this.getUrl()); return hasId && hasUrl; } @Ignore TabEntity(String id, String parentId); TabEntity(String id, String parentId, String title, String url); }
TabEntity { public boolean isValid() { final boolean hasId = !TextUtils.isEmpty(this.getId()); final boolean hasUrl = !TextUtils.isEmpty(this.getUrl()); return hasId && hasUrl; } @Ignore TabEntity(String id, String parentId); TabEntity(String id, String parentId, String title, String url); @NonNull String getId(); vo...
TabEntity { public boolean isValid() { final boolean hasId = !TextUtils.isEmpty(this.getId()); final boolean hasUrl = !TextUtils.isEmpty(this.getUrl()); return hasId && hasUrl; } @Ignore TabEntity(String id, String parentId); TabEntity(String id, String parentId, String title, String url); @NonNull String getId(); vo...
@Test public void testSingleton() { assertNotNull(BrowsingSession.getInstance()); assertEquals(BrowsingSession.getInstance(), BrowsingSession.getInstance()); }
public static synchronized BrowsingSession getInstance() { if (instance == null) { instance = new BrowsingSession(); } return instance; }
BrowsingSession { public static synchronized BrowsingSession getInstance() { if (instance == null) { instance = new BrowsingSession(); } return instance; } }
BrowsingSession { public static synchronized BrowsingSession getInstance() { if (instance == null) { instance = new BrowsingSession(); } return instance; } private BrowsingSession(); }
BrowsingSession { public static synchronized BrowsingSession getInstance() { if (instance == null) { instance = new BrowsingSession(); } return instance; } private BrowsingSession(); static synchronized BrowsingSession getInstance(); void countBlockedTracker(); void setBlockedTrackerCount(int count); void resetTracker...
BrowsingSession { public static synchronized BrowsingSession getInstance() { if (instance == null) { instance = new BrowsingSession(); } return instance; } private BrowsingSession(); static synchronized BrowsingSession getInstance(); void countBlockedTracker(); void setBlockedTrackerCount(int count); void resetTracker...
@Test public void testParser() throws Exception { final InputStream stream = new FileInputStream(searchPluginPath); final SearchEngine searchEngine = SearchEngineParser.load(searchEngineIdentifier, stream); assertEquals(searchEngineIdentifier, searchEngine.getIdentifier()); assertNotNull(searchEngine.getName()); assert...
public static SearchEngine load(AssetManager assetManager, String identifier, String path) throws IOException { try (final InputStream stream = assetManager.open(path)) { return load(identifier, stream); } catch (XmlPullParserException e) { throw new AssertionError("Parser exception while reading " + path, e); } }
SearchEngineParser { public static SearchEngine load(AssetManager assetManager, String identifier, String path) throws IOException { try (final InputStream stream = assetManager.open(path)) { return load(identifier, stream); } catch (XmlPullParserException e) { throw new AssertionError("Parser exception while reading "...
SearchEngineParser { public static SearchEngine load(AssetManager assetManager, String identifier, String path) throws IOException { try (final InputStream stream = assetManager.open(path)) { return load(identifier, stream); } catch (XmlPullParserException e) { throw new AssertionError("Parser exception while reading "...
SearchEngineParser { public static SearchEngine load(AssetManager assetManager, String identifier, String path) throws IOException { try (final InputStream stream = assetManager.open(path)) { return load(identifier, stream); } catch (XmlPullParserException e) { throw new AssertionError("Parser exception while reading "...
SearchEngineParser { public static SearchEngine load(AssetManager assetManager, String identifier, String path) throws IOException { try (final InputStream stream = assetManager.open(path)) { return load(identifier, stream); } catch (XmlPullParserException e) { throw new AssertionError("Parser exception while reading "...
@Test public void matches() throws Exception { final UrlMatcher matcher = new UrlMatcher(new String[] { "bcd.random" }); assertTrue(matcher.matches(Uri.parse("http: assertTrue(matcher.matches(Uri.parse("http: assertTrue(matcher.matches(Uri.parse("http: assertTrue(matcher.matches(Uri.parse("http: assertTrue(matcher.matc...
public boolean matches(final Uri resourceURI, final Uri pageURI) { final String path = resourceURI.getPath(); if (path == null) { return false; } if (blockWebfonts) { for (final String extension : WEBFONT_EXTENSIONS) { if (path.endsWith(extension)) { return true; } } } final String resourceURLString = resourceURI.toStr...
UrlMatcher implements SharedPreferences.OnSharedPreferenceChangeListener { public boolean matches(final Uri resourceURI, final Uri pageURI) { final String path = resourceURI.getPath(); if (path == null) { return false; } if (blockWebfonts) { for (final String extension : WEBFONT_EXTENSIONS) { if (path.endsWith(extensio...
UrlMatcher implements SharedPreferences.OnSharedPreferenceChangeListener { public boolean matches(final Uri resourceURI, final Uri pageURI) { final String path = resourceURI.getPath(); if (path == null) { return false; } if (blockWebfonts) { for (final String extension : WEBFONT_EXTENSIONS) { if (path.endsWith(extensio...
UrlMatcher implements SharedPreferences.OnSharedPreferenceChangeListener { public boolean matches(final Uri resourceURI, final Uri pageURI) { final String path = resourceURI.getPath(); if (path == null) { return false; } if (blockWebfonts) { for (final String extension : WEBFONT_EXTENSIONS) { if (path.endsWith(extensio...
UrlMatcher implements SharedPreferences.OnSharedPreferenceChangeListener { public boolean matches(final Uri resourceURI, final Uri pageURI) { final String path = resourceURI.getPath(); if (path == null) { return false; } if (blockWebfonts) { for (final String extension : WEBFONT_EXTENSIONS) { if (path.endsWith(extensio...
@Test public void categoriesWork() { final Map<String, Trie> categories = new HashMap<>(); final Map<String, String> categoryPrefMap = new HashMap<>(); final int CAT_COUNT = 4; final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(ApplicationProvider.getApplicationContext()); { final Share...
public boolean matches(final Uri resourceURI, final Uri pageURI) { final String path = resourceURI.getPath(); if (path == null) { return false; } if (blockWebfonts) { for (final String extension : WEBFONT_EXTENSIONS) { if (path.endsWith(extension)) { return true; } } } final String resourceURLString = resourceURI.toStr...
UrlMatcher implements SharedPreferences.OnSharedPreferenceChangeListener { public boolean matches(final Uri resourceURI, final Uri pageURI) { final String path = resourceURI.getPath(); if (path == null) { return false; } if (blockWebfonts) { for (final String extension : WEBFONT_EXTENSIONS) { if (path.endsWith(extensio...
UrlMatcher implements SharedPreferences.OnSharedPreferenceChangeListener { public boolean matches(final Uri resourceURI, final Uri pageURI) { final String path = resourceURI.getPath(); if (path == null) { return false; } if (blockWebfonts) { for (final String extension : WEBFONT_EXTENSIONS) { if (path.endsWith(extensio...
UrlMatcher implements SharedPreferences.OnSharedPreferenceChangeListener { public boolean matches(final Uri resourceURI, final Uri pageURI) { final String path = resourceURI.getPath(); if (path == null) { return false; } if (blockWebfonts) { for (final String extension : WEBFONT_EXTENSIONS) { if (path.endsWith(extensio...
UrlMatcher implements SharedPreferences.OnSharedPreferenceChangeListener { public boolean matches(final Uri resourceURI, final Uri pageURI) { final String path = resourceURI.getPath(); if (path == null) { return false; } if (blockWebfonts) { for (final String extension : WEBFONT_EXTENSIONS) { if (path.endsWith(extensio...
@Test public void findNode() throws Exception { final Trie trie = Trie.createRootNode(); assertNull(trie.findNode(FocusString.create("hello"))); final Trie putNode = trie.put(FocusString.create("hello")); final Trie foundNode = trie.findNode(FocusString.create("hello")); assertNotNull(putNode); assertNotNull(foundNode)...
public Trie findNode(final FocusString string) { if (terminator) { if (string.length() == 0 || string.charAt(0) == '.') { return this; } } else if (string.length() == 0) { return null; } final Trie next = children.get(string.charAt(0)); if (next == null) { return null; } return next.findNode(string.substring(1)); }
Trie { public Trie findNode(final FocusString string) { if (terminator) { if (string.length() == 0 || string.charAt(0) == '.') { return this; } } else if (string.length() == 0) { return null; } final Trie next = children.get(string.charAt(0)); if (next == null) { return null; } return next.findNode(string.substring(1))...
Trie { public Trie findNode(final FocusString string) { if (terminator) { if (string.length() == 0 || string.charAt(0) == '.') { return this; } } else if (string.length() == 0) { return null; } final Trie next = children.get(string.charAt(0)); if (next == null) { return null; } return next.findNode(string.substring(1))...
Trie { public Trie findNode(final FocusString string) { if (terminator) { if (string.length() == 0 || string.charAt(0) == '.') { return this; } } else if (string.length() == 0) { return null; } final Trie next = children.get(string.charAt(0)); if (next == null) { return null; } return next.findNode(string.substring(1))...
Trie { public Trie findNode(final FocusString string) { if (terminator) { if (string.length() == 0 || string.charAt(0) == '.') { return this; } } else if (string.length() == 0) { return null; } final Trie next = children.get(string.charAt(0)); if (next == null) { return null; } return next.findNode(string.substring(1))...
@Test public void shouldInterceptRequest() throws Exception { trackingProtectionWebViewClient.notifyCurrentURL("http: { final WebResourceRequest request = createRequest("http: final WebResourceResponse response = trackingProtectionWebViewClient.shouldInterceptRequest(webView, request); assertResourceAllowed(response); ...
@Override public WebResourceResponse shouldInterceptRequest(final WebView view, final WebResourceRequest request) { if (!blockingEnabled) { return super.shouldInterceptRequest(view, request); } final Uri resourceUri = request.getUrl(); final String scheme = resourceUri.getScheme(); if (!request.isForMainFrame() && !sch...
TrackingProtectionWebViewClient extends WebViewClient { @Override public WebResourceResponse shouldInterceptRequest(final WebView view, final WebResourceRequest request) { if (!blockingEnabled) { return super.shouldInterceptRequest(view, request); } final Uri resourceUri = request.getUrl(); final String scheme = resour...
TrackingProtectionWebViewClient extends WebViewClient { @Override public WebResourceResponse shouldInterceptRequest(final WebView view, final WebResourceRequest request) { if (!blockingEnabled) { return super.shouldInterceptRequest(view, request); } final Uri resourceUri = request.getUrl(); final String scheme = resour...
TrackingProtectionWebViewClient extends WebViewClient { @Override public WebResourceResponse shouldInterceptRequest(final WebView view, final WebResourceRequest request) { if (!blockingEnabled) { return super.shouldInterceptRequest(view, request); } final Uri resourceUri = request.getUrl(); final String scheme = resour...
TrackingProtectionWebViewClient extends WebViewClient { @Override public WebResourceResponse shouldInterceptRequest(final WebView view, final WebResourceRequest request) { if (!blockingEnabled) { return super.shouldInterceptRequest(view, request); } final Uri resourceUri = request.getUrl(); final String scheme = resour...
@Test public void testGetUABrowserString() { String focusToken = "Focus/1.0"; final String existing = "Mozilla/5.0 (Linux; Android 5.0.2; Android SDK built for x86_64 Build/LSY66K) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/37.0.0.0 Mobile Safari/537.36"; assertEquals("AppleWebKit/537.36 (KHTML, like Gec...
@VisibleForTesting static String getUABrowserString(final String existingUAString, final String focusToken) { int start = existingUAString.indexOf("AppleWebKit"); if (start == -1) { start = existingUAString.indexOf(")") + 2; if (start >= existingUAString.length()) { return focusToken; } } final String[] tokens = existi...
WebViewProvider { @VisibleForTesting static String getUABrowserString(final String existingUAString, final String focusToken) { int start = existingUAString.indexOf("AppleWebKit"); if (start == -1) { start = existingUAString.indexOf(")") + 2; if (start >= existingUAString.length()) { return focusToken; } } final String...
WebViewProvider { @VisibleForTesting static String getUABrowserString(final String existingUAString, final String focusToken) { int start = existingUAString.indexOf("AppleWebKit"); if (start == -1) { start = existingUAString.indexOf(")") + 2; if (start >= existingUAString.length()) { return focusToken; } } final String...
WebViewProvider { @VisibleForTesting static String getUABrowserString(final String existingUAString, final String focusToken) { int start = existingUAString.indexOf("AppleWebKit"); if (start == -1) { start = existingUAString.indexOf(")") + 2; if (start >= existingUAString.length()) { return focusToken; } } final String...
WebViewProvider { @VisibleForTesting static String getUABrowserString(final String existingUAString, final String focusToken) { int start = existingUAString.indexOf("AppleWebKit"); if (start == -1) { start = existingUAString.indexOf(")") + 2; if (start >= existingUAString.length()) { return focusToken; } } final String...
@Test public void emptyCache() throws Exception { cache.close(); assertJournalEquals(); }
public synchronized void close() throws IOException { if (journalWriter == null) { return; } for (Entry entry : new ArrayList<Entry>(lruEntries.values())) { if (entry.currentEditor != null) { entry.currentEditor.abort(); } } trimToSize(); journalWriter.close(); journalWriter = null; }
DiskLruCache implements Closeable { public synchronized void close() throws IOException { if (journalWriter == null) { return; } for (Entry entry : new ArrayList<Entry>(lruEntries.values())) { if (entry.currentEditor != null) { entry.currentEditor.abort(); } } trimToSize(); journalWriter.close(); journalWriter = null; ...
DiskLruCache implements Closeable { public synchronized void close() throws IOException { if (journalWriter == null) { return; } for (Entry entry : new ArrayList<Entry>(lruEntries.values())) { if (entry.currentEditor != null) { entry.currentEditor.abort(); } } trimToSize(); journalWriter.close(); journalWriter = null; ...
DiskLruCache implements Closeable { public synchronized void close() throws IOException { if (journalWriter == null) { return; } for (Entry entry : new ArrayList<Entry>(lruEntries.values())) { if (entry.currentEditor != null) { entry.currentEditor.abort(); } } trimToSize(); journalWriter.close(); journalWriter = null; ...
DiskLruCache implements Closeable { public synchronized void close() throws IOException { if (journalWriter == null) { return; } for (Entry entry : new ArrayList<Entry>(lruEntries.values())) { if (entry.currentEditor != null) { entry.currentEditor.abort(); } } trimToSize(); journalWriter.close(); journalWriter = null; ...
@Test public void isPermittedProtocol() { assertTrue(UrlUtils.isSupportedProtocol("http")); assertTrue(UrlUtils.isSupportedProtocol("https")); assertTrue(UrlUtils.isSupportedProtocol("error")); assertTrue(UrlUtils.isSupportedProtocol("data")); assertFalse(UrlUtils.isSupportedProtocol("market")); }
public static boolean isSupportedProtocol(@NonNull final String scheme) { if (TextUtils.isEmpty(scheme)) { return false; } return isPermittedResourceProtocol(scheme) || scheme.startsWith("error"); }
UrlUtils { public static boolean isSupportedProtocol(@NonNull final String scheme) { if (TextUtils.isEmpty(scheme)) { return false; } return isPermittedResourceProtocol(scheme) || scheme.startsWith("error"); } }
UrlUtils { public static boolean isSupportedProtocol(@NonNull final String scheme) { if (TextUtils.isEmpty(scheme)) { return false; } return isPermittedResourceProtocol(scheme) || scheme.startsWith("error"); } }
UrlUtils { public static boolean isSupportedProtocol(@NonNull final String scheme) { if (TextUtils.isEmpty(scheme)) { return false; } return isPermittedResourceProtocol(scheme) || scheme.startsWith("error"); } static boolean isHttpOrHttps(String url); static boolean isSearchQuery(String text); static String stripUserI...
UrlUtils { public static boolean isSupportedProtocol(@NonNull final String scheme) { if (TextUtils.isEmpty(scheme)) { return false; } return isPermittedResourceProtocol(scheme) || scheme.startsWith("error"); } static boolean isHttpOrHttps(String url); static boolean isSearchQuery(String text); static String stripUserI...
@Test public void readingTheSameFileMultipleTimes() throws Exception { set("a", "a", "b"); DiskLruCache.Value value = cache.get("a"); assertThat(value.getFile(0)).isSameAs(value.getFile(0)); }
public synchronized Value get(String key) throws IOException { checkNotClosed(); Entry entry = lruEntries.get(key); if (entry == null) { return null; } if (!entry.readable) { return null; } for (File file : entry.cleanFiles) { if (!file.exists()) { return null; } } redundantOpCount++; journalWriter.append(READ); journa...
DiskLruCache implements Closeable { public synchronized Value get(String key) throws IOException { checkNotClosed(); Entry entry = lruEntries.get(key); if (entry == null) { return null; } if (!entry.readable) { return null; } for (File file : entry.cleanFiles) { if (!file.exists()) { return null; } } redundantOpCount++...
DiskLruCache implements Closeable { public synchronized Value get(String key) throws IOException { checkNotClosed(); Entry entry = lruEntries.get(key); if (entry == null) { return null; } if (!entry.readable) { return null; } for (File file : entry.cleanFiles) { if (!file.exists()) { return null; } } redundantOpCount++...
DiskLruCache implements Closeable { public synchronized Value get(String key) throws IOException { checkNotClosed(); Entry entry = lruEntries.get(key); if (entry == null) { return null; } if (!entry.readable) { return null; } for (File file : entry.cleanFiles) { if (!file.exists()) { return null; } } redundantOpCount++...
DiskLruCache implements Closeable { public synchronized Value get(String key) throws IOException { checkNotClosed(); Entry entry = lruEntries.get(key); if (entry == null) { return null; } if (!entry.readable) { return null; } for (File file : entry.cleanFiles) { if (!file.exists()) { return null; } } redundantOpCount++...
@Test public void aggressiveClearingHandlesRead() throws Exception { FileUtils.deleteDirectory(cacheDir); assertThat(cache.get("a")).isNull(); }
public synchronized Value get(String key) throws IOException { checkNotClosed(); Entry entry = lruEntries.get(key); if (entry == null) { return null; } if (!entry.readable) { return null; } for (File file : entry.cleanFiles) { if (!file.exists()) { return null; } } redundantOpCount++; journalWriter.append(READ); journa...
DiskLruCache implements Closeable { public synchronized Value get(String key) throws IOException { checkNotClosed(); Entry entry = lruEntries.get(key); if (entry == null) { return null; } if (!entry.readable) { return null; } for (File file : entry.cleanFiles) { if (!file.exists()) { return null; } } redundantOpCount++...
DiskLruCache implements Closeable { public synchronized Value get(String key) throws IOException { checkNotClosed(); Entry entry = lruEntries.get(key); if (entry == null) { return null; } if (!entry.readable) { return null; } for (File file : entry.cleanFiles) { if (!file.exists()) { return null; } } redundantOpCount++...
DiskLruCache implements Closeable { public synchronized Value get(String key) throws IOException { checkNotClosed(); Entry entry = lruEntries.get(key); if (entry == null) { return null; } if (!entry.readable) { return null; } for (File file : entry.cleanFiles) { if (!file.exists()) { return null; } } redundantOpCount++...
DiskLruCache implements Closeable { public synchronized Value get(String key) throws IOException { checkNotClosed(); Entry entry = lruEntries.get(key); if (entry == null) { return null; } if (!entry.readable) { return null; } for (File file : entry.cleanFiles) { if (!file.exists()) { return null; } } redundantOpCount++...
@Test public void testIsSearchQuery() { assertTrue(UrlUtils.isSearchQuery("hello world")); assertFalse(UrlUtils.isSearchQuery("mozilla.org")); assertFalse(UrlUtils.isSearchQuery("mozilla")); }
public static boolean isSearchQuery(String text) { return text.contains(" "); }
UrlUtils { public static boolean isSearchQuery(String text) { return text.contains(" "); } }
UrlUtils { public static boolean isSearchQuery(String text) { return text.contains(" "); } }
UrlUtils { public static boolean isSearchQuery(String text) { return text.contains(" "); } static boolean isHttpOrHttps(String url); static boolean isSearchQuery(String text); static String stripUserInfo(@Nullable String url); static boolean isPermittedResourceProtocol(@NonNull final String scheme); static boolean isS...
UrlUtils { public static boolean isSearchQuery(String text) { return text.contains(" "); } static boolean isHttpOrHttps(String url); static boolean isSearchQuery(String text); static String stripUserInfo(@Nullable String url); static boolean isPermittedResourceProtocol(@NonNull final String scheme); static boolean isS...
@Test @SuppressLint("AuthLeak") public void testStripUserInfo() { assertEquals("", UrlUtils.stripUserInfo(null)); assertEquals("", UrlUtils.stripUserInfo("")); assertEquals("https: assertEquals("https: assertEquals("user@mozilla.org", UrlUtils.stripUserInfo("user@mozilla.org")); assertEquals("ftp: assertEquals("öäü102ß...
public static String stripUserInfo(@Nullable String url) { if (TextUtils.isEmpty(url)) { return ""; } try { URI uri = new URI(url); final String userInfo = uri.getUserInfo(); if (userInfo == null) { return url; } uri = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFr...
UrlUtils { public static String stripUserInfo(@Nullable String url) { if (TextUtils.isEmpty(url)) { return ""; } try { URI uri = new URI(url); final String userInfo = uri.getUserInfo(); if (userInfo == null) { return url; } uri = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery()...
UrlUtils { public static String stripUserInfo(@Nullable String url) { if (TextUtils.isEmpty(url)) { return ""; } try { URI uri = new URI(url); final String userInfo = uri.getUserInfo(); if (userInfo == null) { return url; } uri = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery()...
UrlUtils { public static String stripUserInfo(@Nullable String url) { if (TextUtils.isEmpty(url)) { return ""; } try { URI uri = new URI(url); final String userInfo = uri.getUserInfo(); if (userInfo == null) { return url; } uri = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery()...
UrlUtils { public static String stripUserInfo(@Nullable String url) { if (TextUtils.isEmpty(url)) { return ""; } try { URI uri = new URI(url); final String userInfo = uri.getUserInfo(); if (userInfo == null) { return url; } uri = new URI(uri.getScheme(), null, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery()...
@Test public void isInternalErrorURL() { assertTrue(UrlUtils.isInternalErrorURL("data:text/html;charset=utf-8;base64,")); assertFalse(UrlUtils.isInternalErrorURL("http: assertFalse(UrlUtils.isInternalErrorURL("https: assertFalse(UrlUtils.isInternalErrorURL("www.mozilla.org")); assertFalse(UrlUtils.isInternalErrorURL("e...
public static boolean isInternalErrorURL(final String url) { return "data:text/html;charset=utf-8;base64,".equals(url); }
UrlUtils { public static boolean isInternalErrorURL(final String url) { return "data:text/html;charset=utf-8;base64,".equals(url); } }
UrlUtils { public static boolean isInternalErrorURL(final String url) { return "data:text/html;charset=utf-8;base64,".equals(url); } }
UrlUtils { public static boolean isInternalErrorURL(final String url) { return "data:text/html;charset=utf-8;base64,".equals(url); } static boolean isHttpOrHttps(String url); static boolean isSearchQuery(String text); static String stripUserInfo(@Nullable String url); static boolean isPermittedResourceProtocol(@NonNul...
UrlUtils { public static boolean isInternalErrorURL(final String url) { return "data:text/html;charset=utf-8;base64,".equals(url); } static boolean isHttpOrHttps(String url); static boolean isSearchQuery(String text); static String stripUserInfo(@Nullable String url); static boolean isPermittedResourceProtocol(@NonNul...
@Test public void isHttpOrHttpsUrl() { assertFalse(UrlUtils.isHttpOrHttps(null)); assertFalse(UrlUtils.isHttpOrHttps("")); assertFalse(UrlUtils.isHttpOrHttps(" ")); assertFalse(UrlUtils.isHttpOrHttps("mozilla.org")); assertFalse(UrlUtils.isHttpOrHttps("httpstrf: assertTrue(UrlUtils.isHttpOrHttps("https: assertTrue(UrlU...
public static boolean isHttpOrHttps(String url) { if (TextUtils.isEmpty(url)) { return false; } return url.startsWith("http:") || url.startsWith("https:"); }
UrlUtils { public static boolean isHttpOrHttps(String url) { if (TextUtils.isEmpty(url)) { return false; } return url.startsWith("http:") || url.startsWith("https:"); } }
UrlUtils { public static boolean isHttpOrHttps(String url) { if (TextUtils.isEmpty(url)) { return false; } return url.startsWith("http:") || url.startsWith("https:"); } }
UrlUtils { public static boolean isHttpOrHttps(String url) { if (TextUtils.isEmpty(url)) { return false; } return url.startsWith("http:") || url.startsWith("https:"); } static boolean isHttpOrHttps(String url); static boolean isSearchQuery(String text); static String stripUserInfo(@Nullable String url); static boolean...
UrlUtils { public static boolean isHttpOrHttps(String url) { if (TextUtils.isEmpty(url)) { return false; } return url.startsWith("http:") || url.startsWith("https:"); } static boolean isHttpOrHttps(String url); static boolean isSearchQuery(String text); static String stripUserInfo(@Nullable String url); static boolean...
@Test public void stripCommonSubdomains() { assertEquals(UrlUtils.stripCommonSubdomains("m.mobile.com"), "mobile.com"); assertEquals(UrlUtils.stripCommonSubdomains("mobile.mozilla.org"), "mozilla.org"); assertEquals(UrlUtils.stripCommonSubdomains("www.synology.com"), "synology.com"); assertEquals(UrlUtils.stripCommonSu...
public static String stripCommonSubdomains(@Nullable String host) { return stripPrefix(host, COMMON_SUBDOMAINS_PREFIX_ARRAY); }
UrlUtils { public static String stripCommonSubdomains(@Nullable String host) { return stripPrefix(host, COMMON_SUBDOMAINS_PREFIX_ARRAY); } }
UrlUtils { public static String stripCommonSubdomains(@Nullable String host) { return stripPrefix(host, COMMON_SUBDOMAINS_PREFIX_ARRAY); } }
UrlUtils { public static String stripCommonSubdomains(@Nullable String host) { return stripPrefix(host, COMMON_SUBDOMAINS_PREFIX_ARRAY); } static boolean isHttpOrHttps(String url); static boolean isSearchQuery(String text); static String stripUserInfo(@Nullable String url); static boolean isPermittedResourceProtocol(@...
UrlUtils { public static String stripCommonSubdomains(@Nullable String host) { return stripPrefix(host, COMMON_SUBDOMAINS_PREFIX_ARRAY); } static boolean isHttpOrHttps(String url); static boolean isSearchQuery(String text); static String stripUserInfo(@Nullable String url); static boolean isPermittedResourceProtocol(@...
@Test public void stripHttp() { assertEquals(UrlUtils.stripHttp("http: assertEquals(UrlUtils.stripHttp("https: assertEquals(UrlUtils.stripHttp("ftp: assertEquals(UrlUtils.stripHttp("synology.com"), "synology.com"); }
public static String stripHttp(@Nullable String host) { return stripPrefix(host, HTTP_SCHEME_PREFIX_ARRAY); }
UrlUtils { public static String stripHttp(@Nullable String host) { return stripPrefix(host, HTTP_SCHEME_PREFIX_ARRAY); } }
UrlUtils { public static String stripHttp(@Nullable String host) { return stripPrefix(host, HTTP_SCHEME_PREFIX_ARRAY); } }
UrlUtils { public static String stripHttp(@Nullable String host) { return stripPrefix(host, HTTP_SCHEME_PREFIX_ARRAY); } static boolean isHttpOrHttps(String url); static boolean isSearchQuery(String text); static String stripUserInfo(@Nullable String url); static boolean isPermittedResourceProtocol(@NonNull final Stri...
UrlUtils { public static String stripHttp(@Nullable String host) { return stripPrefix(host, HTTP_SCHEME_PREFIX_ARRAY); } static boolean isHttpOrHttps(String url); static boolean isSearchQuery(String text); static String stripUserInfo(@Nullable String url); static boolean isPermittedResourceProtocol(@NonNull final Stri...
@Test public void testCreation() { Assert.assertNotNull(TabUtil.argument("parent_id", false, false)); Assert.assertNotNull(TabUtil.argument(null, false, false)); Assert.assertNotNull(TabUtil.argument(null, false, true)); Assert.assertNotNull(TabUtil.argument(null, true, false)); }
public static Bundle argument(@Nullable final String parentId, boolean fromExternal, boolean toFocus) { final Bundle bundle = new Bundle(); if (!TextUtils.isEmpty(parentId)) { bundle.putString(ARG_PARENT_ID, parentId); } bundle.putBoolean(ARG_EXTERNAL, fromExternal); bundle.putBoolean(ARG_FOCUS, toFocus); return bundle...
TabUtil { public static Bundle argument(@Nullable final String parentId, boolean fromExternal, boolean toFocus) { final Bundle bundle = new Bundle(); if (!TextUtils.isEmpty(parentId)) { bundle.putString(ARG_PARENT_ID, parentId); } bundle.putBoolean(ARG_EXTERNAL, fromExternal); bundle.putBoolean(ARG_FOCUS, toFocus); ret...
TabUtil { public static Bundle argument(@Nullable final String parentId, boolean fromExternal, boolean toFocus) { final Bundle bundle = new Bundle(); if (!TextUtils.isEmpty(parentId)) { bundle.putString(ARG_PARENT_ID, parentId); } bundle.putBoolean(ARG_EXTERNAL, fromExternal); bundle.putBoolean(ARG_FOCUS, toFocus); ret...
TabUtil { public static Bundle argument(@Nullable final String parentId, boolean fromExternal, boolean toFocus) { final Bundle bundle = new Bundle(); if (!TextUtils.isEmpty(parentId)) { bundle.putString(ARG_PARENT_ID, parentId); } bundle.putBoolean(ARG_EXTERNAL, fromExternal); bundle.putBoolean(ARG_FOCUS, toFocus); ret...
TabUtil { public static Bundle argument(@Nullable final String parentId, boolean fromExternal, boolean toFocus) { final Bundle bundle = new Bundle(); if (!TextUtils.isEmpty(parentId)) { bundle.putString(ARG_PARENT_ID, parentId); } bundle.putBoolean(ARG_EXTERNAL, fromExternal); bundle.putBoolean(ARG_FOCUS, toFocus); ret...
@Test public void testSort() { AbstractRuleProvider v1 = new WCPPhase1Class1(); AbstractRuleProvider v2 = new WCPPhase1Class2(); AbstractRuleProvider vI = new WCPPhaseDependentClass2(); AbstractRuleProvider v3 = new WCPPhase1Class3(); AbstractRuleProvider v4 = new WCPPhase2Class1(); AbstractRuleProvider v5 = new WCPDep...
public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); static List<RuleProvider> sort(List<RuleProvider> providers); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); static List<RuleProvider> sort(List<RuleProvider> providers); }
@Test public void testSortCycle() { WCPPhase1Class1 v1 = new WCPPhase1Class1(WCPPhase1Class3.class); AbstractRuleProvider v2 = new WCPPhase1Class2(); AbstractRuleProvider v3 = new WCPPhase1Class3(); AbstractRuleProvider v4 = new WCPPhase2Class1(); List<RuleProvider> ruleProviders = new ArrayList<>(); ruleProviders.add(...
public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); static List<RuleProvider> sort(List<RuleProvider> providers); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); static List<RuleProvider> sort(List<RuleProvider> providers); }
@Test public void testImproperCrossPhaseDependency() { AbstractRuleProvider v1 = new WCPPhase1Class1(); AbstractRuleProvider v2 = new WCPPhase1Class2(); AbstractRuleProvider v3 = new WCPPhase1Class3(); AbstractRuleProvider v4 = new WCPPhase2Class1(); AbstractRuleProvider v5 = new WCPPhase2Class3(); AbstractRuleProvider...
public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); static List<RuleProvider> sort(List<RuleProvider> providers); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); static List<RuleProvider> sort(List<RuleProvider> providers); }
@Test public void testAcceptableCrossPhaseDependency() { AbstractRuleProvider v1 = new WCPPhase1Class1(); AbstractRuleProvider v2 = new WCPPhase1Class2(); AbstractRuleProvider v3 = new WCPPhase1Class3(); AbstractRuleProvider v4 = new WCPPhase2Class1(); AbstractRuleProvider v5 = new WCPDependentPhase2Step2(); AbstractRu...
public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); static List<RuleProvider> sort(List<RuleProvider> providers); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); static List<RuleProvider> sort(List<RuleProvider> providers); }
@Test public void testPhaseSorting() { List<RuleProvider> ruleProviders = new ArrayList<>(); ruleProviders.addAll(getPhases()); List<RuleProvider> results = RuleProviderSorter.sort(ruleProviders); Assert.assertEquals(4, results.size()); int row = 0; Assert.assertTrue(results.get(row) instanceof Phase1); Assert.assertTr...
public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); static List<RuleProvider> sort(List<RuleProvider> providers); }
RuleProviderSorter { public static List<RuleProvider> sort(List<RuleProvider> providers) { RuleProviderSorter sorter = new RuleProviderSorter(providers); return sorter.getProviders(); } private RuleProviderSorter(List<RuleProvider> providers); static List<RuleProvider> sort(List<RuleProvider> providers); }
@Test public void testAccept() { TestTagsARules rulesA = new TestTagsARules(); TestTagsBRules rulesB = new TestTagsBRules(); TestTagsA1B1Rules rulesA1B1 = new TestTagsA1B1Rules(); Assert.assertEquals(true, isProviderAcceptedByTags(rulesA, Arrays.asList("tagA1"), false, null, false)); Assert.assertEquals(false, isProvid...
@Override public boolean accept(RuleProvider provider) { Set<String> tags = provider.getMetadata().getTags(); boolean result = true; if (!includeTags.isEmpty()) { if (requireAllIncludeTags) result = tags.containsAll(includeTags); else result = CollectionUtils.containsAny(tags, includeTags); } if (result && !excludeTags...
TaggedRuleProviderPredicate implements Predicate<RuleProvider> { @Override public boolean accept(RuleProvider provider) { Set<String> tags = provider.getMetadata().getTags(); boolean result = true; if (!includeTags.isEmpty()) { if (requireAllIncludeTags) result = tags.containsAll(includeTags); else result = CollectionU...
TaggedRuleProviderPredicate implements Predicate<RuleProvider> { @Override public boolean accept(RuleProvider provider) { Set<String> tags = provider.getMetadata().getTags(); boolean result = true; if (!includeTags.isEmpty()) { if (requireAllIncludeTags) result = tags.containsAll(includeTags); else result = CollectionU...
TaggedRuleProviderPredicate implements Predicate<RuleProvider> { @Override public boolean accept(RuleProvider provider) { Set<String> tags = provider.getMetadata().getTags(); boolean result = true; if (!includeTags.isEmpty()) { if (requireAllIncludeTags) result = tags.containsAll(includeTags); else result = CollectionU...
TaggedRuleProviderPredicate implements Predicate<RuleProvider> { @Override public boolean accept(RuleProvider provider) { Set<String> tags = provider.getMetadata().getTags(); boolean result = true; if (!includeTags.isEmpty()) { if (requireAllIncludeTags) result = tags.containsAll(includeTags); else result = CollectionU...
@Test public void testWindupUserDir() { Assert.assertEquals(Paths.get(""), PathUtil.getWindupUserDir()); setUserHome("/foo"); Assert.assertEquals(Paths.get("/foo", ".mta"), PathUtil.getWindupUserDir()); }
public static Path getWindupUserDir() { String userHome = System.getProperty("user.home"); if (userHome == null) { Path path = new File("").toPath(); LOG.warning("$USER_HOME not set, using [" + path.toAbsolutePath().toString() + "] instead."); return path; } return Paths.get(userHome).resolve(".mta"); }
PathUtil { public static Path getWindupUserDir() { String userHome = System.getProperty("user.home"); if (userHome == null) { Path path = new File("").toPath(); LOG.warning("$USER_HOME not set, using [" + path.toAbsolutePath().toString() + "] instead."); return path; } return Paths.get(userHome).resolve(".mta"); } }
PathUtil { public static Path getWindupUserDir() { String userHome = System.getProperty("user.home"); if (userHome == null) { Path path = new File("").toPath(); LOG.warning("$USER_HOME not set, using [" + path.toAbsolutePath().toString() + "] instead."); return path; } return Paths.get(userHome).resolve(".mta"); } }
PathUtil { public static Path getWindupUserDir() { String userHome = System.getProperty("user.home"); if (userHome == null) { Path path = new File("").toPath(); LOG.warning("$USER_HOME not set, using [" + path.toAbsolutePath().toString() + "] instead."); return path; } return Paths.get(userHome).resolve(".mta"); } sta...
PathUtil { public static Path getWindupUserDir() { String userHome = System.getProperty("user.home"); if (userHome == null) { Path path = new File("").toPath(); LOG.warning("$USER_HOME not set, using [" + path.toAbsolutePath().toString() + "] instead."); return path; } return Paths.get(userHome).resolve(".mta"); } sta...
@Test public void testWindupIgnoreDir() { Assert.assertEquals(Paths.get("ignore"), PathUtil.getUserIgnoreDir()); setUserHome("/foo"); Assert.assertEquals(Paths.get("/foo", ".mta", "ignore"), PathUtil.getUserIgnoreDir()); }
public static Path getUserIgnoreDir() { return getUserSubdirectory(IGNORE_DIRECTORY_NAME); }
PathUtil { public static Path getUserIgnoreDir() { return getUserSubdirectory(IGNORE_DIRECTORY_NAME); } }
PathUtil { public static Path getUserIgnoreDir() { return getUserSubdirectory(IGNORE_DIRECTORY_NAME); } }
PathUtil { public static Path getUserIgnoreDir() { return getUserSubdirectory(IGNORE_DIRECTORY_NAME); } static Path getWindupUserDir(); static Path getWindupHome(); static void setWindupHome(Path windupHome); static Path getUserCacheDir(); static Path getWindupCacheDir(); static Path getUserIgnoreDir(); static Path ge...
PathUtil { public static Path getUserIgnoreDir() { return getUserSubdirectory(IGNORE_DIRECTORY_NAME); } static Path getWindupUserDir(); static Path getWindupHome(); static void setWindupHome(Path windupHome); static Path getUserCacheDir(); static Path getWindupCacheDir(); static Path getUserIgnoreDir(); static Path ge...
@Test public void testTickCounter() { int maxTicks = 75; int tickDuration = 30; int deltaMultiplier = 5; t = new TickCounter(new TickHandler() { @Override public void onTick() { tickCount++; } @Override public int getDeltaMultiplier() { return deltaMultiplier; } }, maxTicks, tickDuration); long startTime = System.curre...
public TickCounter(TickHandler tickHandler, int maxTicks, int tickDuration) { this(tickHandler, maxTicks, tickDuration, 0); }
TickCounter { public TickCounter(TickHandler tickHandler, int maxTicks, int tickDuration) { this(tickHandler, maxTicks, tickDuration, 0); } }
TickCounter { public TickCounter(TickHandler tickHandler, int maxTicks, int tickDuration) { this(tickHandler, maxTicks, tickDuration, 0); } TickCounter(TickHandler tickHandler, int maxTicks, int tickDuration); TickCounter(TickHandler tickHandler, int maxTicks, int tickDuration, int tickOffset); }
TickCounter { public TickCounter(TickHandler tickHandler, int maxTicks, int tickDuration) { this(tickHandler, maxTicks, tickDuration, 0); } TickCounter(TickHandler tickHandler, int maxTicks, int tickDuration); TickCounter(TickHandler tickHandler, int maxTicks, int tickDuration, int tickOffset); boolean update();...
TickCounter { public TickCounter(TickHandler tickHandler, int maxTicks, int tickDuration) { this(tickHandler, maxTicks, tickDuration, 0); } TickCounter(TickHandler tickHandler, int maxTicks, int tickDuration); TickCounter(TickHandler tickHandler, int maxTicks, int tickDuration, int tickOffset); boolean update();...
@Test public void testKeyByValue() { Map<Integer, Integer> map = new HashMap<>(); map.put(1, 1); map.put(2, 4); map.put(3, 9); map.put(4, 16); assertEquals((Integer) 1, CollectionUtils.getKeyByValue(map, 1)); assertEquals((Integer) 2, CollectionUtils.getKeyByValue(map, 4)); assertEquals((Integer) 3, CollectionUtils.get...
public static synchronized <T, E> T getKeyByValue(Map<T, E> map, E value) { Preconditions.checkNotNull(map, "The map cannot be null"); for (Entry<T, E> entry : map.entrySet()) { if (Objects.equals(value, entry.getValue())) { return entry.getKey(); } } return null; }
CollectionUtils { public static synchronized <T, E> T getKeyByValue(Map<T, E> map, E value) { Preconditions.checkNotNull(map, "The map cannot be null"); for (Entry<T, E> entry : map.entrySet()) { if (Objects.equals(value, entry.getValue())) { return entry.getKey(); } } return null; } }
CollectionUtils { public static synchronized <T, E> T getKeyByValue(Map<T, E> map, E value) { Preconditions.checkNotNull(map, "The map cannot be null"); for (Entry<T, E> entry : map.entrySet()) { if (Objects.equals(value, entry.getValue())) { return entry.getKey(); } } return null; } private CollectionUtils(); }
CollectionUtils { public static synchronized <T, E> T getKeyByValue(Map<T, E> map, E value) { Preconditions.checkNotNull(map, "The map cannot be null"); for (Entry<T, E> entry : map.entrySet()) { if (Objects.equals(value, entry.getValue())) { return entry.getKey(); } } return null; } private CollectionUtils(); static ...
CollectionUtils { public static synchronized <T, E> T getKeyByValue(Map<T, E> map, E value) { Preconditions.checkNotNull(map, "The map cannot be null"); for (Entry<T, E> entry : map.entrySet()) { if (Objects.equals(value, entry.getValue())) { return entry.getKey(); } } return null; } private CollectionUtils(); static ...
@Test public void testSortByValue() { Map<Integer, Integer> map = new HashMap<>(); map.put(1, 16); map.put(2, 8); map.put(3, 9); map.put(4, 5); map.put(5, 15); map = CollectionUtils.sortByValue(map); Integer[] tmp = map.keySet().toArray(new Integer[5]); assertEquals((Integer) 1, tmp[4]); assertEquals((Integer) 5, tmp[3...
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue( Map<K, V> map) { Preconditions.checkNotNull(map, "The map cannot be null"); List<Entry<K, V>> list = new ArrayList<>(map.entrySet()); list.sort(Entry.comparingByValue()); Map<K, V> result = new LinkedHashMap<>(); for (Entry<K, V> entry : list) { ...
CollectionUtils { public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue( Map<K, V> map) { Preconditions.checkNotNull(map, "The map cannot be null"); List<Entry<K, V>> list = new ArrayList<>(map.entrySet()); list.sort(Entry.comparingByValue()); Map<K, V> result = new LinkedHashMap<>(); for (Entry<K, V...
CollectionUtils { public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue( Map<K, V> map) { Preconditions.checkNotNull(map, "The map cannot be null"); List<Entry<K, V>> list = new ArrayList<>(map.entrySet()); list.sort(Entry.comparingByValue()); Map<K, V> result = new LinkedHashMap<>(); for (Entry<K, V...
CollectionUtils { public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue( Map<K, V> map) { Preconditions.checkNotNull(map, "The map cannot be null"); List<Entry<K, V>> list = new ArrayList<>(map.entrySet()); list.sort(Entry.comparingByValue()); Map<K, V> result = new LinkedHashMap<>(); for (Entry<K, V...
CollectionUtils { public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue( Map<K, V> map) { Preconditions.checkNotNull(map, "The map cannot be null"); List<Entry<K, V>> list = new ArrayList<>(map.entrySet()); list.sort(Entry.comparingByValue()); Map<K, V> result = new LinkedHashMap<>(); for (Entry<K, V...
@Test public void testFindMostPopular() { Integer[] array = {1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 7, 8}; List<Integer> list = new ArrayList<>(Arrays.asList(array)); assertEquals((Integer) 5, CollectionUtils.findMostPopularElement(list)); }
public static <T extends Comparable<T>> T findMostPopularElement( List<T> list) { Preconditions.checkNotNull(list, "The list cannot be null"); Collections.sort(list); T previous = list.get(0); T popular = list.get(0); int count = 1; int maxCount = 1; for (int i = 1; i < list.size(); i++) { if (list.get(i) == previous) ...
CollectionUtils { public static <T extends Comparable<T>> T findMostPopularElement( List<T> list) { Preconditions.checkNotNull(list, "The list cannot be null"); Collections.sort(list); T previous = list.get(0); T popular = list.get(0); int count = 1; int maxCount = 1; for (int i = 1; i < list.size(); i++) { if (list.ge...
CollectionUtils { public static <T extends Comparable<T>> T findMostPopularElement( List<T> list) { Preconditions.checkNotNull(list, "The list cannot be null"); Collections.sort(list); T previous = list.get(0); T popular = list.get(0); int count = 1; int maxCount = 1; for (int i = 1; i < list.size(); i++) { if (list.ge...
CollectionUtils { public static <T extends Comparable<T>> T findMostPopularElement( List<T> list) { Preconditions.checkNotNull(list, "The list cannot be null"); Collections.sort(list); T previous = list.get(0); T popular = list.get(0); int count = 1; int maxCount = 1; for (int i = 1; i < list.size(); i++) { if (list.ge...
CollectionUtils { public static <T extends Comparable<T>> T findMostPopularElement( List<T> list) { Preconditions.checkNotNull(list, "The list cannot be null"); Collections.sort(list); T previous = list.get(0); T popular = list.get(0); int count = 1; int maxCount = 1; for (int i = 1; i < list.size(); i++) { if (list.ge...
@Test public void whenCreateCalledWithUserModelThenExpectJwtUserDetailsToBeReturned() throws Exception { final User user = new User(); user.setId(USER_ID); user.setUsername(USERNAME); user.setPassword(PASSWORD); user.setFirstname(FIRSTNAME); user.setLastname(LASTNAME); user.setEmail(EMAIL); user.setEnabled(USER_ENABLED...
public static JwtUser create(User user) { return new JwtUser( user.getId(), user.getUsername(), user.getFirstname(), user.getLastname(), user.getPassword(), user.getEmail(), user.getEnabled(), user.getLastPasswordResetDate().getTime(), mapUserRolesToGrantedAuthorities(user.getRoles()), user.getRoles() ); }
JwtUserFactory { public static JwtUser create(User user) { return new JwtUser( user.getId(), user.getUsername(), user.getFirstname(), user.getLastname(), user.getPassword(), user.getEmail(), user.getEnabled(), user.getLastPasswordResetDate().getTime(), mapUserRolesToGrantedAuthorities(user.getRoles()), user.getRoles() ...
JwtUserFactory { public static JwtUser create(User user) { return new JwtUser( user.getId(), user.getUsername(), user.getFirstname(), user.getLastname(), user.getPassword(), user.getEmail(), user.getEnabled(), user.getLastPasswordResetDate().getTime(), mapUserRolesToGrantedAuthorities(user.getRoles()), user.getRoles() ...
JwtUserFactory { public static JwtUser create(User user) { return new JwtUser( user.getId(), user.getUsername(), user.getFirstname(), user.getLastname(), user.getPassword(), user.getEmail(), user.getEnabled(), user.getLastPasswordResetDate().getTime(), mapUserRolesToGrantedAuthorities(user.getRoles()), user.getRoles() ...
JwtUserFactory { public static JwtUser create(User user) { return new JwtUser( user.getId(), user.getUsername(), user.getFirstname(), user.getLastname(), user.getPassword(), user.getEmail(), user.getEnabled(), user.getLastPasswordResetDate().getTime(), mapUserRolesToGrantedAuthorities(user.getRoles()), user.getRoles() ...
@Test public void whenCommenceCalledThenExpectUnauthorizedResponse() throws Exception { final JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint = new JwtAuthenticationEntryPoint(); jwtAuthenticationEntryPoint.commence(request, response, authException); verify(response, times(1)).sendError(HttpServletResponse.SC_U...
@Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); }
JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); } }
JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); } }
JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); } @Override void commence(HttpS...
JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { @Override public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException { response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized"); } @Override void commence(HttpS...
@Test public void whenFilterCalledWithoutAuthorizationHeaderThenCallNextFilterInChain() throws Exception { when(request.getHeader(AUTHORIZATION_HEADER)).thenReturn(null); jwtAuthenticationFilter.doFilterInternal(request, response, filterChain); verify(request, times(1)).getHeader(AUTHORIZATION_HEADER); verify(filterCha...
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null && authorizationHeader.startsWith(BEARER_PREFIX)) { au...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
@Test public void whenFilterCalledWithBearerTokenWithMissingUsernameThenCallNextFilterInChain() throws Exception { when(request.getHeader(AUTHORIZATION_HEADER)).thenReturn(BEARER_PREFIX + "dummy-token"); jwtAuthenticationFilter.doFilterInternal(request, response, filterChain); verify(request, times(1)).getHeader(AUTHOR...
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null && authorizationHeader.startsWith(BEARER_PREFIX)) { au...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
@Test public void whenFilterCalledWithTokenWithMissingUsernameThenCallNextFilterInChain() throws Exception { when(request.getHeader(AUTHORIZATION_HEADER)).thenReturn("dummy-token"); when(jwtUtils.getUsernameFromTokenClaims((any()))).thenReturn(null); jwtAuthenticationFilter.doFilterInternal(request, response, filterCha...
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null && authorizationHeader.startsWith(BEARER_PREFIX)) { au...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
@Test public void whenFilterCalledWithInvalidTokenThenCallNextFilterInChain() throws Exception { when(request.getHeader(AUTHORIZATION_HEADER)).thenReturn("dummy-token"); when(jwtUtils.getUsernameFromTokenClaims((any()))).thenReturn(USERNAME); when(jwtUtils.validateTokenAndGetClaims((any()))).thenReturn(claims); jwtAuth...
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null && authorizationHeader.startsWith(BEARER_PREFIX)) { au...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
@Test public void whenFilterCalledWithValidTokenThenExpectSuccessfulAuthenticationAndCallNextFilterInChain() throws Exception { when(request.getHeader(AUTHORIZATION_HEADER)).thenReturn("dummy-token"); when(jwtUtils.getUsernameFromTokenClaims((any()))).thenReturn(USERNAME); when(jwtUtils.validateTokenAndGetClaims((any()...
@Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null && authorizationHeader.startsWith(BEARER_PREFIX)) { au...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
JwtAuthenticationFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { try { String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER); if (authorizationHeader != null...
@Test public void whenLoadByUsernameCalledWithKnownUsernameThenExpectUserDetailsToBeReturned() throws Exception { PowerMock.mockStatic(JwtUserFactory.class); final User user = PowerMock.createMock(User.class); final JwtUser jwtUser = EasyMock.createMock(JwtUser.class); expect(userRepository.findByUsername(KNOWN_USERNAM...
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { final User user = userRepository.findByUsername(username); if (user == null) { throw new UsernameNotFoundException(String.format("No user found with username '%s'.", username)); } else { return JwtUserFactory.create(user...
JwtUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { final User user = userRepository.findByUsername(username); if (user == null) { throw new UsernameNotFoundException(String.format("No user found with username '%s'.", ...
JwtUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { final User user = userRepository.findByUsername(username); if (user == null) { throw new UsernameNotFoundException(String.format("No user found with username '%s'.", ...
JwtUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { final User user = userRepository.findByUsername(username); if (user == null) { throw new UsernameNotFoundException(String.format("No user found with username '%s'.", ...
JwtUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { final User user = userRepository.findByUsername(username); if (user == null) { throw new UsernameNotFoundException(String.format("No user found with username '%s'.", ...
@Test(expected = UsernameNotFoundException.class) public void whenLoadByUsernameCalledWithUnknownUsernameThenExpectUsernameNotFoundException() throws Exception { expect(userRepository.findByUsername(UNKNOWN_USERNAME)).andStubReturn(null); PowerMock.replayAll(); final JwtUserDetailsService jwtUserDetailsService = new Jw...
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { final User user = userRepository.findByUsername(username); if (user == null) { throw new UsernameNotFoundException(String.format("No user found with username '%s'.", username)); } else { return JwtUserFactory.create(user...
JwtUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { final User user = userRepository.findByUsername(username); if (user == null) { throw new UsernameNotFoundException(String.format("No user found with username '%s'.", ...
JwtUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { final User user = userRepository.findByUsername(username); if (user == null) { throw new UsernameNotFoundException(String.format("No user found with username '%s'.", ...
JwtUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { final User user = userRepository.findByUsername(username); if (user == null) { throw new UsernameNotFoundException(String.format("No user found with username '%s'.", ...
JwtUserDetailsService implements UserDetailsService { @Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { final User user = userRepository.findByUsername(username); if (user == null) { throw new UsernameNotFoundException(String.format("No user found with username '%s'.", ...
@Test public void whenGetBotStatusCalledWhenUserIsAuthenticatedThenExpectSuccess() throws Exception { given(botProcessService.getBotStatus(BOT_1_ID)).willReturn(bot1Status); mockMvc.perform(get(RUNTIME_ENDPOINT_BASE_URI + BOT_1_ID + STATUS_RESOURCE_PATH) .header("Authorization", "Bearer " + getJwt(VALID_USER_NAME, VALI...
@PreAuthorize("hasRole('USER')") @RequestMapping(value = "/{botId}" + STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getBotStatus(@AuthenticationPrincipal User user, @PathVariable String botId) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_URI + botId + STATUS_RESOURCE_PATH + " - getBotStatus()"...
BotStatusController extends AbstractRuntimeController { @PreAuthorize("hasRole('USER')") @RequestMapping(value = "/{botId}" + STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getBotStatus(@AuthenticationPrincipal User user, @PathVariable String botId) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_...
BotStatusController extends AbstractRuntimeController { @PreAuthorize("hasRole('USER')") @RequestMapping(value = "/{botId}" + STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getBotStatus(@AuthenticationPrincipal User user, @PathVariable String botId) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_...
BotStatusController extends AbstractRuntimeController { @PreAuthorize("hasRole('USER')") @RequestMapping(value = "/{botId}" + STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getBotStatus(@AuthenticationPrincipal User user, @PathVariable String botId) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_...
BotStatusController extends AbstractRuntimeController { @PreAuthorize("hasRole('USER')") @RequestMapping(value = "/{botId}" + STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getBotStatus(@AuthenticationPrincipal User user, @PathVariable String botId) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_...
@Test public void whenGetBotStatusCalledWithUnknownBotIdThenExpectNotFoundResponse() throws Exception { given(botProcessService.getBotStatus(UNKNOWN_BOT_ID)).willReturn(null); mockMvc.perform(get(RUNTIME_ENDPOINT_BASE_URI + UNKNOWN_BOT_ID + STATUS_RESOURCE_PATH) .header("Authorization", "Bearer " + getJwt(VALID_USER_NA...
@PreAuthorize("hasRole('USER')") @RequestMapping(value = "/{botId}" + STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getBotStatus(@AuthenticationPrincipal User user, @PathVariable String botId) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_URI + botId + STATUS_RESOURCE_PATH + " - getBotStatus()"...
BotStatusController extends AbstractRuntimeController { @PreAuthorize("hasRole('USER')") @RequestMapping(value = "/{botId}" + STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getBotStatus(@AuthenticationPrincipal User user, @PathVariable String botId) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_...
BotStatusController extends AbstractRuntimeController { @PreAuthorize("hasRole('USER')") @RequestMapping(value = "/{botId}" + STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getBotStatus(@AuthenticationPrincipal User user, @PathVariable String botId) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_...
BotStatusController extends AbstractRuntimeController { @PreAuthorize("hasRole('USER')") @RequestMapping(value = "/{botId}" + STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getBotStatus(@AuthenticationPrincipal User user, @PathVariable String botId) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_...
BotStatusController extends AbstractRuntimeController { @PreAuthorize("hasRole('USER')") @RequestMapping(value = "/{botId}" + STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getBotStatus(@AuthenticationPrincipal User user, @PathVariable String botId) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_...
@Test public void testUsernameCanBeExtractedFromTokenClaims() throws Exception { when(claims.getSubject()).thenReturn(USERNAME); assertThat(jwtUtils.getUsernameFromTokenClaims(claims)).isEqualTo(USERNAME); verify(claims, times(1)).getSubject(); }
public String getUsernameFromTokenClaims(Claims claims) { try { final String username = claims.getSubject(); if (username == null) { final String errorMsg = "Failed to extract username claim from token!"; LOG.error(errorMsg); throw new JwtAuthenticationException(errorMsg); } return username; } catch (Exception e) { fin...
JwtUtils { public String getUsernameFromTokenClaims(Claims claims) { try { final String username = claims.getSubject(); if (username == null) { final String errorMsg = "Failed to extract username claim from token!"; LOG.error(errorMsg); throw new JwtAuthenticationException(errorMsg); } return username; } catch (Excepti...
JwtUtils { public String getUsernameFromTokenClaims(Claims claims) { try { final String username = claims.getSubject(); if (username == null) { final String errorMsg = "Failed to extract username claim from token!"; LOG.error(errorMsg); throw new JwtAuthenticationException(errorMsg); } return username; } catch (Excepti...
JwtUtils { public String getUsernameFromTokenClaims(Claims claims) { try { final String username = claims.getSubject(); if (username == null) { final String errorMsg = "Failed to extract username claim from token!"; LOG.error(errorMsg); throw new JwtAuthenticationException(errorMsg); } return username; } catch (Excepti...
JwtUtils { public String getUsernameFromTokenClaims(Claims claims) { try { final String username = claims.getSubject(); if (username == null) { final String errorMsg = "Failed to extract username claim from token!"; LOG.error(errorMsg); throw new JwtAuthenticationException(errorMsg); } return username; } catch (Excepti...
@Test public void whenGetAllBotStatusCalledWhenUserIsAuthenticatedThenExpectSuccess() throws Exception { final List<BotStatus> allBotStatus = new ArrayList<>(); allBotStatus.add(bot1Status); allBotStatus.add(bot2Status); given(botProcessService.getAllBotStatus()).willReturn(allBotStatus); mockMvc.perform(get(RUNTIME_EN...
@PreAuthorize("hasRole('USER')") @RequestMapping(value = STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getAllBotStatus(@AuthenticationPrincipal User user) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_URI + STATUS_RESOURCE_PATH + " - getAllBotStatus()"); final List<BotStatus> allBotStatus = bot...
BotStatusController extends AbstractRuntimeController { @PreAuthorize("hasRole('USER')") @RequestMapping(value = STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getAllBotStatus(@AuthenticationPrincipal User user) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_URI + STATUS_RESOURCE_PATH + " - getAl...
BotStatusController extends AbstractRuntimeController { @PreAuthorize("hasRole('USER')") @RequestMapping(value = STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getAllBotStatus(@AuthenticationPrincipal User user) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_URI + STATUS_RESOURCE_PATH + " - getAl...
BotStatusController extends AbstractRuntimeController { @PreAuthorize("hasRole('USER')") @RequestMapping(value = STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getAllBotStatus(@AuthenticationPrincipal User user) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_URI + STATUS_RESOURCE_PATH + " - getAl...
BotStatusController extends AbstractRuntimeController { @PreAuthorize("hasRole('USER')") @RequestMapping(value = STATUS_RESOURCE_PATH, method = RequestMethod.GET) public ResponseEntity<?> getAllBotStatus(@AuthenticationPrincipal User user) { LOG.info("GET " + RUNTIME_ENDPOINT_BASE_URI + STATUS_RESOURCE_PATH + " - getAl...
@Test public void testAddingAndFetchingOptionalConfigItems() throws Exception { final OptionalConfig strategyConfig = new OptionalConfig(); strategyConfig.getItems().put(BUY_FEE_CONFIG_ITEM_KEY, BUY_FEE_CONFIG_ITEM_VALUE); strategyConfig.getItems().put(SELL_FEE_CONFIG_ITEM_KEY, SELL_FEE_CONFIG_ITEM_VALUE); assertEquals...
public Map<String, String> getItems() { return items; }
OptionalConfig { public Map<String, String> getItems() { return items; } }
OptionalConfig { public Map<String, String> getItems() { return items; } OptionalConfig(); }
OptionalConfig { public Map<String, String> getItems() { return items; } OptionalConfig(); Map<String, String> getItems(); void setItems(Map<String, String> items); @Override String toString(); }
OptionalConfig { public Map<String, String> getItems() { return items; } OptionalConfig(); Map<String, String> getItems(); void setItems(Map<String, String> items); @Override String toString(); }
@Test(expected = JwtAuthenticationException.class) public void testExceptionThrownIfUsernameCannotBeExtractedFromTokenClaims() throws Exception { when(claims.getSubject()).thenReturn(null); jwtUtils.getUsernameFromTokenClaims(claims); verify(claims, times(1)).getSubject(); }
public String getUsernameFromTokenClaims(Claims claims) { try { final String username = claims.getSubject(); if (username == null) { final String errorMsg = "Failed to extract username claim from token!"; LOG.error(errorMsg); throw new JwtAuthenticationException(errorMsg); } return username; } catch (Exception e) { fin...
JwtUtils { public String getUsernameFromTokenClaims(Claims claims) { try { final String username = claims.getSubject(); if (username == null) { final String errorMsg = "Failed to extract username claim from token!"; LOG.error(errorMsg); throw new JwtAuthenticationException(errorMsg); } return username; } catch (Excepti...
JwtUtils { public String getUsernameFromTokenClaims(Claims claims) { try { final String username = claims.getSubject(); if (username == null) { final String errorMsg = "Failed to extract username claim from token!"; LOG.error(errorMsg); throw new JwtAuthenticationException(errorMsg); } return username; } catch (Excepti...
JwtUtils { public String getUsernameFromTokenClaims(Claims claims) { try { final String username = claims.getSubject(); if (username == null) { final String errorMsg = "Failed to extract username claim from token!"; LOG.error(errorMsg); throw new JwtAuthenticationException(errorMsg); } return username; } catch (Excepti...
JwtUtils { public String getUsernameFromTokenClaims(Claims claims) { try { final String username = claims.getSubject(); if (username == null) { final String errorMsg = "Failed to extract username claim from token!"; LOG.error(errorMsg); throw new JwtAuthenticationException(errorMsg); } return username; } catch (Excepti...
@Test public void testIssuedAtDateCanBeExtractedFromTokenClaims() throws Exception { when(claims.getIssuedAt()).thenReturn(ISSUED_AT_DATE); assertThat(jwtUtils.getIssuedAtDateFromTokenClaims(claims)) .isCloseTo(ISSUED_AT_DATE, GRADLE_FRIENDLY_TIME_TOLERANCE_IN_MILLIS); verify(claims, times(1)).getIssuedAt(); }
Date getIssuedAtDateFromTokenClaims(Claims claims) throws JwtAuthenticationException { try { return claims.getIssuedAt(); } catch (Exception e) { final String errorMsg = "Failed to extract iat claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } }
JwtUtils { Date getIssuedAtDateFromTokenClaims(Claims claims) throws JwtAuthenticationException { try { return claims.getIssuedAt(); } catch (Exception e) { final String errorMsg = "Failed to extract iat claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } } }
JwtUtils { Date getIssuedAtDateFromTokenClaims(Claims claims) throws JwtAuthenticationException { try { return claims.getIssuedAt(); } catch (Exception e) { final String errorMsg = "Failed to extract iat claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } } }
JwtUtils { Date getIssuedAtDateFromTokenClaims(Claims claims) throws JwtAuthenticationException { try { return claims.getIssuedAt(); } catch (Exception e) { final String errorMsg = "Failed to extract iat claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } } Claims validateT...
JwtUtils { Date getIssuedAtDateFromTokenClaims(Claims claims) throws JwtAuthenticationException { try { return claims.getIssuedAt(); } catch (Exception e) { final String errorMsg = "Failed to extract iat claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } } Claims validateT...
@Test public void testExpirationDateCanBeExtractedFromTokenClaims() throws Exception { when(claims.getExpiration()).thenReturn(EXPIRATION_DATE); assertThat(jwtUtils.getExpirationDateFromTokenClaims(claims)) .isCloseTo(EXPIRATION_DATE, GRADLE_FRIENDLY_TIME_TOLERANCE_IN_MILLIS); verify(claims, times(1)).getExpiration(); ...
Date getExpirationDateFromTokenClaims(Claims claims) throws JwtAuthenticationException { try { return claims.getExpiration(); } catch (Exception e) { final String errorMsg = "Failed to extract expiration claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } }
JwtUtils { Date getExpirationDateFromTokenClaims(Claims claims) throws JwtAuthenticationException { try { return claims.getExpiration(); } catch (Exception e) { final String errorMsg = "Failed to extract expiration claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } } }
JwtUtils { Date getExpirationDateFromTokenClaims(Claims claims) throws JwtAuthenticationException { try { return claims.getExpiration(); } catch (Exception e) { final String errorMsg = "Failed to extract expiration claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } } }
JwtUtils { Date getExpirationDateFromTokenClaims(Claims claims) throws JwtAuthenticationException { try { return claims.getExpiration(); } catch (Exception e) { final String errorMsg = "Failed to extract expiration claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } } Claim...
JwtUtils { Date getExpirationDateFromTokenClaims(Claims claims) throws JwtAuthenticationException { try { return claims.getExpiration(); } catch (Exception e) { final String errorMsg = "Failed to extract expiration claim from token!"; LOG.error(errorMsg, e); throw new JwtAuthenticationException(errorMsg, e); } } Claim...
@Test public void testRolesCanBeExtractedFromTokenClaims() throws Exception { when(claims.get(JwtUtils.CLAIM_KEY_ROLES)).thenReturn(ROLES); final List<GrantedAuthority> roles = jwtUtils.getRolesFromTokenClaims(claims); assertThat(roles.size()).isEqualTo(2); assertThat(roles.get(0).getAuthority()).isEqualTo(RoleName.ROL...
public List<GrantedAuthority> getRolesFromTokenClaims(Claims claims) throws JwtAuthenticationException { final List<GrantedAuthority> roles = new ArrayList<>(); try { @SuppressWarnings("unchecked") final List<String> rolesFromClaim = (List<String>) claims.get(CLAIM_KEY_ROLES); for (final String roleFromClaim : rolesFro...
JwtUtils { public List<GrantedAuthority> getRolesFromTokenClaims(Claims claims) throws JwtAuthenticationException { final List<GrantedAuthority> roles = new ArrayList<>(); try { @SuppressWarnings("unchecked") final List<String> rolesFromClaim = (List<String>) claims.get(CLAIM_KEY_ROLES); for (final String roleFromClaim...
JwtUtils { public List<GrantedAuthority> getRolesFromTokenClaims(Claims claims) throws JwtAuthenticationException { final List<GrantedAuthority> roles = new ArrayList<>(); try { @SuppressWarnings("unchecked") final List<String> rolesFromClaim = (List<String>) claims.get(CLAIM_KEY_ROLES); for (final String roleFromClaim...
JwtUtils { public List<GrantedAuthority> getRolesFromTokenClaims(Claims claims) throws JwtAuthenticationException { final List<GrantedAuthority> roles = new ArrayList<>(); try { @SuppressWarnings("unchecked") final List<String> rolesFromClaim = (List<String>) claims.get(CLAIM_KEY_ROLES); for (final String roleFromClaim...
JwtUtils { public List<GrantedAuthority> getRolesFromTokenClaims(Claims claims) throws JwtAuthenticationException { final List<GrantedAuthority> roles = new ArrayList<>(); try { @SuppressWarnings("unchecked") final List<String> rolesFromClaim = (List<String>) claims.get(CLAIM_KEY_ROLES); for (final String roleFromClaim...
@Test public void testLastPasswordResetDateCanBeExtractedFromTokenClaims() throws Exception { when(claims.get(JwtUtils.CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE)) .thenReturn(LAST_PASSWORD_RESET_DATE.getTime()); assertThat(jwtUtils.getLastPasswordResetDateFromTokenClaims(claims)) .isCloseTo(LAST_PASSWORD_RESET_DATE, GRADLE_F...
Date getLastPasswordResetDateFromTokenClaims(Claims claims) { Date lastPasswordResetDate; try { lastPasswordResetDate = new Date((Long) claims.get(CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE)); } catch (Exception e) { LOG.error("Failed to extract lastPasswordResetDate claim from token!", e); lastPasswordResetDate = null; } ret...
JwtUtils { Date getLastPasswordResetDateFromTokenClaims(Claims claims) { Date lastPasswordResetDate; try { lastPasswordResetDate = new Date((Long) claims.get(CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE)); } catch (Exception e) { LOG.error("Failed to extract lastPasswordResetDate claim from token!", e); lastPasswordResetDate = ...
JwtUtils { Date getLastPasswordResetDateFromTokenClaims(Claims claims) { Date lastPasswordResetDate; try { lastPasswordResetDate = new Date((Long) claims.get(CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE)); } catch (Exception e) { LOG.error("Failed to extract lastPasswordResetDate claim from token!", e); lastPasswordResetDate = ...
JwtUtils { Date getLastPasswordResetDateFromTokenClaims(Claims claims) { Date lastPasswordResetDate; try { lastPasswordResetDate = new Date((Long) claims.get(CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE)); } catch (Exception e) { LOG.error("Failed to extract lastPasswordResetDate claim from token!", e); lastPasswordResetDate = ...
JwtUtils { Date getLastPasswordResetDateFromTokenClaims(Claims claims) { Date lastPasswordResetDate; try { lastPasswordResetDate = new Date((Long) claims.get(CLAIM_KEY_LAST_PASSWORD_CHANGE_DATE)); } catch (Exception e) { LOG.error("Failed to extract lastPasswordResetDate claim from token!", e); lastPasswordResetDate = ...
@Test public void whenValidateTokenCalledWithNonExpiredTokenThenExpectSuccess() throws Exception { final String token = createToken(); assertThat(jwtUtils.validateTokenAndGetClaims(token)).isNotNull(); }
public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPasswordResetD...
JwtUtils { public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPas...
JwtUtils { public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPas...
JwtUtils { public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPas...
JwtUtils { public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPas...
@Test(expected = JwtAuthenticationException.class) public void whenValidateTokenCalledWithExpiredTokenThenExpectFailure() throws Exception { ReflectionTestUtils.setField(jwtUtils, "allowedClockSkewInSecs", 0L); ReflectionTestUtils.setField(jwtUtils, "expirationInSecs", 0L); final String token = createToken(); jwtUtils....
public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPasswordResetD...
JwtUtils { public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPas...
JwtUtils { public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPas...
JwtUtils { public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPas...
JwtUtils { public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPas...
@Test(expected = JwtAuthenticationException.class) public void whenValidateTokenCalledWithCreatedDateEarlierThanLastPasswordResetDateThenExpectFailure() throws Exception { final String token = createTokenWithInvalidCreationDate(); jwtUtils.validateTokenAndGetClaims(token); }
public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPasswordResetD...
JwtUtils { public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPas...
JwtUtils { public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPas...
JwtUtils { public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPas...
JwtUtils { public Claims validateTokenAndGetClaims(String token) { try { final Claims claims = getClaimsFromToken(token); final Date created = getIssuedAtDateFromTokenClaims(claims); final Date lastPasswordResetDate = getLastPasswordResetDateFromTokenClaims(claims); if (isCreatedBeforeLastPasswordReset(created, lastPas...
@Test public void shouldReturnEmptyOptionalString() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "value.one"); properties.put("key.two", "value.two"); final Properlty prop = buildProperlty(properties); assertFalse(prop.get("key.three").isPresent()); }
public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
@Test public void shouldReturnEmptyOptionalDouble() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "value.one"); properties.put("key.two", "value.two"); final Properlty prop = buildProperlty(properties); assertFalse(prop.getDouble("key.three").isPresent()); }
public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); }
Properlty { public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); } }
Properlty { public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, F...
Properlty { public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, F...
@Test public void shouldReturnDefaultDouble() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "1"); final Properlty prop = buildProperlty(properties); assertEquals(1d, prop.getDouble("key.one", 1.1111d), 0.1d); assertEquals(10d, prop.getDouble("key.two", 10d), 0.1d); }
public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); }
Properlty { public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); } }
Properlty { public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, F...
Properlty { public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, F...
@Test(expected=NumberFormatException.class) public void shouldThrowExceptionParsingWrongDouble() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "not a number"); final Properlty prop = buildProperlty(properties); prop.getDouble("key.one"); }
public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); }
Properlty { public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); } }
Properlty { public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, F...
Properlty { public Optional<Double> getDouble(String key) { return get(key).map(Double::parseDouble); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, F...
@Test public void shouldReturnEmptyOptionalFloat() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "value.one"); properties.put("key.two", "value.two"); final Properlty prop = buildProperlty(properties); assertFalse(prop.getFloat("key.three").isPresent()); }
public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); }
Properlty { public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); } }
Properlty { public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Funct...
Properlty { public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Funct...
@Test public void shouldReturnDefaultFloat() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "1"); final Properlty prop = buildProperlty(properties); assertEquals(1f, prop.getFloat("key.one", 10), 0.1f); assertEquals(10f, prop.getFloat("key.two", 10), 0.1f); }
public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); }
Properlty { public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); } }
Properlty { public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Funct...
Properlty { public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Funct...
@Test(expected=NumberFormatException.class) public void shouldThrowExceptionParsingWrongFloat() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "not a number"); final Properlty prop = buildProperlty(properties); prop.getFloat("key.one"); }
public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); }
Properlty { public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); } }
Properlty { public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Funct...
Properlty { public Optional<Float> getFloat(String key) { return get(key).map(Float::parseFloat); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Funct...
@Test public void shouldReturnEmptyOptionalLong() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "value.one"); properties.put("key.two", "value.two"); final Properlty prop = buildProperlty(properties); assertFalse(prop.getLong("key.three").isPresent()); }
public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); }
Properlty { public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); } }
Properlty { public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Function<...
Properlty { public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Function<...
@Test public void shouldReturnDefaultLong() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "1"); final Properlty prop = buildProperlty(properties); assertEquals(1l, prop.getLong("key.one", 10l)); assertEquals(10l, prop.getLong("key.two", 10l)); }
public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); }
Properlty { public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); } }
Properlty { public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Function<...
Properlty { public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Function<...
@Test public void shouldReturnDefaultBigDecimal() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "1"); final Properlty prop = buildProperlty(properties); assertEquals(1, prop.getBigDecimal("key.one", new BigDecimal(10)).intValue()); assertEquals(10, prop.getBigDecimal("key.two", new...
public Optional<BigDecimal> getBigDecimal(String key) { return get(key).map((val) -> new BigDecimal(val)); }
Properlty { public Optional<BigDecimal> getBigDecimal(String key) { return get(key).map((val) -> new BigDecimal(val)); } }
Properlty { public Optional<BigDecimal> getBigDecimal(String key) { return get(key).map((val) -> new BigDecimal(val)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public Optional<BigDecimal> getBigDecimal(String key) { return get(key).map((val) -> new BigDecimal(val)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> ...
Properlty { public Optional<BigDecimal> getBigDecimal(String key) { return get(key).map((val) -> new BigDecimal(val)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> ...
@Test public void shouldReturnDefaultBigInteger() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "1"); final Properlty prop = buildProperlty(properties); assertEquals(1, prop.getBigInteger("key.one", new BigInteger("10")).intValue()); assertEquals(10, prop.getBigInteger("key.two", n...
public Optional<BigInteger> getBigInteger(String key) { return get(key).map((val) -> new BigInteger(val)); }
Properlty { public Optional<BigInteger> getBigInteger(String key) { return get(key).map((val) -> new BigInteger(val)); } }
Properlty { public Optional<BigInteger> getBigInteger(String key) { return get(key).map((val) -> new BigInteger(val)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public Optional<BigInteger> getBigInteger(String key) { return get(key).map((val) -> new BigInteger(val)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> ...
Properlty { public Optional<BigInteger> getBigInteger(String key) { return get(key).map((val) -> new BigInteger(val)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> ...
@Test public void shouldReturnOptionalString() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "value.one"); properties.put("key.two", "value.two"); final Properlty prop = buildProperlty(properties); assertEquals("value.one", prop.get("key.one").get()); assertEquals("value.two", prop...
public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
@Test(expected=NumberFormatException.class) public void shouldThrowExceptionParsingWrongLong() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "not a number"); final Properlty prop = buildProperlty(properties); prop.getLong("key.one"); }
public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); }
Properlty { public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); } }
Properlty { public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Function<...
Properlty { public Optional<Long> getLong(String key) { return get(key).map(Long::parseLong); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Function<...
@Test public void shouldReturnEmptyOptionalEnum() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "value.one"); properties.put("key.two", "value.two"); final Properlty prop = buildProperlty(properties); assertFalse(prop.getEnum("key.three", NeedSomebodyToLove.class).isPresent()); }
public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); }
Properlty { public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); } }
Properlty { public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String d...
Properlty { public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String d...
@Test public void shouldReturnDefaultEnum() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "ME"); final Properlty prop = buildProperlty(properties); assertEquals(NeedSomebodyToLove.ME, prop.getEnum("key.one", NeedSomebodyToLove.THEM)); assertEquals(NeedSomebodyToLove.THEM, prop.getE...
public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); }
Properlty { public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); } }
Properlty { public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String d...
Properlty { public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String d...
@Test(expected=IllegalArgumentException.class) public void shouldThrowExceptionParsingWrongEnumLong() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "not an enum"); final Properlty prop = buildProperlty(properties); prop.getEnum("key.one", NeedSomebodyToLove.class); }
public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); }
Properlty { public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); } }
Properlty { public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String d...
Properlty { public <T extends Enum<T>> Optional<T> getEnum(String key, Class<T> type) { return get(key).map(value -> Enum.valueOf(type, value)); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String d...
@Test public void shouldReturntheKeyApplyingTheMapFunction() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "111"); final Properlty prop = buildProperlty(properties); assertEquals(111, prop.get("key.one", Integer::valueOf).get().intValue()); assertEquals(222, prop.get("key.two", 222...
public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
@Test public void shouldReturnValueToArray() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "111,AAAAA,BBB"); final Properlty prop = buildProperlty(properties); final String[] values = prop.getArray("key.one"); assertEquals(3, values.length); assertEquals("111", values[0]); assertEq...
public String[] getArray(String key) { return getArray(key, Default.LIST_SEPARATOR); }
Properlty { public String[] getArray(String key) { return getArray(key, Default.LIST_SEPARATOR); } }
Properlty { public String[] getArray(String key) { return getArray(key, Default.LIST_SEPARATOR); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); }
Properlty { public String[] getArray(String key) { return getArray(key, Default.LIST_SEPARATOR); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Functi...
Properlty { public String[] getArray(String key) { return getArray(key, Default.LIST_SEPARATOR); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties); static ProperltyBuilder builder(); Optional<String> get(String key); String get(String key, String defaultValue); Optional<T> get(String key, Functi...
@Test public void shouldMatchPlaceholdersNotSensitiveCase() { final Map<String, String> properties = new HashMap<>(); properties.put("key.ONE", "${value1:defaultValue1}"); properties.put("keY.TWO", "${KEY.one:defaultValue2}"); properties.put("key.three", "${KEY.one:defaultValue3}"); final boolean caseSensitive = false;...
public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
@Test public void shouldMatchPlaceholdersSensitiveCase() { final Map<String, String> properties = new HashMap<>(); properties.put("key.ONE", "${value1:defaultValue1}"); properties.put("keY.TWO", "${KEY.one:defaultValue2}"); properties.put("key.three", "${KEY.one:defaultValue3}"); final boolean caseSensitive = true; fin...
public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
@Test public void shouldReturnEmpty() { final String input = ""; assertTrue(StringUtils.allTokens(input, startDelimiter, endDelimiter).isEmpty()); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
@Test public void shouldReturnEmpty2() { final String input = "asfasdfasfdasfdasf_${_asdasd"; assertTrue(StringUtils.allTokens(input, startDelimiter, endDelimiter).isEmpty()); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
@Test public void shouldReturnCaseInsensitive() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "value.one"); properties.put("KEy.tWo", "value.two"); final boolean caseSensitive = false; final Properlty prop = buildProperlty(properties, caseSensitive); assertEquals("value.one", prop....
public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
@Test public void shouldReturnEmpty3() { final String input = "asfasdfasfdasfdasf_}_asdasd"; assertTrue(StringUtils.allTokens(input, startDelimiter, endDelimiter).isEmpty()); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
@Test public void shouldReturnSimpleToken() { final String input = "${TOKEN}"; final List<String> tokens = StringUtils.allTokens(input, startDelimiter, endDelimiter); assertEquals(1, tokens.size()); assertEquals("TOKEN", tokens.get(0)); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
@Test public void shouldReturnTokenAtTheEnd() { final String input = "asfasdfasfdasfdasf_${TOKEN}"; final List<String> tokens = StringUtils.allTokens(input, startDelimiter, endDelimiter); assertEquals(1, tokens.size()); assertEquals("TOKEN", tokens.get(0)); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
@Test public void shouldReturnTokenAtTheBeginning() { final String input = "${TOKEN}asfasdfasfd_${_asfdasf"; final List<String> tokens = StringUtils.allTokens(input, startDelimiter, endDelimiter); assertEquals(1, tokens.size()); assertEquals("TOKEN", tokens.get(0)); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
@Test public void shouldReturnTokenInTheMiddle() { final String input = "asfasdfasf${TOKEN}dasfdasf"; final List<String> tokens = StringUtils.allTokens(input, startDelimiter, endDelimiter); assertEquals(1, tokens.size()); assertEquals("TOKEN", tokens.get(0)); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
@Test public void shouldReturnTokenInTheMiddle2() { final String input = "asfas}dfasf${TOKEN}dasfdasf"; final List<String> tokens = StringUtils.allTokens(input, startDelimiter, endDelimiter); assertEquals(1, tokens.size()); assertEquals("TOKEN", tokens.get(0)); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
@Test public void shouldReturnTokenInTheMiddle3() { final String input = "asfas${dfasf${TOKEN}dasfdasf"; final List<String> tokens = StringUtils.allTokens(input, startDelimiter, endDelimiter); assertEquals(1, tokens.size()); assertEquals("TOKEN", tokens.get(0)); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
@Test public void shouldReturnTokenInTheMiddle4() { final String input = "asfas${dfasf${TOKEN}dasfd${asf"; final List<String> tokens = StringUtils.allTokens(input, startDelimiter, endDelimiter); assertEquals(1, tokens.size()); assertEquals("TOKEN", tokens.get(0)); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
@Test public void shouldReturnTokenInTheMiddle5() { final String input = "asfas${dfasf${TOKEN}dasfd}asf"; final List<String> tokens = StringUtils.allTokens(input, startDelimiter, endDelimiter); assertEquals(1, tokens.size()); assertEquals("TOKEN", tokens.get(0)); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
@Test public void shouldReturnInnerToken() { final String input = "asfas${dfasf${TOKEN}dasf}dasf"; final List<String> tokens = StringUtils.allTokens(input, startDelimiter, endDelimiter); assertEquals(1, tokens.size()); assertEquals("TOKEN", tokens.get(0)); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
@Test public void shouldReturnDefaultString() { final Map<String, String> properties = new HashMap<>(); properties.put("key.one", "value.one"); final Properlty prop = buildProperlty(properties); assertEquals("value.one", prop.get("key.one", "default")); assertEquals("default", prop.get("key.two", "default")); }
public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } }
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
Properlty { public Optional<String> get(String key) { if (!caseSensitive) { key = key.toLowerCase(); } final PropertyValue value = properties.get(key); if (value != null) { return Optional.ofNullable(value.getValue()); } return Optional.empty(); } Properlty(boolean caseSensitive, Map<String, PropertyValue> properties);...
@Test public void shouldReturnNestedToken() { final String input = "${${${TOKEN}}}"; final List<String> tokens = StringUtils.allTokens(input, startDelimiter, endDelimiter); assertEquals(1, tokens.size()); assertEquals("TOKEN", tokens.get(0)); }
public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue); input = inpu...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...
StringUtils { public static List<String> allTokens(String input, String startDelimiter, String endDelimiter) { final List<String> tokens = new ArrayList<>(); Optional<String> token = firstToken(input, startDelimiter, endDelimiter); while(token.isPresent()) { final String tokenValue = token.get(); tokens.add(tokenValue)...