Ejemplo n.º 1
0
  @Test
  @SuppressWarnings("unchecked")
  public void parse_object() throws IOException {
    List<Object> members =
        (List<Object>) parser.parse(resources.sourceFile(Paths.get("_data", "members.yml")));

    assertThat(members).hasSize(3);
    assertThat((Map<String, Object>) members.get(0))
        .containsExactly(entry("name", "Tom Preston-Werner"), entry("github", "mojombo"));
  }
  /** Test that before the timeout we have a draw that is not 1, 2, ..., MAX */
  @Test(timeout = 1000L)
  public void testDrawIsRandom() throws Exception {
    final List<Integer> nonRandom = new ArrayList<>();
    for (int i = 1; i < SilanisLottery.MAX_BALL; i++) {
      nonRandom.add(i);
    }

    List<Integer> draws;
    do {
      draws = new ArrayList<>();
      this.fillDraws(draws);
    } while (draws.equals(nonRandom));
  }
 /**
  * Draw until there is no more available draw
  *
  * @param draws input list
  */
 private void fillDraws(List<Integer> draws) {
   try {
     while (this.drawableInteger.isDrawWithoutReplacementAvailable()) {
       final int draw = this.drawableInteger.drawWithoutReplacement();
       draws.add(draw);
     }
   } catch (final NoAvailableDrawWithoutReplacementException e) {
     fail("Unexpected exception: we stop when there is no more available draw.", e);
   }
 }