LongestPrefix extends SimpleComparativeQuery<O, A> { public LongestPrefix(Attribute<O, A> attribute, A value) { super(attribute); this.value = checkQueryValueNotNull(value); } LongestPrefix(Attribute<O, A> attribute, A value); A getValue(); @Override boolean equals(Object o); @Override Iterable<O> getMatchesForSimpleAttribute(SimpleAttribute<O, A> attribute, ObjectSet<O> objectsInCollection, QueryOptions queryOptions); @Override Iterable<O> getMatchesForNonSimpleAttribute(Attribute<O, A> attribute, ObjectSet<O> objectsInCollection, QueryOptions queryOptions); @Override String toString();  }
@Test @UseDataProvider(value = "mobileTerminatingScenarios") public void testLongestPrefix(String prefix, String expectedOperator, Integer expectedCount) { Query<MobileTerminating> q = longestPrefix(MobileTerminating.PREFIX, prefix); validateLongestPrefixWithCache(q, mobileTerminatingCache, expectedOperator, expectedCount); }
@Test @UseDataProvider(value = "mobileTerminatingScenarios") public void testLongestPrefixWithoutIndex(String prefix, String expectedOperator, Integer expectedCount) { Query<MobileTerminating> q = longestPrefix(MobileTerminating.PREFIX, prefix); validateLongestPrefixWithCache(q, mobileTerminatingCacheNoIndex, expectedOperator, expectedCount); }
@Test public void testLongestPrefix() { Attribute<String, String> stringIdentity = new SelfAttribute<String>(String.class, "identity"); assertTrue(LongestPrefix.countPrefixChars( "35387123456", "35387") > 0); assertEquals(5, LongestPrefix.countPrefixChars( "35387123456", "35387")); assertTrue(LongestPrefix.countPrefixChars("35387", "35387") > 0); assertEquals(5, LongestPrefix.countPrefixChars("35387", "35387")); assertFalse(LongestPrefix.countPrefixChars("35386123456", "35387") > 0); assertEquals(0, LongestPrefix.countPrefixChars("35386123456", "35387")); assertFalse(LongestPrefix.countPrefixChars("35386123456", "35387") > 0); assertEquals(0, LongestPrefix.countPrefixChars("35386123456", "35387")); assertFalse(LongestPrefix.countPrefixChars("3538", "35387") > 0); assertEquals(0, LongestPrefix.countPrefixChars("3538", "35387")); }