Skip to content

Commit 700fadd

Browse files
committed
Remove deprecated GsonHelper class
Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
1 parent 4e55cee commit 700fadd

File tree

5 files changed

+19
-111
lines changed

5 files changed

+19
-111
lines changed

modules/nf-commons/src/main/nextflow/util/GsonHelper.groovy

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

modules/nf-commons/src/test/nextflow/util/GsonHelperTest.groovy

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

modules/nf-lineage/src/main/nextflow/lineage/LinUtils.groovy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ import nextflow.serde.gson.GsonEncoder
4040
@CompileStatic
4141
class LinUtils {
4242

43-
private static final String[] EMPTY_ARRAY = new String[] {}
44-
4543
/**
4644
* Get a lineage record or fragment from the Lineage store.
4745
*

plugins/nf-tower/src/main/io/seqera/tower/plugin/TowerFusionToken.groovy

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import nextflow.fusion.FusionConfig
3434
import nextflow.fusion.FusionToken
3535
import nextflow.platform.PlatformHelper
3636
import nextflow.plugin.Priority
37-
import nextflow.util.GsonHelper
37+
import nextflow.serde.gson.GsonEncoder
3838
import nextflow.util.Threads
3939
import org.pf4j.Extension
4040
/**
@@ -269,7 +269,8 @@ class TowerFusionToken implements FusionToken {
269269
* @return The resulting HttpRequest object
270270
*/
271271
private HttpRequest makeHttpRequest(GetLicenseTokenRequest req) {
272-
final body = HttpRequest.BodyPublishers.ofString( GsonHelper.toJson(req) )
272+
final gson = new GsonEncoder<GetLicenseTokenRequest>() {}
273+
final body = HttpRequest.BodyPublishers.ofString( gson.encode(req) )
273274
return HttpRequest.newBuilder()
274275
.uri(URI.create("${endpoint}/${LICENSE_TOKEN_PATH}").normalize())
275276
.header('Content-Type', 'application/json')
@@ -298,7 +299,8 @@ class TowerFusionToken implements FusionToken {
298299
* @throws JsonSyntaxException if the JSON string is not well-formed
299300
*/
300301
protected static GetLicenseTokenResponse parseLicenseTokenResponse(String json) throws JsonSyntaxException {
301-
return GsonHelper.fromJson(json, GetLicenseTokenResponse.class)
302+
final gson = new GsonEncoder<GetLicenseTokenResponse>() {}
303+
return gson.decode(json)
302304
}
303305

304306
/**

plugins/nf-tower/src/test/io/seqera/tower/plugin/TowerFusionEnvTest.groovy

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
package io.seqera.tower.plugin
22

3+
import static com.github.tomakehurst.wiremock.client.WireMock.*
4+
35
import java.time.Instant
46
import java.time.temporal.ChronoUnit
57

68
import com.github.tomakehurst.wiremock.WireMockServer
79
import com.github.tomakehurst.wiremock.client.WireMock
810
import com.github.tomakehurst.wiremock.stubbing.Scenario
11+
import com.google.gson.GsonBuilder
912
import io.seqera.tower.plugin.exception.UnauthorizedException
1013
import nextflow.Global
1114
import nextflow.Session
1215
import nextflow.SysEnv
13-
import nextflow.util.GsonHelper
16+
import nextflow.serde.gson.InstantAdapter
1417
import spock.lang.Shared
1518
import spock.lang.Specification
16-
17-
import static com.github.tomakehurst.wiremock.client.WireMock.*
18-
1919
/**
2020
* Test cases for the TowerFusionEnv class.
2121
*
@@ -44,6 +44,13 @@ class TowerFusionEnvTest extends Specification {
4444
SysEnv.pop() // <-- restore the system host env
4545
}
4646

47+
static String toJson(Object obj) {
48+
new GsonBuilder()
49+
.registerTypeAdapter(Instant, new InstantAdapter())
50+
.create()
51+
.toJson(obj)
52+
}
53+
4754
def 'should return the endpoint from the config'() {
4855
given: 'a session'
4956
Global.session = Mock(Session) {
@@ -263,7 +270,7 @@ class TowerFusionEnvTest extends Specification {
263270

264271
and: 'a mock endpoint returning a valid token'
265272
final now = Instant.now()
266-
final expirationDate = GsonHelper.toJson(now.plus(1, ChronoUnit.DAYS))
273+
final expirationDate = toJson(now.plus(1, ChronoUnit.DAYS))
267274
wireMockServer.stubFor(
268275
WireMock.post(urlEqualTo("/license/token/"))
269276
.withHeader('Authorization', equalTo('Bearer abc123'))
@@ -306,7 +313,7 @@ class TowerFusionEnvTest extends Specification {
306313

307314
and: 'a mock endpoint returning a valid token'
308315
final now = Instant.now()
309-
final expirationDate = GsonHelper.toJson(now.plus(1, ChronoUnit.DAYS))
316+
final expirationDate = toJson(now.plus(1, ChronoUnit.DAYS))
310317
wireMockServer.stubFor(
311318
WireMock.post(urlEqualTo("/license/token/"))
312319
.withHeader('Authorization', equalTo('Bearer abc123'))
@@ -354,7 +361,7 @@ class TowerFusionEnvTest extends Specification {
354361
and: 'prepare stubs'
355362

356363
final now = Instant.now()
357-
final expirationDate = GsonHelper.toJson(now.plus(1, ChronoUnit.DAYS))
364+
final expirationDate = toJson(now.plus(1, ChronoUnit.DAYS))
358365

359366
// 1️⃣ First attempt: /license/token/ fails with 401
360367
wireMockServer.stubFor(

0 commit comments

Comments
 (0)