fix: groovy dependency version (#3776)
This commit is contained in:
parent
89c4933a2b
commit
52d257a545
|
@ -8,6 +8,6 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'org.codehaus.groovy:groovy-all:2.5.0-alpha-1'
|
compile 'org.codehaus.groovy:groovy-all:2.4.13'
|
||||||
testCompile 'org.spockframework:spock-core:1.1-groovy-2.4'
|
testCompile 'org.spockframework:spock-core:1.1-groovy-2.4'
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,17 +23,17 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.groovy</groupId>
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
<artifactId>groovy</artifactId>
|
<artifactId>groovy</artifactId>
|
||||||
<version>2.5.0-alpha-1</version>
|
<version>2.4.13</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.groovy</groupId>
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
<artifactId>groovy-all</artifactId>
|
<artifactId>groovy-all</artifactId>
|
||||||
<version>2.5.0-alpha-1</version>
|
<version>2.4.13</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.groovy</groupId>
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
<artifactId>groovy-sql</artifactId>
|
<artifactId>groovy-sql</artifactId>
|
||||||
<version>2.5.0-alpha-1</version>
|
<version>2.4.13</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.junit.jupiter</groupId>
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.baeldung.json
|
package com.baeldung.json
|
||||||
|
|
||||||
import groovy.json.JsonGenerator
|
|
||||||
import groovy.json.JsonOutput
|
import groovy.json.JsonOutput
|
||||||
import groovy.json.JsonParserType
|
import groovy.json.JsonParserType
|
||||||
import groovy.json.JsonSlurper
|
import groovy.json.JsonSlurper
|
||||||
|
@ -21,14 +20,6 @@ class JsonParser {
|
||||||
JsonOutput.toJson(account)
|
JsonOutput.toJson(account)
|
||||||
}
|
}
|
||||||
|
|
||||||
String toJson(Account account, String dateFormat, String... fieldsToExclude) {
|
|
||||||
JsonGenerator generator = new JsonGenerator.Options()
|
|
||||||
.dateFormat(dateFormat)
|
|
||||||
.excludeFieldsByName(fieldsToExclude)
|
|
||||||
.build()
|
|
||||||
generator.toJson(account)
|
|
||||||
}
|
|
||||||
|
|
||||||
String prettyfy(String json) {
|
String prettyfy(String json) {
|
||||||
JsonOutput.prettyPrint(json)
|
JsonOutput.prettyPrint(json)
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,20 +52,6 @@ class JsonParserTest extends Specification {
|
||||||
json == '{"value":15.6,"createdAt":"2018-01-01T00:00:00+0000","id":"123"}'
|
json == '{"value":15.6,"createdAt":"2018-01-01T00:00:00+0000","id":"123"}'
|
||||||
}
|
}
|
||||||
|
|
||||||
def 'Should parse to Json given an Account object, a date format and fields to exclude' () {
|
|
||||||
given:
|
|
||||||
Account account = new Account(
|
|
||||||
id: '123',
|
|
||||||
value: 15.6,
|
|
||||||
createdAt: new SimpleDateFormat('MM/dd/yyyy').parse('01/01/2018')
|
|
||||||
)
|
|
||||||
when:
|
|
||||||
def json = jsonParser.toJson(account, 'MM/dd/yyyy', 'value')
|
|
||||||
then:
|
|
||||||
json
|
|
||||||
json == '{"createdAt":"01/01/2018","id":"123"}'
|
|
||||||
}
|
|
||||||
|
|
||||||
def 'Should prettify given a json string' () {
|
def 'Should prettify given a json string' () {
|
||||||
given:
|
given:
|
||||||
String json = '{"value":15.6,"createdAt":"01/01/2018","id":"123456"}'
|
String json = '{"value":15.6,"createdAt":"01/01/2018","id":"123456"}'
|
||||||
|
|
Loading…
Reference in New Issue