├── .gitignore ├── .idea ├── .gitignore ├── compiler.xml ├── jarRepositories.xml ├── misc.xml ├── uiDesigner.xml └── vcs.xml ├── pom.xml ├── src ├── main │ └── java │ │ ├── reporting │ │ ├── ExtentReportManager.java │ │ └── Setup.java │ │ ├── restUtils │ │ ├── AssertionKeys.java │ │ ├── AssertionUtils.java │ │ └── RestUtils.java │ │ └── utils │ │ ├── DateUtils.java │ │ ├── ExcelUtils.java │ │ ├── JsonUtils.java │ │ ├── RandomDataGenerator.java │ │ └── RandomDataTypeNames.java └── test │ ├── java │ └── airlines │ │ ├── AirlineAPIs.java │ │ ├── AirlineTests.java │ │ ├── AirlineTestsNew.java │ │ ├── AirlineTestsScenarios.java │ │ ├── Base.java │ │ ├── ExcelTest.java │ │ ├── InstancioExample.java │ │ ├── Payloads.java │ │ ├── PoijiTests.java │ │ ├── javersExamples │ │ ├── Address.java │ │ ├── JaversTest.java │ │ └── Student.java │ │ └── pojos │ │ ├── Airline.java │ │ ├── AirlinePoiji.java │ │ ├── BasePojo.java │ │ ├── CompareObjects.java │ │ ├── CreateAirline.java │ │ ├── Employee.java │ │ ├── Gender.java │ │ └── Student.java │ └── resources │ ├── airlines │ ├── dev │ │ └── airlinesApiData.json │ └── qa │ │ └── airlinesApiData.json │ └── testdata │ ├── CreateAirlineData.xlsx │ └── CreateAirlineDataScenarios.xlsx └── testng.xml /.gitignore: -------------------------------------------------------------------------------- 1 | Demo.json 2 | Demo2.json 3 | reports/TestReport2023_03_25_00_04_35.html 4 | /D1/D2/D3/SubPackage.json 5 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.example 8 | RetargetCommonRestAPIAutomationFramework 9 | 1.0-SNAPSHOT 10 | 11 | 12 | 13 | 14 | org.apache.maven.plugins 15 | maven-surefire-plugin 16 | 3.0.0-M7 17 | 18 | 19 | testng.xml 20 | 21 | 0 22 | 23 | 24 | 25 | 26 | 27 | 28 | 11 29 | 11 30 | 5.3.0 31 | 7.7.0 32 | 2.14.1 33 | 2.10 34 | 5.0.9 35 | 1.8.0 36 | 1.18.24 37 | 3.12.0 38 | 6.12.0 39 | 40 | 41 | 42 | 43 | 44 | io.rest-assured 45 | rest-assured 46 | ${restassuredVersion} 47 | 48 | 49 | 50 | 51 | org.testng 52 | testng 53 | ${testngVersion} 54 | 55 | 56 | 57 | 58 | com.fasterxml.jackson.core 59 | jackson-databind 60 | ${jacksonVersion} 61 | 62 | 63 | 64 | 65 | com.google.code.gson 66 | gson 67 | ${gsonVersion} 68 | 69 | 70 | 71 | com.aventstack 72 | extentreports 73 | ${extentVersion} 74 | 75 | 76 | 77 | net.datafaker 78 | datafaker 79 | ${datafakerVersion} 80 | 81 | 82 | 83 | 84 | org.projectlombok 85 | lombok 86 | ${lombokVersion} 87 | 88 | 89 | 90 | 91 | org.apache.commons 92 | commons-lang3 93 | ${apacheCommonLangVersion} 94 | 95 | 96 | 97 | 98 | org.javers 99 | javers-core 100 | ${javersVersion} 101 | 102 | 103 | 104 | 105 | org.apache.poi 106 | poi 107 | 5.2.3 108 | 109 | 110 | 111 | 112 | org.apache.poi 113 | poi-ooxml 114 | 5.2.3 115 | 116 | 117 | 118 | 119 | com.github.ozlerhakan 120 | poiji 121 | 4.1.1 122 | 123 | 124 | 125 | 126 | org.instancio 127 | instancio-core 128 | 2.15.0 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /src/main/java/reporting/ExtentReportManager.java: -------------------------------------------------------------------------------- 1 | package reporting; 2 | 3 | import com.aventstack.extentreports.ExtentReports; 4 | import com.aventstack.extentreports.markuputils.CodeLanguage; 5 | import com.aventstack.extentreports.markuputils.ExtentColor; 6 | import com.aventstack.extentreports.markuputils.MarkupHelper; 7 | import com.aventstack.extentreports.reporter.ExtentSparkReporter; 8 | import com.aventstack.extentreports.reporter.configuration.Theme; 9 | import io.restassured.RestAssured; 10 | import io.restassured.http.Header; 11 | 12 | import java.time.LocalDateTime; 13 | import java.time.format.DateTimeFormatter; 14 | import java.util.List; 15 | 16 | 17 | public class ExtentReportManager { 18 | 19 | public static ExtentReports extentReports; 20 | 21 | public static ExtentReports createInstance(String fileName, String reportName, String documentTitle) { 22 | ExtentSparkReporter extentSparkReporter = new ExtentSparkReporter(fileName); 23 | extentSparkReporter.config().setReportName(reportName); 24 | extentSparkReporter.config().setDocumentTitle(documentTitle); 25 | extentSparkReporter.config().setTheme(Theme.DARK); 26 | extentSparkReporter.config().setEncoding("utf-8"); 27 | extentReports = new ExtentReports(); 28 | extentReports.attachReporter(extentSparkReporter); 29 | return extentReports; 30 | } 31 | 32 | public static String getReportNameWithTimeStamp() { 33 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy_MM_dd_HH_mm_ss"); 34 | LocalDateTime localDateTime = LocalDateTime.now(); 35 | String formattedTime = dateTimeFormatter.format(localDateTime); 36 | String reportName = "TestReport" + formattedTime + ".html"; 37 | return reportName; 38 | } 39 | 40 | public static void logPassDetails(String log) { 41 | Setup.extentTest.get().pass(MarkupHelper.createLabel(log, ExtentColor.GREEN)); 42 | } 43 | public static void logFailureDetails(String log) { 44 | Setup.extentTest.get().fail(MarkupHelper.createLabel(log, ExtentColor.RED)); 45 | } 46 | public static void logExceptionDetails(String log) { 47 | Setup.extentTest.get().fail(log); 48 | } 49 | public static void logInfoDetails(String log) { 50 | Setup.extentTest.get().info(MarkupHelper.createLabel(log, ExtentColor.GREY)); 51 | } 52 | public static void logWarningDetails(String log) { 53 | Setup.extentTest.get().warning(MarkupHelper.createLabel(log, ExtentColor.YELLOW)); 54 | } 55 | public static void logJson(String json) { 56 | Setup.extentTest.get().info(MarkupHelper.createCodeBlock(json, CodeLanguage.JSON)); 57 | } 58 | public static void logHeaders(List
headersList) { 59 | 60 | String[][] arrayHeaders = headersList.stream().map(header -> new String[] {header.getName(), header.getValue()}) 61 | .toArray(String[][] :: new); 62 | Setup.extentTest.get().info(MarkupHelper.createTable(arrayHeaders)); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/reporting/Setup.java: -------------------------------------------------------------------------------- 1 | package reporting; 2 | 3 | import com.aventstack.extentreports.ExtentReports; 4 | import com.aventstack.extentreports.ExtentTest; 5 | import org.testng.ITestContext; 6 | import org.testng.ITestListener; 7 | import org.testng.ITestResult; 8 | 9 | import java.util.Arrays; 10 | 11 | public class Setup implements ITestListener { 12 | 13 | public static ExtentReports extentReports; 14 | public static ThreadLocal extentTest = new ThreadLocal<>(); 15 | 16 | public void onStart(ITestContext context) { 17 | String fileName = ExtentReportManager.getReportNameWithTimeStamp(); 18 | String fullReportPath = System.getProperty("user.dir") + "\\reports\\" + fileName; 19 | extentReports = ExtentReportManager.createInstance(fullReportPath, "Test API Automation Report", "Test ExecutionReport"); 20 | } 21 | 22 | public void onFinish(ITestContext context) { 23 | if (extentReports != null) 24 | extentReports.flush(); 25 | } 26 | 27 | public void onTestStart(ITestResult result) { 28 | // ExtentTest test = extentReports.createTest("Test Name " + result.getTestClass().getName() + " - " + result.getMethod().getMethodName(), 29 | // result.getMethod().getDescription()); 30 | // extentTest.set(test); 31 | } 32 | 33 | public void onTestFailure(ITestResult result) { 34 | ExtentReportManager.logFailureDetails(result.getThrowable().getMessage()); 35 | String stackTrace = Arrays.toString(result.getThrowable().getStackTrace()); 36 | stackTrace = stackTrace.replaceAll(",", "
"); 37 | String formmatedTrace = "
\n" + 38 | " Click Here To See Exception Logs\n" + 39 | " " + stackTrace + "\n" + 40 | "
\n"; 41 | ExtentReportManager.logExceptionDetails(formmatedTrace); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/restUtils/AssertionKeys.java: -------------------------------------------------------------------------------- 1 | package restUtils; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | @AllArgsConstructor 8 | public class AssertionKeys { 9 | private String jsonPath; 10 | private Object expectedValue; 11 | private Object actualValue; 12 | private String result; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/restUtils/AssertionUtils.java: -------------------------------------------------------------------------------- 1 | package restUtils; 2 | 3 | import com.aventstack.extentreports.markuputils.MarkupHelper; 4 | import io.restassured.response.Response; 5 | import reporting.ExtentReportManager; 6 | import reporting.Setup; 7 | 8 | import java.util.*; 9 | 10 | public class AssertionUtils { 11 | 12 | public static void assertExpectedValuesWithJsonPath(Response response, Map expectedValuesMap) { 13 | List actualValuesMap = new ArrayList<>(); 14 | // Table headers 15 | actualValuesMap.add(new AssertionKeys("JSON_PATH", "EXPECTED_VALUE", "ACTUAL_VALUE", "RESULT")); 16 | boolean allMatched = true; 17 | // Iterate to extract value from response using jsonpath 18 | Set jsonPaths = expectedValuesMap.keySet(); 19 | for(String jsonPath : jsonPaths) { 20 | Optional actualValue = Optional.ofNullable(response.jsonPath().get(jsonPath)); 21 | if(actualValue.isPresent()) { 22 | Object value = actualValue.get(); 23 | // Assert actual and expected values 24 | if(value.equals(expectedValuesMap.get(jsonPath))) 25 | // if value is matched then add details 26 | actualValuesMap.add(new AssertionKeys(jsonPath, expectedValuesMap.get(jsonPath), value, "MATCHED ✅")); 27 | else { 28 | // if single assertion is failed then to update final result as failure 29 | allMatched = false; 30 | actualValuesMap.add(new AssertionKeys(jsonPath, expectedValuesMap.get(jsonPath), value, "NOT_MATCHED ❌")); 31 | } 32 | } 33 | // if jsonpath does not exist in the response 34 | else { 35 | allMatched = false; 36 | actualValuesMap.add(new AssertionKeys(jsonPath, expectedValuesMap.get(jsonPath), "VALUE_NOT_FOUND", "NOT_MATCHED ❌")); 37 | } 38 | } 39 | // To decide final result 40 | if(allMatched) 41 | ExtentReportManager.logPassDetails("All assertions are passed. 😊😊😊😊😊"); 42 | else 43 | ExtentReportManager.logFailureDetails("All assertions are not passed. 😒😒😒😒😒"); 44 | 45 | // To log the details in a tabular format in extent report 46 | String[][] finalAssertionsMap = actualValuesMap.stream().map(assertions -> new String[] {assertions.getJsonPath(), 47 | String.valueOf(assertions.getExpectedValue()), String.valueOf(assertions.getActualValue()), assertions.getResult()}) 48 | .toArray(String[][] :: new); 49 | Setup.extentTest.get().info(MarkupHelper.createTable(finalAssertionsMap)); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/restUtils/RestUtils.java: -------------------------------------------------------------------------------- 1 | package restUtils; 2 | 3 | import io.restassured.RestAssured; 4 | import io.restassured.http.ContentType; 5 | import io.restassured.response.Response; 6 | import io.restassured.specification.QueryableRequestSpecification; 7 | import io.restassured.specification.RequestSpecification; 8 | import io.restassured.specification.SpecificationQuerier; 9 | import reporting.ExtentReportManager; 10 | 11 | import java.util.Map; 12 | 13 | public class RestUtils { 14 | 15 | private static RequestSpecification getRequestSpecification(String endPoint, Object requestPayload, Mapheaders) { 16 | return RestAssured.given() 17 | .baseUri(endPoint) 18 | .headers(headers) 19 | .contentType(ContentType.JSON) 20 | .body(requestPayload); 21 | } 22 | 23 | private static void printRequestLogInReport(RequestSpecification requestSpecification) { 24 | QueryableRequestSpecification queryableRequestSpecification = SpecificationQuerier.query(requestSpecification); 25 | ExtentReportManager.logInfoDetails("Endpoint is " + queryableRequestSpecification.getBaseUri()); 26 | ExtentReportManager.logInfoDetails("Method is " + queryableRequestSpecification.getMethod()); 27 | ExtentReportManager.logInfoDetails("Headers are "); 28 | ExtentReportManager.logHeaders(queryableRequestSpecification.getHeaders().asList()); 29 | ExtentReportManager.logInfoDetails("Request body is "); 30 | ExtentReportManager.logJson(queryableRequestSpecification.getBody()); 31 | } 32 | 33 | private static void printResponseLogInReport(Response response) { 34 | ExtentReportManager.logInfoDetails("Response status is " + response.getStatusCode()); 35 | ExtentReportManager.logInfoDetails("Response Headers are "); 36 | ExtentReportManager.logHeaders(response.getHeaders().asList()); 37 | ExtentReportManager.logInfoDetails("Response body is "); 38 | ExtentReportManager.logJson(response.getBody().prettyPrint()); 39 | } 40 | 41 | public static Response performPost(String endPoint, String requestPayload, Mapheaders) { 42 | RequestSpecification requestSpecification = getRequestSpecification(endPoint, requestPayload, headers); 43 | Response response = requestSpecification.post(); 44 | printRequestLogInReport(requestSpecification); 45 | printResponseLogInReport(response); 46 | return response; 47 | } 48 | 49 | public static Response performPost(String endPoint, Map requestPayload, Mapheaders) { 50 | RequestSpecification requestSpecification = getRequestSpecification(endPoint, requestPayload, headers); 51 | Response response = requestSpecification.post(); 52 | printRequestLogInReport(requestSpecification); 53 | printResponseLogInReport(response); 54 | return response; 55 | } 56 | 57 | public static Response performPost(String endPoint, Object requestPayloadAsPojo, Mapheaders) { 58 | RequestSpecification requestSpecification = getRequestSpecification(endPoint, requestPayloadAsPojo, headers); 59 | Response response = requestSpecification.post(); 60 | printRequestLogInReport(requestSpecification); 61 | printResponseLogInReport(response); 62 | return response; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/utils/DateUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import java.time.LocalDate; 4 | import java.util.Date; 5 | 6 | public class DateUtils { 7 | 8 | public static int getCurrentYear() { 9 | return LocalDate.now().getYear(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/utils/ExcelUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import org.apache.poi.ss.usermodel.DataFormatter; 4 | import org.apache.poi.ss.usermodel.Sheet; 5 | import org.apache.poi.ss.usermodel.Workbook; 6 | import org.apache.poi.ss.usermodel.WorkbookFactory; 7 | 8 | import java.io.File; 9 | import java.io.IOException; 10 | import java.util.ArrayList; 11 | import java.util.LinkedHashMap; 12 | import java.util.List; 13 | import java.util.stream.Collectors; 14 | 15 | public class ExcelUtils { 16 | 17 | public static List> getExcelDataAsListOfMap(String excelFileName, String sheetName) throws IOException { 18 | List> dataFromExcel = new ArrayList<>(); 19 | Workbook workbook = WorkbookFactory.create(new File("src/test/resources/testdata/" + excelFileName + ".xlsx")); 20 | Sheet sheet = workbook.getSheet(sheetName); 21 | 22 | int totalRows = sheet.getPhysicalNumberOfRows(); 23 | LinkedHashMap mapData; 24 | List allKeys = new ArrayList<>(); 25 | DataFormatter dataFormatter = new DataFormatter(); 26 | for(int i = 0; i< totalRows ; i++) { 27 | mapData = new LinkedHashMap<>(); 28 | if( i == 0) { 29 | int totalCols = sheet.getRow(0).getPhysicalNumberOfCells(); 30 | for (int j = 0; j < totalCols; j++) { 31 | allKeys.add(sheet.getRow(0).getCell(j).getStringCellValue()); 32 | } 33 | } 34 | else { 35 | int totalCols = sheet.getRow(i).getPhysicalNumberOfCells(); 36 | for (int j = 0; j < totalCols; j++) { 37 | String cellValue = dataFormatter.formatCellValue(sheet.getRow(i).getCell(j)); 38 | int size = 6; 39 | if(cellValue.contains("RandomNumber")) { 40 | // With size 41 | if(cellValue.contains("_")) { 42 | size = Integer.parseInt((cellValue.split("_"))[1]); 43 | } 44 | cellValue = RandomDataGenerator.getRandomNumber(size); 45 | } 46 | mapData.put(allKeys.get(j), cellValue); 47 | } 48 | dataFromExcel.add(mapData); 49 | } 50 | } 51 | dataFromExcel = dataFromExcel.stream().filter(keyValuePair -> keyValuePair.get("Enabled").equalsIgnoreCase("Y")) 52 | .collect(Collectors.toList()); 53 | return dataFromExcel; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/utils/JsonUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | 4 | import com.fasterxml.jackson.core.type.TypeReference; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | 7 | import java.io.File; 8 | import java.io.IOException; 9 | import java.util.Map; 10 | 11 | public class JsonUtils { 12 | 13 | private static ObjectMapper objectMapper = new ObjectMapper(); 14 | public static Map getJsonDataAsMap(String jsonFileName) throws IOException { 15 | String completeJsonFilePath = System.getProperty("user.dir") + "/src/test/resources/" + jsonFileName; 16 | Map data = objectMapper.readValue(new File(completeJsonFilePath), new TypeReference<>(){}); 17 | return data; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/utils/RandomDataGenerator.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import net.datafaker.Faker; 4 | import org.apache.commons.lang3.RandomStringUtils; 5 | 6 | public class RandomDataGenerator { 7 | 8 | public static Faker faker = new Faker(); 9 | 10 | public static String getRandomDataFor(RandomDataTypeNames dataTypesNames) { 11 | switch (dataTypesNames) { 12 | case FIRSTNAME: 13 | return faker.name().firstName(); 14 | case LASTNAME: 15 | return faker.name().lastName(); 16 | case FULLNAME: 17 | return faker.name().fullName(); 18 | case COUNTRY: 19 | return faker.address().country(); 20 | case CITYNAME: 21 | return faker.address().cityName(); 22 | default: 23 | return "Data type name not available"; 24 | } 25 | } 26 | 27 | public static String getRandomNumber(int count) { 28 | return faker.number().digits(count); 29 | } 30 | 31 | public static int getRandomNumber(int min, int max) { 32 | return faker.number().numberBetween(min, max); 33 | } 34 | 35 | public static String getRandomAlphabets(int count) { 36 | return RandomStringUtils.randomAlphabetic(count); 37 | } 38 | 39 | public static String getRandomWebsiteName() { 40 | return "https://" + RandomDataGenerator.getRandomAlphabets(10) + ".com"; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/utils/RandomDataTypeNames.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | public enum RandomDataTypeNames { 4 | FIRSTNAME, 5 | LASTNAME, 6 | FULLNAME, 7 | COUNTRY, 8 | CITYNAME 9 | } 10 | -------------------------------------------------------------------------------- /src/test/java/airlines/AirlineAPIs.java: -------------------------------------------------------------------------------- 1 | package airlines; 2 | 3 | import airlines.pojos.Airline; 4 | import airlines.pojos.CreateAirline; 5 | import io.restassured.response.Response; 6 | import restUtils.RestUtils; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | public class AirlineAPIs { 12 | 13 | public Response createAirline(Map createAirlinePayload) { 14 | String endPoint = (String) Base.dataFromJsonFile.get("createAirLineEndpoint"); 15 | return RestUtils.performPost(endPoint,createAirlinePayload, new HashMap<>()); 16 | } 17 | 18 | public Response createAirline(Airline createAirlinePayload) { 19 | String endPoint = (String) Base.dataFromJsonFile.get("createAirLineEndpoint"); 20 | return RestUtils.performPost(endPoint,createAirlinePayload, new HashMap<>()); 21 | } 22 | 23 | public Response createAirline(CreateAirline createAirlinePayload) { 24 | String endPoint = (String) Base.dataFromJsonFile.get("createAirLineEndpoint"); 25 | return RestUtils.performPost(endPoint,createAirlinePayload, new HashMap<>()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/airlines/AirlineTests.java: -------------------------------------------------------------------------------- 1 | package airlines; 2 | 3 | import airlines.pojos.Airline; 4 | import airlines.pojos.Employee; 5 | import airlines.pojos.Gender; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import io.restassured.response.Response; 8 | import org.testng.Assert; 9 | import org.testng.annotations.Test; 10 | import reporting.ExtentReportManager; 11 | import reporting.Setup; 12 | import utils.RandomDataGenerator; 13 | 14 | import java.io.IOException; 15 | import java.util.Arrays; 16 | import java.util.stream.Stream; 17 | 18 | public class AirlineTests extends AirlineAPIs { 19 | 20 | // @Test() 21 | // public void createAirline() throws IOException { 22 | // //Airline payload = Payloads.getCreateAirlinePayloadFromPojo(); 23 | // //Airline payload = new Airline(); 24 | //// Airline payload = new Airline().toBuilder().name("Amod").build(); 25 | //// Response response = createAirline(payload); 26 | //// Assert.assertEquals(response.statusCode(), 200); 27 | // Airline payload = new Airline().toBuilder().build(); 28 | // System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(payload)); 29 | // } 30 | 31 | // @Test() 32 | // public void createAirlineAndVerifyResponse() throws IOException { 33 | // Airline payload = new Airline(); 34 | // Response response = createAirline(payload); 35 | // payload.setCountry("RandomCOuntry"); 36 | // 37 | // // first way 38 | // Assert.assertEquals(response.jsonPath().getString("name"), payload.getName()); 39 | // 40 | // ObjectMapper objectMapper = new ObjectMapper(); 41 | // Airline createAirlineResponse = objectMapper.readValue(response.getBody().asString(), Airline.class); 42 | // Assert.assertEquals(createAirlineResponse, payload); 43 | // } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/airlines/AirlineTestsNew.java: -------------------------------------------------------------------------------- 1 | package airlines; 2 | 3 | import airlines.pojos.Airline; 4 | import airlines.pojos.AirlinePoiji; 5 | import com.poiji.bind.Poiji; 6 | import io.restassured.response.Response; 7 | import org.testng.annotations.DataProvider; 8 | import org.testng.annotations.Test; 9 | import restUtils.AssertionUtils; 10 | import utils.ExcelUtils; 11 | import utils.RandomDataGenerator; 12 | 13 | import java.io.File; 14 | import java.io.IOException; 15 | import java.util.*; 16 | 17 | public class AirlineTestsNew extends AirlineAPIs{ 18 | 19 | @Test 20 | public void createAirlineAndVerify() { 21 | Airline request = Payloads.getCreateAirlinePayloadFromPojo(); 22 | Response response = createAirline(request); 23 | Map expectedValueMap = new HashMap<>(); 24 | expectedValueMap.put("id", request.getId()); 25 | expectedValueMap.put("name", request.getName()+ "dfsef"); 26 | expectedValueMap.put("country", request.getCountry()); 27 | expectedValueMap.put("logo", request.getLogo()+ "dsfsd"); 28 | expectedValueMap.put("slogan", request.getSlogan()); 29 | expectedValueMap.put("head_quaters", request.getHead_quaters()); 30 | expectedValueMap.put("website", request.getWebsite()); 31 | expectedValueMap.put("established", request.getEstablished()); 32 | AssertionUtils.assertExpectedValuesWithJsonPath(response, expectedValueMap); 33 | } 34 | 35 | 36 | @Test(dataProvider = "airlineData" ) 37 | public void createAirlineAndVerify(Airline airline) { 38 | Response response = createAirline(airline); 39 | Map expectedValueMap = new HashMap<>(); 40 | expectedValueMap.put("id", airline.getId()); 41 | expectedValueMap.put("name", airline.getName()); 42 | expectedValueMap.put("country", airline.getCountry()); 43 | expectedValueMap.put("logo", airline.getLogo()); 44 | expectedValueMap.put("slogan", airline.getSlogan()); 45 | expectedValueMap.put("head_quaters", airline.getHead_quaters()); 46 | expectedValueMap.put("website", airline.getWebsite()); 47 | expectedValueMap.put("established", airline.getEstablished()); 48 | AssertionUtils.assertExpectedValuesWithJsonPath(response, expectedValueMap); 49 | } 50 | 51 | 52 | @Test(dataProvider = "airlineDataPoiji" ) 53 | public void createAirlineAndVerifyPoiji(Airline airline) { 54 | 55 | String cellValue = airline.getIdValue(); 56 | int size = 6; 57 | if(cellValue.contains("RandomNumber")) { 58 | // With size 59 | if(cellValue.contains("_")) { 60 | size = Integer.parseInt((cellValue.split("_"))[1]); 61 | } 62 | cellValue = RandomDataGenerator.getRandomNumber(size); 63 | } 64 | 65 | airline.setId(Integer.parseInt(cellValue)); 66 | 67 | Response response = createAirline(airline); 68 | Map expectedValueMap = new HashMap<>(); 69 | expectedValueMap.put("id", airline.getId()); 70 | expectedValueMap.put("name", airline.getName()); 71 | expectedValueMap.put("country", airline.getCountry()); 72 | expectedValueMap.put("logo", airline.getLogo()); 73 | expectedValueMap.put("slogan", airline.getSlogan()); 74 | expectedValueMap.put("head_quaters", airline.getHead_quaters()); 75 | expectedValueMap.put("website", airline.getWebsite()); 76 | expectedValueMap.put("established", airline.getEstablished()); 77 | AssertionUtils.assertExpectedValuesWithJsonPath(response, expectedValueMap); 78 | } 79 | 80 | @DataProvider(name = "airlineData") 81 | public Iterator getCreateAirlineData() throws IOException { 82 | List> excelDataAsListOfMap = ExcelUtils.getExcelDataAsListOfMap("CreateAirlineData", "Sheet1"); 83 | System.out.println(excelDataAsListOfMap); 84 | List airlineData = new ArrayList<>(); 85 | for(LinkedHashMap data : excelDataAsListOfMap) { 86 | Airline airline = Airline.builder() 87 | .id(Integer.parseInt(data.get("Id"))) 88 | .name(data.get("Name")) 89 | .country(data.get("Country")) 90 | .logo(data.get("Logo")) 91 | .established(data.get("Established")) 92 | .website(data.get("Website")) 93 | .slogan(data.get("Slogan")) 94 | .head_quaters(data.get("HeadQuarter")) 95 | .build(); 96 | airlineData.add(airline); 97 | } 98 | return airlineData.iterator(); 99 | } 100 | 101 | @DataProvider(name = "airlineDataPoiji") 102 | public Iterator getCreateAirlineDataPoiji() throws IOException { 103 | List airlineData = Poiji.fromExcel(new File("src/test/resources/testdata/CreateAirlineData.xlsx"), 104 | Airline.class); 105 | return airlineData.iterator(); 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/test/java/airlines/AirlineTestsScenarios.java: -------------------------------------------------------------------------------- 1 | package airlines; 2 | 3 | import airlines.pojos.CreateAirline; 4 | import com.aventstack.extentreports.ExtentReports; 5 | import com.aventstack.extentreports.ExtentTest; 6 | import io.restassured.response.Response; 7 | import org.testng.Assert; 8 | import org.testng.annotations.DataProvider; 9 | import org.testng.annotations.Test; 10 | import reporting.ExtentReportManager; 11 | import reporting.Setup; 12 | import restUtils.AssertionUtils; 13 | import utils.ExcelUtils; 14 | 15 | import java.io.IOException; 16 | import java.util.*; 17 | 18 | public class AirlineTestsScenarios extends AirlineAPIs{ 19 | 20 | @Test(dataProvider = "airlineData" ) 21 | public void createAirlineAndVerify(CreateAirline airline) { 22 | 23 | ExtentTest test = Setup.extentReports.createTest("Test Name - " + airline.getScenarioId(), 24 | airline.getScenarioDesc()); 25 | Setup.extentTest.set(test); 26 | 27 | Response response = createAirline(airline); 28 | 29 | if(airline.getExpectedStatusCode() != 200){ 30 | if(airline.getScenarioId().equalsIgnoreCase("CreateAirline_DuplicateID")) 31 | response = createAirline(airline); 32 | Assert.assertEquals(response.getStatusCode(), airline.getExpectedStatusCode()); 33 | Assert.assertEquals(response.jsonPath().getString("message"), airline.getExpectedErrorMessage()); 34 | } 35 | else { 36 | Map expectedValueMap = new HashMap<>(); 37 | expectedValueMap.put("id", airline.getId()); 38 | expectedValueMap.put("name", airline.getName()); 39 | expectedValueMap.put("country", airline.getCountry()); 40 | expectedValueMap.put("logo", airline.getLogo()); 41 | expectedValueMap.put("slogan", airline.getSlogan()); 42 | expectedValueMap.put("head_quaters", airline.getHead_quaters()); 43 | expectedValueMap.put("website", airline.getWebsite()); 44 | expectedValueMap.put("established", airline.getEstablished()); 45 | 46 | if(airline.getScenarioId().equalsIgnoreCase("CreateAirline_WithoutID")) { 47 | expectedValueMap.remove("id"); 48 | } 49 | AssertionUtils.assertExpectedValuesWithJsonPath(response, expectedValueMap); 50 | } 51 | 52 | } 53 | 54 | @DataProvider(name = "airlineData") 55 | public Iterator getCreateAirlineData() throws IOException { 56 | List> excelDataAsListOfMap = ExcelUtils 57 | .getExcelDataAsListOfMap("CreateAirlineDataScenarios", "Sheet1"); 58 | List airlineData = new ArrayList<>(); 59 | for(LinkedHashMap data : excelDataAsListOfMap) { 60 | CreateAirline airline = getCustomizedAirlineData(data); 61 | airlineData.add(airline); 62 | } 63 | return airlineData.iterator(); 64 | } 65 | 66 | private CreateAirline getCustomizedAirlineData(LinkedHashMap data) { 67 | CreateAirline createAirline = new CreateAirline(); 68 | createAirline.setScenarioId(data.get("ScenaroID")); 69 | createAirline.setScenarioDesc(data.get("ScenarioDesc")); 70 | createAirline.setExpectedStatusCode(Integer.parseInt(data.get("ExpectedStatusCode"))); 71 | if(!data.get("ExpectedErrorMessage").equals("NO_DATA")) 72 | createAirline.setExpectedErrorMessage(data.get("ExpectedErrorMessage")); 73 | if(!data.get("Id").equalsIgnoreCase("NO_DATA")) 74 | createAirline.setId(Integer.parseInt(data.get("Id"))); 75 | if(!data.get("Name").equalsIgnoreCase("NO_DATA")) 76 | createAirline.setName(data.get("Name")); 77 | if(!data.get("Country").equalsIgnoreCase("NO_DATA")) 78 | createAirline.setCountry(data.get("Country")); 79 | if(!data.get("Logo").equalsIgnoreCase("NO_DATA")) 80 | createAirline.setLogo(data.get("Logo")); 81 | if(!data.get("Slogan").equalsIgnoreCase("NO_DATA")) 82 | createAirline.setSlogan(data.get("Slogan")); 83 | if(!data.get("HeadQuarter").equalsIgnoreCase("NO_DATA")) 84 | createAirline.setHead_quaters(data.get("HeadQuarter")); 85 | if(!data.get("Website").equalsIgnoreCase("NO_DATA")) 86 | createAirline.setWebsite(data.get("Website")); 87 | if(!data.get("Established").equalsIgnoreCase("NO_DATA")) 88 | createAirline.setEstablished(data.get("Established")); 89 | 90 | return createAirline; 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/test/java/airlines/Base.java: -------------------------------------------------------------------------------- 1 | package airlines; 2 | 3 | import utils.JsonUtils; 4 | 5 | import java.io.IOException; 6 | import java.util.Map; 7 | 8 | public class Base { 9 | 10 | public static Map dataFromJsonFile; 11 | 12 | static { 13 | String env = System.getProperty("env") == null ? "qa" : System.getProperty("env"); 14 | try { 15 | dataFromJsonFile = JsonUtils.getJsonDataAsMap("airlines/"+env+"/airlinesApiData.json"); 16 | } catch (IOException e) { 17 | e.printStackTrace(); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/java/airlines/ExcelTest.java: -------------------------------------------------------------------------------- 1 | package airlines; 2 | 3 | import com.fasterxml.jackson.core.type.TypeReference; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import org.apache.poi.ss.formula.functions.T; 6 | import utils.ExcelUtils; 7 | 8 | import java.io.IOException; 9 | 10 | public class ExcelTest { 11 | 12 | public static void main(String[] args) throws IOException { 13 | System.out.println(ExcelUtils.getExcelDataAsListOfMap("CreateAirlineData", "Sheet1")); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/airlines/InstancioExample.java: -------------------------------------------------------------------------------- 1 | package airlines; 2 | 3 | import airlines.pojos.Airline; 4 | import airlines.pojos.CreateAirline; 5 | import airlines.pojos.Gender; 6 | import airlines.pojos.Student; 7 | import com.fasterxml.jackson.core.JsonProcessingException; 8 | import com.fasterxml.jackson.databind.ObjectMapper; 9 | import org.instancio.GeneratorSpecProvider; 10 | import org.instancio.Instancio; 11 | import org.instancio.Select; 12 | import org.instancio.generator.Generator; 13 | import org.instancio.generator.GeneratorSpec; 14 | 15 | import java.util.ArrayList; 16 | import java.util.Arrays; 17 | import java.util.List; 18 | import java.util.Set; 19 | 20 | public class InstancioExample { 21 | public static void main(String[] args) throws JsonProcessingException { 22 | Student createAirline = Instancio.create(Student.class); 23 | System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(createAirline)); 24 | 25 | Set list = Instancio.ofSet(Student.class).size(10).create(); 26 | System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(list)); 27 | 28 | Student ss = Instancio.of(Student.class) 29 | .ignore(Select.field("logo")) 30 | .generate(Select.field("id"), gen -> gen.ints().range(18, 65)) 31 | //.generate(Select.field("established"), gen -> gen.oneOf(Arrays.asList("abc","Def"))) 32 | .generate(Select.field("established"), gen -> gen.temporal().localDateTime().past().asString()) 33 | .generate(Select.field("name"), gen -> gen.text().pattern("#d#d#d-#d#d-#d#d")) 34 | .create(); 35 | 36 | System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(ss)); 37 | 38 | Student ss1 = Instancio.of(Student.class) 39 | .ignore(Select.field("slogan")) 40 | .ignore(Select.field(Airline.class, "country")) 41 | .create(); 42 | 43 | System.out.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(ss1)); 44 | 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/airlines/Payloads.java: -------------------------------------------------------------------------------- 1 | package airlines; 2 | 3 | import airlines.pojos.Airline; 4 | import utils.DateUtils; 5 | import utils.RandomDataGenerator; 6 | import utils.RandomDataTypeNames; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | public class Payloads { 12 | 13 | public static String getCreateAirlinePayloadFromString(String id, String name, String country, String logo, 14 | String slogan, String head_quaters, String website, String established) { 15 | String payload = "{\n" + 16 | " \"id\": "+id+",\n" + 17 | " \"name\": \""+name+"\",\n" + 18 | " \"country\": \""+country+"\",\n" + 19 | " \"logo\": \""+logo+"\",\n" + 20 | " \"slogan\": \""+slogan+"\",\n" + 21 | " \"head_quaters\": \""+head_quaters+"\",\n" + 22 | " \"website\": \""+website+"\",\n" + 23 | " \"established\": \""+established+"\"\n" + 24 | "}"; 25 | return payload; 26 | } 27 | 28 | public static Map getCreateAirlinePayloadFromMap(String id, String name, String country, String logo, 29 | String slogan, String head_quaters, String website, String established) { 30 | Map payload = new HashMap<>(); 31 | payload.put("id", id); 32 | payload.put("name", name); 33 | payload.put("country", country); 34 | payload.put("logo", logo); 35 | payload.put("slogan", slogan); 36 | payload.put("head_quaters", head_quaters); 37 | payload.put("website", website); 38 | payload.put("established", established); 39 | return payload; 40 | } 41 | 42 | public static Map getCreateAirlinePayloadFromMap() { 43 | Map payload = new HashMap<>(); 44 | payload.put("id", RandomDataGenerator.getRandomNumber(10)); 45 | payload.put("name", RandomDataGenerator.getRandomDataFor(RandomDataTypeNames.FIRSTNAME)); 46 | payload.put("country", RandomDataGenerator.getRandomDataFor(RandomDataTypeNames.COUNTRY)); 47 | payload.put("logo", RandomDataGenerator.getRandomAlphabets(25)); 48 | payload.put("slogan", RandomDataGenerator.getRandomAlphabets(20)); 49 | payload.put("head_quaters", RandomDataGenerator.getRandomDataFor(RandomDataTypeNames.CITYNAME)); 50 | payload.put("website", RandomDataGenerator.getRandomWebsiteName()); 51 | payload.put("established", RandomDataGenerator.getRandomNumber(1900, DateUtils.getCurrentYear())); 52 | return payload; 53 | } 54 | 55 | public static Airline getCreateAirlinePayloadFromPojo() { 56 | return Airline 57 | .builder() 58 | .id(Integer.parseInt(RandomDataGenerator.getRandomNumber(6))) 59 | .name(RandomDataGenerator.getRandomDataFor(RandomDataTypeNames.FIRSTNAME)) 60 | .country(RandomDataGenerator.getRandomDataFor(RandomDataTypeNames.COUNTRY)) 61 | .logo(RandomDataGenerator.getRandomAlphabets(25)) 62 | .slogan(RandomDataGenerator.getRandomAlphabets(20)) 63 | .head_quaters(RandomDataGenerator.getRandomDataFor(RandomDataTypeNames.CITYNAME)) 64 | .website(RandomDataGenerator.getRandomWebsiteName()) 65 | .established(String.valueOf(RandomDataGenerator.getRandomNumber(1900, DateUtils.getCurrentYear()))) 66 | .build(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/test/java/airlines/PoijiTests.java: -------------------------------------------------------------------------------- 1 | package airlines; 2 | 3 | import airlines.pojos.AirlinePoiji; 4 | import com.fasterxml.jackson.core.JsonProcessingException; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | import com.poiji.bind.Poiji; 7 | import com.poiji.option.PoijiOptions; 8 | import utils.RandomDataGenerator; 9 | 10 | import java.io.File; 11 | import java.util.List; 12 | 13 | public class PoijiTests { 14 | 15 | public static void main(String[] args) throws JsonProcessingException { 16 | PoijiOptions option = PoijiOptions.PoijiOptionsBuilder.settings().addListDelimiter(";").build(); 17 | List data = Poiji.fromExcel(new File("src/test/resources/testdata/CreateAirlineData.xlsx"), 18 | AirlinePoiji.class, option); 19 | System.out.println(data); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/airlines/javersExamples/Address.java: -------------------------------------------------------------------------------- 1 | package airlines.javersExamples; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | @Getter 7 | @Setter 8 | public class Address { 9 | 10 | private int id; 11 | private String addressLine; 12 | } 13 | -------------------------------------------------------------------------------- /src/test/java/airlines/javersExamples/JaversTest.java: -------------------------------------------------------------------------------- 1 | package airlines.javersExamples; 2 | 3 | import org.javers.core.Javers; 4 | import org.javers.core.JaversBuilder; 5 | import org.javers.core.diff.Diff; 6 | import org.javers.core.diff.ListCompareAlgorithm; 7 | 8 | import java.util.Arrays; 9 | 10 | public class JaversTest { 11 | public static void main(String[] args) { 12 | 13 | Student s1 = new Student(); 14 | s1.setId(1); 15 | s1.setName("Amod"); 16 | 17 | Address a1 = new Address(); 18 | a1.setId(100); 19 | a1.setAddressLine("Address line 1"); 20 | 21 | Address a2 = new Address(); 22 | a2.setId(200); 23 | a2.setAddressLine("Address line 2"); 24 | 25 | s1.setAddress(Arrays.asList(a1, a2)); 26 | 27 | Student s2 = new Student(); 28 | s2.setId(1); 29 | s2.setName("Amod"); 30 | s2.setAddress(Arrays.asList(a2, a1)); 31 | 32 | Javers javers = JaversBuilder.javers() 33 | .withListCompareAlgorithm(ListCompareAlgorithm.AS_SET).build(); 34 | Diff diff = javers.compare(s2, s1); 35 | System.out.println(diff.prettyPrint()); 36 | System.out.println(diff.getChanges()); 37 | 38 | // 100 Address Line 1, 200 Address Line 2 ==> S1 39 | // 200 Address Line 2, 100 Address Line 1 ==> S1 40 | 41 | 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/airlines/javersExamples/Student.java: -------------------------------------------------------------------------------- 1 | package airlines.javersExamples; 2 | 3 | import lombok.Getter; 4 | import lombok.Setter; 5 | 6 | import java.util.List; 7 | 8 | @Getter 9 | @Setter 10 | public class Student { 11 | private int id; 12 | private String name; 13 | private List
address; 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/airlines/pojos/Airline.java: -------------------------------------------------------------------------------- 1 | package airlines.pojos; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | import com.poiji.annotation.ExcelCell; 6 | import com.poiji.annotation.ExcelCellName; 7 | import lombok.*; 8 | import utils.DateUtils; 9 | import utils.RandomDataGenerator; 10 | import utils.RandomDataTypeNames; 11 | 12 | @Data 13 | @NoArgsConstructor 14 | @AllArgsConstructor 15 | @EqualsAndHashCode 16 | @Builder(toBuilder = true) 17 | @JsonIgnoreProperties(ignoreUnknown = true) 18 | public class Airline { 19 | 20 | //private String gender = Stream.of("male","female","others").findAny().get(); 21 | //private Gender gender = Arrays.stream(Gender.values()).findAny().get(); 22 | 23 | private int id = Integer.parseInt(RandomDataGenerator.getRandomNumber(6)); 24 | 25 | @ExcelCell(0) 26 | @JsonIgnore 27 | private String idValue; 28 | 29 | @ExcelCellName("Name") 30 | private String name = RandomDataGenerator.getRandomDataFor(RandomDataTypeNames.FIRSTNAME); 31 | @ExcelCellName("Country") 32 | private String country = RandomDataGenerator.getRandomDataFor(RandomDataTypeNames.COUNTRY); 33 | @ExcelCellName("Logo") 34 | private String logo = RandomDataGenerator.getRandomAlphabets(25); 35 | @ExcelCellName("Slogan") 36 | private String slogan = RandomDataGenerator.getRandomAlphabets(20); 37 | @ExcelCellName("HeadQuarter") 38 | private String head_quaters = RandomDataGenerator.getRandomDataFor(RandomDataTypeNames.CITYNAME); 39 | @ExcelCellName("Website") 40 | private String website = RandomDataGenerator.getRandomWebsiteName(); 41 | @ExcelCellName("Established") 42 | private String established = String.valueOf(RandomDataGenerator.getRandomNumber(1900, DateUtils.getCurrentYear())); 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/airlines/pojos/AirlinePoiji.java: -------------------------------------------------------------------------------- 1 | package airlines.pojos; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.poiji.annotation.ExcelCell; 5 | import com.poiji.annotation.ExcelCellName; 6 | import com.poiji.annotation.ExcelUnknownCells; 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | import lombok.ToString; 10 | 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | @ToString 15 | public class AirlinePoiji { 16 | 17 | @ExcelCell(0) 18 | private int id; 19 | @ExcelCellName("Name") 20 | private String name; 21 | @ExcelCellName("Country") 22 | private String country; 23 | @ExcelCellName("Logo") 24 | private String logo; 25 | @ExcelCellName("Slogan") 26 | private String slogan; 27 | @ExcelCellName("HeadQuarter") 28 | private List head_quaters; 29 | @ExcelCellName("Website") 30 | private String website; 31 | @ExcelCellName("Established") 32 | private String established; 33 | 34 | @ExcelUnknownCells 35 | private Map extracells; 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/airlines/pojos/BasePojo.java: -------------------------------------------------------------------------------- 1 | package airlines.pojos; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | @Getter 8 | @Setter 9 | public class BasePojo { 10 | 11 | @JsonIgnore 12 | private String scenarioId; 13 | @JsonIgnore 14 | private String scenarioDesc; 15 | @JsonIgnore 16 | private int expectedStatusCode; 17 | @JsonIgnore 18 | private String expectedErrorMessage; 19 | } 20 | -------------------------------------------------------------------------------- /src/test/java/airlines/pojos/CompareObjects.java: -------------------------------------------------------------------------------- 1 | package airlines.pojos; 2 | 3 | import java.util.HashSet; 4 | 5 | public class CompareObjects { 6 | 7 | public static void main(String[] args) { 8 | 9 | Employee employee1 = new Employee(1, "Amod","male"); 10 | Employee employee2 = new Employee(2, "Amod", "male"); 11 | 12 | //System.out.println(employee1 == employee2); 13 | System.out.println(employee1.equals(employee2)); 14 | 15 | HashSet set = new HashSet(); 16 | set.add(employee1); 17 | set.add(employee2); 18 | System.out.println(set); 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/java/airlines/pojos/CreateAirline.java: -------------------------------------------------------------------------------- 1 | package airlines.pojos; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonInclude; 5 | import lombok.AllArgsConstructor; 6 | import lombok.Data; 7 | import lombok.EqualsAndHashCode; 8 | import lombok.NoArgsConstructor; 9 | 10 | @Data 11 | @NoArgsConstructor 12 | @AllArgsConstructor 13 | @EqualsAndHashCode 14 | @JsonIgnoreProperties(ignoreUnknown = true) 15 | @JsonInclude(JsonInclude.Include.NON_DEFAULT) 16 | public class CreateAirline extends BasePojo{ 17 | private int id; 18 | private String name; 19 | private String country; 20 | private String logo; 21 | private String slogan; 22 | private String head_quaters; 23 | private String website; 24 | private String established; 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/airlines/pojos/Employee.java: -------------------------------------------------------------------------------- 1 | package airlines.pojos; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.EqualsAndHashCode; 5 | 6 | import java.util.Objects; 7 | 8 | @AllArgsConstructor 9 | @EqualsAndHashCode 10 | public class Employee { 11 | private int id; 12 | private String name; 13 | private String gender; 14 | } 15 | -------------------------------------------------------------------------------- /src/test/java/airlines/pojos/Gender.java: -------------------------------------------------------------------------------- 1 | package airlines.pojos; 2 | 3 | public enum Gender { 4 | male, 5 | female, 6 | others 7 | } 8 | -------------------------------------------------------------------------------- /src/test/java/airlines/pojos/Student.java: -------------------------------------------------------------------------------- 1 | package airlines.pojos; 2 | 3 | import lombok.Data; 4 | import lombok.EqualsAndHashCode; 5 | 6 | 7 | @EqualsAndHashCode 8 | @Data 9 | public class Student { 10 | private int id; 11 | private String name; 12 | private String country; 13 | private boolean logo; 14 | private double slogan; 15 | private String head_quaters; 16 | private String website; 17 | private String established; 18 | private Airline gender; 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/airlines/dev/airlinesApiData.json: -------------------------------------------------------------------------------- 1 | { 2 | "createAirLineEndpoint" : "https://api.instantwebtools.net/v1/airlines" 3 | } -------------------------------------------------------------------------------- /src/test/resources/airlines/qa/airlinesApiData.json: -------------------------------------------------------------------------------- 1 | { 2 | "createAirLineEndpoint" : "https://api.instantwebtools.net/v1/airlines" 3 | } -------------------------------------------------------------------------------- /src/test/resources/testdata/CreateAirlineData.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amod-mahajan/RetargetCommonRestAPIAutomationFramework/8dbeb792e59577cdc7595d324a0284e5c4f4bd64/src/test/resources/testdata/CreateAirlineData.xlsx -------------------------------------------------------------------------------- /src/test/resources/testdata/CreateAirlineDataScenarios.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amod-mahajan/RetargetCommonRestAPIAutomationFramework/8dbeb792e59577cdc7595d324a0284e5c4f4bd64/src/test/resources/testdata/CreateAirlineDataScenarios.xlsx -------------------------------------------------------------------------------- /testng.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | --------------------------------------------------------------------------------