jazzyekim
13 years agoOccasional Contributor
Set MockOperation script using groovy
Hi there!
I am creating script that generates mock from an interface with all necessary settings setup. Beyond settings I need to set scripts to Mock/Operation/Response.
For mocks OnRequest and AfterRequest it is quite easy. There is appropriate methods, e.g.
same is for Response:
but as for Operation it is not so obvious. I am able to set dispatcher style to "SCRIPT" and get MockOperationDispatcher :
Dispatcher has methods like getEditorComponent(), but I still can't find the way how can I set script in it.
Does anyone know how I can do it?
I am creating script that generates mock from an interface with all necessary settings setup. Beyond settings I need to set scripts to Mock/Operation/Response.
For mocks OnRequest and AfterRequest it is quite easy. There is appropriate methods, e.g.
public void setupMock (WsdlMockService mock)
{
...
String script = ReadTextFile.getFileContent(config.getOnRequestPath());
mock.setOnRequestScript(script) ;
...
}
same is for Response:
public void createAndSetupResponseSet ( WsdlMockOperation operation )
{
...
//create a set of responses
WsdlMockResponse response = operation.addNewMockResponse("Response 1", true);
//set script for responses
String script = ReadTextFile.getFileContent(config.getResponsePath());
response.setScript(script);
...
}
but as for Operation it is not so obvious. I am able to set dispatcher style to "SCRIPT" and get MockOperationDispatcher :
for(WsdlMockOperation it: arrOperations)
{
MockOperationDispatcher dispatcher = it.setDispatchStyle("SCRIPT");
}
Dispatcher has methods like getEditorComponent(), but I still can't find the way how can I set script in it.
Does anyone know how I can do it?