@Property public void shouldReturnCorrectPartitionForGetHashKey( @Size(min = 1, max = 5) List<@InRange(minInt = 1, maxInt = 20) Integer> partitionSizes, @InRange(minInt = 0, maxInt = 50) int bucketId) { BucketTargetingFixedResolver resolver = new BucketTargetingFixedResolver(); ConcurrentMap<String, Integer[]> fakePartitions = new ConcurrentHashMap<>(); int startingBucket = 0; for (int i = 0; i < partitionSizes.size(); i++) { fakePartitions.put("p" + i, new Integer[] {startingBucket, partitionSizes.get(i)}); startingBucket += partitionSizes.get(i); } assumeTrue(bucketId < startingBucket); final PartitionedRegion region = mock(PartitionedRegion.class); when(region.getPartitionsMap()).thenReturn(fakePartitions); when(region.isFixedPartitionedRegion()).thenReturn(true); when(region.getPartitionResolver()).thenReturn(resolver); assertEquals(bucketId, PartitionedRegionHelper.getHashKey(region, Operation.CREATE, "key", "value", bucketId)); }
@Property public void shouldHold(Foo @Size(min = 2, max = 4) [] f) { attempts.add(f); fail(); } }
@Property public void shouldHold(@Size(min = 2, max = 5) Set<Integer> items) { failed = items; fail(); } }
@Property public void shouldHold(@Size(min = 2, max = 5) Map<Integer, Double> items) { failed = items; fail(); } }
@Property public void shouldHold(@Size(min = 2, max = 5) List<?> items) { failed = items; fail(); } }
@Property public void shouldHold(@Size(min = 2, max = 5) Set<String> items) { assertThat(items.size(), lessThanOrEqualTo(5)); } }
@Property public void shouldHold(@Size(min = 4, max = 3) Map<Integer, ?> items) { assertThat(items.size(), lessThanOrEqualTo(3)); } }
@Property public void shouldHold(@Size(min = 2, max = 5) List<?> items) { assertThat(items.size(), allOf(greaterThanOrEqualTo(2), lessThanOrEqualTo(5))); } }
@Property public void shouldHold(boolean @Size(min = 2, max = 4) [] b) { assertThat(b.length, allOf(greaterThanOrEqualTo(2), lessThanOrEqualTo(4))); } }
@Property public void shouldHold( @Size(min = 4, max = 5) @Distinct Map<@InRange(minInt = 1, maxInt = 5) Integer, Double> items) { assertThat( items.size(), allOf( greaterThanOrEqualTo(4), lessThanOrEqualTo(5))); } }
@Property public void shouldHold( @Size(min = 4, max = 5) @Distinct Set<@InRange(minInt = 1, maxInt = 5) Integer> items) { assertThat(items.size(), allOf(greaterThanOrEqualTo(4), lessThanOrEqualTo(5))); } }
@Property public void shouldHold( @InRange(minInt = 1, maxInt = 5) int @Size(min = 4, max = 5) @Distinct [] i) { failed = i; fail(); } }
@Property public void shouldHold( @Size(min = 4, max = 5) @Distinct List<@InRange(minInt = 1, maxInt = 5) Integer> items) { failed = items; fail(); } }
@Property public void shouldHold( @Size(min = 4, max = 5) @Distinct Map<@InRange(minInt = 1, maxInt = 5) Integer, Double> items) { failed = items; fail(); } }
@Property public void shouldHold( @Size(min = 4, max = 5) @Distinct Set<@InRange(minInt = 1, maxInt = 5) Integer> items) { failed = items; fail(); } }
@Property public void shouldHold( @Size(min = 2, max = 5) @Distinct List<@InRange(minInt = 1, maxInt = 5) Integer> items) { assertThat( items.size(), allOf( greaterThanOrEqualTo(2), lessThanOrEqualTo(5))); assertTrue(Lists.isDistinct(items)); } }
@Property public void shouldHold( @InRange(minInt = 1, maxInt = 5) int @Size(min = 2, max = 5) @Distinct [] i) { assertThat( i.length, allOf( greaterThanOrEqualTo(2), lessThanOrEqualTo(5))); assertTrue(Lists.isDistinct(Ints.asList(i))); } }