How to use createWithWsdl method of com.consol.citrus.mvn.plugin.CreateTestMojo class

Best Citrus code snippet using com.consol.citrus.mvn.plugin.CreateTestMojo.createWithWsdl

Source:CreateTestMojo.java Github

copy

Full Screen

...128 .withName(name)129 .withAuthor(author)130 .withDescription(description)131 .usePackage(targetPackage);132 createWithWsdl(generator);133 return;134 }135 String useSwagger = prompter.prompt("Create test with Swagger API?", CollectionUtils.arrayToList(new String[] {"y", "n"}), "n");136 if (useSwagger.equalsIgnoreCase("y")) {137 SwaggerTestGenerator generator = getSwaggerTestGenerator();138 generator.withFramework(UnitFramework.fromString(framework))139 .withName(name)140 .withAuthor(author)141 .withDescription(description)142 .usePackage(targetPackage);143 createWithSwagger(generator);144 return;145 }146 String confirm = prompter.prompt("Confirm test creation:\n" +147 "type: " + getType() + "\n" +148 "framework: " + framework + "\n" +149 "name: " + name + "\n" +150 "author: " + author + "\n" +151 "description: " + description + "\n" +152 "package: " + targetPackage + "\n", CollectionUtils.arrayToList(new String[] {"y", "n"}), "y");153 if (confirm.equalsIgnoreCase("n")) {154 return;155 }156 if (getType().equals("java")) {157 JavaDslTestGenerator generator = (JavaDslTestGenerator) getJavaTestGenerator()158 .withFramework(UnitFramework.fromString(framework))159 .withName(name)160 .withAuthor(author)161 .withDescription(description)162 .usePackage(targetPackage);163 generator.create();164 } else {165 XmlTestGenerator generator = (XmlTestGenerator) getXmlTestGenerator()166 .withFramework(UnitFramework.fromString(framework))167 .withName(name)168 .withAuthor(author)169 .withDescription(description)170 .usePackage(targetPackage);171 generator.create();172 }173 getLog().info("Successfully created new test case " + targetPackage + "." + name);174 } catch (ArrayIndexOutOfBoundsException e) {175 getLog().info("Wrong parameter usage! See citrus:help for usage details (mvn citrus:help -Ddetail=true -Dgoal=create-test).");176 } catch (PrompterException e) {177 getLog().info(e);178 getLog().info("Failed to create test! See citrus:help for usage details (mvn citrus:help -Ddetail=true -Dgoal=create-test).");179 }180 }181 /**182 * Creates test case with request and response messages from XML schema.183 * @param generator184 * @throws MojoExecutionException185 */186 public void createWithXsd(XsdTestGenerator generator) throws MojoExecutionException {187 try {188 String xsd = null;189 while(!StringUtils.hasText(xsd)) {190 xsd = prompter.prompt("Enter path to XSD");191 }192 generator.withXsd(xsd);193 String xsdRequestMessage = prompter.prompt("Enter request element name");194 generator.withRequestMessage(xsdRequestMessage);195 String xsdResponseMessage = prompter.prompt("Enter response element name", generator.getResponseMessageSuggestion());196 generator.withResponseMessage(xsdResponseMessage);197 String mode = prompter.prompt("Choose mode:", Arrays.stream(TestGenerator.GeneratorMode.values()).map(TestGenerator.GeneratorMode::name).collect(Collectors.toList()), TestGenerator.GeneratorMode.CLIENT.name());198 generator.withMode(TestGenerator.GeneratorMode.valueOf(mode.toUpperCase()));199 String confirm = prompter.prompt("Confirm test creation:\n" +200 "type: " + getType() + "\n" +201 "framework: " + generator.getFramework() + "\n" +202 "name: " + generator.getName() + "\n" +203 "author: " + generator.getAuthor() + "\n" +204 "description: " + generator.getDescription() + "\n" +205 "xsd: " + generator.getXsd() + "\n" +206 "request: " + generator.getRequestMessage() + "\n" +207 "response: " + generator.getResponseMessage() + "\n" +208 "actor: " + generator.getMode() + "\n" +209 "package: " + generator.getTargetPackage() + "\n", CollectionUtils.arrayToList(new String[] {"y", "n"}), "y");210 if (confirm.equalsIgnoreCase("n")) {211 return;212 }213 generator.create();214 getLog().info("Successfully created new test case " + generator.getTargetPackage() + "." + generator.getName());215 } catch (ArrayIndexOutOfBoundsException e) {216 getLog().info("Wrong parameter usage! See citrus:help for usage details (mvn citrus:help -Ddetail=true -Dgoal=create-test).");217 } catch (PrompterException e) {218 getLog().info(e);219 getLog().info("Failed to create test! See citrus:help for usage details (mvn citrus:help -Ddetail=true -Dgoal=create-test).");220 }221 }222 /**223 * Creates test case with request and response messages from WSDL definition.224 * @param generator225 * @throws MojoExecutionException226 */227 public void createWithWsdl(WsdlTestGenerator generator) throws MojoExecutionException {228 try {229 String wsdl = null;230 while (!StringUtils.hasText(wsdl)) {231 wsdl = prompter.prompt("Enter path to WSDL");232 }233 if (!StringUtils.hasText(wsdl)) {234 throw new MojoExecutionException("Please provide proper path to WSDL file");235 }236 generator.withWsdl(wsdl);237 String mode = prompter.prompt("Choose mode:", Arrays.stream(TestGenerator.GeneratorMode.values()).map(TestGenerator.GeneratorMode::name).collect(Collectors.toList()), TestGenerator.GeneratorMode.CLIENT.name());238 generator.withMode(TestGenerator.GeneratorMode.valueOf(mode.toUpperCase()));239 String operation = prompter.prompt("Enter operation name", "all");240 if (!operation.equals("all")) {241 generator.withOperation(operation);...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Citrus automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful