11package it .aboutbits .springboot .testing .validation .source ;
22
33import it .aboutbits .springboot .testing .validation .core .ValueSource ;
4+ import it .aboutbits .springboot .toolbox .type .ScaledBigDecimal ;
45import org .jetbrains .annotations .NotNull ;
56
67import java .math .BigDecimal ;
@@ -18,16 +19,17 @@ public class BiggerThanValueSource implements ValueSource {
1819 TYPE_SOURCES .put (Integer .class , BiggerThanValueSource ::getIntegerStream );
1920 TYPE_SOURCES .put (int .class , BiggerThanValueSource ::getIntegerStream );
2021
21- TYPE_SOURCES .put (Float .class , BiggerThanValueSource ::getFloatStream );
22- TYPE_SOURCES .put (float .class , BiggerThanValueSource ::getFloatStream );
23-
2422 TYPE_SOURCES .put (Long .class , BiggerThanValueSource ::getLongStream );
2523 TYPE_SOURCES .put (long .class , BiggerThanValueSource ::getLongStream );
2624
25+ TYPE_SOURCES .put (Float .class , BiggerThanValueSource ::getFloatStream );
26+ TYPE_SOURCES .put (float .class , BiggerThanValueSource ::getFloatStream );
27+
2728 TYPE_SOURCES .put (Double .class , BiggerThanValueSource ::getDoubleStream );
2829 TYPE_SOURCES .put (double .class , BiggerThanValueSource ::getDoubleStream );
2930
3031 TYPE_SOURCES .put (BigDecimal .class , BiggerThanValueSource ::getBigDecimalStream );
32+ TYPE_SOURCES .put (ScaledBigDecimal .class , BiggerThanValueSource ::getScaledBigDecimalStream );
3133 }
3234
3335 public static void registerType (Class <?> type , Function <Object [], Stream <?>> source ) {
@@ -46,24 +48,13 @@ public <T> Stream<T> values(Class<T> propertyClass, Object... args) {
4648 }
4749
4850 @ NotNull
49- private static Stream <BigDecimal > getBigDecimalStream (Object [] args ) {
50- var minValue = Long .valueOf ((long ) args [0 ]).doubleValue () + 0.1d ;
51- var maxValue = Double .MAX_VALUE ;
52-
53- return Stream .concat (
54- Stream .of (BigDecimal .valueOf (minValue ), BigDecimal .valueOf (maxValue )),
55- RANDOM .doubles (minValue , maxValue ).limit (5 ).boxed ().map (BigDecimal ::valueOf )
56- );
57- }
58-
59- @ NotNull
60- private static Stream <Double > getDoubleStream (Object [] args ) {
61- var minValue = Long .valueOf ((long ) args [0 ]).doubleValue () + 0.1d ;
62- var maxValue = Double .MAX_VALUE ;
51+ private static Stream <Integer > getIntegerStream (Object [] args ) {
52+ var minValue = Long .valueOf ((long ) args [0 ]).intValue () + 1 ;
53+ var maxValue = Integer .MAX_VALUE ;
6354
6455 return Stream .concat (
6556 Stream .of (minValue , maxValue ),
66- RANDOM .doubles (minValue , maxValue ).limit (5 ).boxed ()
57+ RANDOM .ints (minValue , maxValue ).limit (5 ).boxed ()
6758 );
6859 }
6960
@@ -92,13 +83,35 @@ private static Stream<Float> getFloatStream(Object[] args) {
9283 }
9384
9485 @ NotNull
95- private static Stream <Integer > getIntegerStream (Object [] args ) {
96- var minValue = Long .valueOf ((long ) args [0 ]).intValue () + 1 ;
97- var maxValue = Integer .MAX_VALUE ;
86+ private static Stream <Double > getDoubleStream (Object [] args ) {
87+ var minValue = Long .valueOf ((long ) args [0 ]).doubleValue () + 0.1d ;
88+ var maxValue = Double .MAX_VALUE ;
9889
9990 return Stream .concat (
10091 Stream .of (minValue , maxValue ),
101- RANDOM .ints (minValue , maxValue ).limit (5 ).boxed ()
92+ RANDOM .doubles (minValue , maxValue ).limit (5 ).boxed ()
93+ );
94+ }
95+
96+ @ NotNull
97+ private static Stream <ScaledBigDecimal > getScaledBigDecimalStream (Object [] args ) {
98+ var minValue = Long .valueOf ((long ) args [0 ]).doubleValue () + 0.1d ;
99+ var maxValue = Double .MAX_VALUE ;
100+
101+ return Stream .concat (
102+ Stream .of (ScaledBigDecimal .valueOf (minValue ), ScaledBigDecimal .valueOf (maxValue )),
103+ RANDOM .doubles (minValue , maxValue ).limit (5 ).boxed ().map (ScaledBigDecimal ::valueOf )
104+ );
105+ }
106+
107+ @ NotNull
108+ private static Stream <BigDecimal > getBigDecimalStream (Object [] args ) {
109+ var minValue = Long .valueOf ((long ) args [0 ]).doubleValue () + 0.1d ;
110+ var maxValue = Double .MAX_VALUE ;
111+
112+ return Stream .concat (
113+ Stream .of (BigDecimal .valueOf (minValue ), BigDecimal .valueOf (maxValue )),
114+ RANDOM .doubles (minValue , maxValue ).limit (5 ).boxed ().map (BigDecimal ::valueOf )
102115 );
103116 }
104117}
0 commit comments