target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 42 86.8k | src_fm_fc_ms_ff stringlengths 43 86.8k |
|---|---|---|---|---|---|
@Test void generatedBeansNumberShouldBeEqualToSpecifiedNumber() { Stream<Person> persons = easyRandom.objects(Person.class, 2); assertThat(persons).hasSize(2).hasOnlyElementsOfType(Person.class); } | public <T> Stream<T> objects(final Class<T> type, final int streamSize) { if (streamSize < 0) { throw new IllegalArgumentException("The stream size must be positive"); } return Stream.generate(() -> nextObject(type)).limit(streamSize); } | EasyRandom extends Random { public <T> Stream<T> objects(final Class<T> type, final int streamSize) { if (streamSize < 0) { throw new IllegalArgumentException("The stream size must be positive"); } return Stream.generate(() -> nextObject(type)).limit(streamSize); } } | EasyRandom extends Random { public <T> Stream<T> objects(final Class<T> type, final int streamSize) { if (streamSize < 0) { throw new IllegalArgumentException("The stream size must be positive"); } return Stream.generate(() -> nextObject(type)).limit(streamSize); } EasyRandom(); EasyRandom(final EasyRandomParameters e... | EasyRandom extends Random { public <T> Stream<T> objects(final Class<T> type, final int streamSize) { if (streamSize < 0) { throw new IllegalArgumentException("The stream size must be positive"); } return Stream.generate(() -> nextObject(type)).limit(streamSize); } EasyRandom(); EasyRandom(final EasyRandomParameters e... | EasyRandom extends Random { public <T> Stream<T> objects(final Class<T> type, final int streamSize) { if (streamSize < 0) { throw new IllegalArgumentException("The stream size must be positive"); } return Stream.generate(() -> nextObject(type)).limit(streamSize); } EasyRandom(); EasyRandom(final EasyRandomParameters e... |
@Test void whenSpecifiedNumberOfBeansToGenerateIsNegative_thenShouldThrowAnIllegalArgumentException() { assertThatThrownBy(() -> easyRandom.objects(Person.class, -2)).isInstanceOf(IllegalArgumentException.class); } | public <T> Stream<T> objects(final Class<T> type, final int streamSize) { if (streamSize < 0) { throw new IllegalArgumentException("The stream size must be positive"); } return Stream.generate(() -> nextObject(type)).limit(streamSize); } | EasyRandom extends Random { public <T> Stream<T> objects(final Class<T> type, final int streamSize) { if (streamSize < 0) { throw new IllegalArgumentException("The stream size must be positive"); } return Stream.generate(() -> nextObject(type)).limit(streamSize); } } | EasyRandom extends Random { public <T> Stream<T> objects(final Class<T> type, final int streamSize) { if (streamSize < 0) { throw new IllegalArgumentException("The stream size must be positive"); } return Stream.generate(() -> nextObject(type)).limit(streamSize); } EasyRandom(); EasyRandom(final EasyRandomParameters e... | EasyRandom extends Random { public <T> Stream<T> objects(final Class<T> type, final int streamSize) { if (streamSize < 0) { throw new IllegalArgumentException("The stream size must be positive"); } return Stream.generate(() -> nextObject(type)).limit(streamSize); } EasyRandom(); EasyRandom(final EasyRandomParameters e... | EasyRandom extends Random { public <T> Stream<T> objects(final Class<T> type, final int streamSize) { if (streamSize < 0) { throw new IllegalArgumentException("The stream size must be positive"); } return Stream.generate(() -> nextObject(type)).limit(streamSize); } EasyRandom(); EasyRandom(final EasyRandomParameters e... |
@Test void testGetInheritedFields() { assertThat(ReflectionUtils.getInheritedFields(SocialPerson.class)).hasSize(11); } | public static List<Field> getInheritedFields(Class<?> type) { List<Field> inheritedFields = new ArrayList<>(); while (type.getSuperclass() != null) { Class<?> superclass = type.getSuperclass(); inheritedFields.addAll(asList(superclass.getDeclaredFields())); type = superclass; } return inheritedFields; } | ReflectionUtils { public static List<Field> getInheritedFields(Class<?> type) { List<Field> inheritedFields = new ArrayList<>(); while (type.getSuperclass() != null) { Class<?> superclass = type.getSuperclass(); inheritedFields.addAll(asList(superclass.getDeclaredFields())); type = superclass; } return inheritedFields;... | ReflectionUtils { public static List<Field> getInheritedFields(Class<?> type) { List<Field> inheritedFields = new ArrayList<>(); while (type.getSuperclass() != null) { Class<?> superclass = type.getSuperclass(); inheritedFields.addAll(asList(superclass.getDeclaredFields())); type = superclass; } return inheritedFields;... | ReflectionUtils { public static List<Field> getInheritedFields(Class<?> type) { List<Field> inheritedFields = new ArrayList<>(); while (type.getSuperclass() != null) { Class<?> superclass = type.getSuperclass(); inheritedFields.addAll(asList(superclass.getDeclaredFields())); type = superclass; } return inheritedFields;... | ReflectionUtils { public static List<Field> getInheritedFields(Class<?> type) { List<Field> inheritedFields = new ArrayList<>(); while (type.getSuperclass() != null) { Class<?> superclass = type.getSuperclass(); inheritedFields.addAll(asList(superclass.getDeclaredFields())); type = superclass; } return inheritedFields;... |
@Test void whenUnableToInstantiateField_thenShouldThrowObjectGenerationException() { assertThatThrownBy(() -> easyRandom.nextObject(AbstractBean.class)).isInstanceOf(ObjectCreationException.class); } | public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... |
@Test void beansWithRecursiveStructureMustNotCauseStackOverflowException() { Node node = easyRandom.nextObject(Node.class); assertThat(node).hasNoNullFieldsOrProperties(); } | public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... |
@Test void objectTypeMustBeCorrectlyPopulated() { Object object = easyRandom.nextObject(Object.class); assertThat(object).isNotNull(); } | public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... |
@Test void annotatedRandomizerArgumentsShouldBeCorrectlyParsed() { TestData data = easyRandom.nextObject(TestData.class); then(data.getDate()).isBetween(valueOf(of(2016, 1, 10, 0, 0, 0)), valueOf(of(2016, 1, 30, 23, 59, 59))); then(data.getPrice()).isBetween(200, 500); } | public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... |
@Test void nextEnumShouldNotAlwaysReturnTheSameValue() { HashSet<TestEnum> distinctEnumBeans = new HashSet<>(); for (int i = 0; i < 10; i++) { distinctEnumBeans.add(easyRandom.nextObject(TestEnum.class)); } assertThat(distinctEnumBeans.size()).isGreaterThan(1); } | public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... |
@Test void fieldsOfTypeClassShouldBeSkipped() { try { TestBean testBean = easyRandom.nextObject(TestBean.class); assertThat(testBean.getException()).isNotNull(); assertThat(testBean.getClazz()).isNull(); } catch (Exception e) { fail("Should skip fields of type Class"); } } | public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... |
@Test void differentCollectionsShouldBeRandomizedWithDifferentSizes() { class Foo { List<String> names; List<String> addresses; } Foo foo = new EasyRandom().nextObject(Foo.class); assertThat(foo.names.size()).isNotEqualTo(foo.addresses.size()); } | public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... |
@Test void differentArraysShouldBeRandomizedWithDifferentSizes() { class Foo { String[] names; String[] addresses; } Foo foo = new EasyRandom().nextObject(Foo.class); assertThat(foo.names.length).isNotEqualTo(foo.addresses.length); } | public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... |
@Disabled("Dummy test to see possible reasons of randomization failures") @Test void tryToRandomizeAllPublicConcreteTypesInTheClasspath(){ int success = 0; int failure = 0; List<Class<?>> publicConcreteTypes = ReflectionUtils.getPublicConcreteSubTypesOf(Object.class); System.out.println("Found " + publicConcreteTypes.s... | public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); } | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... | EasyRandom extends Random { public <T> T nextObject(final Class<T> type) { return doPopulateBean(type, new RandomizationContext(type, parameters)); } EasyRandom(); EasyRandom(final EasyRandomParameters easyRandomParameters); T nextObject(final Class<T> type); Stream<T> objects(final Class<T> type, final int streamSize... |
@Test void whenSkipRandomizerIsRegisteredForTheField_thenTheFieldShouldBeSkipped() throws Exception { Field name = Human.class.getDeclaredField("name"); Human human = new Human(); randomizer = new SkipRandomizer(); RandomizationContext context = new RandomizationContext(Human.class, new EasyRandomParameters()); when(ra... | void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwareRandomizer<?>) ... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... |
@Test void testIsStatic() throws Exception { assertThat(ReflectionUtils.isStatic(Human.class.getField("SERIAL_VERSION_UID"))).isTrue(); } | public static boolean isStatic(final Field field) { return Modifier.isStatic(field.getModifiers()); } | ReflectionUtils { public static boolean isStatic(final Field field) { return Modifier.isStatic(field.getModifiers()); } } | ReflectionUtils { public static boolean isStatic(final Field field) { return Modifier.isStatic(field.getModifiers()); } private ReflectionUtils(); } | ReflectionUtils { public static boolean isStatic(final Field field) { return Modifier.isStatic(field.getModifiers()); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> getInheritedF... | ReflectionUtils { public static boolean isStatic(final Field field) { return Modifier.isStatic(field.getModifiers()); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> getInheritedF... |
@Test void whenCustomRandomizerIsRegisteredForTheField_thenTheFieldShouldBePopulatedWithTheRandomValue() throws Exception { Field name = Human.class.getDeclaredField("name"); Human human = new Human(); RandomizationContext context = new RandomizationContext(Human.class, new EasyRandomParameters()); when(randomizerProvi... | void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwareRandomizer<?>) ... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... |
@Test void whenTheFieldIsOfTypeArray_thenShouldDelegatePopulationToArrayPopulator() throws Exception { Field strings = ArrayBean.class.getDeclaredField("strings"); ArrayBean arrayBean = new ArrayBean(); String[] object = new String[0]; RandomizationContext context = new RandomizationContext(ArrayBean.class, new EasyRan... | void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwareRandomizer<?>) ... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... |
@Test void whenTheFieldIsOfTypeCollection_thenShouldDelegatePopulationToCollectionPopulator() throws Exception { Field strings = CollectionBean.class.getDeclaredField("typedCollection"); CollectionBean collectionBean = new CollectionBean(); Collection<Person> persons = Collections.emptyList(); RandomizationContext cont... | void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwareRandomizer<?>) ... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... |
@Test void whenTheFieldIsOfTypeMap_thenShouldDelegatePopulationToMapPopulator() throws Exception { Field strings = MapBean.class.getDeclaredField("typedMap"); MapBean mapBean = new MapBean(); Map<Integer, Person> idToPerson = new HashMap<>(); RandomizationContext context = new RandomizationContext(MapBean.class, new Ea... | void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwareRandomizer<?>) ... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... |
@Test void whenRandomizationDepthIsExceeded_thenFieldsAreNotInitialized() throws Exception { Field name = Human.class.getDeclaredField("name"); Human human = new Human(); RandomizationContext context = Mockito.mock(RandomizationContext.class); when(context.hasExceededRandomizationDepth()).thenReturn(true); fieldPopulat... | void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwareRandomizer<?>) ... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... |
@Test @Disabled("Objenesis is able to create an instance of JAXBElement type. Hence no error is thrown as expected in this test") void shouldFailWithNiceErrorMessageWhenUnableToCreateFieldValue() throws Exception { FieldPopulator fieldPopulator = new FieldPopulator(new EasyRandom(), randomizerProvider, arrayPopulator, ... | void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwareRandomizer<?>) ... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... | FieldPopulator { void populateField(final Object target, final Field field, final RandomizationContext context) throws IllegalAccessException { Randomizer<?> randomizer = getRandomizer(field, context); if (randomizer instanceof SkipRandomizer) { return; } if (randomizer instanceof ContextAwareRandomizer) { ((ContextAwa... |
@Test void testCompare() { assertThat(priorityComparator.compare(foo, bar)).isGreaterThan(0); List<Object> objects = Arrays.asList(foo,bar); objects.sort(priorityComparator); assertThat(objects).containsExactly(bar, foo); } | @Override public int compare(final Object o1, final Object o2) { int o1Priority = getPriority(o1); int o2Priority = getPriority(o2); return o2Priority - o1Priority; } | PriorityComparator implements Comparator<Object> { @Override public int compare(final Object o1, final Object o2) { int o1Priority = getPriority(o1); int o2Priority = getPriority(o2); return o2Priority - o1Priority; } } | PriorityComparator implements Comparator<Object> { @Override public int compare(final Object o1, final Object o2) { int o1Priority = getPriority(o1); int o2Priority = getPriority(o2); return o2Priority - o1Priority; } } | PriorityComparator implements Comparator<Object> { @Override public int compare(final Object o1, final Object o2) { int o1Priority = getPriority(o1); int o2Priority = getPriority(o2); return o2Priority - o1Priority; } @Override int compare(final Object o1, final Object o2); } | PriorityComparator implements Comparator<Object> { @Override public int compare(final Object o1, final Object o2) { int o1Priority = getPriority(o1); int o2Priority = getPriority(o2); return o2Priority - o1Priority; } @Override int compare(final Object o1, final Object o2); } |
@Test void rawInterfaceCollectionTypesMustBeReturnedEmpty() throws Exception { when(context.getParameters()).thenReturn(parameters); Field field = Foo.class.getDeclaredField("rawInterfaceList"); Collection<?> collection = collectionPopulator.getRandomCollection(field, context); assertThat(collection).isEmpty(); } | @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collection collection; if (isIn... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... |
@Test void rawConcreteCollectionTypesMustBeReturnedEmpty() throws Exception { when(context.getParameters()).thenReturn(parameters); Field field = Foo.class.getDeclaredField("rawConcreteList"); Collection<?> collection = collectionPopulator.getRandomCollection(field, context); assertThat(collection).isEmpty(); } | @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collection collection; if (isIn... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... |
@Test void typedInterfaceCollectionTypesMightBePopulated() throws Exception { when(context.getParameters()).thenReturn(parameters); when(easyRandom.doPopulateBean(String.class, context)).thenReturn(STRING); Field field = Foo.class.getDeclaredField("typedInterfaceList"); @SuppressWarnings("unchecked") Collection<String>... | @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collection collection; if (isIn... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... |
@Test void testIsInterface() { assertThat(ReflectionUtils.isInterface(List.class)).isTrue(); assertThat(ReflectionUtils.isInterface(Mammal.class)).isTrue(); assertThat(ReflectionUtils.isInterface(MammalImpl.class)).isFalse(); assertThat(ReflectionUtils.isInterface(ArrayList.class)).isFalse(); } | public static boolean isInterface(final Class<?> type) { return type.isInterface(); } | ReflectionUtils { public static boolean isInterface(final Class<?> type) { return type.isInterface(); } } | ReflectionUtils { public static boolean isInterface(final Class<?> type) { return type.isInterface(); } private ReflectionUtils(); } | ReflectionUtils { public static boolean isInterface(final Class<?> type) { return type.isInterface(); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> getInheritedFields(Class<?> t... | ReflectionUtils { public static boolean isInterface(final Class<?> type) { return type.isInterface(); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> getInheritedFields(Class<?> t... |
@Test void typedConcreteCollectionTypesMightBePopulated() throws Exception { when(context.getParameters()).thenReturn(parameters); when(easyRandom.doPopulateBean(String.class, context)).thenReturn(STRING); Field field = Foo.class.getDeclaredField("typedConcreteList"); @SuppressWarnings("unchecked") Collection<String> c... | @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collection collection; if (isIn... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... | CollectionPopulator { @SuppressWarnings({"unchecked", "rawtypes"}) Collection<?> getRandomCollection(final Field field, final RandomizationContext context) { int randomSize = getRandomCollectionSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Collectio... |
@Test void staticFieldsShouldBeExcluded() throws NoSuchFieldException { Field field = Human.class.getDeclaredField("SERIAL_VERSION_UID"); boolean actual = exclusionPolicy.shouldBeExcluded(field, randomizerContext); assertThat(actual).isTrue(); } | public boolean shouldBeExcluded(final Field field, final RandomizerContext context) { if (isStatic(field)) { return true; } Set<Predicate<Field>> fieldExclusionPredicates = context.getParameters().getFieldExclusionPredicates(); for (Predicate<Field> fieldExclusionPredicate : fieldExclusionPredicates) { if (fieldExclusi... | DefaultExclusionPolicy implements ExclusionPolicy { public boolean shouldBeExcluded(final Field field, final RandomizerContext context) { if (isStatic(field)) { return true; } Set<Predicate<Field>> fieldExclusionPredicates = context.getParameters().getFieldExclusionPredicates(); for (Predicate<Field> fieldExclusionPred... | DefaultExclusionPolicy implements ExclusionPolicy { public boolean shouldBeExcluded(final Field field, final RandomizerContext context) { if (isStatic(field)) { return true; } Set<Predicate<Field>> fieldExclusionPredicates = context.getParameters().getFieldExclusionPredicates(); for (Predicate<Field> fieldExclusionPred... | DefaultExclusionPolicy implements ExclusionPolicy { public boolean shouldBeExcluded(final Field field, final RandomizerContext context) { if (isStatic(field)) { return true; } Set<Predicate<Field>> fieldExclusionPredicates = context.getParameters().getFieldExclusionPredicates(); for (Predicate<Field> fieldExclusionPred... | DefaultExclusionPolicy implements ExclusionPolicy { public boolean shouldBeExcluded(final Field field, final RandomizerContext context) { if (isStatic(field)) { return true; } Set<Predicate<Field>> fieldExclusionPredicates = context.getParameters().getFieldExclusionPredicates(); for (Predicate<Field> fieldExclusionPred... |
@Test void rawInterfaceMapTypesMustBeGeneratedEmpty() throws Exception { when(context.getParameters()).thenReturn(parameters); Field field = Foo.class.getDeclaredField("rawMap"); Map<?, ?> randomMap = mapPopulator.getRandomMap(field, context); assertThat(randomMap).isEmpty(); } | @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldType)) { map = (M... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... |
@Test void rawConcreteMapTypesMustBeGeneratedEmpty() throws Exception { when(context.getParameters()).thenReturn(parameters); Field field = Foo.class.getDeclaredField("concreteMap"); Map<?, ?> randomMap = mapPopulator.getRandomMap(field, context); assertThat(randomMap).isEmpty(); } | @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldType)) { map = (M... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... |
@Test void typedInterfaceMapTypesMightBePopulated() throws Exception { when(context.getParameters()).thenReturn(parameters); when(easyRandom.doPopulateBean(String.class, context)).thenReturn(FOO, BAR); Field field = Foo.class.getDeclaredField("typedMap"); Map<String, String> randomMap = (Map<String, String>) mapPopulat... | @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldType)) { map = (M... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... |
@Test void typedConcreteMapTypesMightBePopulated() throws Exception { when(context.getParameters()).thenReturn(parameters); when(easyRandom.doPopulateBean(String.class, context)).thenReturn(FOO, BAR); Field field = Foo.class.getDeclaredField("typedConcreteMap"); Map<String, String> randomMap = (Map<String, String>) map... | @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldType)) { map = (M... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... |
@Test void notAddNullKeysToMap() throws NoSuchFieldException { when(context.getParameters()).thenReturn(parameters); when(easyRandom.doPopulateBean(String.class, context)).thenReturn(null); Field field = Foo.class.getDeclaredField("typedConcreteMap"); Map<String, String> randomMap = (Map<String, String>) mapPopulator.g... | @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldType)) { map = (M... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... | MapPopulator { @SuppressWarnings("unchecked") Map<?, ?> getRandomMap(final Field field, final RandomizationContext context) { int randomSize = getRandomMapSize(context.getParameters()); Class<?> fieldType = field.getType(); Type fieldGenericType = field.getGenericType(); Map<Object, Object> map; if (isInterface(fieldTy... |
@Test void concreteClassesShouldBeCreatedAsExpected() { String string = objenesisObjectFactory.createInstance(String.class, context); assertThat(string).isNotNull(); } | @Override public <T> T createInstance(Class<T> type, RandomizerContext context) { if (context.getParameters().isScanClasspathForConcreteTypes() && isAbstract(type)) { Class<?> randomConcreteSubType = randomElementOf(getPublicConcreteSubTypesOf((type))); if (randomConcreteSubType == null) { throw new InstantiationError(... | ObjenesisObjectFactory implements ObjectFactory { @Override public <T> T createInstance(Class<T> type, RandomizerContext context) { if (context.getParameters().isScanClasspathForConcreteTypes() && isAbstract(type)) { Class<?> randomConcreteSubType = randomElementOf(getPublicConcreteSubTypesOf((type))); if (randomConcre... | ObjenesisObjectFactory implements ObjectFactory { @Override public <T> T createInstance(Class<T> type, RandomizerContext context) { if (context.getParameters().isScanClasspathForConcreteTypes() && isAbstract(type)) { Class<?> randomConcreteSubType = randomElementOf(getPublicConcreteSubTypesOf((type))); if (randomConcre... | ObjenesisObjectFactory implements ObjectFactory { @Override public <T> T createInstance(Class<T> type, RandomizerContext context) { if (context.getParameters().isScanClasspathForConcreteTypes() && isAbstract(type)) { Class<?> randomConcreteSubType = randomElementOf(getPublicConcreteSubTypesOf((type))); if (randomConcre... | ObjenesisObjectFactory implements ObjectFactory { @Override public <T> T createInstance(Class<T> type, RandomizerContext context) { if (context.getParameters().isScanClasspathForConcreteTypes() && isAbstract(type)) { Class<?> randomConcreteSubType = randomElementOf(getPublicConcreteSubTypesOf((type))); if (randomConcre... |
@Test void whenNoConcreteTypeIsFound_thenShouldThrowAnInstantiationError() { Mockito.when(context.getParameters().isScanClasspathForConcreteTypes()).thenReturn(true); assertThatThrownBy(() -> objenesisObjectFactory.createInstance(AbstractFoo.class, context)).isInstanceOf(InstantiationError.class); } | @Override public <T> T createInstance(Class<T> type, RandomizerContext context) { if (context.getParameters().isScanClasspathForConcreteTypes() && isAbstract(type)) { Class<?> randomConcreteSubType = randomElementOf(getPublicConcreteSubTypesOf((type))); if (randomConcreteSubType == null) { throw new InstantiationError(... | ObjenesisObjectFactory implements ObjectFactory { @Override public <T> T createInstance(Class<T> type, RandomizerContext context) { if (context.getParameters().isScanClasspathForConcreteTypes() && isAbstract(type)) { Class<?> randomConcreteSubType = randomElementOf(getPublicConcreteSubTypesOf((type))); if (randomConcre... | ObjenesisObjectFactory implements ObjectFactory { @Override public <T> T createInstance(Class<T> type, RandomizerContext context) { if (context.getParameters().isScanClasspathForConcreteTypes() && isAbstract(type)) { Class<?> randomConcreteSubType = randomElementOf(getPublicConcreteSubTypesOf((type))); if (randomConcre... | ObjenesisObjectFactory implements ObjectFactory { @Override public <T> T createInstance(Class<T> type, RandomizerContext context) { if (context.getParameters().isScanClasspathForConcreteTypes() && isAbstract(type)) { Class<?> randomConcreteSubType = randomElementOf(getPublicConcreteSubTypesOf((type))); if (randomConcre... | ObjenesisObjectFactory implements ObjectFactory { @Override public <T> T createInstance(Class<T> type, RandomizerContext context) { if (context.getParameters().isScanClasspathForConcreteTypes() && isAbstract(type)) { Class<?> randomConcreteSubType = randomElementOf(getPublicConcreteSubTypesOf((type))); if (randomConcre... |
@Test void should_throw_an_exception_when_all_values_are_excluded() { assertThatThrownBy(() -> aNewEnumRandomizer(Gender.class, Gender.values())).isInstanceOf(IllegalArgumentException.class); } | public static <E extends Enum<E>> EnumRandomizer<E> aNewEnumRandomizer(final Class<E> enumeration) { return new EnumRandomizer<>(enumeration); } | EnumRandomizer extends AbstractRandomizer<E> { public static <E extends Enum<E>> EnumRandomizer<E> aNewEnumRandomizer(final Class<E> enumeration) { return new EnumRandomizer<>(enumeration); } } | EnumRandomizer extends AbstractRandomizer<E> { public static <E extends Enum<E>> EnumRandomizer<E> aNewEnumRandomizer(final Class<E> enumeration) { return new EnumRandomizer<>(enumeration); } EnumRandomizer(final Class<E> enumeration); EnumRandomizer(final Class<E> enumeration, final long seed); EnumRandomizer(final ... | EnumRandomizer extends AbstractRandomizer<E> { public static <E extends Enum<E>> EnumRandomizer<E> aNewEnumRandomizer(final Class<E> enumeration) { return new EnumRandomizer<>(enumeration); } EnumRandomizer(final Class<E> enumeration); EnumRandomizer(final Class<E> enumeration, final long seed); EnumRandomizer(final ... | EnumRandomizer extends AbstractRandomizer<E> { public static <E extends Enum<E>> EnumRandomizer<E> aNewEnumRandomizer(final Class<E> enumeration) { return new EnumRandomizer<>(enumeration); } EnumRandomizer(final Class<E> enumeration); EnumRandomizer(final Class<E> enumeration, final long seed); EnumRandomizer(final ... |
@Test void testIsAbstract() { assertThat(ReflectionUtils.isAbstract(Foo.class)).isFalse(); assertThat(ReflectionUtils.isAbstract(Bar.class)).isTrue(); } | public static <T> boolean isAbstract(final Class<T> type) { return Modifier.isAbstract(type.getModifiers()); } | ReflectionUtils { public static <T> boolean isAbstract(final Class<T> type) { return Modifier.isAbstract(type.getModifiers()); } } | ReflectionUtils { public static <T> boolean isAbstract(final Class<T> type) { return Modifier.isAbstract(type.getModifiers()); } private ReflectionUtils(); } | ReflectionUtils { public static <T> boolean isAbstract(final Class<T> type) { return Modifier.isAbstract(type.getModifiers()); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> getI... | ReflectionUtils { public static <T> boolean isAbstract(final Class<T> type) { return Modifier.isAbstract(type.getModifiers()); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> getI... |
@Test void whenOptionalPercentIsOneHundredThenShouldGenerateValue() { assertThat(optionalRandomizer.getRandomValue()) .isEqualTo(NAME); } | @Override public T getRandomValue() { int randomPercent = random.nextInt(MAX_PERCENT); if (randomPercent <= optionalPercent) { return delegate.getRandomValue(); } return null; } | OptionalRandomizer extends AbstractRandomizer<T> { @Override public T getRandomValue() { int randomPercent = random.nextInt(MAX_PERCENT); if (randomPercent <= optionalPercent) { return delegate.getRandomValue(); } return null; } } | OptionalRandomizer extends AbstractRandomizer<T> { @Override public T getRandomValue() { int randomPercent = random.nextInt(MAX_PERCENT); if (randomPercent <= optionalPercent) { return delegate.getRandomValue(); } return null; } OptionalRandomizer(final Randomizer<T> delegate, final int optionalPercent); } | OptionalRandomizer extends AbstractRandomizer<T> { @Override public T getRandomValue() { int randomPercent = random.nextInt(MAX_PERCENT); if (randomPercent <= optionalPercent) { return delegate.getRandomValue(); } return null; } OptionalRandomizer(final Randomizer<T> delegate, final int optionalPercent); static Randomi... | OptionalRandomizer extends AbstractRandomizer<T> { @Override public T getRandomValue() { int randomPercent = random.nextInt(MAX_PERCENT); if (randomPercent <= optionalPercent) { return delegate.getRandomValue(); } return null; } OptionalRandomizer(final Randomizer<T> delegate, final int optionalPercent); static Randomi... |
@Test void generatedValueShouldBeWithinSpecifiedRange() { Double randomValue = randomizer.getRandomValue(); assertThat(randomValue).isBetween(min, max); } | @Override public Double getRandomValue() { return nextDouble(min, max); } | DoubleRangeRandomizer extends AbstractRangeRandomizer<Double> { @Override public Double getRandomValue() { return nextDouble(min, max); } } | DoubleRangeRandomizer extends AbstractRangeRandomizer<Double> { @Override public Double getRandomValue() { return nextDouble(min, max); } DoubleRangeRandomizer(final Double min, final Double max); DoubleRangeRandomizer(final Double min, final Double max, final long seed); } | DoubleRangeRandomizer extends AbstractRangeRandomizer<Double> { @Override public Double getRandomValue() { return nextDouble(min, max); } DoubleRangeRandomizer(final Double min, final Double max); DoubleRangeRandomizer(final Double min, final Double max, final long seed); static DoubleRangeRandomizer aNewDoubleRangeRa... | DoubleRangeRandomizer extends AbstractRangeRandomizer<Double> { @Override public Double getRandomValue() { return nextDouble(min, max); } DoubleRangeRandomizer(final Double min, final Double max); DoubleRangeRandomizer(final Double min, final Double max, final long seed); static DoubleRangeRandomizer aNewDoubleRangeRa... |
@Test void whenSpecifiedMinValueIsAfterMaxValueThenThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewDoubleRangeRandomizer(max, min)).isInstanceOf(IllegalArgumentException.class); } | public static DoubleRangeRandomizer aNewDoubleRangeRandomizer(final Double min, final Double max) { return new DoubleRangeRandomizer(min, max); } | DoubleRangeRandomizer extends AbstractRangeRandomizer<Double> { public static DoubleRangeRandomizer aNewDoubleRangeRandomizer(final Double min, final Double max) { return new DoubleRangeRandomizer(min, max); } } | DoubleRangeRandomizer extends AbstractRangeRandomizer<Double> { public static DoubleRangeRandomizer aNewDoubleRangeRandomizer(final Double min, final Double max) { return new DoubleRangeRandomizer(min, max); } DoubleRangeRandomizer(final Double min, final Double max); DoubleRangeRandomizer(final Double min, final Doub... | DoubleRangeRandomizer extends AbstractRangeRandomizer<Double> { public static DoubleRangeRandomizer aNewDoubleRangeRandomizer(final Double min, final Double max) { return new DoubleRangeRandomizer(min, max); } DoubleRangeRandomizer(final Double min, final Double max); DoubleRangeRandomizer(final Double min, final Doub... | DoubleRangeRandomizer extends AbstractRangeRandomizer<Double> { public static DoubleRangeRandomizer aNewDoubleRangeRandomizer(final Double min, final Double max) { return new DoubleRangeRandomizer(min, max); } DoubleRangeRandomizer(final Double min, final Double max); DoubleRangeRandomizer(final Double min, final Doub... |
@Test void generatedDateShouldNotBeNull() { assertThat(randomizer.getRandomValue()).isNotNull(); } | @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble(minDateTime, maxDateTime); return new Date(randomDateTime); } | SqlDateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble(minDateTime, maxDateTime); return new Date(randomDateTime); } } | SqlDateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble(minDateTime, maxDateTime); return new Date(randomDateTime); } SqlDateRangeRandomizer(final Date min, final D... | SqlDateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble(minDateTime, maxDateTime); return new Date(randomDateTime); } SqlDateRangeRandomizer(final Date min, final D... | SqlDateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble(minDateTime, maxDateTime); return new Date(randomDateTime); } SqlDateRangeRandomizer(final Date min, final D... |
@Test void generatedDateShouldBeWithinSpecifiedRange() { assertThat(randomizer.getRandomValue()).isBetween(minDate, maxDate); } | @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble(minDateTime, maxDateTime); return new Date(randomDateTime); } | SqlDateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble(minDateTime, maxDateTime); return new Date(randomDateTime); } } | SqlDateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble(minDateTime, maxDateTime); return new Date(randomDateTime); } SqlDateRangeRandomizer(final Date min, final D... | SqlDateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble(minDateTime, maxDateTime); return new Date(randomDateTime); } SqlDateRangeRandomizer(final Date min, final D... | SqlDateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble(minDateTime, maxDateTime); return new Date(randomDateTime); } SqlDateRangeRandomizer(final Date min, final D... |
@Test void generatedValueShouldBeWithinSpecifiedRange() { Byte randomValue = randomizer.getRandomValue(); assertThat(randomValue).isBetween(min, max); } | @Override public Byte getRandomValue() { return (byte) nextDouble(min, max); } | ByteRangeRandomizer extends AbstractRangeRandomizer<Byte> { @Override public Byte getRandomValue() { return (byte) nextDouble(min, max); } } | ByteRangeRandomizer extends AbstractRangeRandomizer<Byte> { @Override public Byte getRandomValue() { return (byte) nextDouble(min, max); } ByteRangeRandomizer(final Byte min, final Byte max); ByteRangeRandomizer(final Byte min, final Byte max, final long seed); } | ByteRangeRandomizer extends AbstractRangeRandomizer<Byte> { @Override public Byte getRandomValue() { return (byte) nextDouble(min, max); } ByteRangeRandomizer(final Byte min, final Byte max); ByteRangeRandomizer(final Byte min, final Byte max, final long seed); static ByteRangeRandomizer aNewByteRangeRandomizer(final ... | ByteRangeRandomizer extends AbstractRangeRandomizer<Byte> { @Override public Byte getRandomValue() { return (byte) nextDouble(min, max); } ByteRangeRandomizer(final Byte min, final Byte max); ByteRangeRandomizer(final Byte min, final Byte max, final long seed); static ByteRangeRandomizer aNewByteRangeRandomizer(final ... |
@Test void whenSpecifiedMinValueIsAfterMaxValueThenThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewByteRangeRandomizer(max, min)).isInstanceOf(IllegalArgumentException.class); } | public static ByteRangeRandomizer aNewByteRangeRandomizer(final Byte min, final Byte max) { return new ByteRangeRandomizer(min, max); } | ByteRangeRandomizer extends AbstractRangeRandomizer<Byte> { public static ByteRangeRandomizer aNewByteRangeRandomizer(final Byte min, final Byte max) { return new ByteRangeRandomizer(min, max); } } | ByteRangeRandomizer extends AbstractRangeRandomizer<Byte> { public static ByteRangeRandomizer aNewByteRangeRandomizer(final Byte min, final Byte max) { return new ByteRangeRandomizer(min, max); } ByteRangeRandomizer(final Byte min, final Byte max); ByteRangeRandomizer(final Byte min, final Byte max, final long seed); ... | ByteRangeRandomizer extends AbstractRangeRandomizer<Byte> { public static ByteRangeRandomizer aNewByteRangeRandomizer(final Byte min, final Byte max) { return new ByteRangeRandomizer(min, max); } ByteRangeRandomizer(final Byte min, final Byte max); ByteRangeRandomizer(final Byte min, final Byte max, final long seed); ... | ByteRangeRandomizer extends AbstractRangeRandomizer<Byte> { public static ByteRangeRandomizer aNewByteRangeRandomizer(final Byte min, final Byte max) { return new ByteRangeRandomizer(min, max); } ByteRangeRandomizer(final Byte min, final Byte max); ByteRangeRandomizer(final Byte min, final Byte max, final long seed); ... |
@Test void generatedOffsetDateTimeShouldNotBeNull() { assertThat(randomizer.getRandomValue()).isNotNull(); } | @Override public OffsetDateTime getRandomValue() { long minSeconds = min.toEpochSecond(); long maxSeconds = max.toEpochSecond(); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSeconds = max.getNano(); long nanoSeconds = (long) nextDouble(minNanoSeconds, maxNanoS... | OffsetDateTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetDateTime> { @Override public OffsetDateTime getRandomValue() { long minSeconds = min.toEpochSecond(); long maxSeconds = max.toEpochSecond(); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSecond... | OffsetDateTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetDateTime> { @Override public OffsetDateTime getRandomValue() { long minSeconds = min.toEpochSecond(); long maxSeconds = max.toEpochSecond(); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSecond... | OffsetDateTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetDateTime> { @Override public OffsetDateTime getRandomValue() { long minSeconds = min.toEpochSecond(); long maxSeconds = max.toEpochSecond(); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSecond... | OffsetDateTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetDateTime> { @Override public OffsetDateTime getRandomValue() { long minSeconds = min.toEpochSecond(); long maxSeconds = max.toEpochSecond(); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSecond... |
@Test void generatedOffsetDateTimeShouldBeWithinSpecifiedRange() { assertThat(randomizer.getRandomValue()).isBetween(minOffsetDateTime, maxOffsetDateTime); } | @Override public OffsetDateTime getRandomValue() { long minSeconds = min.toEpochSecond(); long maxSeconds = max.toEpochSecond(); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSeconds = max.getNano(); long nanoSeconds = (long) nextDouble(minNanoSeconds, maxNanoS... | OffsetDateTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetDateTime> { @Override public OffsetDateTime getRandomValue() { long minSeconds = min.toEpochSecond(); long maxSeconds = max.toEpochSecond(); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSecond... | OffsetDateTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetDateTime> { @Override public OffsetDateTime getRandomValue() { long minSeconds = min.toEpochSecond(); long maxSeconds = max.toEpochSecond(); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSecond... | OffsetDateTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetDateTime> { @Override public OffsetDateTime getRandomValue() { long minSeconds = min.toEpochSecond(); long maxSeconds = max.toEpochSecond(); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSecond... | OffsetDateTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetDateTime> { @Override public OffsetDateTime getRandomValue() { long minSeconds = min.toEpochSecond(); long maxSeconds = max.toEpochSecond(); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSecond... |
@Test void whenSpecifiedMinOffsetDateTimeIsAfterMaxOffsetDateTime_thenShouldThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewOffsetDateTimeRangeRandomizer(maxOffsetDateTime, minOffsetDateTime)).isInstanceOf(IllegalArgumentException.class); } | public static OffsetDateTimeRangeRandomizer aNewOffsetDateTimeRangeRandomizer(final OffsetDateTime min, final OffsetDateTime max) { return new OffsetDateTimeRangeRandomizer(min, max); } | OffsetDateTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetDateTime> { public static OffsetDateTimeRangeRandomizer aNewOffsetDateTimeRangeRandomizer(final OffsetDateTime min, final OffsetDateTime max) { return new OffsetDateTimeRangeRandomizer(min, max); } } | OffsetDateTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetDateTime> { public static OffsetDateTimeRangeRandomizer aNewOffsetDateTimeRangeRandomizer(final OffsetDateTime min, final OffsetDateTime max) { return new OffsetDateTimeRangeRandomizer(min, max); } OffsetDateTimeRangeRandomizer(final OffsetDateTime min... | OffsetDateTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetDateTime> { public static OffsetDateTimeRangeRandomizer aNewOffsetDateTimeRangeRandomizer(final OffsetDateTime min, final OffsetDateTime max) { return new OffsetDateTimeRangeRandomizer(min, max); } OffsetDateTimeRangeRandomizer(final OffsetDateTime min... | OffsetDateTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetDateTime> { public static OffsetDateTimeRangeRandomizer aNewOffsetDateTimeRangeRandomizer(final OffsetDateTime min, final OffsetDateTime max) { return new OffsetDateTimeRangeRandomizer(min, max); } OffsetDateTimeRangeRandomizer(final OffsetDateTime min... |
@Test void testIsPublic() { assertThat(ReflectionUtils.isPublic(Foo.class)).isTrue(); assertThat(ReflectionUtils.isPublic(Dummy.class)).isFalse(); } | public static <T> boolean isPublic(final Class<T> type) { return Modifier.isPublic(type.getModifiers()); } | ReflectionUtils { public static <T> boolean isPublic(final Class<T> type) { return Modifier.isPublic(type.getModifiers()); } } | ReflectionUtils { public static <T> boolean isPublic(final Class<T> type) { return Modifier.isPublic(type.getModifiers()); } private ReflectionUtils(); } | ReflectionUtils { public static <T> boolean isPublic(final Class<T> type) { return Modifier.isPublic(type.getModifiers()); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> getInher... | ReflectionUtils { public static <T> boolean isPublic(final Class<T> type) { return Modifier.isPublic(type.getModifiers()); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> getInher... |
@Test void generatedLocalDateShouldNotBeNull() { assertThat(randomizer.getRandomValue()).isNotNull(); } | @Override public LocalDate getRandomValue() { long minEpochDay = min.getLong(ChronoField.EPOCH_DAY); long maxEpochDay = max.getLong(ChronoField.EPOCH_DAY); long randomEpochDay = (long) nextDouble(minEpochDay, maxEpochDay); return LocalDate.ofEpochDay(randomEpochDay); } | LocalDateRangeRandomizer extends AbstractRangeRandomizer<LocalDate> { @Override public LocalDate getRandomValue() { long minEpochDay = min.getLong(ChronoField.EPOCH_DAY); long maxEpochDay = max.getLong(ChronoField.EPOCH_DAY); long randomEpochDay = (long) nextDouble(minEpochDay, maxEpochDay); return LocalDate.ofEpochDay... | LocalDateRangeRandomizer extends AbstractRangeRandomizer<LocalDate> { @Override public LocalDate getRandomValue() { long minEpochDay = min.getLong(ChronoField.EPOCH_DAY); long maxEpochDay = max.getLong(ChronoField.EPOCH_DAY); long randomEpochDay = (long) nextDouble(minEpochDay, maxEpochDay); return LocalDate.ofEpochDay... | LocalDateRangeRandomizer extends AbstractRangeRandomizer<LocalDate> { @Override public LocalDate getRandomValue() { long minEpochDay = min.getLong(ChronoField.EPOCH_DAY); long maxEpochDay = max.getLong(ChronoField.EPOCH_DAY); long randomEpochDay = (long) nextDouble(minEpochDay, maxEpochDay); return LocalDate.ofEpochDay... | LocalDateRangeRandomizer extends AbstractRangeRandomizer<LocalDate> { @Override public LocalDate getRandomValue() { long minEpochDay = min.getLong(ChronoField.EPOCH_DAY); long maxEpochDay = max.getLong(ChronoField.EPOCH_DAY); long randomEpochDay = (long) nextDouble(minEpochDay, maxEpochDay); return LocalDate.ofEpochDay... |
@Test void generatedLocalDateShouldBeWithinSpecifiedRange() { assertThat(randomizer.getRandomValue()).isBetween(minDate, maxDate); } | @Override public LocalDate getRandomValue() { long minEpochDay = min.getLong(ChronoField.EPOCH_DAY); long maxEpochDay = max.getLong(ChronoField.EPOCH_DAY); long randomEpochDay = (long) nextDouble(minEpochDay, maxEpochDay); return LocalDate.ofEpochDay(randomEpochDay); } | LocalDateRangeRandomizer extends AbstractRangeRandomizer<LocalDate> { @Override public LocalDate getRandomValue() { long minEpochDay = min.getLong(ChronoField.EPOCH_DAY); long maxEpochDay = max.getLong(ChronoField.EPOCH_DAY); long randomEpochDay = (long) nextDouble(minEpochDay, maxEpochDay); return LocalDate.ofEpochDay... | LocalDateRangeRandomizer extends AbstractRangeRandomizer<LocalDate> { @Override public LocalDate getRandomValue() { long minEpochDay = min.getLong(ChronoField.EPOCH_DAY); long maxEpochDay = max.getLong(ChronoField.EPOCH_DAY); long randomEpochDay = (long) nextDouble(minEpochDay, maxEpochDay); return LocalDate.ofEpochDay... | LocalDateRangeRandomizer extends AbstractRangeRandomizer<LocalDate> { @Override public LocalDate getRandomValue() { long minEpochDay = min.getLong(ChronoField.EPOCH_DAY); long maxEpochDay = max.getLong(ChronoField.EPOCH_DAY); long randomEpochDay = (long) nextDouble(minEpochDay, maxEpochDay); return LocalDate.ofEpochDay... | LocalDateRangeRandomizer extends AbstractRangeRandomizer<LocalDate> { @Override public LocalDate getRandomValue() { long minEpochDay = min.getLong(ChronoField.EPOCH_DAY); long maxEpochDay = max.getLong(ChronoField.EPOCH_DAY); long randomEpochDay = (long) nextDouble(minEpochDay, maxEpochDay); return LocalDate.ofEpochDay... |
@Test void whenSpecifiedMinDateIsAfterMaxDate_thenShouldThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewLocalDateRangeRandomizer(maxDate, minDate)).isInstanceOf(IllegalArgumentException.class); } | public static LocalDateRangeRandomizer aNewLocalDateRangeRandomizer(final LocalDate min, final LocalDate max) { return new LocalDateRangeRandomizer(min, max); } | LocalDateRangeRandomizer extends AbstractRangeRandomizer<LocalDate> { public static LocalDateRangeRandomizer aNewLocalDateRangeRandomizer(final LocalDate min, final LocalDate max) { return new LocalDateRangeRandomizer(min, max); } } | LocalDateRangeRandomizer extends AbstractRangeRandomizer<LocalDate> { public static LocalDateRangeRandomizer aNewLocalDateRangeRandomizer(final LocalDate min, final LocalDate max) { return new LocalDateRangeRandomizer(min, max); } LocalDateRangeRandomizer(final LocalDate min, final LocalDate max); LocalDateRangeRandom... | LocalDateRangeRandomizer extends AbstractRangeRandomizer<LocalDate> { public static LocalDateRangeRandomizer aNewLocalDateRangeRandomizer(final LocalDate min, final LocalDate max) { return new LocalDateRangeRandomizer(min, max); } LocalDateRangeRandomizer(final LocalDate min, final LocalDate max); LocalDateRangeRandom... | LocalDateRangeRandomizer extends AbstractRangeRandomizer<LocalDate> { public static LocalDateRangeRandomizer aNewLocalDateRangeRandomizer(final LocalDate min, final LocalDate max) { return new LocalDateRangeRandomizer(min, max); } LocalDateRangeRandomizer(final LocalDate min, final LocalDate max); LocalDateRangeRandom... |
@Test void generatedInstantShouldNotBeNull() { assertThat(randomizer.getRandomValue()).isNotNull(); } | @Override public Instant getRandomValue() { long minEpochMillis = min.toEpochMilli(); long maxEpochMillis = max.toEpochMilli(); long randomEpochMillis = (long) nextDouble(minEpochMillis, maxEpochMillis); return Instant.ofEpochMilli(randomEpochMillis); } | InstantRangeRandomizer extends AbstractRangeRandomizer<Instant> { @Override public Instant getRandomValue() { long minEpochMillis = min.toEpochMilli(); long maxEpochMillis = max.toEpochMilli(); long randomEpochMillis = (long) nextDouble(minEpochMillis, maxEpochMillis); return Instant.ofEpochMilli(randomEpochMillis); } ... | InstantRangeRandomizer extends AbstractRangeRandomizer<Instant> { @Override public Instant getRandomValue() { long minEpochMillis = min.toEpochMilli(); long maxEpochMillis = max.toEpochMilli(); long randomEpochMillis = (long) nextDouble(minEpochMillis, maxEpochMillis); return Instant.ofEpochMilli(randomEpochMillis); } ... | InstantRangeRandomizer extends AbstractRangeRandomizer<Instant> { @Override public Instant getRandomValue() { long minEpochMillis = min.toEpochMilli(); long maxEpochMillis = max.toEpochMilli(); long randomEpochMillis = (long) nextDouble(minEpochMillis, maxEpochMillis); return Instant.ofEpochMilli(randomEpochMillis); } ... | InstantRangeRandomizer extends AbstractRangeRandomizer<Instant> { @Override public Instant getRandomValue() { long minEpochMillis = min.toEpochMilli(); long maxEpochMillis = max.toEpochMilli(); long randomEpochMillis = (long) nextDouble(minEpochMillis, maxEpochMillis); return Instant.ofEpochMilli(randomEpochMillis); } ... |
@Test void generatedInstantShouldBeWithinSpecifiedRange() { assertThat(randomizer.getRandomValue()).isBetween(minInstant, maxInstant); } | @Override public Instant getRandomValue() { long minEpochMillis = min.toEpochMilli(); long maxEpochMillis = max.toEpochMilli(); long randomEpochMillis = (long) nextDouble(minEpochMillis, maxEpochMillis); return Instant.ofEpochMilli(randomEpochMillis); } | InstantRangeRandomizer extends AbstractRangeRandomizer<Instant> { @Override public Instant getRandomValue() { long minEpochMillis = min.toEpochMilli(); long maxEpochMillis = max.toEpochMilli(); long randomEpochMillis = (long) nextDouble(minEpochMillis, maxEpochMillis); return Instant.ofEpochMilli(randomEpochMillis); } ... | InstantRangeRandomizer extends AbstractRangeRandomizer<Instant> { @Override public Instant getRandomValue() { long minEpochMillis = min.toEpochMilli(); long maxEpochMillis = max.toEpochMilli(); long randomEpochMillis = (long) nextDouble(minEpochMillis, maxEpochMillis); return Instant.ofEpochMilli(randomEpochMillis); } ... | InstantRangeRandomizer extends AbstractRangeRandomizer<Instant> { @Override public Instant getRandomValue() { long minEpochMillis = min.toEpochMilli(); long maxEpochMillis = max.toEpochMilli(); long randomEpochMillis = (long) nextDouble(minEpochMillis, maxEpochMillis); return Instant.ofEpochMilli(randomEpochMillis); } ... | InstantRangeRandomizer extends AbstractRangeRandomizer<Instant> { @Override public Instant getRandomValue() { long minEpochMillis = min.toEpochMilli(); long maxEpochMillis = max.toEpochMilli(); long randomEpochMillis = (long) nextDouble(minEpochMillis, maxEpochMillis); return Instant.ofEpochMilli(randomEpochMillis); } ... |
@Test void whenSpecifiedMinInstantIsAfterMaxInstant_thenShouldThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewInstantRangeRandomizer(maxInstant, minInstant)).isInstanceOf(IllegalArgumentException.class); } | public static InstantRangeRandomizer aNewInstantRangeRandomizer(final Instant min, final Instant max) { return new InstantRangeRandomizer(min, max); } | InstantRangeRandomizer extends AbstractRangeRandomizer<Instant> { public static InstantRangeRandomizer aNewInstantRangeRandomizer(final Instant min, final Instant max) { return new InstantRangeRandomizer(min, max); } } | InstantRangeRandomizer extends AbstractRangeRandomizer<Instant> { public static InstantRangeRandomizer aNewInstantRangeRandomizer(final Instant min, final Instant max) { return new InstantRangeRandomizer(min, max); } InstantRangeRandomizer(final Instant min, final Instant max); InstantRangeRandomizer(final Instant min... | InstantRangeRandomizer extends AbstractRangeRandomizer<Instant> { public static InstantRangeRandomizer aNewInstantRangeRandomizer(final Instant min, final Instant max) { return new InstantRangeRandomizer(min, max); } InstantRangeRandomizer(final Instant min, final Instant max); InstantRangeRandomizer(final Instant min... | InstantRangeRandomizer extends AbstractRangeRandomizer<Instant> { public static InstantRangeRandomizer aNewInstantRangeRandomizer(final Instant min, final Instant max) { return new InstantRangeRandomizer(min, max); } InstantRangeRandomizer(final Instant min, final Instant max); InstantRangeRandomizer(final Instant min... |
@Test void generatedValueShouldBeWithinSpecifiedRange() { BigInteger randomValue = randomizer.getRandomValue(); assertThat(randomValue.intValue()).isBetween(min, max); } | @Override public BigInteger getRandomValue() { return new BigInteger(String.valueOf(delegate.getRandomValue())); } | BigIntegerRangeRandomizer implements Randomizer<BigInteger> { @Override public BigInteger getRandomValue() { return new BigInteger(String.valueOf(delegate.getRandomValue())); } } | BigIntegerRangeRandomizer implements Randomizer<BigInteger> { @Override public BigInteger getRandomValue() { return new BigInteger(String.valueOf(delegate.getRandomValue())); } BigIntegerRangeRandomizer(final Integer min, final Integer max); BigIntegerRangeRandomizer(final Integer min, final Integer max, final long se... | BigIntegerRangeRandomizer implements Randomizer<BigInteger> { @Override public BigInteger getRandomValue() { return new BigInteger(String.valueOf(delegate.getRandomValue())); } BigIntegerRangeRandomizer(final Integer min, final Integer max); BigIntegerRangeRandomizer(final Integer min, final Integer max, final long se... | BigIntegerRangeRandomizer implements Randomizer<BigInteger> { @Override public BigInteger getRandomValue() { return new BigInteger(String.valueOf(delegate.getRandomValue())); } BigIntegerRangeRandomizer(final Integer min, final Integer max); BigIntegerRangeRandomizer(final Integer min, final Integer max, final long se... |
@Test void whenSpecifiedMinValueIsAfterMaxValueThenThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewBigIntegerRangeRandomizer(max, min)).isInstanceOf(IllegalArgumentException.class); } | public static BigIntegerRangeRandomizer aNewBigIntegerRangeRandomizer(final Integer min, final Integer max) { return new BigIntegerRangeRandomizer(min, max); } | BigIntegerRangeRandomizer implements Randomizer<BigInteger> { public static BigIntegerRangeRandomizer aNewBigIntegerRangeRandomizer(final Integer min, final Integer max) { return new BigIntegerRangeRandomizer(min, max); } } | BigIntegerRangeRandomizer implements Randomizer<BigInteger> { public static BigIntegerRangeRandomizer aNewBigIntegerRangeRandomizer(final Integer min, final Integer max) { return new BigIntegerRangeRandomizer(min, max); } BigIntegerRangeRandomizer(final Integer min, final Integer max); BigIntegerRangeRandomizer(final ... | BigIntegerRangeRandomizer implements Randomizer<BigInteger> { public static BigIntegerRangeRandomizer aNewBigIntegerRangeRandomizer(final Integer min, final Integer max) { return new BigIntegerRangeRandomizer(min, max); } BigIntegerRangeRandomizer(final Integer min, final Integer max); BigIntegerRangeRandomizer(final ... | BigIntegerRangeRandomizer implements Randomizer<BigInteger> { public static BigIntegerRangeRandomizer aNewBigIntegerRangeRandomizer(final Integer min, final Integer max) { return new BigIntegerRangeRandomizer(min, max); } BigIntegerRangeRandomizer(final Integer min, final Integer max); BigIntegerRangeRandomizer(final ... |
@Test void generatedOffsetTimeShouldNotBeNull() { assertThat(randomizer.getRandomValue()).isNotNull(); } | @Override public OffsetTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); return OffsetTime.of(LocalTime.ofSecondOfDay(randomSecondOfDay), EasyRand... | OffsetTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetTime> { @Override public OffsetTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); r... | OffsetTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetTime> { @Override public OffsetTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); r... | OffsetTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetTime> { @Override public OffsetTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); r... | OffsetTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetTime> { @Override public OffsetTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); r... |
@Test void generatedOffsetTimeShouldBeWithinSpecifiedRange() { assertThat(randomizer.getRandomValue()).isBetween(minTime, maxTime); } | @Override public OffsetTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); return OffsetTime.of(LocalTime.ofSecondOfDay(randomSecondOfDay), EasyRand... | OffsetTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetTime> { @Override public OffsetTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); r... | OffsetTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetTime> { @Override public OffsetTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); r... | OffsetTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetTime> { @Override public OffsetTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); r... | OffsetTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetTime> { @Override public OffsetTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); r... |
@Test void testIsArrayType() { assertThat(ReflectionUtils.isArrayType(int[].class)).isTrue(); assertThat(ReflectionUtils.isArrayType(Foo.class)).isFalse(); } | public static boolean isArrayType(final Class<?> type) { return type.isArray(); } | ReflectionUtils { public static boolean isArrayType(final Class<?> type) { return type.isArray(); } } | ReflectionUtils { public static boolean isArrayType(final Class<?> type) { return type.isArray(); } private ReflectionUtils(); } | ReflectionUtils { public static boolean isArrayType(final Class<?> type) { return type.isArray(); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> getInheritedFields(Class<?> type)... | ReflectionUtils { public static boolean isArrayType(final Class<?> type) { return type.isArray(); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> getInheritedFields(Class<?> type)... |
@Test void whenSpecifiedMinTimeIsAfterMaxDate_thenShouldThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewOffsetTimeRangeRandomizer(maxTime, minTime)).isInstanceOf(IllegalArgumentException.class); } | public static OffsetTimeRangeRandomizer aNewOffsetTimeRangeRandomizer(final OffsetTime min, final OffsetTime max) { return new OffsetTimeRangeRandomizer(min, max); } | OffsetTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetTime> { public static OffsetTimeRangeRandomizer aNewOffsetTimeRangeRandomizer(final OffsetTime min, final OffsetTime max) { return new OffsetTimeRangeRandomizer(min, max); } } | OffsetTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetTime> { public static OffsetTimeRangeRandomizer aNewOffsetTimeRangeRandomizer(final OffsetTime min, final OffsetTime max) { return new OffsetTimeRangeRandomizer(min, max); } OffsetTimeRangeRandomizer(final OffsetTime min, final OffsetTime max); OffsetTime... | OffsetTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetTime> { public static OffsetTimeRangeRandomizer aNewOffsetTimeRangeRandomizer(final OffsetTime min, final OffsetTime max) { return new OffsetTimeRangeRandomizer(min, max); } OffsetTimeRangeRandomizer(final OffsetTime min, final OffsetTime max); OffsetTime... | OffsetTimeRangeRandomizer extends AbstractRangeRandomizer<OffsetTime> { public static OffsetTimeRangeRandomizer aNewOffsetTimeRangeRandomizer(final OffsetTime min, final OffsetTime max) { return new OffsetTimeRangeRandomizer(min, max); } OffsetTimeRangeRandomizer(final OffsetTime min, final OffsetTime max); OffsetTime... |
@Test void generatedLocalTimeShouldNotBeNull() { assertThat(randomizer.getRandomValue()).isNotNull(); } | @Override public LocalTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); return LocalTime.ofSecondOfDay(randomSecondOfDay); } | LocalTimeRangeRandomizer extends AbstractRangeRandomizer<LocalTime> { @Override public LocalTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); retu... | LocalTimeRangeRandomizer extends AbstractRangeRandomizer<LocalTime> { @Override public LocalTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); retu... | LocalTimeRangeRandomizer extends AbstractRangeRandomizer<LocalTime> { @Override public LocalTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); retu... | LocalTimeRangeRandomizer extends AbstractRangeRandomizer<LocalTime> { @Override public LocalTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); retu... |
@Test void generatedLocalTimeShouldBeWithinSpecifiedRange() { assertThat(randomizer.getRandomValue()).isBetween(minTime, maxTime); } | @Override public LocalTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); return LocalTime.ofSecondOfDay(randomSecondOfDay); } | LocalTimeRangeRandomizer extends AbstractRangeRandomizer<LocalTime> { @Override public LocalTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); retu... | LocalTimeRangeRandomizer extends AbstractRangeRandomizer<LocalTime> { @Override public LocalTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); retu... | LocalTimeRangeRandomizer extends AbstractRangeRandomizer<LocalTime> { @Override public LocalTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); retu... | LocalTimeRangeRandomizer extends AbstractRangeRandomizer<LocalTime> { @Override public LocalTime getRandomValue() { long minSecondOfDay = min.getLong(ChronoField.SECOND_OF_DAY); long maxSecondOfDay = max.getLong(ChronoField.SECOND_OF_DAY); long randomSecondOfDay = (long) nextDouble(minSecondOfDay, maxSecondOfDay); retu... |
@Test void whenSpecifiedMinTimeIsAfterMaxDate_thenShouldThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewLocalTimeRangeRandomizer(maxTime, minTime)).isInstanceOf(IllegalArgumentException.class); } | public static LocalTimeRangeRandomizer aNewLocalTimeRangeRandomizer(final LocalTime min, final LocalTime max) { return new LocalTimeRangeRandomizer(min, max); } | LocalTimeRangeRandomizer extends AbstractRangeRandomizer<LocalTime> { public static LocalTimeRangeRandomizer aNewLocalTimeRangeRandomizer(final LocalTime min, final LocalTime max) { return new LocalTimeRangeRandomizer(min, max); } } | LocalTimeRangeRandomizer extends AbstractRangeRandomizer<LocalTime> { public static LocalTimeRangeRandomizer aNewLocalTimeRangeRandomizer(final LocalTime min, final LocalTime max) { return new LocalTimeRangeRandomizer(min, max); } LocalTimeRangeRandomizer(final LocalTime min, final LocalTime max); LocalTimeRangeRandom... | LocalTimeRangeRandomizer extends AbstractRangeRandomizer<LocalTime> { public static LocalTimeRangeRandomizer aNewLocalTimeRangeRandomizer(final LocalTime min, final LocalTime max) { return new LocalTimeRangeRandomizer(min, max); } LocalTimeRangeRandomizer(final LocalTime min, final LocalTime max); LocalTimeRangeRandom... | LocalTimeRangeRandomizer extends AbstractRangeRandomizer<LocalTime> { public static LocalTimeRangeRandomizer aNewLocalTimeRangeRandomizer(final LocalTime min, final LocalTime max) { return new LocalTimeRangeRandomizer(min, max); } LocalTimeRangeRandomizer(final LocalTime min, final LocalTime max); LocalTimeRangeRandom... |
@Test void generatedDateShouldNotBeNull() { assertThat(randomizer.getRandomValue()).isNotNull(); } | @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble((double) minDateTime, (double) maxDateTime); return new Date(randomDateTime); } | DateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble((double) minDateTime, (double) maxDateTime); return new Date(randomDateTime); } } | DateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble((double) minDateTime, (double) maxDateTime); return new Date(randomDateTime); } DateRangeRandomizer(final Date ... | DateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble((double) minDateTime, (double) maxDateTime); return new Date(randomDateTime); } DateRangeRandomizer(final Date ... | DateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble((double) minDateTime, (double) maxDateTime); return new Date(randomDateTime); } DateRangeRandomizer(final Date ... |
@Test void generatedDateShouldBeWithinSpecifiedRange() { assertThat(randomizer.getRandomValue()).isBetween(minDate, maxDate); } | @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble((double) minDateTime, (double) maxDateTime); return new Date(randomDateTime); } | DateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble((double) minDateTime, (double) maxDateTime); return new Date(randomDateTime); } } | DateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble((double) minDateTime, (double) maxDateTime); return new Date(randomDateTime); } DateRangeRandomizer(final Date ... | DateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble((double) minDateTime, (double) maxDateTime); return new Date(randomDateTime); } DateRangeRandomizer(final Date ... | DateRangeRandomizer extends AbstractRangeRandomizer<Date> { @Override public Date getRandomValue() { long minDateTime = min.getTime(); long maxDateTime = max.getTime(); long randomDateTime = (long) nextDouble((double) minDateTime, (double) maxDateTime); return new Date(randomDateTime); } DateRangeRandomizer(final Date ... |
@Test void whenSpecifiedMinDateIsAfterMaxDate_thenShouldThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewDateRangeRandomizer(maxDate, minDate)).isInstanceOf(IllegalArgumentException.class); } | public static DateRangeRandomizer aNewDateRangeRandomizer(final Date min, final Date max) { return new DateRangeRandomizer(min, max); } | DateRangeRandomizer extends AbstractRangeRandomizer<Date> { public static DateRangeRandomizer aNewDateRangeRandomizer(final Date min, final Date max) { return new DateRangeRandomizer(min, max); } } | DateRangeRandomizer extends AbstractRangeRandomizer<Date> { public static DateRangeRandomizer aNewDateRangeRandomizer(final Date min, final Date max) { return new DateRangeRandomizer(min, max); } DateRangeRandomizer(final Date min, final Date max); DateRangeRandomizer(final Date min, final Date max, final long seed); ... | DateRangeRandomizer extends AbstractRangeRandomizer<Date> { public static DateRangeRandomizer aNewDateRangeRandomizer(final Date min, final Date max) { return new DateRangeRandomizer(min, max); } DateRangeRandomizer(final Date min, final Date max); DateRangeRandomizer(final Date min, final Date max, final long seed); ... | DateRangeRandomizer extends AbstractRangeRandomizer<Date> { public static DateRangeRandomizer aNewDateRangeRandomizer(final Date min, final Date max) { return new DateRangeRandomizer(min, max); } DateRangeRandomizer(final Date min, final Date max); DateRangeRandomizer(final Date min, final Date max, final long seed); ... |
@Test void generatedYearMonthShouldNotBeNull() { assertThat(randomizer.getRandomValue()).isNotNull(); } | @Override public YearMonth getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); long minMonth = min.getLong(ChronoField.MONTH_OF_YEAR); long maxMonth = max.getLong(ChronoField.MONTH_OF_YEAR); long randomMont... | YearMonthRangeRandomizer extends AbstractRangeRandomizer<YearMonth> { @Override public YearMonth getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); long minMonth = min.getLong(ChronoField.MONTH_OF_YEAR); l... | YearMonthRangeRandomizer extends AbstractRangeRandomizer<YearMonth> { @Override public YearMonth getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); long minMonth = min.getLong(ChronoField.MONTH_OF_YEAR); l... | YearMonthRangeRandomizer extends AbstractRangeRandomizer<YearMonth> { @Override public YearMonth getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); long minMonth = min.getLong(ChronoField.MONTH_OF_YEAR); l... | YearMonthRangeRandomizer extends AbstractRangeRandomizer<YearMonth> { @Override public YearMonth getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); long minMonth = min.getLong(ChronoField.MONTH_OF_YEAR); l... |
@Test void generatedYearMonthShouldBeWithinSpecifiedRange() { assertThat(randomizer.getRandomValue()).isBetween(minYearMonth, maxYearMonth); } | @Override public YearMonth getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); long minMonth = min.getLong(ChronoField.MONTH_OF_YEAR); long maxMonth = max.getLong(ChronoField.MONTH_OF_YEAR); long randomMont... | YearMonthRangeRandomizer extends AbstractRangeRandomizer<YearMonth> { @Override public YearMonth getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); long minMonth = min.getLong(ChronoField.MONTH_OF_YEAR); l... | YearMonthRangeRandomizer extends AbstractRangeRandomizer<YearMonth> { @Override public YearMonth getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); long minMonth = min.getLong(ChronoField.MONTH_OF_YEAR); l... | YearMonthRangeRandomizer extends AbstractRangeRandomizer<YearMonth> { @Override public YearMonth getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); long minMonth = min.getLong(ChronoField.MONTH_OF_YEAR); l... | YearMonthRangeRandomizer extends AbstractRangeRandomizer<YearMonth> { @Override public YearMonth getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); long minMonth = min.getLong(ChronoField.MONTH_OF_YEAR); l... |
@Test void whenSpecifiedMinYearMonthIsAfterMaxYearMonth_thenShouldThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewYearMonthRangeRandomizer(maxYearMonth, minYearMonth)).isInstanceOf(IllegalArgumentException.class); } | public static YearMonthRangeRandomizer aNewYearMonthRangeRandomizer(final YearMonth min, final YearMonth max) { return new YearMonthRangeRandomizer(min, max); } | YearMonthRangeRandomizer extends AbstractRangeRandomizer<YearMonth> { public static YearMonthRangeRandomizer aNewYearMonthRangeRandomizer(final YearMonth min, final YearMonth max) { return new YearMonthRangeRandomizer(min, max); } } | YearMonthRangeRandomizer extends AbstractRangeRandomizer<YearMonth> { public static YearMonthRangeRandomizer aNewYearMonthRangeRandomizer(final YearMonth min, final YearMonth max) { return new YearMonthRangeRandomizer(min, max); } YearMonthRangeRandomizer(final YearMonth min, final YearMonth max); YearMonthRangeRandom... | YearMonthRangeRandomizer extends AbstractRangeRandomizer<YearMonth> { public static YearMonthRangeRandomizer aNewYearMonthRangeRandomizer(final YearMonth min, final YearMonth max) { return new YearMonthRangeRandomizer(min, max); } YearMonthRangeRandomizer(final YearMonth min, final YearMonth max); YearMonthRangeRandom... | YearMonthRangeRandomizer extends AbstractRangeRandomizer<YearMonth> { public static YearMonthRangeRandomizer aNewYearMonthRangeRandomizer(final YearMonth min, final YearMonth max) { return new YearMonthRangeRandomizer(min, max); } YearMonthRangeRandomizer(final YearMonth min, final YearMonth max); YearMonthRangeRandom... |
@Test void testIsEnumType() { assertThat(ReflectionUtils.isEnumType(Gender.class)).isTrue(); assertThat(ReflectionUtils.isEnumType(Foo.class)).isFalse(); } | public static boolean isEnumType(final Class<?> type) { return type.isEnum(); } | ReflectionUtils { public static boolean isEnumType(final Class<?> type) { return type.isEnum(); } } | ReflectionUtils { public static boolean isEnumType(final Class<?> type) { return type.isEnum(); } private ReflectionUtils(); } | ReflectionUtils { public static boolean isEnumType(final Class<?> type) { return type.isEnum(); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> getInheritedFields(Class<?> type); ... | ReflectionUtils { public static boolean isEnumType(final Class<?> type) { return type.isEnum(); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> getInheritedFields(Class<?> type); ... |
@Test void generatedYearShouldNotBeNull() { assertThat(randomizer.getRandomValue()).isNotNull(); } | @Override public Year getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); return Year.of(Math.toIntExact(randomYear)); } | YearRangeRandomizer extends AbstractRangeRandomizer<Year> { @Override public Year getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); return Year.of(Math.toIntExact(randomYear)); } } | YearRangeRandomizer extends AbstractRangeRandomizer<Year> { @Override public Year getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); return Year.of(Math.toIntExact(randomYear)); } YearRangeRandomizer(final... | YearRangeRandomizer extends AbstractRangeRandomizer<Year> { @Override public Year getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); return Year.of(Math.toIntExact(randomYear)); } YearRangeRandomizer(final... | YearRangeRandomizer extends AbstractRangeRandomizer<Year> { @Override public Year getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); return Year.of(Math.toIntExact(randomYear)); } YearRangeRandomizer(final... |
@Test void generatedYearShouldBeWithinSpecifiedRange() { assertThat(randomizer.getRandomValue()).isBetween(minYear, maxYear); } | @Override public Year getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); return Year.of(Math.toIntExact(randomYear)); } | YearRangeRandomizer extends AbstractRangeRandomizer<Year> { @Override public Year getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); return Year.of(Math.toIntExact(randomYear)); } } | YearRangeRandomizer extends AbstractRangeRandomizer<Year> { @Override public Year getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); return Year.of(Math.toIntExact(randomYear)); } YearRangeRandomizer(final... | YearRangeRandomizer extends AbstractRangeRandomizer<Year> { @Override public Year getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); return Year.of(Math.toIntExact(randomYear)); } YearRangeRandomizer(final... | YearRangeRandomizer extends AbstractRangeRandomizer<Year> { @Override public Year getRandomValue() { long minYear = min.getLong(ChronoField.YEAR); long maxYear = max.getLong(ChronoField.YEAR); long randomYear = (long) nextDouble(minYear, maxYear); return Year.of(Math.toIntExact(randomYear)); } YearRangeRandomizer(final... |
@Test void whenSpecifiedMinYearIsAfterMaxYear_thenShouldThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewYearRangeRandomizer(maxYear, minYear)).isInstanceOf(IllegalArgumentException.class); } | public static YearRangeRandomizer aNewYearRangeRandomizer(final Year min, final Year max) { return new YearRangeRandomizer(min, max); } | YearRangeRandomizer extends AbstractRangeRandomizer<Year> { public static YearRangeRandomizer aNewYearRangeRandomizer(final Year min, final Year max) { return new YearRangeRandomizer(min, max); } } | YearRangeRandomizer extends AbstractRangeRandomizer<Year> { public static YearRangeRandomizer aNewYearRangeRandomizer(final Year min, final Year max) { return new YearRangeRandomizer(min, max); } YearRangeRandomizer(final Year min, final Year max); YearRangeRandomizer(final Year min, final Year max, final long seed); ... | YearRangeRandomizer extends AbstractRangeRandomizer<Year> { public static YearRangeRandomizer aNewYearRangeRandomizer(final Year min, final Year max) { return new YearRangeRandomizer(min, max); } YearRangeRandomizer(final Year min, final Year max); YearRangeRandomizer(final Year min, final Year max, final long seed); ... | YearRangeRandomizer extends AbstractRangeRandomizer<Year> { public static YearRangeRandomizer aNewYearRangeRandomizer(final Year min, final Year max) { return new YearRangeRandomizer(min, max); } YearRangeRandomizer(final Year min, final Year max); YearRangeRandomizer(final Year min, final Year max, final long seed); ... |
@Test void generatedValueShouldBeWithinSpecifiedRange() { Long randomValue = randomizer.getRandomValue(); assertThat(randomValue).isBetween(min, max); } | @Override public Long getRandomValue() { return (long) nextDouble(min, max); } | LongRangeRandomizer extends AbstractRangeRandomizer<Long> { @Override public Long getRandomValue() { return (long) nextDouble(min, max); } } | LongRangeRandomizer extends AbstractRangeRandomizer<Long> { @Override public Long getRandomValue() { return (long) nextDouble(min, max); } LongRangeRandomizer(final Long min, final Long max); LongRangeRandomizer(final Long min, final Long max, final long seed); } | LongRangeRandomizer extends AbstractRangeRandomizer<Long> { @Override public Long getRandomValue() { return (long) nextDouble(min, max); } LongRangeRandomizer(final Long min, final Long max); LongRangeRandomizer(final Long min, final Long max, final long seed); static LongRangeRandomizer aNewLongRangeRandomizer(final ... | LongRangeRandomizer extends AbstractRangeRandomizer<Long> { @Override public Long getRandomValue() { return (long) nextDouble(min, max); } LongRangeRandomizer(final Long min, final Long max); LongRangeRandomizer(final Long min, final Long max, final long seed); static LongRangeRandomizer aNewLongRangeRandomizer(final ... |
@Test void whenSpecifiedMinValueIsAfterMaxValueThenThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewLongRangeRandomizer(max, min)).isInstanceOf(IllegalArgumentException.class); } | public static LongRangeRandomizer aNewLongRangeRandomizer(final Long min, final Long max) { return new LongRangeRandomizer(min, max); } | LongRangeRandomizer extends AbstractRangeRandomizer<Long> { public static LongRangeRandomizer aNewLongRangeRandomizer(final Long min, final Long max) { return new LongRangeRandomizer(min, max); } } | LongRangeRandomizer extends AbstractRangeRandomizer<Long> { public static LongRangeRandomizer aNewLongRangeRandomizer(final Long min, final Long max) { return new LongRangeRandomizer(min, max); } LongRangeRandomizer(final Long min, final Long max); LongRangeRandomizer(final Long min, final Long max, final long seed); ... | LongRangeRandomizer extends AbstractRangeRandomizer<Long> { public static LongRangeRandomizer aNewLongRangeRandomizer(final Long min, final Long max) { return new LongRangeRandomizer(min, max); } LongRangeRandomizer(final Long min, final Long max); LongRangeRandomizer(final Long min, final Long max, final long seed); ... | LongRangeRandomizer extends AbstractRangeRandomizer<Long> { public static LongRangeRandomizer aNewLongRangeRandomizer(final Long min, final Long max) { return new LongRangeRandomizer(min, max); } LongRangeRandomizer(final Long min, final Long max); LongRangeRandomizer(final Long min, final Long max, final long seed); ... |
@Test void generatedLocalDateTimeShouldNotBeNull() { assertThat(randomizer.getRandomValue()).isNotNull(); } | @Override public LocalDateTime getRandomValue() { long minSeconds = min.toEpochSecond(ZoneOffset.UTC); long maxSeconds = max.toEpochSecond(ZoneOffset.UTC); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSeconds = max.getNano(); long nanoSeconds = (long) nextDoub... | LocalDateTimeRangeRandomizer extends AbstractRangeRandomizer<LocalDateTime> { @Override public LocalDateTime getRandomValue() { long minSeconds = min.toEpochSecond(ZoneOffset.UTC); long maxSeconds = max.toEpochSecond(ZoneOffset.UTC); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.get... | LocalDateTimeRangeRandomizer extends AbstractRangeRandomizer<LocalDateTime> { @Override public LocalDateTime getRandomValue() { long minSeconds = min.toEpochSecond(ZoneOffset.UTC); long maxSeconds = max.toEpochSecond(ZoneOffset.UTC); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.get... | LocalDateTimeRangeRandomizer extends AbstractRangeRandomizer<LocalDateTime> { @Override public LocalDateTime getRandomValue() { long minSeconds = min.toEpochSecond(ZoneOffset.UTC); long maxSeconds = max.toEpochSecond(ZoneOffset.UTC); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.get... | LocalDateTimeRangeRandomizer extends AbstractRangeRandomizer<LocalDateTime> { @Override public LocalDateTime getRandomValue() { long minSeconds = min.toEpochSecond(ZoneOffset.UTC); long maxSeconds = max.toEpochSecond(ZoneOffset.UTC); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.get... |
@Test void generatedLocalDateTimeShouldBeWithinSpecifiedRange() { assertThat(randomizer.getRandomValue()).isBetween(minDateTime, maxDateTime); } | @Override public LocalDateTime getRandomValue() { long minSeconds = min.toEpochSecond(ZoneOffset.UTC); long maxSeconds = max.toEpochSecond(ZoneOffset.UTC); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.getNano(); int maxNanoSeconds = max.getNano(); long nanoSeconds = (long) nextDoub... | LocalDateTimeRangeRandomizer extends AbstractRangeRandomizer<LocalDateTime> { @Override public LocalDateTime getRandomValue() { long minSeconds = min.toEpochSecond(ZoneOffset.UTC); long maxSeconds = max.toEpochSecond(ZoneOffset.UTC); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.get... | LocalDateTimeRangeRandomizer extends AbstractRangeRandomizer<LocalDateTime> { @Override public LocalDateTime getRandomValue() { long minSeconds = min.toEpochSecond(ZoneOffset.UTC); long maxSeconds = max.toEpochSecond(ZoneOffset.UTC); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.get... | LocalDateTimeRangeRandomizer extends AbstractRangeRandomizer<LocalDateTime> { @Override public LocalDateTime getRandomValue() { long minSeconds = min.toEpochSecond(ZoneOffset.UTC); long maxSeconds = max.toEpochSecond(ZoneOffset.UTC); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.get... | LocalDateTimeRangeRandomizer extends AbstractRangeRandomizer<LocalDateTime> { @Override public LocalDateTime getRandomValue() { long minSeconds = min.toEpochSecond(ZoneOffset.UTC); long maxSeconds = max.toEpochSecond(ZoneOffset.UTC); long seconds = (long) nextDouble(minSeconds, maxSeconds); int minNanoSeconds = min.get... |
@Test void whenSpecifiedMinDateTimeIsAfterMaxDateTime_thenShouldThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewLocalDateTimeRangeRandomizer(maxDateTime, minDateTime)).isInstanceOf(IllegalArgumentException.class); } | public static LocalDateTimeRangeRandomizer aNewLocalDateTimeRangeRandomizer(final LocalDateTime min, final LocalDateTime max) { return new LocalDateTimeRangeRandomizer(min, max); } | LocalDateTimeRangeRandomizer extends AbstractRangeRandomizer<LocalDateTime> { public static LocalDateTimeRangeRandomizer aNewLocalDateTimeRangeRandomizer(final LocalDateTime min, final LocalDateTime max) { return new LocalDateTimeRangeRandomizer(min, max); } } | LocalDateTimeRangeRandomizer extends AbstractRangeRandomizer<LocalDateTime> { public static LocalDateTimeRangeRandomizer aNewLocalDateTimeRangeRandomizer(final LocalDateTime min, final LocalDateTime max) { return new LocalDateTimeRangeRandomizer(min, max); } LocalDateTimeRangeRandomizer(final LocalDateTime min, final L... | LocalDateTimeRangeRandomizer extends AbstractRangeRandomizer<LocalDateTime> { public static LocalDateTimeRangeRandomizer aNewLocalDateTimeRangeRandomizer(final LocalDateTime min, final LocalDateTime max) { return new LocalDateTimeRangeRandomizer(min, max); } LocalDateTimeRangeRandomizer(final LocalDateTime min, final L... | LocalDateTimeRangeRandomizer extends AbstractRangeRandomizer<LocalDateTime> { public static LocalDateTimeRangeRandomizer aNewLocalDateTimeRangeRandomizer(final LocalDateTime min, final LocalDateTime max) { return new LocalDateTimeRangeRandomizer(min, max); } LocalDateTimeRangeRandomizer(final LocalDateTime min, final L... |
@Test void generatedValueShouldBeWithinSpecifiedRange() { Integer randomValue = randomizer.getRandomValue(); assertThat(randomValue).isBetween(min, max); } | @Override public Integer getRandomValue() { return (int) nextDouble(min, max); } | IntegerRangeRandomizer extends AbstractRangeRandomizer<Integer> { @Override public Integer getRandomValue() { return (int) nextDouble(min, max); } } | IntegerRangeRandomizer extends AbstractRangeRandomizer<Integer> { @Override public Integer getRandomValue() { return (int) nextDouble(min, max); } IntegerRangeRandomizer(final Integer min, final Integer max); IntegerRangeRandomizer(final Integer min, final Integer max, final long seed); } | IntegerRangeRandomizer extends AbstractRangeRandomizer<Integer> { @Override public Integer getRandomValue() { return (int) nextDouble(min, max); } IntegerRangeRandomizer(final Integer min, final Integer max); IntegerRangeRandomizer(final Integer min, final Integer max, final long seed); static IntegerRangeRandomizer a... | IntegerRangeRandomizer extends AbstractRangeRandomizer<Integer> { @Override public Integer getRandomValue() { return (int) nextDouble(min, max); } IntegerRangeRandomizer(final Integer min, final Integer max); IntegerRangeRandomizer(final Integer min, final Integer max, final long seed); static IntegerRangeRandomizer a... |
@Test void whenSpecifiedMinValueIsAfterMaxValueThenThrowIllegalArgumentException() { assertThatThrownBy(() -> aNewIntegerRangeRandomizer(max, min)).isInstanceOf(IllegalArgumentException.class); } | public static IntegerRangeRandomizer aNewIntegerRangeRandomizer(final Integer min, final Integer max) { return new IntegerRangeRandomizer(min, max); } | IntegerRangeRandomizer extends AbstractRangeRandomizer<Integer> { public static IntegerRangeRandomizer aNewIntegerRangeRandomizer(final Integer min, final Integer max) { return new IntegerRangeRandomizer(min, max); } } | IntegerRangeRandomizer extends AbstractRangeRandomizer<Integer> { public static IntegerRangeRandomizer aNewIntegerRangeRandomizer(final Integer min, final Integer max) { return new IntegerRangeRandomizer(min, max); } IntegerRangeRandomizer(final Integer min, final Integer max); IntegerRangeRandomizer(final Integer min... | IntegerRangeRandomizer extends AbstractRangeRandomizer<Integer> { public static IntegerRangeRandomizer aNewIntegerRangeRandomizer(final Integer min, final Integer max) { return new IntegerRangeRandomizer(min, max); } IntegerRangeRandomizer(final Integer min, final Integer max); IntegerRangeRandomizer(final Integer min... | IntegerRangeRandomizer extends AbstractRangeRandomizer<Integer> { public static IntegerRangeRandomizer aNewIntegerRangeRandomizer(final Integer min, final Integer max) { return new IntegerRangeRandomizer(min, max); } IntegerRangeRandomizer(final Integer min, final Integer max); IntegerRangeRandomizer(final Integer min... |
@Test void testIsCollectionType() { assertThat(ReflectionUtils.isCollectionType(CustomList.class)).isTrue(); assertThat(ReflectionUtils.isCollectionType(Foo.class)).isFalse(); } | public static boolean isCollectionType(final Class<?> type) { return Collection.class.isAssignableFrom(type); } | ReflectionUtils { public static boolean isCollectionType(final Class<?> type) { return Collection.class.isAssignableFrom(type); } } | ReflectionUtils { public static boolean isCollectionType(final Class<?> type) { return Collection.class.isAssignableFrom(type); } private ReflectionUtils(); } | ReflectionUtils { public static boolean isCollectionType(final Class<?> type) { return Collection.class.isAssignableFrom(type); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> get... | ReflectionUtils { public static boolean isCollectionType(final Class<?> type) { return Collection.class.isAssignableFrom(type); } private ReflectionUtils(); @SuppressWarnings("unchecked") static Randomizer<T> asRandomizer(final Supplier<T> supplier); static List<Field> getDeclaredFields(T type); static List<Field> get... |
@Test public void testGetNumberPhoneticRhymePart() { assertEquals(wordParser.phoneticRhymePart("-1"), "uno"); assertEquals(wordParser.phoneticRhymePart("0"), "ero"); assertEquals(wordParser.phoneticRhymePart("dos"), "os"); assertEquals(wordParser.phoneticRhymePart("3521637"), "ete"); assertEquals(wordParser.phoneticRhy... | @Override public String phoneticRhymePart(final String word) { String withoutPunctuation = removeTwitterChars(removeTrailingPunctuation(word)); if (WordUtils.isNumber(withoutPunctuation)) { withoutPunctuation = SpanishNumber.getBaseSound(withoutPunctuation); } String rhymePart = rhymePart(withoutPunctuation); StringBui... | SpanishWordParser implements WordParser { @Override public String phoneticRhymePart(final String word) { String withoutPunctuation = removeTwitterChars(removeTrailingPunctuation(word)); if (WordUtils.isNumber(withoutPunctuation)) { withoutPunctuation = SpanishNumber.getBaseSound(withoutPunctuation); } String rhymePart ... | SpanishWordParser implements WordParser { @Override public String phoneticRhymePart(final String word) { String withoutPunctuation = removeTwitterChars(removeTrailingPunctuation(word)); if (WordUtils.isNumber(withoutPunctuation)) { withoutPunctuation = SpanishNumber.getBaseSound(withoutPunctuation); } String rhymePart ... | SpanishWordParser implements WordParser { @Override public String phoneticRhymePart(final String word) { String withoutPunctuation = removeTwitterChars(removeTrailingPunctuation(word)); if (WordUtils.isNumber(withoutPunctuation)) { withoutPunctuation = SpanishNumber.getBaseSound(withoutPunctuation); } String rhymePart ... | SpanishWordParser implements WordParser { @Override public String phoneticRhymePart(final String word) { String withoutPunctuation = removeTwitterChars(removeTrailingPunctuation(word)); if (WordUtils.isNumber(withoutPunctuation)) { withoutPunctuation = SpanishNumber.getBaseSound(withoutPunctuation); } String rhymePart ... |
@Test(expectedExceptions = IOException.class) public void testDeleteUnexistingRhyme() throws IOException { store.delete("Unexisting"); } | public void delete(final String sentence) throws IOException { String word = WordUtils.getLastWord(sentence); if (word.isEmpty()) { return; } String rhyme = normalizeString(wordParser.phoneticRhymePart(word)); StressType type = wordParser.stressType(word); connect(); try { String sentenceKey = getUniqueIdKey(sentencens... | RedisStore { public void delete(final String sentence) throws IOException { String word = WordUtils.getLastWord(sentence); if (word.isEmpty()) { return; } String rhyme = normalizeString(wordParser.phoneticRhymePart(word)); StressType type = wordParser.stressType(word); connect(); try { String sentenceKey = getUniqueIdK... | RedisStore { public void delete(final String sentence) throws IOException { String word = WordUtils.getLastWord(sentence); if (word.isEmpty()) { return; } String rhyme = normalizeString(wordParser.phoneticRhymePart(word)); StressType type = wordParser.stressType(word); connect(); try { String sentenceKey = getUniqueIdK... | RedisStore { public void delete(final String sentence) throws IOException { String word = WordUtils.getLastWord(sentence); if (word.isEmpty()) { return; } String rhyme = normalizeString(wordParser.phoneticRhymePart(word)); StressType type = wordParser.stressType(word); connect(); try { String sentenceKey = getUniqueIdK... | RedisStore { public void delete(final String sentence) throws IOException { String word = WordUtils.getLastWord(sentence); if (word.isEmpty()) { return; } String rhyme = normalizeString(wordParser.phoneticRhymePart(word)); StressType type = wordParser.stressType(word); connect(); try { String sentenceKey = getUniqueIdK... |
@Test public void testSum() { assertEquals(store.sum("foo"), "acbd18db4cc2f85cedef654fccc4a4d8"); assertEquals(store.sum("bar"), "37b51d194a7513e45b56f6524f2d51f2"); } | @VisibleForTesting String sum(final String value) { return Hashing.md5().hashString(value, encoding).toString(); } | RedisStore { @VisibleForTesting String sum(final String value) { return Hashing.md5().hashString(value, encoding).toString(); } } | RedisStore { @VisibleForTesting String sum(final String value) { return Hashing.md5().hashString(value, encoding).toString(); } @Inject RedisStore(@Named("sentence") final Keymaker sentencens,
@Named("index") final Keymaker indexns, final WordParser wordParser, final Jedis redis,
final @Named(REDIS_PAS... | RedisStore { @VisibleForTesting String sum(final String value) { return Hashing.md5().hashString(value, encoding).toString(); } @Inject RedisStore(@Named("sentence") final Keymaker sentencens,
@Named("index") final Keymaker indexns, final WordParser wordParser, final Jedis redis,
final @Named(REDIS_PAS... | RedisStore { @VisibleForTesting String sum(final String value) { return Hashing.md5().hashString(value, encoding).toString(); } @Inject RedisStore(@Named("sentence") final Keymaker sentencens,
@Named("index") final Keymaker indexns, final WordParser wordParser, final Jedis redis,
final @Named(REDIS_PAS... |
@Test public void testKeymaker() { checkKeymaker(""); checkKeymaker(":"); checkKeymaker("test"); checkKeymaker(":test:"); checkKeymaker("test::"); checkKeymaker("::test"); checkKeymaker("test:test2"); } | public Keymaker(final String namespace) { this.namespace = checkNotNull(namespace, "Namespace cannot be null"); } | Keymaker { public Keymaker(final String namespace) { this.namespace = checkNotNull(namespace, "Namespace cannot be null"); } } | Keymaker { public Keymaker(final String namespace) { this.namespace = checkNotNull(namespace, "Namespace cannot be null"); } Keymaker(final String namespace); } | Keymaker { public Keymaker(final String namespace) { this.namespace = checkNotNull(namespace, "Namespace cannot be null"); } Keymaker(final String namespace); Keymaker build(final String... namespaces); @Override String toString(); } | Keymaker { public Keymaker(final String namespace) { this.namespace = checkNotNull(namespace, "Namespace cannot be null"); } Keymaker(final String namespace); Keymaker build(final String... namespaces); @Override String toString(); } |
@Test public void testExecuteWithExistingRhyme() throws TwitterException { ReplyCommand replyCommand = createReplyCommand("Este test es casi perfecto"); replyCommand.execute(); assertTrue(twitter.getLastUpdatedStatus().contains("Rima por defecto")); } | @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme with the screen name: {}", targetUser); rhyme =... | ReplyCommand extends AbstracTwitterCommand { @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme wi... | ReplyCommand extends AbstracTwitterCommand { @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme wi... | ReplyCommand extends AbstracTwitterCommand { @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme wi... | ReplyCommand extends AbstracTwitterCommand { @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme wi... |
@Test public void testExecuteWithScreenNameRhyme() throws TwitterException { ReplyCommand replyCommand = createReplyCommand("Rima esto con el usuario"); replyCommand.execute(); assertTrue(twitter.getLastUpdatedStatus().contains("Esta rima es infame")); } | @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme with the screen name: {}", targetUser); rhyme =... | ReplyCommand extends AbstracTwitterCommand { @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme wi... | ReplyCommand extends AbstracTwitterCommand { @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme wi... | ReplyCommand extends AbstracTwitterCommand { @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme wi... | ReplyCommand extends AbstracTwitterCommand { @Override public void execute() throws TwitterException { String rhyme = null; String targetUser = status.getUser().getScreenName(); try { rhyme = rhymeStore.getRhyme(status.getText()); if (rhyme == null) { if (wordParser.isWord(targetUser)) { LOGGER.info("Trying to rhyme wi... |
@Test public void testCapitalize() { assertEquals(capitalize(null), null); assertEquals(capitalize(""), ""); assertEquals(capitalize("hola"), "Hola"); assertEquals(capitalize("hOLA"), "HOLA"); } | public static String capitalize(final String str) { if (str == null) { return null; } switch (str.length()) { case 0: return str; case 1: return str.toUpperCase(); default: return str.substring(0, 1).toUpperCase() + str.substring(1); } } | WordUtils { public static String capitalize(final String str) { if (str == null) { return null; } switch (str.length()) { case 0: return str; case 1: return str.toUpperCase(); default: return str.substring(0, 1).toUpperCase() + str.substring(1); } } } | WordUtils { public static String capitalize(final String str) { if (str == null) { return null; } switch (str.length()) { case 0: return str; case 1: return str.toUpperCase(); default: return str.substring(0, 1).toUpperCase() + str.substring(1); } } } | WordUtils { public static String capitalize(final String str) { if (str == null) { return null; } switch (str.length()) { case 0: return str; case 1: return str.toUpperCase(); default: return str.substring(0, 1).toUpperCase() + str.substring(1); } } static String getLastWord(final String sentence); static String capit... | WordUtils { public static String capitalize(final String str) { if (str == null) { return null; } switch (str.length()) { case 0: return str; case 1: return str.toUpperCase(); default: return str.substring(0, 1).toUpperCase() + str.substring(1); } } static String getLastWord(final String sentence); static String capit... |
@Test public void testGetLastWord() { assertEquals(getLastWord(null), ""); assertEquals(getLastWord(""), ""); assertEquals(getLastWord("hola"), "hola"); assertEquals(getLastWord("hola adios"), "adios"); assertEquals(getLastWord("hola ."), "."); } | public static String getLastWord(final String sentence) { String word = ""; if (sentence != null) { List<String> words = Arrays.asList(sentence.split(" ")); if (words.size() > 0) { word = words.get(words.size() - 1); } } return word; } | WordUtils { public static String getLastWord(final String sentence) { String word = ""; if (sentence != null) { List<String> words = Arrays.asList(sentence.split(" ")); if (words.size() > 0) { word = words.get(words.size() - 1); } } return word; } } | WordUtils { public static String getLastWord(final String sentence) { String word = ""; if (sentence != null) { List<String> words = Arrays.asList(sentence.split(" ")); if (words.size() > 0) { word = words.get(words.size() - 1); } } return word; } } | WordUtils { public static String getLastWord(final String sentence) { String word = ""; if (sentence != null) { List<String> words = Arrays.asList(sentence.split(" ")); if (words.size() > 0) { word = words.get(words.size() - 1); } } return word; } static String getLastWord(final String sentence); static String capital... | WordUtils { public static String getLastWord(final String sentence) { String word = ""; if (sentence != null) { List<String> words = Arrays.asList(sentence.split(" ")); if (words.size() > 0) { word = words.get(words.size() - 1); } } return word; } static String getLastWord(final String sentence); static String capital... |
@Test public void testIsNumber() { assertFalse(isNumber(null)); assertFalse(isNumber("")); assertFalse(isNumber("a")); assertFalse(isNumber("-a")); assertFalse(isNumber("23a")); assertTrue(isNumber("-1")); assertTrue(isNumber("0")); assertTrue(isNumber("12345")); } | public static boolean isNumber(String word) { if (word == null) { return false; } String wordToParse = new String(word); if (wordToParse.startsWith("-")) { wordToParse = wordToParse.replaceFirst("-", ""); } if (wordToParse.length() == 0) { return false; } for (char c : wordToParse.toCharArray()) { if (!Character.isDigi... | WordUtils { public static boolean isNumber(String word) { if (word == null) { return false; } String wordToParse = new String(word); if (wordToParse.startsWith("-")) { wordToParse = wordToParse.replaceFirst("-", ""); } if (wordToParse.length() == 0) { return false; } for (char c : wordToParse.toCharArray()) { if (!Char... | WordUtils { public static boolean isNumber(String word) { if (word == null) { return false; } String wordToParse = new String(word); if (wordToParse.startsWith("-")) { wordToParse = wordToParse.replaceFirst("-", ""); } if (wordToParse.length() == 0) { return false; } for (char c : wordToParse.toCharArray()) { if (!Char... | WordUtils { public static boolean isNumber(String word) { if (word == null) { return false; } String wordToParse = new String(word); if (wordToParse.startsWith("-")) { wordToParse = wordToParse.replaceFirst("-", ""); } if (wordToParse.length() == 0) { return false; } for (char c : wordToParse.toCharArray()) { if (!Char... | WordUtils { public static boolean isNumber(String word) { if (word == null) { return false; } String wordToParse = new String(word); if (wordToParse.startsWith("-")) { wordToParse = wordToParse.replaceFirst("-", ""); } if (wordToParse.length() == 0) { return false; } for (char c : wordToParse.toCharArray()) { if (!Char... |
@Test public void testGetConfigValue() { assertNull(getConfigValue("unexisting")); assertEquals(getConfigValue(REDIS_HOST), "localhost"); } | static String getConfigValue(final String propertyName) { return getConfiguration().getProperty(propertyName); } | Configuration { static String getConfigValue(final String propertyName) { return getConfiguration().getProperty(propertyName); } } | Configuration { static String getConfigValue(final String propertyName) { return getConfiguration().getProperty(propertyName); } private Configuration(); } | Configuration { static String getConfigValue(final String propertyName) { return getConfiguration().getProperty(propertyName); } private Configuration(); } | Configuration { static String getConfigValue(final String propertyName) { return getConfiguration().getProperty(propertyName); } private Configuration(); static final String CONFIG_FILE; static final String REDIS_HOST; static final String REDIS_PORT; static final String REDIS_PASSWORD; static final String FALLBACK_RH... |
@Test public void testGetRequiredConfigValue() { assertEquals(getRequiredConfigValue(REDIS_HOST), "localhost"); } | static String getRequiredConfigValue(final String propertyName) { String value = getConfiguration().getProperty(propertyName); if (value == null) { throw new ConfigurationException("Te requested property [" + propertyName + "] was not set."); } return value; } | Configuration { static String getRequiredConfigValue(final String propertyName) { String value = getConfiguration().getProperty(propertyName); if (value == null) { throw new ConfigurationException("Te requested property [" + propertyName + "] was not set."); } return value; } } | Configuration { static String getRequiredConfigValue(final String propertyName) { String value = getConfiguration().getProperty(propertyName); if (value == null) { throw new ConfigurationException("Te requested property [" + propertyName + "] was not set."); } return value; } private Configuration(); } | Configuration { static String getRequiredConfigValue(final String propertyName) { String value = getConfiguration().getProperty(propertyName); if (value == null) { throw new ConfigurationException("Te requested property [" + propertyName + "] was not set."); } return value; } private Configuration(); } | Configuration { static String getRequiredConfigValue(final String propertyName) { String value = getConfiguration().getProperty(propertyName); if (value == null) { throw new ConfigurationException("Te requested property [" + propertyName + "] was not set."); } return value; } private Configuration(); static final Str... |
@Test(expectedExceptions = ConfigurationException.class) public void testGetUnexistingRequiredConfigValue() { getRequiredConfigValue("unexisting"); } | static String getRequiredConfigValue(final String propertyName) { String value = getConfiguration().getProperty(propertyName); if (value == null) { throw new ConfigurationException("Te requested property [" + propertyName + "] was not set."); } return value; } | Configuration { static String getRequiredConfigValue(final String propertyName) { String value = getConfiguration().getProperty(propertyName); if (value == null) { throw new ConfigurationException("Te requested property [" + propertyName + "] was not set."); } return value; } } | Configuration { static String getRequiredConfigValue(final String propertyName) { String value = getConfiguration().getProperty(propertyName); if (value == null) { throw new ConfigurationException("Te requested property [" + propertyName + "] was not set."); } return value; } private Configuration(); } | Configuration { static String getRequiredConfigValue(final String propertyName) { String value = getConfiguration().getProperty(propertyName); if (value == null) { throw new ConfigurationException("Te requested property [" + propertyName + "] was not set."); } return value; } private Configuration(); } | Configuration { static String getRequiredConfigValue(final String propertyName) { String value = getConfiguration().getProperty(propertyName); if (value == null) { throw new ConfigurationException("Te requested property [" + propertyName + "] was not set."); } return value; } private Configuration(); static final Str... |
@Test public void testFindAll() throws IOException { assertEquals(store.findAll().size(), 2); } | public Set<String> findAll() throws IOException { Set<String> rhymes = new HashSet<String>(); connect(); try { String lastId = getLastId(sentencens); if (lastId != null) { Integer n = Integer.parseInt(getLastId(sentencens)); for (int i = 1; i <= n; i++) { String id = sentencens.build(String.valueOf(i)).toString(); if (... | RedisStore { public Set<String> findAll() throws IOException { Set<String> rhymes = new HashSet<String>(); connect(); try { String lastId = getLastId(sentencens); if (lastId != null) { Integer n = Integer.parseInt(getLastId(sentencens)); for (int i = 1; i <= n; i++) { String id = sentencens.build(String.valueOf(i)).toS... | RedisStore { public Set<String> findAll() throws IOException { Set<String> rhymes = new HashSet<String>(); connect(); try { String lastId = getLastId(sentencens); if (lastId != null) { Integer n = Integer.parseInt(getLastId(sentencens)); for (int i = 1; i <= n; i++) { String id = sentencens.build(String.valueOf(i)).toS... | RedisStore { public Set<String> findAll() throws IOException { Set<String> rhymes = new HashSet<String>(); connect(); try { String lastId = getLastId(sentencens); if (lastId != null) { Integer n = Integer.parseInt(getLastId(sentencens)); for (int i = 1; i <= n; i++) { String id = sentencens.build(String.valueOf(i)).toS... | RedisStore { public Set<String> findAll() throws IOException { Set<String> rhymes = new HashSet<String>(); connect(); try { String lastId = getLastId(sentencens); if (lastId != null) { Integer n = Integer.parseInt(getLastId(sentencens)); for (int i = 1; i <= n; i++) { String id = sentencens.build(String.valueOf(i)).toS... |
@Test public void testGetRhyme() throws IOException { assertNull(store.getRhyme("no hay rima")); assertEquals(store.getRhyme("¿Hay algo que rime con tres?"), "Me escondo y no me ves"); assertEquals(store.getRhyme("Nada rima con dos"), "Ya son veintidós!!"); } | public String getRhyme(final String sentence) throws IOException { String lastWord = WordUtils.getLastWord(sentence); String rhymepart = wordParser.phoneticRhymePart(lastWord); StressType type = wordParser.stressType(lastWord); LOGGER.debug("Finding rhymes for {}", sentence); Set<String> rhymes = Sets.newHashSet(); con... | RedisStore { public String getRhyme(final String sentence) throws IOException { String lastWord = WordUtils.getLastWord(sentence); String rhymepart = wordParser.phoneticRhymePart(lastWord); StressType type = wordParser.stressType(lastWord); LOGGER.debug("Finding rhymes for {}", sentence); Set<String> rhymes = Sets.newH... | RedisStore { public String getRhyme(final String sentence) throws IOException { String lastWord = WordUtils.getLastWord(sentence); String rhymepart = wordParser.phoneticRhymePart(lastWord); StressType type = wordParser.stressType(lastWord); LOGGER.debug("Finding rhymes for {}", sentence); Set<String> rhymes = Sets.newH... | RedisStore { public String getRhyme(final String sentence) throws IOException { String lastWord = WordUtils.getLastWord(sentence); String rhymepart = wordParser.phoneticRhymePart(lastWord); StressType type = wordParser.stressType(lastWord); LOGGER.debug("Finding rhymes for {}", sentence); Set<String> rhymes = Sets.newH... | RedisStore { public String getRhyme(final String sentence) throws IOException { String lastWord = WordUtils.getLastWord(sentence); String rhymepart = wordParser.phoneticRhymePart(lastWord); StressType type = wordParser.stressType(lastWord); LOGGER.debug("Finding rhymes for {}", sentence); Set<String> rhymes = Sets.newH... |
@Test public void testDeleteWithoutText() throws IOException { store.delete(null); store.delete(""); } | public void delete(final String sentence) throws IOException { String word = WordUtils.getLastWord(sentence); if (word.isEmpty()) { return; } String rhyme = normalizeString(wordParser.phoneticRhymePart(word)); StressType type = wordParser.stressType(word); connect(); try { String sentenceKey = getUniqueIdKey(sentencens... | RedisStore { public void delete(final String sentence) throws IOException { String word = WordUtils.getLastWord(sentence); if (word.isEmpty()) { return; } String rhyme = normalizeString(wordParser.phoneticRhymePart(word)); StressType type = wordParser.stressType(word); connect(); try { String sentenceKey = getUniqueIdK... | RedisStore { public void delete(final String sentence) throws IOException { String word = WordUtils.getLastWord(sentence); if (word.isEmpty()) { return; } String rhyme = normalizeString(wordParser.phoneticRhymePart(word)); StressType type = wordParser.stressType(word); connect(); try { String sentenceKey = getUniqueIdK... | RedisStore { public void delete(final String sentence) throws IOException { String word = WordUtils.getLastWord(sentence); if (word.isEmpty()) { return; } String rhyme = normalizeString(wordParser.phoneticRhymePart(word)); StressType type = wordParser.stressType(word); connect(); try { String sentenceKey = getUniqueIdK... | RedisStore { public void delete(final String sentence) throws IOException { String word = WordUtils.getLastWord(sentence); if (word.isEmpty()) { return; } String rhyme = normalizeString(wordParser.phoneticRhymePart(word)); StressType type = wordParser.stressType(word); connect(); try { String sentenceKey = getUniqueIdK... |
@Test public void test() { ArrayList<BatchScheduler.ActiveJob> activeJobs = new ArrayList<BatchScheduler.ActiveJob>(); activeJobs.addAll(Arrays.asList(job1,job2,job3,job4,job5,job6,job7,job8,job9,job10)); int numCpusAllocated = 5; int numCpusTotal = 10; double load = 0.4; PartitionStatistics partitionStatistics = new P... | public static SchedulerDecisions schedule(List<ActiveJob> activeJobsAllSites, PartitionStatistics partitionStatistics, int userQuotaOde, int userQuotaPde, VCellServerID systemID) { Hashtable<User, UserQuotaInfo> userQuotaInfoMap = new Hashtable<User, UserQuotaInfo>(); int numPendingJobsAllSites = 0; for (ActiveJob acti... | BatchScheduler { public static SchedulerDecisions schedule(List<ActiveJob> activeJobsAllSites, PartitionStatistics partitionStatistics, int userQuotaOde, int userQuotaPde, VCellServerID systemID) { Hashtable<User, UserQuotaInfo> userQuotaInfoMap = new Hashtable<User, UserQuotaInfo>(); int numPendingJobsAllSites = 0; fo... | BatchScheduler { public static SchedulerDecisions schedule(List<ActiveJob> activeJobsAllSites, PartitionStatistics partitionStatistics, int userQuotaOde, int userQuotaPde, VCellServerID systemID) { Hashtable<User, UserQuotaInfo> userQuotaInfoMap = new Hashtable<User, UserQuotaInfo>(); int numPendingJobsAllSites = 0; fo... | BatchScheduler { public static SchedulerDecisions schedule(List<ActiveJob> activeJobsAllSites, PartitionStatistics partitionStatistics, int userQuotaOde, int userQuotaPde, VCellServerID systemID) { Hashtable<User, UserQuotaInfo> userQuotaInfoMap = new Hashtable<User, UserQuotaInfo>(); int numPendingJobsAllSites = 0; fo... | BatchScheduler { public static SchedulerDecisions schedule(List<ActiveJob> activeJobsAllSites, PartitionStatistics partitionStatistics, int userQuotaOde, int userQuotaPde, VCellServerID systemID) { Hashtable<User, UserQuotaInfo> userQuotaInfoMap = new Hashtable<User, UserQuotaInfo>(); int numPendingJobsAllSites = 0; fo... |
@Test public void validateIndexes( ) { boolean punched[] = new boolean[index.getXYZ()]; for (int x = 0; x < mX; x++) for (int y = 0; y < mY; y++) for (int z = 0; z < mZ; z++) { final int idx = index.rollup(x,y,z); assertFalse(punched[idx]); punched[idx] = true; } for (int p = 0; p < punched.length; ++p) { assertTrue(pu... | public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } } | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } DimensionalIndex(int newX, int newY, int newZ); DimensionalIndex(String newX, String... | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } DimensionalIndex(int newX, int newY, int newZ); DimensionalIndex(String newX, String... | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } DimensionalIndex(int newX, int newY, int newZ); DimensionalIndex(String newX, String... |
@Test(expected = RuntimeException.class) public void badX( ) { index.rollup(mX, 0,0); } | public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } } | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } DimensionalIndex(int newX, int newY, int newZ); DimensionalIndex(String newX, String... | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } DimensionalIndex(int newX, int newY, int newZ); DimensionalIndex(String newX, String... | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } DimensionalIndex(int newX, int newY, int newZ); DimensionalIndex(String newX, String... |
@Test(expected = RuntimeException.class) public void badY( ) { index.rollup(0, mY,0); } | public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } } | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } DimensionalIndex(int newX, int newY, int newZ); DimensionalIndex(String newX, String... | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } DimensionalIndex(int newX, int newY, int newZ); DimensionalIndex(String newX, String... | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } DimensionalIndex(int newX, int newY, int newZ); DimensionalIndex(String newX, String... |
@Test(expected = RuntimeException.class) public void badZ( ) { index.rollup(0,0,mZ); } | public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } } | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } DimensionalIndex(int newX, int newY, int newZ); DimensionalIndex(String newX, String... | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } DimensionalIndex(int newX, int newY, int newZ); DimensionalIndex(String newX, String... | DimensionalIndex extends ISize { public int rollup(int xValue, int yValue, int zValue) { check(xValue,super.getX(),'x'); check(yValue,super.getY(),'y'); check(zValue,super.getZ(),'z'); return xValue + yValue * getX( ) + zValue * xy; } DimensionalIndex(int newX, int newY, int newZ); DimensionalIndex(String newX, String... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.