Я пытаюсь выполнить автоматический поиск OAuth, указанный по ссылке https://support.smartbear.com/readyapi/docs/projects/requests/auth/types/oauth2/automate/sample.html, используя следующий код Groovy:
// Import the required classes
import com.eviware.soapui.impl.rest.actions.oauth.OltuOAuth2ClientFacade;
import com.eviware.soapui.support.editor.inspectors.auth.TokenType;
import com.eviware.soapui.model.support.ModelSupport;
// Set up variables
def project = ModelSupport.getModelItemProject(context.getModelItem());
def authProfile = project.getAuthRepository().getEntry("OAuth 2");
def oldToken = authProfile.getAccessToken();
def tokenType = TokenType.ACCESS;
// Create a facade object
def oAuthFacade = new OltuOAuth2ClientFacade(tokenType);
// Request an access token in headless mode
oAuthFacade.requestAccessToken(authProfile, true, true);
// Wait until the access token gets updated
while(oldToken == authProfile.getAccessToken()) {
}
//The sleep method can be used instead of a while loop
//sleep(3000);
// Post the info to the log
log.info("Set new token: " + authProfile.getAccessToken());
Но я получаю следующую ошибку, что не удается разрешить класс TokenType:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script15.groovy: 5: unable to resolve class com.eviware.soapui.support.editor.inspectors.auth.TokenType @ line 5, column 1. import com.eviware.soapui.support.editor.inspectors.auth.TokenType; ^ org.codehaus.groovy.syntax.SyntaxException: unable to resolve class com.eviware.soapui.support.editor.inspectors.auth.TokenType @ line 5, column 1. at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:149) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1225) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:178) at org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:651) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:931) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:542) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:694) at groovy.lang.GroovyShell.parse(GroovyShell.java:706) at groovy.lang.GroovyShell.parse(GroovyShell.java:742) at groovy.lang.GroovyShell.parse(GroovyShell.java:733) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:136) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:87) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141) at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:250) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 1 error
Если я не импортирую TokenType, то получаю сообщение об ошибке No Such Property TokenType
.Как я могу импортировать класс TokenType ИЛИ есть ли другой способ запросить новый токен доступа без использования TokenType?