Skip to content
This repository was archived by the owner on Apr 14, 2023. It is now read-only.

Commit 354e832

Browse files
Merge pull request #793 from ScottLogic/705-remove-integerFieldValueSource
705 remove integer field value source
2 parents 907c944 + 15402b7 commit 354e832

File tree

7 files changed

+57
-545
lines changed

7 files changed

+57
-545
lines changed

generator/src/main/java/com/scottlogic/deg/generator/generation/StandardFieldValueSourceEvaluator.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ private FieldValueSource getNumericSource(FieldSpec fieldSpec) {
9494

9595
int numericScale = getNumericScale(fieldSpec.getGranularityRestrictions());
9696

97-
if ((restrictions.min == null && restrictions.max == null) || isFieldValueAnInteger(restrictions, numericScale)) {
98-
return new IntegerFieldValueSource(
99-
restrictions,
100-
getBlacklist(fieldSpec));
101-
}
102-
10397
return new RealNumberFieldValueSource(
10498
restrictions,
10599
getBlacklist(fieldSpec),
@@ -118,14 +112,6 @@ private int getNumericScale(GranularityRestrictions granularityRestrictions) {
118112
return maximumGranularity;
119113
}
120114

121-
private boolean isFieldValueAnInteger(NumericRestrictions numericRestrictions, int numericScale) {
122-
if (numericScale > 0) {
123-
return false;
124-
}
125-
126-
return numericRestrictions.areLimitValuesInteger();
127-
}
128-
129115
private Set<Object> getBlacklist(FieldSpec fieldSpec) {
130116
if (fieldSpec.getSetRestrictions() == null)
131117
return Collections.emptySet();

generator/src/main/java/com/scottlogic/deg/generator/generation/fieldvaluesources/IntegerFieldValueSource.java

Lines changed: 0 additions & 163 deletions
This file was deleted.

generator/src/test/java/com/scottlogic/deg/generator/cucumber/GreaterThan.feature

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,20 @@ Scenario: greaterThan run against a non contradicting not greaterThan should be
152152
| 4 |
153153
| 5 |
154154

155+
@ignore #594 - Reverse order of value generation when only upper-bound operators are provided
155156
Scenario: not greaterThan run against a non contradicting not greaterThan should be successful (not greaterThan 5 AND not greaterThan 4)
156157
Given foo is anything but greater than 5
157158
And foo is anything but greater than 4
158159
And foo is anything but null
159160
And foo is of type "integer"
160161
And the generator can generate at most 5 rows
161162
Then the following data should be generated:
162-
| foo |
163-
| -100000000000000000000 |
164-
| -99999999999999999999 |
165-
| -99999999999999999998 |
166-
| -99999999999999999997 |
167-
| -99999999999999999996 |
163+
| foo |
164+
| 3 |
165+
| 2 |
166+
| 1 |
167+
| 0 |
168+
| -1 |
168169

169170
Scenario: greaterThan run against a contradicting not greaterThan should only only generate string, temporal and null (greaterThan 2 AND not greaterThan 2)
170171
Given foo is greater than 2
@@ -200,19 +201,20 @@ Scenario: greaterThan run against a non contradicting not greaterThanOrEqualTo s
200201
| 3 |
201202
| 4 |
202203

204+
@ignore #594 - Reverse order of value generation when only upper-bound operators are provided
203205
Scenario: not greaterThan run against a non contradicting not greaterThanOrEqualTo should be successful (not greaterThan 5 AND not greaterThanOrEqualTo 4)
204206
Given foo is anything but greater than 5
205207
And foo is anything but greater than or equal to 4
206208
And foo is of type "integer"
207209
And foo is anything but null
208210
And the generator can generate at most 5 rows
209211
Then the following data should be generated:
210-
| foo |
211-
| -100000000000000000000 |
212-
| -99999999999999999999 |
213-
| -99999999999999999998 |
214-
| -99999999999999999997 |
215-
| -99999999999999999996 |
212+
| foo |
213+
| 4 |
214+
| 3 |
215+
| 2 |
216+
| 1 |
217+
| 0 |
216218

217219
Scenario: greaterThan run against a contradicting not greaterThan should only only generate string, temporal and null (greaterThan 2 AND not greaterThanOrEqualTo 3)
218220
Given foo is greater than 2
@@ -247,19 +249,20 @@ Scenario: greaterThan run against a non contradicting not lessThan should be suc
247249
| 5 |
248250
| 6 |
249251

252+
@ignore #594 - Reverse order of value generation when only upper-bound operators are provided
250253
Scenario: not greaterThan run against a non contradicting lessThan should be successful (not greaterThan 4 AND lessThan 2)
251254
Given foo is anything but greater than 4
252255
And foo is less than 2
253256
And foo is of type "integer"
254257
And foo is anything but null
255258
And the generator can generate at most 5 rows
256259
Then the following data should be generated:
257-
| foo |
258-
| -100000000000000000000 |
259-
| -99999999999999999999 |
260-
| -99999999999999999998 |
261-
| -99999999999999999997 |
262-
| -99999999999999999996 |
260+
| foo |
261+
| 1 |
262+
| 0 |
263+
| -1 |
264+
| -2 |
265+
| -3 |
263266

264267
Scenario: not greaterThan run against a non contradicting not lessThan should be successful (not greaterThan 5 AND not lessThan 4)
265268
Given foo is anything but greater than 5
@@ -314,7 +317,7 @@ Scenario: greaterThan run against a non contradicting not lessThanOrEqualTo shou
314317
| 6 |
315318
| 7 |
316319

317-
@ignore #594 - Reverse order of value generation when only upper-bound operators are provided
320+
@ignore #594 - Reverse order of value generation when only upper-bound operators are provided
318321
Scenario: not greaterThan run against a non contradicting lessThanOrEqualTo should be successful (not greaterThan 4 AND lessThanOrEqualTo 2)
319322
Given foo is anything but greater than 4
320323
And foo is less than or equal to 2
@@ -358,7 +361,7 @@ Scenario: not greaterThan run against a contradicting not lessThanOrEqualTo shou
358361

359362

360363
#granularTo
361-
Scenario: greaterThan run against a non contradicting granularTo should be successful (greaterThan 2 AND granularTo 1)
364+
Scenario: greaterThan run against a non contradicting granularTo should be successful (greaterThan 2 AND granularTo 0.1)
362365
Given foo is greater than 2
363366
And foo is granular to 0.1
364367
And foo is anything but null
@@ -372,19 +375,20 @@ Scenario: greaterThan run against a non contradicting granularTo should be succe
372375
| 2.4 |
373376
| 2.5 |
374377

375-
@ignore #594
376-
Scenario: not greaterThan run against a non contradicting granularTo should be successful (not greaterThan 4 AND granularTo 1)
378+
@ignore #594 - Reverse order of value generation when only upper-bound operators are provided
379+
Scenario: not greaterThan run against a non contradicting granularTo should be successful (not greaterThan 4 AND granularTo 0.1)
377380
Given foo is anything but greater than 4
378-
And foo is of type "integer"
381+
And foo is granular to 0.1
379382
And foo is anything but null
383+
And foo is of type "decimal"
380384
And the generator can generate at most 5 rows
381385
Then the following data should be generated:
382-
| foo |
383-
| 4 |
384-
| 3 |
385-
| 2 |
386-
| 1 |
387-
| 0 |
386+
| foo |
387+
| 3.9 |
388+
| 3.8 |
389+
| 3.7 |
390+
| 3.6 |
391+
| 3.5 |
388392

389393
#after
390394
Scenario: greaterThan run against a non contradicting after should be successful (greaterThan 1 AND after 2019-01-01T00:00:00.00)

generator/src/test/java/com/scottlogic/deg/generator/cucumber/GreaterThanOrEqualTo.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Scenario: greaterThanOrEqualTo run against a non contradicting not greaterThanOr
9999
| 8 |
100100
| 9 |
101101

102-
@ignore #594
102+
@ignore #594 - Reverse order of value generation when only upper-bound operators are provided
103103
Scenario: not greaterThanOrEqualTo run against a non contradicting not greaterThanOrEqualTo should be successful
104104
Given foo is anything but greater than or equal to 5
105105
And foo is anything but greater than or equal to 5
@@ -149,7 +149,7 @@ Scenario: greaterThanOrEqualTo run against a non contradicting not lessThan shou
149149
| 13 |
150150
| 14 |
151151

152-
@ignore #594
152+
@ignore #594 - Reverse order of value generation when only upper-bound operators are provided
153153
Scenario: not greaterThanOrEqualTo run against a non contradicting lessThan should be successful
154154
Given foo is anything but greater than or equal to 10
155155
And foo is less than 10
@@ -220,7 +220,7 @@ Scenario: greaterThanOrEqualTo run against a non contradicting not lessThanOrEqu
220220
| 9 |
221221
| 10 |
222222

223-
@ignore #594
223+
@ignore #594 - Reverse order of value generation when only upper-bound operators are provided
224224
Scenario: not greaterThanOrEqualTo run against a non contradicting lessThanOrEqualTo should be successful
225225
Given foo is anything but greater than or equal to 5
226226
And foo is less than or equal to 5
@@ -292,7 +292,7 @@ Scenario: greaterThanOrEqualTo run against a non contradicting not granularTo sh
292292
| 6 |
293293
| 5 |
294294

295-
@ignore #594
295+
@ignore #594 - Reverse order of value generation when only upper-bound operators are provided
296296
Scenario: not greaterThanOrEqualTo run against a non contradicting granularTo should be successful
297297
Given foo is anything but greater than or equal to 5
298298
And foo is granular to 1
@@ -307,7 +307,7 @@ Scenario: not greaterThanOrEqualTo run against a non contradicting granularTo sh
307307
| 1 |
308308
| 0 |
309309

310-
@ignore #594
310+
@ignore #594 - Reverse order of value generation when only upper-bound operators are provided
311311
Scenario: not greaterThanOrEqualTo run against a non contradicting granularTo should be successful
312312
Given foo is anything but greater than or equal to 5
313313
And foo is anything but granular to 0.1

generator/src/test/java/com/scottlogic/deg/generator/cucumber/Violation.feature

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ Scenario: Running the generator in violate mode for multiple constraints with st
2929
And foo is anything but equal to "hello"
3030
And the generator can generate at most 10 rows
3131
Then the following data should be included in what is generated:
32-
| foo |
33-
| "hello" |
34-
| 0 |
35-
| -2147483648 |
36-
| 2147483646 |
37-
| 1900-01-01T00:00:00.000 |
38-
| 2100-01-01T00:00:00.000 |
39-
| null |
32+
| foo |
33+
| "hello" |
34+
| 0 |
35+
| -100000000000000000000.00000000000000000000 |
36+
| -99999999999999999999.99999999999999999999 |
37+
| 99999999999999999999.99999999999999999999 |
38+
| 100000000000000000000.00000000000000000000 |
39+
| 1900-01-01T00:00:00.000 |
40+
| 2100-01-01T00:00:00.000 |
41+
| null |
4042

4143
### Random
4244

0 commit comments

Comments
 (0)