Forum Discussion
are you aware of the UPPER and LOWER function in ANSI SQL? you said you need to use your sp, but can you change it slightly to force the returned locationtype to lower case.
in regards to the insertion of the T char to indicate UCT or not....could you use a wildcard on your message content assertion? you could wildcard the position between the date and the time time. or instead of message content assertion perhaps you could use a regex assertion instead? although this may be a little less rigorous assertion than you actually need.
this is reminding me of something i did before......i'm sure i had the same timezone indicator problem. i will look through my work tosee if i sorted it out.
cheers
richie
Hi Richie,
I am aware of the UPPER and LOWER functions in SQL, but due to reasons i cannot do that here. (long boring story).
I like your sugestion to use a wildcard with message assertion. I will try that out :)
And so far i have been looking into groovy script:
Date:
def requestedArrivalDate = context.expand( '${LDS SP TimeLine#requestedArrivalDate}.substring(0,19)' )
Date date = Date.parse("yyyy-MM-dd HH:mm:ss",requestedArrivalDate)
testRunner.testCase.setPropertyValue(requestedArrivalDate, date.format("yyyy-MM-dd'T'HH:mm:ss"))
LowerCase:
def locationDescription = context.expand( '${LDS SP TimeLine#locationDescription}' )
testRunner.testCase.setPropertyValue("Location", locationDescription.toString().toLowerCase())
But i was hoping for an far easier solution.
For example that we can do "get data"
and as a result do something like:
'${LDS SP TimeLine#locationDescription}'.toString.toLower
- richie6 years agoCommunity Hero
Hi,
My groovy is rubbish - I can read what you've done - and I can do bits and bobs - but thats only due to the grace of other people's help on this forum.
So - I can't comment on your code or improve it per se - but some of the other lads on the forum should be able to help.
Is the upper case 'T' the only problem with your datetime?
In one of my projects I have an event handler to remove the CDATA tag handler from my response
I use the RequestFilter.afterRequest event type with the following code
def content = context.httpResponse.responseContent log.info( content ) content = content.replaceAll( "<!\\[CDATA\\[", "" ) content = content.replaceAll( "]]>", "" ) log.info( content ) context.httpResponse.responseContent = content log.info(context.httpResponse.responseContent)
Now - this won't work for your situation because the 'T' is not unique in your response - HOWEVER - if you can determine a substring function this would be able to remove the 'T' from the datetime in your response.
Unsure whether this approach will work because I asked this very question a couple of weeks ago on the forum and I didn't get an answer - but if there's bound to be a groovy or Java substring function you can use - I just don't know enough to check the java api to work out how to use it on my own.
If you do manage to use a substring function - I would be very grateful if you could share it!
sorry I can't be of more help!
richie
- Dchen6 years agoOccasional Contributor
Hi,
Currently i am on track with this:
String estimatedArrivalDate = "2017-08-02 21:00:00.000"
String locationDescription = "Port"
String involvedPartyName = "JFHillebrand"
log.info estimatedArrivalDate.substring(0,10)+ "T" + estimatedArrivalDate.substring(11,19)
log.info locationDescription.toLowerCase()
log.info involvedPartyName[0,1].toLowerCase() + involvedPartyName.substring(2)Result:
- Fri May 18 16:02:01 CEST 2018:INFO: 2017-08-02T21:00:00
- Fri May 18 16:02:01 CEST 2018:INFO: port
- Fri May 18 16:02:01 CEST 2018:INFO: jfHillebrand
So it works, but it isn't that pretty...
Does this help your issue?
so if i want to save my results in the testcase "Custom Property" than i add the following line:
estimatedArrivalDate = estimatedArrivalDate.substring(0,10)+ "T" + estimatedArrivalDate.substring(11,19)
testRunner.testCase.setPropertyValue("estimatedArrivalDate", estimatedArrivalDate )