def test_with_non_positive_page_size(self): with self.assertRaises(ValueError): paging(true(), 0) with self.assertRaises(ValueError): paging(true(), -1)
def test_previous_page_when_index_is_zero(self): predicate = paging(true(), 2) self.assertEqual(0, predicate.previous_page()) self.assertEqual(0, predicate.previous_page())
def test_true(self): m = self.fill_map() predicate = true() self.assertCountEqual(self.map.key_set(predicate), list(m.keys()))
def test_with_inner_paging_predicate(self): predicate = paging(true(), 1) with self.assertRaises(TypeError): paging(predicate, 1)
def test_project_with_paging_predicate(self): with self.assertRaises(AssertionError): self.map.project(single_attribute("foo"), paging(true(), 10))
def test_aggregate_with_paging_predicate(self): with self.assertRaises(AssertionError): self.map.aggregate(int_avg("foo"), paging(true(), 10))
REFERENCE_OBJECTS.update({ "AnInnerPortable": _inner_portable, "CustomStreamSerializable": _custom_serializable, "CustomByteArraySerializable": _custom_byte_array_serializable, "AnIdentifiedDataSerializable": _identified, "APortable": _portable, "ArrayList": [None, _non_null_list], "LinkedList": [None, _non_null_list], "TruePredicate": predicate.true(), "FalsePredicate": predicate.false(), "SqlPredicate": predicate.sql(_sql_string), "EqualPredicate": predicate.equal(_sql_string, REFERENCE_OBJECTS["Integer"]), "NotEqualPredicate": predicate.not_equal(_sql_string, REFERENCE_OBJECTS["Integer"]), "GreaterLessPredicate": predicate.greater(_sql_string, REFERENCE_OBJECTS["Integer"]), "BetweenPredicate": predicate.between(_sql_string, REFERENCE_OBJECTS["Integer"], REFERENCE_OBJECTS["Integer"]), "LikePredicate": predicate.like(_sql_string, _sql_string),
REFERENCE_OBJECTS["BigDecimal"], REFERENCE_OBJECTS["LocalDate"], REFERENCE_OBJECTS["LocalTime"], REFERENCE_OBJECTS["OffsetDateTime"], ] REFERENCE_OBJECTS.update( { "AnInnerPortable": _inner_portable, "CustomStreamSerializable": _custom_serializable, "CustomByteArraySerializable": _custom_byte_array_serializable, "AnIdentifiedDataSerializable": _identified, "APortable": _portable, "ArrayList": [None, _non_null_list], "LinkedList": [None, _non_null_list], "TruePredicate": predicate.true(), "FalsePredicate": predicate.false(), "SqlPredicate": predicate.sql(_sql_string), "EqualPredicate": predicate.equal(_sql_string, REFERENCE_OBJECTS["Integer"]), "NotEqualPredicate": predicate.not_equal(_sql_string, REFERENCE_OBJECTS["Integer"]), "GreaterLessPredicate": predicate.greater(_sql_string, REFERENCE_OBJECTS["Integer"]), "BetweenPredicate": predicate.between( _sql_string, REFERENCE_OBJECTS["Integer"], REFERENCE_OBJECTS["Integer"] ), "LikePredicate": predicate.like(_sql_string, _sql_string), "ILikePredicate": predicate.ilike(_sql_string, _sql_string), "InPredicate": predicate.in_( _sql_string, REFERENCE_OBJECTS["Integer"], REFERENCE_OBJECTS["Integer"] ), "RegexPredicate": predicate.regex(_sql_string, _sql_string), "AndPredicate": predicate.and_(
def test_paging(self): predicate = paging(true(), 5) self.assertEqual( str(predicate), "PagingPredicate(predicate=TruePredicate(), page_size=5, comparator=None)", )
def test_true(self): predicate = true() self.assertEqual(str(predicate), "TruePredicate()")
"b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "g": 7, }) size = m1.size() print("Added %s elements" % size) # When using paging predicate without a comparator, # server sorts the entries according to their default # orderings. In this particular case, values will be # sorted in ascending order. predicate = paging(true(), 2) # Get all values with page size of 2 # Prints pages of size 2 in the [1, 2], [3, 4], [5, 6], [7] order for i in range(4): values = m1.values(predicate) print("Page %s:%s" % (i, values)) predicate.next_page( ) # Call next_page on predicate to get the next page on the next iteration # If you want to sort results differently, you have to use # a comparator. Comparator will be serialized and sent # to server. Server will do the sorting accordingly. Hence, # the implementation of the comparator must be defined on the # server side and registered as a Portable or IdentifiedDataSerializable # before the server starts.