How to use ExcelTestDocsGenerator class of com.consol.citrus.docs package

Best Citrus code snippet using com.consol.citrus.docs.ExcelTestDocsGenerator

Source:CreateDocsMojo.java Github

copy

Full Screen

...13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package com.consol.citrus.mvn.plugin;17import com.consol.citrus.docs.ExcelTestDocsGenerator;18import com.consol.citrus.docs.HtmlTestDocsGenerator;19import com.consol.citrus.mvn.plugin.config.docs.ExcelDocConfiguration;20import com.consol.citrus.mvn.plugin.config.docs.HtmlDocConfiguration;21import org.apache.maven.plugin.MojoExecutionException;22import org.apache.maven.plugins.annotations.*;23import org.codehaus.plexus.components.interactivity.Prompter;24import org.codehaus.plexus.components.interactivity.PrompterException;25import java.util.Arrays;26import java.util.Optional;27/**28 * Creates test documentation in interactive mode. Either uses mode excel for MS Excel output or29 * html for HTML web page output.30 *31 * @author Christoph Deppisch32 * @since 2.7.433 */34@Mojo(name = "create-docs")35public class CreateDocsMojo extends AbstractCitrusMojo {36 @Parameter(property = "citrus.skip.create.docs", defaultValue = "false")37 protected boolean skipCreateDocs;38 @Component39 private Prompter prompter;40 private final ExcelTestDocsGenerator excelTestDocsGenerator;41 private final HtmlTestDocsGenerator htmlTestDocsGenerator;42 /**43 * Default constructor.44 */45 public CreateDocsMojo() {46 this(new ExcelTestDocsGenerator(), new HtmlTestDocsGenerator());47 }48 /**49 * Constructor using final fields.50 * @param excelTestDocsGenerator51 * @param htmlTestDocsGenerator52 */53 public CreateDocsMojo(ExcelTestDocsGenerator excelTestDocsGenerator, HtmlTestDocsGenerator htmlTestDocsGenerator) {54 this.excelTestDocsGenerator = excelTestDocsGenerator;55 this.htmlTestDocsGenerator = htmlTestDocsGenerator;56 }57 @Override58 public void doExecute() throws MojoExecutionException {59 if (skipCreateDocs) {60 return;61 }62 try {63 String mode = prompter.prompt("Choose documentation mode:", Arrays.asList("excel", "html"), "html");64 if (mode.equals("excel")) {65 createExcelDoc();66 } else if (mode.equals("html")) {67 createHtmlDoc();68 }69 } catch (PrompterException e) {70 getLog().info(e);71 }72 }73 /**74 * Create HTML documentation in interactive mode.75 * @throws PrompterException76 */77 private void createHtmlDoc() throws PrompterException {78 HtmlDocConfiguration configuration = new HtmlDocConfiguration();79 String heading = prompter.prompt("Enter overview title:", configuration.getHeading());80 String columns = prompter.prompt("Enter number of columns in overview:", configuration.getColumns());81 String pageTitle = prompter.prompt("Enter page title:", configuration.getPageTitle());82 String outputFile = prompter.prompt("Enter output file name:", configuration.getOutputFile());83 String logo = prompter.prompt("Enter file path to logo:", configuration.getLogo());84 String confirm = prompter.prompt("Confirm HTML documentation: outputFile='target/" + outputFile + (outputFile.endsWith(".html") ? "" : ".html") + "'\n",85 Arrays.asList("y", "n"), "y");86 if (confirm.equalsIgnoreCase("n")) {87 return;88 }89 HtmlTestDocsGenerator generator = getHtmlTestDocsGenerator();90 generator.withOutputFile(outputFile + (outputFile.endsWith(".html") ? "" : ".html"))91 .withPageTitle(pageTitle)92 .withOverviewTitle(heading)93 .withColumns(columns)94 .useSrcDirectory(getTestSrcDirectory())95 .withLogo(logo);96 generator.generateDoc();97 getLog().info("Successfully created HTML documentation: outputFile='target/" + outputFile + (outputFile.endsWith(".html") ? "" : ".html") + "'");98 }99 /**100 * Create Excel documentation in interactive mode.101 * @throws PrompterException102 */103 private void createExcelDoc() throws PrompterException {104 ExcelDocConfiguration configuration = new ExcelDocConfiguration();105 String company = prompter.prompt("Enter company:", configuration.getCompany());106 String author = prompter.prompt("Enter author:", configuration.getAuthor());107 String pageTitle = prompter.prompt("Enter page title:", configuration.getPageTitle());108 String outputFile = prompter.prompt("Enter output file name:", configuration.getOutputFile());109 String headers = prompter.prompt("Enter custom headers:", configuration.getHeaders());110 String confirm = prompter.prompt("Confirm Excel documentation: outputFile='target/" + outputFile + (outputFile.endsWith(".xls") ? "" : ".xls") + "'\n",111 Arrays.asList("y", "n"), "y");112 if (confirm.equalsIgnoreCase("n")) {113 return;114 }115 ExcelTestDocsGenerator generator = getExcelTestDocsGenerator();116 generator.withOutputFile(outputFile + (outputFile.endsWith(".xls") ? "" : ".xls"))117 .withPageTitle(pageTitle)118 .withAuthor(author)119 .withCompany(company)120 .useSrcDirectory(getTestSrcDirectory())121 .withCustomHeaders(headers);122 generator.generateDoc();123 getLog().info("Successfully created Excel documentation: outputFile='target/" + outputFile + (outputFile.endsWith(".xls") ? "" : ".xls") + "'");124 }125 /**126 * Gets the htmlTestDocsGenerator.127 *128 * @return129 */130 public HtmlTestDocsGenerator getHtmlTestDocsGenerator() {131 return Optional.ofNullable(htmlTestDocsGenerator).orElse(HtmlTestDocsGenerator.build());132 }133 /**134 * Gets the excelTestDocsGenerator.135 *136 * @return137 */138 public ExcelTestDocsGenerator getExcelTestDocsGenerator() {139 return Optional.ofNullable(excelTestDocsGenerator).orElse(ExcelTestDocsGenerator.build());140 }141 /**142 * Sets the prompter.143 * @param prompter the prompter to set144 */145 public void setPrompter(Prompter prompter) {146 this.prompter = prompter;147 }148}...

Full Screen

Full Screen

Source:ExcelTestDocsGeneratorTest.java Github

copy

Full Screen

...28import java.util.Date;29/**30 * @author Christoph Deppisch31 */32public class ExcelTestDocsGeneratorTest {33 private DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");34 35 @BeforeClass36 public void createSampleIT() {37 XmlTestGenerator generator = (XmlTestGenerator) new XmlTestGenerator()38 .withAuthor("Christoph")39 .withDescription("This is a sample test")40 .withName("SampleIT")41 .usePackage("com.consol.citrus.sample")42 .withFramework(UnitFramework.TESTNG);43 generator.create();44 }45 46 @Test47 public void testExcelDocGeneration() throws IOException {48 ExcelTestDocsGenerator generator = ExcelTestDocsGenerator.build();49 generator.generateDoc();50 51 String docContent = FileUtils.readToString(new FileSystemResource(ExcelTestDocsGenerator.getOutputDirectory() + File.separator + generator.getOutputFile()));52 53 Assert.assertTrue(docContent.contains("<Author>Citrus Testframework</Author>"));54 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Citrus Test Documentation</Data>"));55 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Id</Data>"));56 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Name</Data>"));57 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Author</Data>"));58 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Status</Data>"));59 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Description</Data>"));60 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Date</Data>"));61 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">File</Data>"));62 63 Assert.assertTrue(docContent.contains(">SampleIT<"));64 Assert.assertTrue(docContent.contains(">Christoph<"));65 Assert.assertTrue(docContent.contains(">DRAFT<"));66 Assert.assertTrue(docContent.contains(">This is a sample test<"));67 Assert.assertTrue(docContent.contains(">" + dateFormat.format(new Date()) + "<"));68 Assert.assertTrue(docContent.contains(">SampleIT.xml<"));69 }70 71 @Test72 public void testCustomizedExcelDocGeneration() throws IOException {73 ExcelTestDocsGenerator generator = ExcelTestDocsGenerator.build()74 .withAuthor("TestFactory")75 .withCompany("TestCompany")76 .withOutputFile("CustomCitrusTests.xls")77 .withPageTitle("CustomPageTitle")78 .withCustomHeaders("Id;Name;Autor;Status;Beschreibung;Datum;Dateiname")79 .useSrcDirectory("src" + File.separator + "test" + File.separator);80 generator.generateDoc();81 82 String docContent = FileUtils.readToString(new FileSystemResource(ExcelTestDocsGenerator.getOutputDirectory() + File.separator + generator.getOutputFile()));83 84 Assert.assertTrue(docContent.contains("<Author>TestFactory</Author>"));85 Assert.assertTrue(docContent.contains("<Company>TestCompany</Company>"));86 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">CustomPageTitle</Data>"));87 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Id</Data>"));88 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Name</Data>"));89 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Autor</Data>"));90 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Status</Data>"));91 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Beschreibung</Data>"));92 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Datum</Data>"));93 Assert.assertTrue(docContent.contains("<Data ss:Type=\"String\">Dateiname</Data>"));94 95 Assert.assertTrue(docContent.contains(">SampleIT<"));96 Assert.assertTrue(docContent.contains(">Christoph<"));...

Full Screen

Full Screen

Source:GenerateDocsMojo.java Github

copy

Full Screen

...13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package com.consol.citrus.mvn.plugin;17import com.consol.citrus.docs.ExcelTestDocsGenerator;18import com.consol.citrus.docs.HtmlTestDocsGenerator;19import org.apache.maven.plugin.MojoExecutionException;20import org.apache.maven.plugins.annotations.*;21import java.util.Optional;22/**23 * Generates test overview documentation based on plugin configuration. Html documentation creates a web page that24 * contains a list of all available tests with meta information. Excel documentation creates a table of all available tests with25 * meta information such as name, author, status and so on.26 *27 * @author Christoph Deppisch28 * @since 2.7.429 */30@Mojo(name = "generate-docs", defaultPhase = LifecyclePhase.PROCESS_TEST_RESOURCES)31public class GenerateDocsMojo extends AbstractCitrusMojo {32 @Parameter(property = "citrus.skip.generate.docs", defaultValue = "false")33 protected boolean skipGenerateDocs;34 private final ExcelTestDocsGenerator excelTestDocGenerator;35 private final HtmlTestDocsGenerator htmlTestDocGenerator;36 /**37 * Default constructor.38 */39 public GenerateDocsMojo() {40 this(new ExcelTestDocsGenerator(), new HtmlTestDocsGenerator());41 }42 /**43 * Constructor using final fields.44 * @param excelTestDocGenerator45 * @param htmlTestDocGenerator46 */47 public GenerateDocsMojo(ExcelTestDocsGenerator excelTestDocGenerator, HtmlTestDocsGenerator htmlTestDocGenerator) {48 this.excelTestDocGenerator = excelTestDocGenerator;49 this.htmlTestDocGenerator = htmlTestDocGenerator;50 }51 @Override52 public void doExecute() throws MojoExecutionException {53 if (skipGenerateDocs) {54 return;55 }56 if (getDocs().getExcel() != null) {57 ExcelTestDocsGenerator generator = getExcelTestDocGenerator();58 generator.withOutputFile(getDocs().getExcel().getOutputFile() + (getDocs().getExcel().getOutputFile().endsWith(".xls") ? "" : ".xls"))59 .withPageTitle(getDocs().getExcel().getPageTitle())60 .withAuthor(getDocs().getExcel().getAuthor())61 .withCompany(getDocs().getExcel().getCompany())62 .useSrcDirectory(getTestSrcDirectory())63 .withCustomHeaders(getDocs().getExcel().getHeaders());64 generator.generateDoc();65 getLog().info("Successfully created Excel documentation: outputFile='target/" + getDocs().getExcel().getOutputFile() + (getDocs().getExcel().getOutputFile().endsWith(".xls") ? "" : ".xls") + "'");66 }67 if (getDocs().getHtml() != null) {68 HtmlTestDocsGenerator generator = getHtmlTestDocGenerator();69 generator.withOutputFile(getDocs().getHtml().getOutputFile() + (getDocs().getHtml().getOutputFile().endsWith(".html") ? "" : ".html"))70 .withPageTitle(getDocs().getHtml().getPageTitle())71 .withOverviewTitle(getDocs().getHtml().getHeading())72 .withColumns(getDocs().getHtml().getColumns())73 .useSrcDirectory(getTestSrcDirectory())74 .withLogo(getDocs().getHtml().getLogo());75 generator.generateDoc();76 getLog().info("Successfully created HTML documentation: outputFile='target/" + getDocs().getHtml().getOutputFile() + (getDocs().getHtml().getOutputFile().endsWith(".html") ? "" : ".html") + "'");77 }78 }79 /**80 * Gets the htmlTestDocGenerator.81 *82 * @return83 */84 public HtmlTestDocsGenerator getHtmlTestDocGenerator() {85 return Optional.ofNullable(htmlTestDocGenerator).orElse(HtmlTestDocsGenerator.build());86 }87 /**88 * Gets the excelTestDocGenerator.89 *90 * @return91 */92 public ExcelTestDocsGenerator getExcelTestDocGenerator() {93 return Optional.ofNullable(excelTestDocGenerator).orElse(ExcelTestDocsGenerator.build());94 }95}...

Full Screen

Full Screen

ExcelTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.docs;2import java.io.File;3import java.io.IOException;4import java.util.HashMap;5import java.util.Map;6import org.apache.poi.ss.usermodel.Workbook;7import org.apache.poi.xssf.usermodel.XSSFWorkbook;8public class ExcelTestDocsGeneratorTest {9 public static void main(String[] args) throws IOException {10 Map<String, String> testClassNames = new HashMap<>();11 testClassNames.put("com.consol.citrus.docs.test.CalculatorTest", "Calculator");12 testClassNames.put("com.consol.citrus.docs.test.GreetingTest", "Greeting");13 Workbook workbook = new XSSFWorkbook();14 ExcelTestDocsGenerator generator = new ExcelTestDocsGenerator(workbook);15 generator.generate(testClassNames);16 workbook.write(new File("target/test-docs.xlsx"));17 }18}19package com.consol.citrus.docs;20import java.io.File;21import java.io.IOException;22import java.util.HashMap;23import java.util.Map;24import com.consol.citrus.docs.json.JsonTestDocsGenerator;25import com.consol.citrus.docs.json.model.TestDoc;26public class JsonTestDocsGeneratorTest {27 public static void main(String[] args) throws IOException {28 Map<String, String> testClassNames = new HashMap<>();29 testClassNames.put("com.consol.citrus.docs.test.CalculatorTest", "Calculator");30 testClassNames.put("com.consol.citrus.docs.test.GreetingTest", "Greeting");31 JsonTestDocsGenerator generator = new JsonTestDocsGenerator();32 TestDoc testDoc = generator.generate(testClassNames);33 generator.write(testDoc, new File("target/test-docs.json"));34 }35}36package com.consol.citrus.docs;37import java.io.File;38import java.io.IOException;39import java.util.HashMap;40import java.util.Map;41import com.consol.citrus.docs.json.JsonTestDocsGenerator;42import com.consol.citrus.docs.json.model.TestDoc;43import org.apache.poi.ss.usermodel.Workbook;44import org.apache.poi.xssf.usermodel.XSSFWorkbook;45public class TestDocsGeneratorTest {46 public static void main(String[] args) throws IOException {

Full Screen

Full Screen

ExcelTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.docs;2import org.testng.annotations.Test;3public class ExcelTestDocsGeneratorTest {4 public void testGenerateExcel() {5 ExcelTestDocsGenerator generator = new ExcelTestDocsGenerator();6 generator.setExcelFilePath("src/test/resources/testcases.xls");7 generator.generateExcel();8 }9}10package com.consol.citrus.docs;11import java.io.File;12import java.io.FileInputStream;13import java.io.IOException;14import java.util.ArrayList;15import java.util.List;16import org.apache.poi.ss.usermodel.Cell;17import org.apache.poi.ss.usermodel.Row;18import org.apache.poi.ss.usermodel.Sheet;19import org.apache.poi.ss.usermodel.Workbook;20import org.apache.poi.ss.usermodel.WorkbookFactory;21import org.apache.poi.xssf.usermodel.XSSFWorkbook;22import org.testng.annotations.Test;23public class ExcelTestDocsGeneratorTest {24 public void testGenerateExcel() {25 ExcelTestDocsGenerator generator = new ExcelTestDocsGenerator();26 generator.setExcelFilePath("src/test/resources/testcases.xls");27 generator.generateExcel();28 }29}30package com.consol.citrus.docs;31import java.io.File;32import java.io.FileInputStream;33import java.io.IOException;34import java.util.ArrayList;35import java.util.List;36import org.apache.poi.ss.usermodel.Cell;37import org.apache.poi.ss.usermodel.Row;38import org.apache.poi.ss.usermodel.Sheet;39import org.apache.poi.ss.usermodel.Workbook;40import org.apache.poi.ss.usermodel.WorkbookFactory;41import org.apache.poi.xssf.usermodel.XSSFWorkbook;42import org.testng.annotations.Test;43public class ExcelTestDocsGeneratorTest {44 public void testGenerateExcel() {45 ExcelTestDocsGenerator generator = new ExcelTestDocsGenerator();46 generator.setExcelFilePath("src/test/resources/testcases.xls");47 generator.generateExcel();48 }49}50package com.consol.citrus.docs;51import java.io.File;52import java.io.FileInputStream;53import java.io.IOException;54import java.util.ArrayList;55import java.util.List;56import org.apache.poi.ss.usermodel.Cell;57import org.apache.poi.ss.usermodel.Row;58import org.apache.poi.ss.usermodel.Sheet;59import org.apache.poi.ss.usermodel.Workbook;60import org.apache.poi.ss.usermodel.WorkbookFactory;61import org.apache.poi.xssf.usermodel.XSSFWorkbook;62import org.testng.annotations.Test;63public class ExcelTestDocsGeneratorTest {

Full Screen

Full Screen

ExcelTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.docs.ExcelTestDocsGenerator;2public class 4{3 public static void main(String[] args) {4 ExcelTestDocsGenerator generator = new ExcelTestDocsGenerator();5 generator.generate("C:\\Users\\dell\\Desktop\\citrus-2.7.8\\citrus-2.7.8\\modules\\citrus-test\\src\\test\\resources\\com\\consol\\citrus\\tests\\", "C:\\Users\\dell\\Desktop\\citrus-2.7.8\\citrus-2.7.8\\modules\\citrus-test\\src\\test\\resources\\com\\consol\\citrus\\tests\\");6 }7}

Full Screen

Full Screen

ExcelTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.docs.ExcelTestDocsGenerator;2public class ExcelTestDocsGeneratorExample {3public static void main(String[] args) {4 ExcelTestDocsGenerator generator = new ExcelTestDocsGenerator();5 generator.generate("src/test/resources/citrus-docs.xlsx", "src/test/java");6}7}8import com.consol.citrus.docs.ExcelTestDocsGenerator;9public class ExcelTestDocsGeneratorExample {10public static void main(String[] args) {11 ExcelTestDocsGenerator generator = new ExcelTestDocsGenerator();12 generator.generate("src/test/resources/citrus-docs.xlsx", "src/test/java", "com.consol.citrus.docs");13}14}15import com.consol.citrus.docs.ExcelTestDocsGenerator;16public class ExcelTestDocsGeneratorExample {17public static void main(String[] args) {18 ExcelTestDocsGenerator generator = new ExcelTestDocsGenerator();19 generator.generate("src/test/resources/citrus-docs.xlsx", "src/test/java", "com.consol.citrus.docs", true);20}21}22import com.consol.citrus.docs.ExcelTestDocsGenerator;23public class ExcelTestDocsGeneratorExample {24public static void main(String[] args) {25 ExcelTestDocsGenerator generator = new ExcelTestDocsGenerator();26 generator.generate("src/test/resources/citrus-docs.xlsx", "src/test/java", "com.consol.citrus.docs", true, true);27}28}29import com.consol.citrus.docs.ExcelTestDocsGenerator;30public class ExcelTestDocsGeneratorExample {31public static void main(String[] args) {32 ExcelTestDocsGenerator generator = new ExcelTestDocsGenerator();33 generator.generate("src/test/resources/citrus-docs.xlsx", "src/test/java", "com.consol.citrus.docs", true, true, true);34}35}

Full Screen

Full Screen

ExcelTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.docs.ExcelTestDocsGenerator;2import org.testng.annotations.Test;3import java.io.IOException;4public class ExcelTestDocsGeneratorExample {5public void generateExcelTestDocs() throws IOException {6ExcelTestDocsGenerator excelTestDocsGenerator = new ExcelTestDocsGenerator();7excelTestDocsGenerator.generate();8}9}

Full Screen

Full Screen

ExcelTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.docs.ExcelTestDocsGenerator;2import org.springframework.context.ApplicationContext;3import org.springframework.context.support.ClassPathXmlApplicationContext;4import org.testng.annotations.Test;5public class ExcelTestDocsGeneratorTest {6 public void generateExcelTestDocs() {7 ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");8 ExcelTestDocsGenerator excelTestDocsGenerator = new ExcelTestDocsGenerator(context);9 excelTestDocsGenerator.generateExcelTestDocs("C:/Users/ABC/Desktop/Test/ExcelTestDocs.xlsx");10 }11}

Full Screen

Full Screen

ExcelTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.docs.ExcelTestDocsGenerator;2import com.consol.citrus.docs.TestDocsGenerator;3import com.consol.citrus.docs.model.TestDoc;4import org.springframework.context.ApplicationContext;5import org.springframework.context.support.ClassPathXmlApplicationContext;6import java.util.List;7public class ExcelTestDocsGeneratorTest {8 public static void main(String[] args) {9 ApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:com/consol/citrus/docs/test-docs-generator-context.xml");10 TestDocsGenerator testDocsGenerator = ctx.getBean("testDocsGenerator", TestDocsGenerator.class);11 List<TestDoc> testDocs = testDocsGenerator.generateTestDocs();12 ExcelTestDocsGenerator excelTestDocsGenerator = new ExcelTestDocsGenerator(testDocs);13 excelTestDocsGenerator.generateTestDocs();14 }15}

Full Screen

Full Screen

ExcelTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.docs;2import org.testng.annotations.Test;3import com.consol.citrus.docs.testcase.generator.ExcelTestDocsGenerator;4public class ExcelTestDocsGeneratorTest {5 public void testGenerateTestDocs() {6 ExcelTestDocsGenerator generator = new ExcelTestDocsGenerator();7 generator.generateTestDocs("src/test/resources/test-docs/testdocs.xls");8 }9}

Full Screen

Full Screen

ExcelTestDocsGenerator

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.docs;2import java.io.File;3import java.io.FileInputStream;4import java.io.FileNotFoundException;5import java.io.FileOutputStream;6import java.io.IOException;7import java.util.ArrayList;8import java.util.List;9import org.apache.poi.hssf.usermodel.HSSFCell;10import org.apache.poi.hssf.usermodel.HSSFRow;11import org.apache.poi.hssf.usermodel.HSSFSheet;12import org.apache.poi.hssf.usermodel.HSSFWorkbook;13public class ExcelTestDocsGenerator {14private HSSFWorkbook workbook;15private HSSFSheet sheet;16private HSSFRow row;17private HSSFCell cell;18private List<List<String>> data;19private String excelFilePath;20public ExcelTestDocsGenerator(String excelFilePath) throws IOException {21this.excelFilePath = excelFilePath;22FileInputStream inputStream = new FileInputStream(new File(excelFilePath));23workbook = new HSSFWorkbook(inputStream);24sheet = workbook.getSheetAt(0);25data = new ArrayList<List<String>>();26}27public List<List<String>> readExcelFile() {28for (int i = 1; i <= sheet.getLastRowNum(); i++) {29row = sheet.getRow(i);30List<String> list = new ArrayList<String>();31for (int j = 0; j < row.getLastCellNum(); j++) {32cell = row.getCell(j);33list.add(cell.toString());34}35data.add(list);36}37return data;38}39public void writeExcelFile(List<List<String>> data) throws IOException {40for (int i = 1; i <= sheet.getLastRowNum(); i++) {41row = sheet.getRow(i);42for (int j = 0; j < row.getLastCellNum(); j++) {43cell = row.getCell(j);44cell.setCellValue(data.get(i - 1).get(j));45}46}47FileOutputStream outputStream = new FileOutputStream(excelFilePath);48workbook.write(outputStream);49}50public void generateTestDocs() throws IOException {51TestDocsGenerator testDocsGenerator = new TestDocsGenerator();52readExcelFile();53for (int i = 0; i < data.size(); i++) {54List<String> list = data.get(i);55testDocsGenerator.generateTestDoc(list.get(0), list.get(1), list.get(2),56list.get(3), list.get(4), list.get(5));57list.set(6, testDocsGenerator.getTestDoc());58}59writeExcelFile(data);60}61}

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.

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful