Skip to content

Commit d4b8baf

Browse files
Moving Scalars to an internal class & Updating tests to use the internal types
1 parent f2ceabc commit d4b8baf

File tree

8 files changed

+483
-444
lines changed

8 files changed

+483
-444
lines changed

src/main/java/graphql/scalars/ExtendedScalars.java

Lines changed: 10 additions & 402 deletions
Large diffs are not rendered by default.

src/main/java/graphql/scalars/java/JavaPrimitives.java

Lines changed: 431 additions & 0 deletions
Large diffs are not rendered by default.

src/test/groovy/graphql/scalars/ScalarsBigDecimalTest.groovy renamed to src/test/groovy/graphql/scalars/java/ScalarsBigDecimalTest.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package graphql.scalars
1+
package graphql.scalars.java
22

33
import graphql.Scalars
44
import graphql.language.BooleanValue
@@ -18,7 +18,7 @@ class ScalarsBigDecimalTest extends Specification {
1818
@Unroll
1919
def "BigDecimal parse literal #literal.value as #result"() {
2020
expect:
21-
Scalars.GraphQLBigDecimal.getCoercing().parseLiteral(literal) == result
21+
JavaPrimitives.GraphQLBigDecimal.getCoercing().parseLiteral(literal) == result
2222

2323
where:
2424
literal | result
@@ -31,7 +31,7 @@ class ScalarsBigDecimalTest extends Specification {
3131
@Unroll
3232
def "BigDecimal returns null for invalid #literal"() {
3333
when:
34-
Scalars.GraphQLBigDecimal.getCoercing().parseLiteral(literal)
34+
JavaPrimitives.GraphQLBigDecimal.getCoercing().parseLiteral(literal)
3535
then:
3636
thrown(CoercingParseLiteralException)
3737

@@ -44,8 +44,8 @@ class ScalarsBigDecimalTest extends Specification {
4444
@Unroll
4545
def "BigDecimal serialize #value into #result (#result.class)"() {
4646
expect:
47-
Scalars.GraphQLBigDecimal.getCoercing().serialize(value) == result
48-
Scalars.GraphQLBigDecimal.getCoercing().parseValue(value) == result
47+
JavaPrimitives.GraphQLBigDecimal.getCoercing().serialize(value) == result
48+
JavaPrimitives.GraphQLBigDecimal.getCoercing().parseValue(value) == result
4949

5050
where:
5151
value | result
@@ -67,7 +67,7 @@ class ScalarsBigDecimalTest extends Specification {
6767
@Unroll
6868
def "serialize throws exception for invalid input #value"() {
6969
when:
70-
Scalars.GraphQLBigDecimal.getCoercing().serialize(value)
70+
JavaPrimitives.GraphQLBigDecimal.getCoercing().serialize(value)
7171
then:
7272
thrown(CoercingSerializeException)
7373

@@ -81,7 +81,7 @@ class ScalarsBigDecimalTest extends Specification {
8181
@Unroll
8282
def "parseValue throws exception for invalid input #value"() {
8383
when:
84-
Scalars.GraphQLBigDecimal.getCoercing().parseValue(value)
84+
JavaPrimitives.GraphQLBigDecimal.getCoercing().parseValue(value)
8585
then:
8686
thrown(CoercingParseValueException)
8787

src/test/groovy/graphql/scalars/ScalarsBigIntegerTest.groovy renamed to src/test/groovy/graphql/scalars/java/ScalarsBigIntegerTest.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package graphql.scalars
1+
package graphql.scalars.java
22

33
import graphql.Scalars
44
import graphql.language.BooleanValue
@@ -18,7 +18,7 @@ class ScalarsBigIntegerTest extends Specification {
1818
@Unroll
1919
def "BigInteger parse literal #literal.value as #result"() {
2020
expect:
21-
Scalars.GraphQLBigInteger.getCoercing().parseLiteral(literal) == result
21+
JavaPrimitives.GraphQLBigInteger.getCoercing().parseLiteral(literal) == result
2222

2323
where:
2424
literal | result
@@ -30,7 +30,7 @@ class ScalarsBigIntegerTest extends Specification {
3030
@Unroll
3131
def "BigInteger returns null for invalid #literal"() {
3232
when:
33-
Scalars.GraphQLBigInteger.getCoercing().parseLiteral(literal)
33+
JavaPrimitives.GraphQLBigInteger.getCoercing().parseLiteral(literal)
3434
then:
3535
thrown(CoercingParseLiteralException)
3636

@@ -45,8 +45,8 @@ class ScalarsBigIntegerTest extends Specification {
4545
@Unroll
4646
def "BigInteger serialize #value into #result (#result.class)"() {
4747
expect:
48-
Scalars.GraphQLBigInteger.getCoercing().serialize(value) == result
49-
Scalars.GraphQLBigInteger.getCoercing().parseValue(value) == result
48+
JavaPrimitives.GraphQLBigInteger.getCoercing().serialize(value) == result
49+
JavaPrimitives.GraphQLBigInteger.getCoercing().parseValue(value) == result
5050

5151
where:
5252
value | result
@@ -64,7 +64,7 @@ class ScalarsBigIntegerTest extends Specification {
6464
@Unroll
6565
def "serialize throws exception for invalid input #value"() {
6666
when:
67-
Scalars.GraphQLBigInteger.getCoercing().serialize(value)
67+
JavaPrimitives.GraphQLBigInteger.getCoercing().serialize(value)
6868
then:
6969
thrown(CoercingSerializeException)
7070

@@ -80,7 +80,7 @@ class ScalarsBigIntegerTest extends Specification {
8080
@Unroll
8181
def "parseValue throws exception for invalid input #value"() {
8282
when:
83-
Scalars.GraphQLBigInteger.getCoercing().parseValue(value)
83+
JavaPrimitives.GraphQLBigInteger.getCoercing().parseValue(value)
8484
then:
8585
thrown(CoercingParseValueException)
8686

src/test/groovy/graphql/scalars/ScalarsByteTest.groovy renamed to src/test/groovy/graphql/scalars/java/ScalarsByteTest.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package graphql.scalars
1+
package graphql.scalars.java
22

33
import graphql.Scalars
44
import graphql.language.FloatValue
@@ -17,7 +17,7 @@ class ScalarsByteTest extends Specification {
1717
@Unroll
1818
def "Byte parse literal #literal.value as #result"() {
1919
expect:
20-
Scalars.GraphQLByte.getCoercing().parseLiteral(literal) == result
20+
JavaPrimitives.GraphQLByte.getCoercing().parseLiteral(literal) == result
2121

2222
where:
2323
literal | result
@@ -30,7 +30,7 @@ class ScalarsByteTest extends Specification {
3030
@Unroll
3131
def "Byte returns null for invalid #literal"() {
3232
when:
33-
Scalars.GraphQLByte.getCoercing().parseLiteral(literal)
33+
JavaPrimitives.GraphQLByte.getCoercing().parseLiteral(literal)
3434
then:
3535
thrown(CoercingParseLiteralException)
3636

@@ -49,8 +49,8 @@ class ScalarsByteTest extends Specification {
4949
@Unroll
5050
def "Byte serialize #value into #result (#result.class)"() {
5151
expect:
52-
Scalars.GraphQLByte.getCoercing().serialize(value) == result
53-
Scalars.GraphQLByte.getCoercing().parseValue(value) == result
52+
JavaPrimitives.GraphQLByte.getCoercing().serialize(value) == result
53+
JavaPrimitives.GraphQLByte.getCoercing().parseValue(value) == result
5454

5555
where:
5656
value | result
@@ -74,7 +74,7 @@ class ScalarsByteTest extends Specification {
7474
@Unroll
7575
def "serialize throws exception for invalid input #value"() {
7676
when:
77-
Scalars.GraphQLByte.getCoercing().serialize(value)
77+
JavaPrimitives.GraphQLByte.getCoercing().serialize(value)
7878
then:
7979
thrown(CoercingSerializeException)
8080

@@ -95,7 +95,7 @@ class ScalarsByteTest extends Specification {
9595
@Unroll
9696
def "parseValue throws exception for invalid input #value"() {
9797
when:
98-
Scalars.GraphQLByte.getCoercing().parseValue(value)
98+
JavaPrimitives.GraphQLByte.getCoercing().parseValue(value)
9999
then:
100100
thrown(CoercingParseValueException)
101101

src/test/groovy/graphql/scalars/ScalarsCharTest.groovy renamed to src/test/groovy/graphql/scalars/java/ScalarsCharTest.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package graphql.scalars
1+
package graphql.scalars.java
22

33
import graphql.Scalars
44
import graphql.language.IntValue
@@ -14,7 +14,7 @@ class ScalarsCharTest extends Specification {
1414
@Unroll
1515
def "Char parse literal #literal.value as #result"() {
1616
expect:
17-
Scalars.GraphQLChar.getCoercing().parseLiteral(literal) == result
17+
JavaPrimitives.GraphQLChar.getCoercing().parseLiteral(literal) == result
1818

1919
where:
2020
literal | result
@@ -26,7 +26,7 @@ class ScalarsCharTest extends Specification {
2626
@Unroll
2727
def "Short returns null for invalid #literal"() {
2828
when:
29-
Scalars.GraphQLChar.getCoercing().parseLiteral(literal)
29+
JavaPrimitives.GraphQLChar.getCoercing().parseLiteral(literal)
3030
then:
3131
thrown(CoercingParseLiteralException)
3232

@@ -39,8 +39,8 @@ class ScalarsCharTest extends Specification {
3939
@Unroll
4040
def "Short serialize #value into #result (#result.class)"() {
4141
expect:
42-
Scalars.GraphQLChar.getCoercing().serialize(value) == result
43-
Scalars.GraphQLChar.getCoercing().parseValue(value) == result
42+
JavaPrimitives.GraphQLChar.getCoercing().serialize(value) == result
43+
JavaPrimitives.GraphQLChar.getCoercing().parseValue(value) == result
4444

4545
where:
4646
value | result
@@ -51,7 +51,7 @@ class ScalarsCharTest extends Specification {
5151
@Unroll
5252
def "serialize throws exception for invalid input #value"() {
5353
when:
54-
Scalars.GraphQLChar.getCoercing().serialize(value)
54+
JavaPrimitives.GraphQLChar.getCoercing().serialize(value)
5555
then:
5656
thrown(CoercingSerializeException)
5757

@@ -66,7 +66,7 @@ class ScalarsCharTest extends Specification {
6666
@Unroll
6767
def "parseValue throws exception for invalid input #value"() {
6868
when:
69-
Scalars.GraphQLChar.getCoercing().parseValue(value)
69+
JavaPrimitives.GraphQLChar.getCoercing().parseValue(value)
7070
then:
7171
thrown(CoercingParseValueException)
7272

src/test/groovy/graphql/scalars/ScalarsLongTest.groovy renamed to src/test/groovy/graphql/scalars/java/ScalarsLongTest.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package graphql.scalars
1+
package graphql.scalars.java
22

33
import graphql.Scalars
44
import graphql.language.FloatValue
@@ -23,7 +23,7 @@ class ScalarsLongTest extends Specification {
2323
@Unroll
2424
def "Long parse literal #literal.value as #result"() {
2525
expect:
26-
Scalars.GraphQLLong.getCoercing().parseLiteral(literal) == result
26+
JavaPrimitives.GraphQLLong.getCoercing().parseLiteral(literal) == result
2727

2828
where:
2929
literal | result
@@ -38,7 +38,7 @@ class ScalarsLongTest extends Specification {
3838
@Unroll
3939
def "Long returns null for invalid #literal"() {
4040
when:
41-
Scalars.GraphQLLong.getCoercing().parseLiteral(literal)
41+
JavaPrimitives.GraphQLLong.getCoercing().parseLiteral(literal)
4242
then:
4343
thrown(CoercingParseLiteralException)
4444

@@ -54,8 +54,8 @@ class ScalarsLongTest extends Specification {
5454
@Unroll
5555
def "Long serialize #value into #result (#result.class)"() {
5656
expect:
57-
Scalars.GraphQLLong.getCoercing().serialize(value) == result
58-
Scalars.GraphQLLong.getCoercing().parseValue(value) == result
57+
JavaPrimitives.GraphQLLong.getCoercing().serialize(value) == result
58+
JavaPrimitives.GraphQLLong.getCoercing().parseValue(value) == result
5959

6060
where:
6161
value | result
@@ -80,7 +80,7 @@ class ScalarsLongTest extends Specification {
8080
@Unroll
8181
def "serialize throws exception for invalid input #value"() {
8282
when:
83-
Scalars.GraphQLLong.getCoercing().serialize(value)
83+
JavaPrimitives.GraphQLLong.getCoercing().serialize(value)
8484
then:
8585
thrown(CoercingSerializeException)
8686

@@ -99,7 +99,7 @@ class ScalarsLongTest extends Specification {
9999
@Unroll
100100
def "parseValue throws exception for invalid input #value"() {
101101
when:
102-
Scalars.GraphQLLong.getCoercing().parseValue(value)
102+
JavaPrimitives.GraphQLLong.getCoercing().parseValue(value)
103103
then:
104104
thrown(CoercingParseValueException)
105105

src/test/groovy/graphql/scalars/ScalarsShortTest.groovy renamed to src/test/groovy/graphql/scalars/java/ScalarsShortTest.groovy

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package graphql.scalars
1+
package graphql.scalars.java
22

33
import graphql.Scalars
44
import graphql.language.FloatValue
@@ -17,7 +17,7 @@ class ScalarsShortTest extends Specification {
1717
@Unroll
1818
def "Short parse literal #literal.value as #result"() {
1919
expect:
20-
Scalars.GraphQLShort.getCoercing().parseLiteral(literal) == result
20+
JavaPrimitives.GraphQLShort.getCoercing().parseLiteral(literal) == result
2121

2222
where:
2323
literal | result
@@ -30,7 +30,7 @@ class ScalarsShortTest extends Specification {
3030
@Unroll
3131
def "Short returns null for invalid #literal"() {
3232
when:
33-
Scalars.GraphQLShort.getCoercing().parseLiteral(literal)
33+
JavaPrimitives.GraphQLShort.getCoercing().parseLiteral(literal)
3434
then:
3535
thrown(CoercingParseLiteralException)
3636

@@ -48,8 +48,8 @@ class ScalarsShortTest extends Specification {
4848
@Unroll
4949
def "Short serialize #value into #result (#result.class)"() {
5050
expect:
51-
Scalars.GraphQLShort.getCoercing().serialize(value) == result
52-
Scalars.GraphQLShort.getCoercing().parseValue(value) == result
51+
JavaPrimitives.GraphQLShort.getCoercing().serialize(value) == result
52+
JavaPrimitives.GraphQLShort.getCoercing().parseValue(value) == result
5353

5454
where:
5555
value | result
@@ -73,7 +73,7 @@ class ScalarsShortTest extends Specification {
7373
@Unroll
7474
def "serialize throws exception for invalid input #value"() {
7575
when:
76-
Scalars.GraphQLShort.getCoercing().serialize(value)
76+
JavaPrimitives.GraphQLShort.getCoercing().serialize(value)
7777
then:
7878
thrown(CoercingSerializeException)
7979

@@ -94,7 +94,7 @@ class ScalarsShortTest extends Specification {
9494
@Unroll
9595
def "parseValue throws exception for invalid input #value"() {
9696
when:
97-
Scalars.GraphQLShort.getCoercing().parseValue(value)
97+
JavaPrimitives.GraphQLShort.getCoercing().parseValue(value)
9898
then:
9999
thrown(CoercingParseValueException)
100100

0 commit comments

Comments
 (0)