jhall68w
jhall68w

Reputation: 47

Using Groovy in SOAPUI, is it possible to generate a GUID with no hyphens?

This is what I have currently:

def transactionID = "${java.util.UUID.randomUUID()}";
context.testCase.setPropertyValue('transactionID', transactionID)

Upvotes: 3

Views: 4707

Answers (1)

Szymon Stepniak
Szymon Stepniak

Reputation: 42184

UUID has always a form like 0e62c22e-f590-4e9c-9f29-bc7231453da4, but you can convert it to string and call String.replaceAll('-','') to remove all hyphens:

def transactionID = UUID.randomUUID().toString().replaceAll('-','')
println transactionID // e.g. ea3b6994ca104d54b7d9b12f32eb7878

Upvotes: 7

Related Questions