How to use WsdlJavaTestGenerator class of com.consol.citrus.generate.javadsl package

Best Citrus code snippet using com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator

Source:CreateTestMojo.java Github

copy

Full Screen

...23import com.consol.citrus.generate.WsdlTestGenerator;24import com.consol.citrus.generate.XsdTestGenerator;25import com.consol.citrus.generate.javadsl.JavaDslTestGenerator;26import com.consol.citrus.generate.javadsl.SwaggerJavaTestGenerator;27import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;28import com.consol.citrus.generate.javadsl.XsdJavaTestGenerator;29import com.consol.citrus.generate.xml.SwaggerXmlTestGenerator;30import com.consol.citrus.generate.xml.WsdlXmlTestGenerator;31import com.consol.citrus.generate.xml.XmlTestGenerator;32import com.consol.citrus.generate.xml.XsdXmlTestGenerator;33import org.apache.maven.plugin.MojoExecutionException;34import org.apache.maven.plugin.MojoFailureException;35import org.apache.maven.plugins.annotations.Component;36import org.apache.maven.plugins.annotations.Mojo;37import org.apache.maven.plugins.annotations.Parameter;38import org.codehaus.plexus.components.interactivity.Prompter;39import org.codehaus.plexus.components.interactivity.PrompterException;40import org.springframework.util.StringUtils;41/**42 * Creates new Citrus test cases with empty XML test file and executable Java class.43 *44 * Mojo offers an interactive mode, where the plugin prompts for parameters during execution.45 *46 * @author Christoph Deppisch47 * @since 2.7.448 */49@Mojo(name = "create-test")50public class CreateTestMojo extends AbstractCitrusMojo {51 @Parameter(property = "citrus.skip.create.test", defaultValue = "false")52 protected boolean skipCreateTest;53 @Component54 private Prompter prompter;55 private final XmlTestGenerator xmlTestGenerator;56 private final XsdXmlTestGenerator xsdXmlTestGenerator;57 private final WsdlXmlTestGenerator wsdlXmlTestGenerator;58 private final SwaggerXmlTestGenerator swaggerXmlTestGenerator;59 private final JavaDslTestGenerator javaTestGenerator;60 private final XsdJavaTestGenerator xsdJavaTestGenerator;61 private final WsdlJavaTestGenerator wsdlJavaTestGenerator;62 private final SwaggerJavaTestGenerator swaggerJavaTestGenerator;63 /**64 * Default constructor.65 */66 public CreateTestMojo() {67 this(new XmlTestGenerator(),68 new XsdXmlTestGenerator(),69 new WsdlXmlTestGenerator(),70 new SwaggerXmlTestGenerator(),71 new JavaDslTestGenerator(),72 new XsdJavaTestGenerator(),73 new WsdlJavaTestGenerator(),74 new SwaggerJavaTestGenerator());75 }76 /**77 * Constructor using final fields.78 * @param xmlTestGenerator79 * @param xsdXmlTestGenerator80 * @param wsdlXmlTestGenerator81 * @param swaggerXmlTestGenerator82 * @param javaTestGenerator83 * @param xsdJavaTestGenerator84 * @param wsdlJavaTestGenerator85 * @param swaggerJavaTestGenerator86 */87 public CreateTestMojo(XmlTestGenerator xmlTestGenerator,88 XsdXmlTestGenerator xsdXmlTestGenerator,89 WsdlXmlTestGenerator wsdlXmlTestGenerator,90 SwaggerXmlTestGenerator swaggerXmlTestGenerator,91 JavaDslTestGenerator javaTestGenerator,92 XsdJavaTestGenerator xsdJavaTestGenerator,93 WsdlJavaTestGenerator wsdlJavaTestGenerator,94 SwaggerJavaTestGenerator swaggerJavaTestGenerator) {95 this.xmlTestGenerator = xmlTestGenerator;96 this.xsdXmlTestGenerator = xsdXmlTestGenerator;97 this.wsdlXmlTestGenerator = wsdlXmlTestGenerator;98 this.swaggerXmlTestGenerator = swaggerXmlTestGenerator;99 this.javaTestGenerator = javaTestGenerator;100 this.xsdJavaTestGenerator = xsdJavaTestGenerator;101 this.wsdlJavaTestGenerator = wsdlJavaTestGenerator;102 this.swaggerJavaTestGenerator = swaggerJavaTestGenerator;103 }104 @Override105 public void doExecute() throws MojoExecutionException, MojoFailureException {106 if (skipCreateTest) {107 return;108 }109 try {110 String name = null;111 while (!StringUtils.hasText(name)) {112 name = prompter.prompt("Enter test name:");113 }114 if (!StringUtils.hasText(name)) {115 throw new MojoExecutionException("Please provide proper test name! Test name must not be empty starting with uppercase letter!");116 }117 String author = prompter.prompt("Enter test author:", "Unknown");118 String description = prompter.prompt("Enter test description:", "");119 String targetPackage = prompter.prompt("Enter test package:", "com.consol.citrus");120 String framework = prompter.prompt("Choose unit test framework:", Arrays.asList("testng", "junit4", "junit5"), UnitFramework.TESTNG.name().toLowerCase());121 String type = prompter.prompt("Choose target code base type:", Arrays.asList("java", "xml"), "java");122 setType(type);123 String useXsd = prompter.prompt("Create test with XML schema?", Arrays.asList("y", "n"), "n");124 if (useXsd.equalsIgnoreCase("y")) {125 XsdTestGenerator generator = getXsdTestGenerator();126 generator.withFramework(UnitFramework.fromString(framework))127 .withName(name)128 .withAuthor(author)129 .withDescription(description)130 .usePackage(targetPackage);131 createWithXsd(generator);132 return;133 }134 String useWsdl = prompter.prompt("Create test with WSDL?", Arrays.asList("y", "n"), "n");135 if (useWsdl.equalsIgnoreCase("y")) {136 WsdlTestGenerator generator = getWsdlTestGenerator();137 generator.withFramework(UnitFramework.fromString(framework))138 .withName(name)139 .withAuthor(author)140 .withDescription(description)141 .usePackage(targetPackage);142 createWithWsdl(generator);143 return;144 }145 String useSwagger = prompter.prompt("Create test with Swagger API?", Arrays.asList("y", "n"), "n");146 if (useSwagger.equalsIgnoreCase("y")) {147 SwaggerTestGenerator generator = getSwaggerTestGenerator();148 generator.withFramework(UnitFramework.fromString(framework))149 .withName(name)150 .withAuthor(author)151 .withDescription(description)152 .usePackage(targetPackage);153 createWithSwagger(generator);154 return;155 }156 String confirm = prompter.prompt("Confirm test creation:\n" +157 "type: " + getType() + "\n" +158 "framework: " + framework + "\n" +159 "name: " + name + "\n" +160 "author: " + author + "\n" +161 "description: " + description + "\n" +162 "package: " + targetPackage + "\n", Arrays.asList("y", "n"), "y");163 if (confirm.equalsIgnoreCase("n")) {164 return;165 }166 if (getType().equals("java")) {167 JavaDslTestGenerator generator = (JavaDslTestGenerator) getJavaTestGenerator()168 .withFramework(UnitFramework.fromString(framework))169 .withName(name)170 .withAuthor(author)171 .withDescription(description)172 .usePackage(targetPackage);173 generator.create();174 } else {175 XmlTestGenerator generator = (XmlTestGenerator) getXmlTestGenerator()176 .withFramework(UnitFramework.fromString(framework))177 .withName(name)178 .withAuthor(author)179 .withDescription(description)180 .usePackage(targetPackage);181 generator.create();182 }183 getLog().info("Successfully created new test case " + targetPackage + "." + name);184 } catch (ArrayIndexOutOfBoundsException e) {185 getLog().info("Wrong parameter usage! See citrus:help for usage details (mvn citrus:help -Ddetail=true -Dgoal=create-test).");186 } catch (PrompterException e) {187 getLog().info(e);188 getLog().info("Failed to create test! See citrus:help for usage details (mvn citrus:help -Ddetail=true -Dgoal=create-test).");189 }190 }191 /**192 * Creates test case with request and response messages from XML schema.193 * @param generator194 * @throws MojoExecutionException195 */196 public void createWithXsd(XsdTestGenerator generator) throws MojoExecutionException {197 try {198 String xsd = null;199 while(!StringUtils.hasText(xsd)) {200 xsd = prompter.prompt("Enter path to XSD");201 }202 generator.withXsd(xsd);203 String xsdRequestMessage = prompter.prompt("Enter request element name");204 generator.withRequestMessage(xsdRequestMessage);205 String xsdResponseMessage = prompter.prompt("Enter response element name", generator.getResponseMessageSuggestion());206 generator.withResponseMessage(xsdResponseMessage);207 String mode = prompter.prompt("Choose mode:", Arrays.stream(TestGenerator.GeneratorMode.values()).map(TestGenerator.GeneratorMode::name).collect(Collectors.toList()), TestGenerator.GeneratorMode.CLIENT.name());208 generator.withMode(TestGenerator.GeneratorMode.valueOf(mode.toUpperCase()));209 String confirm = prompter.prompt("Confirm test creation:\n" +210 "type: " + getType() + "\n" +211 "framework: " + generator.getFramework() + "\n" +212 "name: " + generator.getName() + "\n" +213 "author: " + generator.getAuthor() + "\n" +214 "description: " + generator.getDescription() + "\n" +215 "xsd: " + generator.getXsd() + "\n" +216 "request: " + generator.getRequestMessage() + "\n" +217 "response: " + generator.getResponseMessage() + "\n" +218 "actor: " + generator.getMode() + "\n" +219 "package: " + generator.getTargetPackage() + "\n", Arrays.asList("y", "n"), "y");220 if (confirm.equalsIgnoreCase("n")) {221 return;222 }223 generator.create();224 getLog().info("Successfully created new test case " + generator.getTargetPackage() + "." + generator.getName());225 } catch (ArrayIndexOutOfBoundsException e) {226 getLog().info("Wrong parameter usage! See citrus:help for usage details (mvn citrus:help -Ddetail=true -Dgoal=create-test).");227 } catch (PrompterException e) {228 getLog().info(e);229 getLog().info("Failed to create test! See citrus:help for usage details (mvn citrus:help -Ddetail=true -Dgoal=create-test).");230 }231 }232 /**233 * Creates test case with request and response messages from WSDL definition.234 * @param generator235 * @throws MojoExecutionException236 */237 public void createWithWsdl(WsdlTestGenerator generator) throws MojoExecutionException {238 try {239 String wsdl = null;240 while (!StringUtils.hasText(wsdl)) {241 wsdl = prompter.prompt("Enter path to WSDL");242 }243 if (!StringUtils.hasText(wsdl)) {244 throw new MojoExecutionException("Please provide proper path to WSDL file");245 }246 generator.withWsdl(wsdl);247 String mode = prompter.prompt("Choose mode:", Arrays.stream(TestGenerator.GeneratorMode.values()).map(TestGenerator.GeneratorMode::name).collect(Collectors.toList()), TestGenerator.GeneratorMode.CLIENT.name());248 generator.withMode(TestGenerator.GeneratorMode.valueOf(mode.toUpperCase()));249 String operation = prompter.prompt("Enter operation name", "all");250 if (!operation.equals("all")) {251 generator.withOperation(operation);252 }253 String namePrefix = prompter.prompt("Enter test name prefix", generator.getName() + "_");254 generator.withNamePrefix(namePrefix);255 String nameSuffix = prompter.prompt("Enter test name suffix", generator.getNameSuffix());256 generator.withNameSuffix(nameSuffix);257 String confirm = prompter.prompt("Confirm test creation:\n" +258 "type: " + getType() + "\n" +259 "framework: " + generator.getFramework() + "\n" +260 "name: " + generator.getName() + "\n" +261 "author: " + generator.getAuthor() + "\n" +262 "description: " + generator.getDescription() + "\n" +263 "wsdl: " + generator.getWsdl() + "\n" +264 "operation: " + Optional.ofNullable(generator.getOperation()).orElse("all") + "\n" +265 "actor: " + generator.getMode() + "\n" +266 "package: " + generator.getTargetPackage() + "\n", Arrays.asList("y", "n"), "y");267 if (confirm.equalsIgnoreCase("n")) {268 return;269 }270 generator.create();271 getLog().info("Successfully created new test cases from WSDL");272 } catch (ArrayIndexOutOfBoundsException e) {273 getLog().info(e);274 getLog().info("Wrong parameter usage! See citrus:help for usage details (mvn citrus:help -Ddetail=true -Dgoal=create-test).");275 } catch (PrompterException e) {276 getLog().info(e);277 getLog().info("Failed to create suite! See citrus:help for usage details (mvn citrus:help -Ddetail=true -Dgoal=create-test).");278 }279 }280 /**281 * Creates test case with request and response messages from Swagger API.282 * @param generator283 * @throws MojoExecutionException284 */285 public void createWithSwagger(SwaggerTestGenerator generator) throws MojoExecutionException {286 try {287 String swagger = null;288 while (!StringUtils.hasText(swagger)) {289 swagger = prompter.prompt("Enter path to Swagger API");290 }291 if (!StringUtils.hasText(swagger)) {292 throw new MojoExecutionException("Please provide proper path to Swagger API file");293 }294 generator.withSpec(swagger);295 String mode = prompter.prompt("Choose mode:", Arrays.stream(TestGenerator.GeneratorMode.values()).map(TestGenerator.GeneratorMode::name).collect(Collectors.toList()), TestGenerator.GeneratorMode.CLIENT.name());296 generator.withMode(TestGenerator.GeneratorMode.valueOf(mode.toUpperCase()));297 String operation = prompter.prompt("Enter operation name", "all");298 if (!operation.equals("all")) {299 generator.withOperation(operation);300 }301 String namePrefix = prompter.prompt("Enter test name prefix", generator.getName() + "_");302 generator.withNamePrefix(namePrefix);303 String nameSuffix = prompter.prompt("Enter test name suffix", generator.getNameSuffix());304 generator.withNameSuffix(nameSuffix);305 String confirm = prompter.prompt("Confirm test creation:\n" +306 "type: " + getType() + "\n" +307 "framework: " + generator.getFramework() + "\n" +308 "name: " + generator.getName() + "\n" +309 "author: " + generator.getAuthor() + "\n" +310 "description: " + generator.getDescription() + "\n" +311 "swagger-api: " + generator.getSwaggerResource() + "\n" +312 "operation: " + Optional.ofNullable(generator.getOperation()).orElse("all") + "\n" +313 "actor: " + generator.getMode() + "\n" +314 "package: " + generator.getTargetPackage() + "\n", Arrays.asList("y", "n"), "y");315 if (confirm.equalsIgnoreCase("n")) {316 return;317 }318 generator.create();319 getLog().info("Successfully created new test cases from Swagger API");320 } catch (ArrayIndexOutOfBoundsException e) {321 getLog().info(e);322 getLog().info("Wrong parameter usage! See citrus:help for usage details (mvn citrus:help -Ddetail=true -Dgoal=create-test).");323 } catch (PrompterException e) {324 getLog().info(e);325 getLog().info("Failed to create suite! See citrus:help for usage details (mvn citrus:help -Ddetail=true -Dgoal=create-test).");326 }327 }328 /**329 * Method provides test generator instance. Basically introduced for better mocking capabilities in unit tests but330 * also useful for subclasses to provide customized generator instance.331 * .332 * @return test generator.333 */334 public XmlTestGenerator getXmlTestGenerator() {335 return Optional.ofNullable(xmlTestGenerator).orElse(new XmlTestGenerator());336 }337 /**338 * Method provides test generator instance. Basically introduced for better mocking capabilities in unit tests but339 * also useful for subclasses to provide customized generator instance.340 * .341 * @return test generator.342 */343 public JavaDslTestGenerator getJavaTestGenerator() {344 return Optional.ofNullable(javaTestGenerator).orElse(new JavaDslTestGenerator());345 }346 /**347 * Method provides test generator instance. Basically introduced for better mocking capabilities in unit tests but348 * also useful for subclasses to provide customized generator instance.349 * .350 * @return test generator.351 */352 public SwaggerTestGenerator getSwaggerTestGenerator() {353 if (getType().equals("java")) {354 return Optional.ofNullable(swaggerJavaTestGenerator).orElse(new SwaggerJavaTestGenerator());355 } else {356 return Optional.ofNullable(swaggerXmlTestGenerator).orElse(new SwaggerXmlTestGenerator());357 }358 }359 /**360 * Method provides test generator instance. Basically introduced for better mocking capabilities in unit tests but361 * also useful for subclasses to provide customized generator instance.362 * .363 * @return test generator.364 */365 public WsdlTestGenerator getWsdlTestGenerator() {366 if (getType().equals("java")) {367 return Optional.ofNullable(wsdlJavaTestGenerator).orElse(new WsdlJavaTestGenerator());368 } else {369 return Optional.ofNullable(wsdlXmlTestGenerator).orElse(new WsdlXmlTestGenerator());370 }371 }372 /**373 * Method provides test generator instance. Basically introduced for better mocking capabilities in unit tests but374 * also useful for subclasses to provide customized generator instance.375 * .376 * @return test generator.377 */378 public XsdTestGenerator getXsdTestGenerator() {379 if (getType().equals("java")) {380 return Optional.ofNullable(xsdJavaTestGenerator).orElse(new XsdJavaTestGenerator());381 } else {...

Full Screen

Full Screen

Source:GenerateTestMojo.java Github

copy

Full Screen

...20import com.consol.citrus.generate.WsdlTestGenerator;21import com.consol.citrus.generate.XsdTestGenerator;22import com.consol.citrus.generate.javadsl.JavaDslTestGenerator;23import com.consol.citrus.generate.javadsl.SwaggerJavaTestGenerator;24import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;25import com.consol.citrus.generate.javadsl.XsdJavaTestGenerator;26import com.consol.citrus.generate.provider.http.HttpCodeProvider;27import com.consol.citrus.generate.xml.SwaggerXmlTestGenerator;28import com.consol.citrus.generate.xml.WsdlXmlTestGenerator;29import com.consol.citrus.generate.xml.XmlTestGenerator;30import com.consol.citrus.generate.xml.XsdXmlTestGenerator;31import org.apache.maven.plugin.MojoExecutionException;32import org.apache.maven.plugin.MojoFailureException;33import org.apache.maven.plugins.annotations.LifecyclePhase;34import org.apache.maven.plugins.annotations.Mojo;35import org.apache.maven.plugins.annotations.Parameter;36import org.springframework.util.StringUtils;37import java.util.Optional;38/**39 * @author Christoph Deppisch40 * @since 2.7.441 */42@Mojo( name = "generate-tests", defaultPhase = LifecyclePhase.GENERATE_TEST_SOURCES)43public class GenerateTestMojo extends AbstractCitrusMojo {44 @Parameter(property = "citrus.skip.generate.test", defaultValue = "false")45 protected boolean skipGenerateTest;46 @Parameter(property = "citrus.build.directory", defaultValue= "${project.build.directory}/generated/citrus")47 protected String buildDirectory = "target/generated/citrus";48 @Parameter(property = "citrus.build.coverage", defaultValue = "false")49 protected boolean isCoverage;50 private final XmlTestGenerator xmlTestGenerator;51 private final XsdXmlTestGenerator xsdXmlTestGenerator;52 private final WsdlXmlTestGenerator wsdlXmlTestGenerator;53 private final SwaggerXmlTestGenerator swaggerXmlTestGenerator;54 private final JavaDslTestGenerator javaTestGenerator;55 private final XsdJavaTestGenerator xsdJavaTestGenerator;56 private final WsdlJavaTestGenerator wsdlJavaTestGenerator;57 private final SwaggerJavaTestGenerator swaggerJavaTestGenerator;58 /**59 * Default constructor.60 */61 public GenerateTestMojo() {62 this(new XmlTestGenerator(),63 new XsdXmlTestGenerator(),64 new WsdlXmlTestGenerator(),65 new SwaggerXmlTestGenerator(),66 new JavaDslTestGenerator(),67 new XsdJavaTestGenerator(),68 new WsdlJavaTestGenerator(),69 new SwaggerJavaTestGenerator());70 }71 /**72 * Constructor using final fields.73 * @param xmlTestGenerator74 * @param xsdXmlTestGenerator75 * @param wsdlXmlTestGenerator76 * @param swaggerXmlTestGenerator77 * @param javaTestGenerator78 * @param xsdJavaTestGenerator79 * @param wsdlJavaTestGenerator80 * @param swaggerJavaTestGenerator81 */82 public GenerateTestMojo(XmlTestGenerator xmlTestGenerator,83 XsdXmlTestGenerator xsdXmlTestGenerator,84 WsdlXmlTestGenerator wsdlXmlTestGenerator,85 SwaggerXmlTestGenerator swaggerXmlTestGenerator,86 JavaDslTestGenerator javaTestGenerator,87 XsdJavaTestGenerator xsdJavaTestGenerator,88 WsdlJavaTestGenerator wsdlJavaTestGenerator,89 SwaggerJavaTestGenerator swaggerJavaTestGenerator) {90 this.xmlTestGenerator = xmlTestGenerator;91 this.xsdXmlTestGenerator = xsdXmlTestGenerator;92 this.wsdlXmlTestGenerator = wsdlXmlTestGenerator;93 this.swaggerXmlTestGenerator = swaggerXmlTestGenerator;94 this.javaTestGenerator = javaTestGenerator;95 this.xsdJavaTestGenerator = xsdJavaTestGenerator;96 this.wsdlJavaTestGenerator = wsdlJavaTestGenerator;97 this.swaggerJavaTestGenerator = swaggerJavaTestGenerator;98 }99 @Override100 public void doExecute() throws MojoExecutionException, MojoFailureException {101 if (skipGenerateTest) {102 return;103 }104 HttpCodeProvider.setCoverage(isCoverage);105 for (TestConfiguration test : getTests()) {106 if (test.getXsd() != null) {107 XsdTestGenerator generator = getXsdTestGenerator();108 generator.withFramework(getFramework())109 .withName(test.getName())110 .withAuthor(test.getAuthor())111 .withDescription(test.getDescription())112 .usePackage(test.getPackageName())113 .useSrcDirectory(buildDirectory);114 generator.withDisabled(test.isDisabled());115 generator.withMode(TestGenerator.GeneratorMode.valueOf(test.getXsd().getMode()));116 generator.withXsd(test.getXsd().getFile());117 generator.withRequestMessage(test.getXsd().getRequest());118 generator.withResponseMessage(test.getXsd().getResponse());119 if (test.getXsd().getMappings() != null) {120 generator.withInboundMappings(test.getXsd().getMappings().getInbound());121 generator.withOutboundMappings(test.getXsd().getMappings().getOutbound());122 generator.withInboundMappingFile(test.getXsd().getMappings().getInboundFile());123 generator.withOutboundMappingFile(test.getXsd().getMappings().getOutboundFile());124 }125 126 generator.withEndpoint(test.getEndpoint());127 generator.withNameSuffix(test.getSuffix());128 generator.create();129 } else if (test.getWsdl() != null) {130 WsdlTestGenerator generator = getWsdlTestGenerator();131 generator.withFramework(getFramework())132 .withName(test.getName())133 .withAuthor(test.getAuthor())134 .withDescription(test.getDescription())135 .usePackage(test.getPackageName())136 .useSrcDirectory(buildDirectory);137 generator.withDisabled(test.isDisabled());138 generator.withMode(TestGenerator.GeneratorMode.valueOf(test.getWsdl().getMode()));139 generator.withWsdl(test.getWsdl().getFile());140 generator.withOperation(test.getWsdl().getOperation());141 if (test.getWsdl().getMappings() != null) {142 generator.withInboundMappings(test.getWsdl().getMappings().getInbound());143 generator.withOutboundMappings(test.getWsdl().getMappings().getOutbound());144 generator.withInboundMappingFile(test.getWsdl().getMappings().getInboundFile());145 generator.withOutboundMappingFile(test.getWsdl().getMappings().getOutboundFile());146 }147 generator.withEndpoint(test.getEndpoint());148 generator.withNameSuffix(test.getSuffix());149 generator.create();150 } else if (test.getSwagger() != null) {151 SwaggerTestGenerator generator = getSwaggerTestGenerator();152 generator.withFramework(getFramework())153 .withName(test.getName())154 .withAuthor(test.getAuthor())155 .withDescription(test.getDescription())156 .usePackage(test.getPackageName())157 .useSrcDirectory(buildDirectory);158 generator.withDisabled(test.isDisabled());159 generator.withMode(TestGenerator.GeneratorMode.valueOf(test.getSwagger().getMode()));160 generator.withSpec(test.getSwagger().getFile());161 generator.withOperation(test.getSwagger().getOperation());162 if (test.getSwagger().getMappings() != null) {163 generator.withInboundMappings(test.getSwagger().getMappings().getInbound());164 generator.withOutboundMappings(test.getSwagger().getMappings().getOutbound());165 generator.withInboundMappingFile(test.getSwagger().getMappings().getInboundFile());166 generator.withOutboundMappingFile(test.getSwagger().getMappings().getOutboundFile());167 }168 generator.withEndpoint(test.getEndpoint());169 generator.withNameSuffix(test.getSuffix());170 generator.create();171 } else {172 if (!StringUtils.hasText(test.getName())) {173 throw new MojoExecutionException("Please provide proper test name! Test name must not be empty starting with uppercase letter!");174 }175 if (getType().equals("java")) {176 JavaDslTestGenerator generator = (JavaDslTestGenerator) getJavaTestGenerator()177 .withDisabled(test.isDisabled())178 .withFramework(getFramework())179 .withName(test.getName())180 .withAuthor(test.getAuthor())181 .withDescription(test.getDescription())182 .usePackage(test.getPackageName())183 .useSrcDirectory(buildDirectory);184 generator.create();185 } else {186 XmlTestGenerator generator = (XmlTestGenerator) getXmlTestGenerator()187 .withDisabled(test.isDisabled())188 .withFramework(getFramework())189 .withName(test.getName())190 .withAuthor(test.getAuthor())191 .withDescription(test.getDescription())192 .usePackage(test.getPackageName())193 .useSrcDirectory(buildDirectory);194 generator.create();195 }196 getLog().info("Successfully created new test case " + test.getPackageName() + "." + test.getName());197 }198 }199 }200 /**201 * Method provides test generator instance. Basically introduced for better mocking capabilities in unit tests but202 * also useful for subclasses to provide customized generator instance.203 * .204 * @return test generator.205 */206 public XmlTestGenerator getXmlTestGenerator() {207 return Optional.ofNullable(xmlTestGenerator).orElse(new XmlTestGenerator());208 }209 /**210 * Method provides test generator instance. Basically introduced for better mocking capabilities in unit tests but211 * also useful for subclasses to provide customized generator instance.212 * .213 * @return test generator.214 */215 public JavaDslTestGenerator getJavaTestGenerator() {216 return Optional.ofNullable(javaTestGenerator).orElse(new JavaDslTestGenerator());217 }218 /**219 * Method provides test generator instance. Basically introduced for better mocking capabilities in unit tests but220 * also useful for subclasses to provide customized generator instance.221 * .222 * @return test generator.223 */224 public SwaggerTestGenerator225 getSwaggerTestGenerator() {226 if (getType().equals("java")) {227 return Optional.ofNullable(swaggerJavaTestGenerator).orElse(new SwaggerJavaTestGenerator());228 } else {229 return Optional.ofNullable(swaggerXmlTestGenerator).orElse(new SwaggerXmlTestGenerator());230 }231 }232 /**233 * Method provides test generator instance. Basically introduced for better mocking capabilities in unit tests but234 * also useful for subclasses to provide customized generator instance.235 * .236 * @return test generator.237 */238 public WsdlTestGenerator getWsdlTestGenerator() {239 if (getType().equals("java")) {240 return Optional.ofNullable(wsdlJavaTestGenerator).orElse(new WsdlJavaTestGenerator());241 } else {242 return Optional.ofNullable(wsdlXmlTestGenerator).orElse(new WsdlXmlTestGenerator());243 }244 }245 /**246 * Method provides test generator instance. Basically introduced for better mocking capabilities in unit tests but247 * also useful for subclasses to provide customized generator instance.248 * .249 * @return test generator.250 */251 public XsdTestGenerator getXsdTestGenerator() {252 if (getType().equals("java")) {253 return Optional.ofNullable(xsdJavaTestGenerator).orElse(new XsdJavaTestGenerator());254 } else {...

Full Screen

Full Screen

Source:GenerateTestMojoTest.java Github

copy

Full Screen

...21import com.consol.citrus.config.tests.XsdConfiguration;22import com.consol.citrus.generate.UnitFramework;23import com.consol.citrus.generate.javadsl.JavaDslTestGenerator;24import com.consol.citrus.generate.javadsl.SwaggerJavaTestGenerator;25import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;26import com.consol.citrus.generate.javadsl.XsdJavaTestGenerator;27import com.consol.citrus.generate.xml.SwaggerXmlTestGenerator;28import com.consol.citrus.generate.xml.WsdlXmlTestGenerator;29import com.consol.citrus.generate.xml.XmlTestGenerator;30import com.consol.citrus.generate.xml.XsdXmlTestGenerator;31import org.apache.maven.plugin.MojoExecutionException;32import org.apache.maven.plugin.MojoFailureException;33import org.codehaus.plexus.components.interactivity.PrompterException;34import org.mockito.Mockito;35import org.testng.annotations.BeforeMethod;36import org.testng.annotations.Test;37import java.util.Collections;38import static org.mockito.Mockito.*;39/**40 * @author Christoph Deppisch41 */42public class GenerateTestMojoTest {43 private XmlTestGenerator xmlTestGenerator = Mockito.mock(XmlTestGenerator.class);44 private XsdXmlTestGenerator xsdXmlTestGenerator = Mockito.mock(XsdXmlTestGenerator.class);45 private WsdlXmlTestGenerator wsdlXmlTestGenerator = Mockito.mock(WsdlXmlTestGenerator.class);46 private SwaggerXmlTestGenerator swaggerXmlTestGenerator = Mockito.mock(SwaggerXmlTestGenerator.class);47 private JavaDslTestGenerator javaTestGenerator = Mockito.mock(JavaDslTestGenerator.class);48 private XsdJavaTestGenerator xsdJavaTestGenerator = Mockito.mock(XsdJavaTestGenerator.class);49 private WsdlJavaTestGenerator wsdlJavaTestGenerator = Mockito.mock(WsdlJavaTestGenerator.class);50 private SwaggerJavaTestGenerator swaggerJavaTestGenerator = Mockito.mock(SwaggerJavaTestGenerator.class);51 private GenerateTestMojo mojo;52 53 @BeforeMethod54 public void setup() {55 mojo = new GenerateTestMojo(xmlTestGenerator,56 xsdXmlTestGenerator,57 wsdlXmlTestGenerator,58 swaggerXmlTestGenerator,59 javaTestGenerator,60 xsdJavaTestGenerator,61 wsdlJavaTestGenerator,62 swaggerJavaTestGenerator);63 mojo.setType("xml");...

Full Screen

Full Screen

WsdlJavaTestGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;2public class 4 {3 public static void main(String[] args) {4 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator();5 generator.setJavaPackage("com.consol.citrus.samples");6 generator.setJavaName("StockQuoteTest");7 generator.generate();8 }9}10import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;11public class 5 {12 public static void main(String[] args) {13 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator();14 generator.setJavaPackage("com.consol.citrus.samples");15 generator.setJavaName("StockQuoteTest");16 generator.setJavaTargetSourceDirectory("src/test/java");17 generator.generate();18 }19}20import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;21public class 6 {22 public static void main(String[] args) {23 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator();24 generator.setJavaPackage("com.consol.citrus.samples");25 generator.setJavaName("StockQuoteTest");26 generator.setJavaTargetSourceDirectory("src/test/java");27 generator.setJavaTargetResourceDirectory("src/test/resources");28 generator.generate();29 }30}31import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;32public class 7 {33 public static void main(String[] args) {34 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator();35 generator.setWsdl("http

Full Screen

Full Screen

WsdlJavaTestGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;2public class 4 {3 public static void main(String[] args) {4 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator();5 generator.setPackageName("com.consol.citrus.samples");6 generator.setJavaDsl(true);7 generator.setJavaProjectPath("C:\\Users\\hp\\Desktop\\citrus-wsdl-test");8 generator.setTestSourcePath("src\\test\\java");9 generator.setTargetPath("src\\test\\resources");10 generator.setJavaDsl(true);11 generator.generate();12 }13}14import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;15public class 5 {16 public static void main(String[] args) {17 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator();18 generator.setPackageName("com.consol.citrus.samples");19 generator.setJavaDsl(true);20 generator.setJavaProjectPath("C:\\Users\\hp\\Desktop\\citrus-wsdl-test");21 generator.setTestSourcePath("src\\test\\java");22 generator.setTargetPath("src\\test\\resources");23 generator.setJavaDsl(true);24 generator.setTestName("MyTest");25 generator.generate();26 }27}28import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;29public class 6 {30 public static void main(String[] args) {31 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator();32 generator.setPackageName("com.consol.citrus.samples");33 generator.setJavaDsl(true);34 generator.setJavaProjectPath("C:\\Users\\hp

Full Screen

Full Screen

WsdlJavaTestGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;2import com.consol.citrus.ws.client.WebServiceClient;3import com.consol.citrus.ws.server.WebServiceServer;4import org.springframework.context.annotation.Bean;5import org.springframework.context.annotation.Configuration;6import org.springframework.context.annotation.Import;7import org.springframework.ws.soap.SoapVersion;8import org.springframework.ws.soap.saaj.SaajSoapMessageFactory;9import org.springframework.ws.soap.server.SoapMessageDispatcher;10import org.springframework.ws.transport.http.HttpComponentsMessageSender;11import org.springframework.ws.transport.http.HttpTransportConstants;12import org.springframework.ws.transport.http.MessageDispatcherServlet;13import org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter;14import org.springframework.ws.transport.http.support.WebServiceMessageReceiverHandlerMapping;15import org.springframework.ws.transport.http.support.WebServiceMessageSenderHandlerMapping;16import org.springframework.ws.transport.http.support.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerAdapter;17import org.springframework.ws.transport.http.support.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerAdapter.WebServiceMessageSenderHandlerMapping;18import org.springframework.ws.transport.http.support.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerAdapter.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerAdapter;19import org.springframework.ws.transport.http.support.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerAdapter.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerAdapter;20import org.springframework.ws.transport.http.support.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerAdapter.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerAdapter;21import org.springframework.ws.transport.http.support.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerAdapter.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerAdapter;22import org.springframework.ws.transport.http.support.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerAdapter.WebServiceMessageSenderHandlerMapping.WebServiceMessageSenderHandlerMapping.WebSer

Full Screen

Full Screen

WsdlJavaTestGenerator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.generate.javadsl;2import com.consol.citrus.generate.WsdlJavaTestGenerator;3public class 4 {4 public static void main(String[] args) {5 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator();6 generator.setPackageName("com.consol.citrus.generate.javadsl");7 generator.setJavaProjectPath("C:\\Users\\sagar\\Desktop\\Citrus\\4");8 generator.setJavaTestClass("MyTest");9 generator.setJavaTestTargetPath("C:\\Users\\sagar\\Desktop\\Citrus\\4\\src\\test\\java\\com\\consol\\citrus\\generate\\javadsl");10 generator.setJavaTestTargetPackage("com.consol.citrus.generate.javadsl");11 generator.create();12 }13}14package com.consol.citrus.generate.javadsl;15import com.consol.citrus.generate.WsdlJavaTestGenerator;16public class 5 {17 public static void main(String[] args) {18 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator();19 generator.setPackageName("com.consol.citrus.generate.javadsl");20 generator.setJavaProjectPath("C:\\Users\\sagar\\Desktop\\Citrus\\5");21 generator.setJavaTestClass("MyTest");22 generator.setJavaTestTargetPath("C:\\Users\\sagar\\Desktop\\Citrus\\5\\src\\test\\java\\com\\consol\\citrus\\generate\\javadsl");23 generator.setJavaTestTargetPackage("com.consol.citrus.generate.javadsl");24 generator.create();25 }26}27package com.consol.citrus.generate.javadsl;28import com.consol.citrus.generate.WsdlJavaTestGenerator;29public class 6 {30 public static void main(String[] args) {

Full Screen

Full Screen

WsdlJavaTestGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;2import java.io.IOException;3import java.util.HashMap;4import java.util.Map;5public class 4 {6public static void main(String[] args) throws IOException {7Map<String, String> namespaceMap = new HashMap<String, String>();

Full Screen

Full Screen

WsdlJavaTestGenerator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.generate.javadsl;2import java.io.File;3public class WsdlJavaTestGeneratorTest {4 public static void main(String[] args) {5 WsdlJavaTestGenerator javaTestGenerator = new WsdlJavaTestGenerator();6 javaTestGenerator.setOutputDirectory(new File("src/test/java"));7 javaTestGenerator.setPackageName("com.consol.citrus.generate.javadsl");8 javaTestGenerator.setTestName("ConvertSpeedTest");9 javaTestGenerator.setEndpointName("convertSpeedEndpoint");10 javaTestGenerator.setEndpointTimeout(5000L);11 javaTestGenerator.setEndpointRequestTimeout(5000L);12 javaTestGenerator.setEndpointPollingInterval(500L);13 javaTestGenerator.setEndpointIgnoreErrors(true);14 javaTestGenerator.setEndpointIgnoreException(false);15 javaTestGenerator.setEndpointOperationTimeout(5000L);16 javaTestGenerator.setEndpointOperationPollingInterval(500L);17 javaTestGenerator.setEndpointOperationRetryInterval(500L);18 javaTestGenerator.setEndpointOperationRetryCount(3);19 javaTestGenerator.setEndpointOperationIgnoreErrors(true);20 javaTestGenerator.setEndpointOperationIgnoreException(false);21 javaTestGenerator.setEndpointOperationSelector("ConvertSpeed");22 javaTestGenerator.setEndpointOperationSelectorName("operationName");23 javaTestGenerator.setEndpointOperationSelectorNamespacePrefix("ns1");24 javaTestGenerator.setEndpointOperationSelectorXpath("/Envelope/Body/ConvertSpeed");25 javaTestGenerator.setEndpointOperationSelectorXpathValidation(true);26 javaTestGenerator.setEndpointOperationSelectorJsonPath("$.ConvertSpeed");27 javaTestGenerator.setEndpointOperationSelectorJsonPathValidation(true);28 javaTestGenerator.setEndpointOperationSelectorJsonPathValidationReportOnFail(true);

Full Screen

Full Screen

WsdlJavaTestGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;2import java.io.File;3public class 4 {4 public static void main(String[] args) {5 WsdlJavaTestGenerator.generate(new File("src/main/resources/wsdl/HelloService.wsdl"));6 }7}8package com.consol.citrus.generate.javadsl;9import com.consol.citrus.annotations.CitrusTest;10import com.consol.citrus.dsl.testng.TestNGCitrusTestRunner;11import org.springframework.core.io.ClassPathResource;12import org.testng.annotations.Test;13public class HelloServiceJavaTest extends TestNGCitrusTestRunner {14 public void helloServiceJavaTest() {15 variable("operation", "hello");16 variable("soapAction", "hello");17 variable("messageId", "messageId");18 "<MessageId>${messageId}</MessageId>" +19 "</soapenv:Envelope>");20 http()21 .client("helloClient")22 .send()23 .post()24 .soap()25 .messageType("text/xml")26 .contentType("text/xml")27 .payload(new ClassPathResource("templates/soap-request-template.xml"));28 http()29 .client("helloClient")30 .receive()31 .response(HttpStatus.OK)32 .payload(new ClassPathResource("templates/soap-response-template.xml"));33 }34}

Full Screen

Full Screen

WsdlJavaTestGenerator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.generate.javadsl;2import java.io.File;3import org.testng.annotations.Test;4public class WsdlJavaTestGeneratorTest {5public void test() throws Exception {6WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator();7generator.setPackageName("com.consol.citrus.generate.javadsl");8generator.setJavaProjectPath("C:/Users/HP/workspace/axis2");9generator.setJavaTargetPath("src/main/java");10generator.setTestTargetPath("src/test/java");11generator.setTestPackageName("com.consol.citrus.generate.javadsl.test");12generator.setTestJavaProjectPath("C:/Users/HP/workspace/axis2");13generator.setJavaTargetPath("src/main/java");14generator.setTestTargetPath("src/test/java");15generator.setTestPackageName("com.consol.citrus.generate.javadsl.test");16generator.setTestJavaProjectPath("C:/Users/HP/workspace/axis2");17generator.setJavaTargetPath("src/main/java");18generator.setTestTargetPath("src/test/java");19generator.setTestPackageName("com.consol.citrus.generate.javadsl.test");20generator.setTestJavaProjectPath("C:/Users/HP/workspace/axis2");21generator.setJavaTargetPath("src/main/java");22generator.setTestTargetPath("src/test/java");23generator.setTestPackageName("com.consol.citrus.generate.javadsl.test");24generator.setTestJavaProjectPath("C:/Users/HP/workspace/axis2");25generator.setJavaTargetPath("src/main/java");26generator.setTestTargetPath("src/test/java");27generator.setTestPackageName("com.consol.citrus.generate.javadsl.test");28generator.setTestJavaProjectPath("C:/Users/HP/workspace/axis2");29generator.setJavaTargetPath("src/main/java");30generator.setTestTargetPath("src/test/java");31generator.setTestPackageName("com.consol.citrus.generate.javadsl.test");32generator.setTestJavaProjectPath("C:/Users/HP/workspace/axis2");33generator.setJavaTargetPath("src/main/java");34generator.setTestTargetPath("src/test/java");35generator.setTestPackageName("com.consol.citrus.generate.javadsl.test");36generator.setTestJavaProjectPath("C:/Users/HP/workspace/axis2");

Full Screen

Full Screen

WsdlJavaTestGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;2import org.springframework.core.io.ClassPathResource;3import org.springframework.core.io.Resource;4public class 4 {5 public static void main(String[] args) {6 Resource wsdl = new ClassPathResource("wsdl/4.wsdl");7 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator(wsdl);8 generator.setJavaPackage("com.consol.citrus.samples");9 generator.setJavaName("4");10 generator.generate();11 }12}13import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;14import org.springframework.core.io.ClassPathResource;15import org.springframework.core.io.Resource;16public class 5 {17 public static void main(String[] args) {18 Resource wsdl = new ClassPathResource("wsdl/5.wsdl");19 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator(wsdl);20 generator.setJavaPackage("com.consol.citrus.samples");21 generator.setJavaName("5");22 generator.generate();23 }24}25import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;26import org.springframework.core.io.ClassPathResource;27import org.springframework.core.io.Resource;28public class 6 {29 public static void main(String[] args) {30 Resource wsdl = new ClassPathResource("wsdl/6.wsdl");31 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator(wsdl);32 generator.setJavaPackage("com.consol.citrus.samples");33 generator.setJavaName("6");34 generator.generate();35 }36}

Full Screen

Full Screen

WsdlJavaTestGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.generate.javadsl.WsdlJavaTestGenerator;2import java.io.File;3import java.io.IOException;4public class 4 {5 public static void main(String[] args) throws IOException {6 WsdlJavaTestGenerator generator = new WsdlJavaTestGenerator();7 generator.generate(new File("src/main/resources/wsdl/HelloService.wsdl"), new File("src/main/java/"));8 }9}10import com.consol.citrus.generate.WsdlTestGenerator;11import java.io.File;12import java.io.IOException;13public class 5 {14 public static void main(String[] args) throws IOException {15 WsdlTestGenerator generator = new WsdlTestGenerator();16 generator.generate(new File("src/main/resources/wsdl/HelloService.wsdl"), new File("src/main/java/"));17 }18}19import com.consol.citrus.generate.WsdlTestGenerator;20import java.io.File;21import java.io.IOException;22public class 6 {23 public static void main(String[] args) throws IOException {24 WsdlTestGenerator generator = new WsdlTestGenerator();25 generator.generate(new File("src/main/resources/wsdl/HelloService.wsdl"), new File("src/main/java/"));26 }27}28import com.consol.citrus.generate.WsdlTestGenerator;29import java.io.File;30import java.io.IOException;31public class 7 {32 public static void main(String[] args) throws IOException {33 WsdlTestGenerator generator = new WsdlTestGenerator();34 generator.generate(new File("src/main/resources/wsdl/HelloService.wsdl"), new File("src/main/java/"));35 }36}

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful