mercredi 24 février 2016

Using take(n) more than once on Random sequence

I would like to take groups of strings from a Randomized sequence. I found that Randoms.takeFromValues provides a sequence that is most suitable for this. But it does not quiet work as expected. I am sure there is something I am not doing right. Here is a test code, It fails at second assertion as the size of list2 is 2 instead of 3.

@Test
public void totallylazy_random_sequence_test() {
    List<String> strings = list("string-1","string-2","string-3","string-4","string-5","string-6");
    Sequence<String> selector = Randoms.takeFromValues(strings);
    List<String> list1 = selector.take(3).toList();
    List<String> list2 = selector.take(3).toList();
    assertThat(list1.size(), is(3));
    assertThat(list2.size(), is(3));
}




Aucun commentaire:

Enregistrer un commentaire