fix: groovy dependency version (#3776)

This commit is contained in:
Bruno Mattos Torrão 2018-03-07 09:13:24 -03:00 committed by Grzegorz Piwowarek
parent 89c4933a2b
commit 52d257a545
4 changed files with 4 additions and 27 deletions

View File

@ -8,6 +8,6 @@ repositories {
}
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'
}

View File

@ -23,17 +23,17 @@
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>2.5.0-alpha-1</version>
<version>2.4.13</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.5.0-alpha-1</version>
<version>2.4.13</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-sql</artifactId>
<version>2.5.0-alpha-1</version>
<version>2.4.13</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>

View File

@ -1,6 +1,5 @@
package com.baeldung.json
import groovy.json.JsonGenerator
import groovy.json.JsonOutput
import groovy.json.JsonParserType
import groovy.json.JsonSlurper
@ -21,14 +20,6 @@ class JsonParser {
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) {
JsonOutput.prettyPrint(json)
}

View File

@ -52,20 +52,6 @@ class JsonParserTest extends Specification {
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' () {
given:
String json = '{"value":15.6,"createdAt":"01/01/2018","id":"123456"}'