private MultiDataSetRequest.Builder fuzz(final MultiDataSetRequest.Builder reqBuilder) { MultiDataSetRequest.Builder builder = reqBuilder; if (_random.nextDouble() > WITH_FREQUENCY_PROBABILITY) { builder = builder.withFrequency(Frequency.values()[_random.nextInt(Frequency.values().length)]); } if (_random.nextDouble() > WITH_TRANSFORM_PROBABILITY) { builder = builder.withTransform(Transform.values()[(int) (_random.nextInt(Transform.values().length))]); } if (_random.nextDouble() > WITH_MAX_ROWS_PROBABILITY) { builder = builder.withMaxRows(_random.nextInt(MAX_ROWS)); } LocalDate startDate = LocalDate.ofEpochDay(_random.nextInt(MAX_YEARS_OUT * DAYS_PER_YEAR) + (BASE_YEARS_FROM_EPOCH * DAYS_PER_YEAR)); if (_random.nextDouble() > WITH_START_DATE_PROBABILITY) { builder = builder.withStartDate(startDate); } if (_random.nextDouble() > WITH_END_DATE_PROBABILITY) { builder = builder.withEndDate(startDate.plusDays(_random.nextInt(DAYS_PER_YEAR * MAX_PLUS_YEARS))); } return builder; }
@Test public void testComplexMultiDataSetRequestEqualsAndHashCodeAgainstStringAndObject() { // Note that the tests on hashCode here are beyond the contract requirements of hashCode, we're saying they must differ if the object differs, which is // generally good, but not required. MultiDataSetRequest request1 = MultiDataSetRequest.Builder .of(QuandlCodeRequest.allColumns("CODE/CODE")) .withFrequency(Frequency.NONE) .withMaxRows(49) .withSortOrder(SortOrder.ASCENDING) .withStartDate(LocalDate.of(2010, 1, 1)) .withEndDate(LocalDate.of(2011, 1, 1)) .build(); Assert.assertNotEquals(request1, "Hello"); Assert.assertNotEquals(request1, new Object()); }
.of(QuandlCodeRequest.allColumns("CODE/CODE")) .withFrequency(Frequency.NONE) .withMaxRows(49) .withSortOrder(SortOrder.ASCENDING) .withStartDate(LocalDate.of(2010, 1, 1)) .of(QuandlCodeRequest.allColumns("CODE/CODF")) // note the F in there .withFrequency(Frequency.NONE) .withMaxRows(49) .withSortOrder(SortOrder.ASCENDING) .withStartDate(LocalDate.of(2010, 1, 1)) .of(QuandlCodeRequest.singleColumn("CODE/CODE", 0)) .withFrequency(Frequency.NONE) .withMaxRows(49) .withSortOrder(SortOrder.ASCENDING) .withStartDate(LocalDate.of(2010, 1, 1)) .of(QuandlCodeRequest.allColumns("CODE/CODE"), QuandlCodeRequest.singleColumn("CODE/CODE", 0)) .withFrequency(Frequency.NONE) .withMaxRows(49) .withSortOrder(SortOrder.ASCENDING) .withStartDate(LocalDate.of(2010, 1, 1)) .withMaxRows(49) .withSortOrder(SortOrder.ASCENDING) .withStartDate(LocalDate.of(2010, 1, 1)) .withMaxRows(49)