cancel
Showing results for 
Search instead for 
Did you mean: 

Groovy and Java scripts in one project

Highlighted
Contributor

Groovy and Java scripts in one project

I have a project need where i need to perform some REST calls in a groovy project but then in the same project need to call some REST API's which has some java script in it for pre setup ....can they both be in the same project as per soap ui documentation we can have only one language in the project properties with the script language set to groovy or Javascript ?

 

So this would be like a nested project where i need both groovy and Javascript to work in the same project 

39 REPLIES 39
Highlighted
Contributor

Yours would be a XML from soap ui which I could import and change the values for my host and run it hopefully
Highlighted
Community Hero

Hey @ameesh1984,

Slow up a bit mate, we're getting ahead of ourselves.

Its gonna be about another 3 hours til i have the chance to look at the prescript (remember im not a scripter so no guarantees), have you made any headway with your script?

SOME QUESTIONS:

Q1. Does the postman collection have only a single request in it? Seems like a lot of effort for a single request fella....wouldn't it just be easier for you to manually create a single request?

Q2. If you want me to create the request myself i'm gonna need a lot more info than youve supplied so far. All i know is the full URL, that there is a parameterised hostname and there is some other parameter.

Q3. You haven't indicated the http method/verb....what method is used by the request....GET? POST? PATCH? PUT? DELETE? etc.

Q4. Is there a payload associated with the request? If there is a payload, whats the datatype of payload?

Q5. You state there are only 2 parms...hostname and master key. What parm type is the master key? Header? Uri/template? Matrix? Query?

Q6. Are there any custom headers (people quite often forget about the headers thinking theyre just environmental, but you do get custom headers occasionally)???

I'm more than happy to do the above fella, but it's probably quicker for you to do it rather than even bothering to type the answers to my questions! To be honest the fact that you wanna import the request from a collection rather than just create the thing directly in soapui makes me think its far more complicated than described...or am i misunderstanding something else? (I tend to have a perpetual cloud of confusion most days of the week...)

Cheers!

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Contributor

If you open the collection all 10 requests use the same pre request script

I need one of them converted to groovy so that it can work with soap ui

If you have an azure instance to test against you can try it with your variables for 1 request
Highlighted
Community Hero

What do you mean "if you have an azure instance you can try it with variables for 1 request"

Azure is just the clour hosting platform. I have a number of different projects hosting various different applications, but none of them are expecting me to publish your request to them.

Im also gonna need the previous questions i asked answered so i know what im trying and can tailor the request accordingly!

Ta

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Contributor

First are you able to import this collection into your Postman
https://github.com/liupeirong/cosmosdb-postman-collection
Once you do you will see a collection called "Query Collection - specify query in body"
 
All is had to do is in the environment look up on the top right of postman set my azure host and Master key and the query as put below in the body of my message 
 
{
"query": "SELECT * FROM provider_pharmacy c WHERE c.pharmacyId = @id",
"parameters": [
{"name": "@id", "value": "xbbbbbd"}
]
}
 
I need the same to work from soap ui but i dont have the pre request script in groovy
 
This should answer all your questions 

Highlighted
Contributor

Any update on this did u get to try

I am not a js guy hence struggling to find the statements to convert it to groovy
Highlighted
Community Hero

Sorry @ameesh1984,

I had a bit of a family emergency so didnt getround to it. I'll do it later tonight.
Apologies for the delay,

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Community Hero

Hey @ameesh1984 

 

right - I successfully imported the one postman collection, but couldnt import the second cos it wasnt really a collection - its just an environment config file as far s i can tell.

 

I've exported the postman collection and attached.

 

I'm about a quarter ogf the way through converting  the JS to groovy.  how far have you got?  it would make sense if we dont want to waste time but for one of us to start at the bottom of the script and work up whilst the other works down.

 

This is what I've converted so far (remember postman stores properties as global variables so they;re all stored at the same level - so I've set them all to store at project level).

 

//Postman stores properties a global variables and there are no levels of storage in Postman.  I've assumed it's best if you store them at project level, so that's what I've done

import org.codehaus.groovy.runtime.*; //needed for the date handling

// store our master key for documentdb
def mastKey = testRunner.testCase.testSuite.project.getPropertyValue("DocumentDBMasterKey");
log.info("mastKey = " + mastKey);

// store our date as RFC1123 format (DD-MON-YYYY)for the request
def today = new Date();
def UTCstring = DateGroovyMethods.format(dateTime, 'dd-MMM-yyyy')
testRunner.testCase.testSuite.project.setPropertyValue("RFC1123time", UTCstring.toString())

// Grab the request url - not too sure about this one.  for this to work something is already defined as 'request' and 'url' but I dont know if thats postman or not...???
def url = request.url.trim(); 
log.info("request url = " + url);

// strip the url of the hostname up and leading slash
def strippedurl = url.replace(new RegExp('^https?://[^/]+/'),'/');
log.info("stripped Url = " + strippedurl);

 

anyway - we need to collaborate if we're going to get this sorted - so hit me back with your script progress and please remember - I'm not a scripter - I just steal all Rao's an Himanshu's good ideas!

 

nice one

 

rich

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
Highlighted
Contributor

Well your way faster than me

If you did not import the other json how will this work , both need to be imported and then one XML for soap ui exported out
Highlighted
Community Hero

the trouble is the  other one isn't actually a collection - its just environmetn config - so ReadyAPI! isn't actually recognising it as a collection I'm guessing.

 

I'm not very good with Postman - I'll have to have a look and see how it works - but to suffice  it to say - it might be easier for you to just edit the project I gave you and add in the environment config.  The problem is I can't play with the thing (make submissions) and go through the standard trial and error thing myself to see how it works and  what it's doing. 

 

ta

 

rich

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
New Here?
Join us and watch the welcome video:
Top Kudoed Authors