├── .gitignore
├── .gitignore~
├── .metadata
├── .lock
├── .mylyn
│ ├── .taskListIndex
│ │ ├── segments.gen
│ │ └── segments_1
│ ├── .tasks.xml.zip
│ ├── repositories.xml.zip
│ └── tasks.xml.zip
├── .plugins
│ ├── org.eclipse.core.resources
│ │ ├── .root
│ │ │ ├── .indexes
│ │ │ │ ├── history.version
│ │ │ │ ├── properties.index
│ │ │ │ └── properties.version
│ │ │ └── 2.tree
│ │ └── .safetable
│ │ │ └── org.eclipse.core.resources
│ ├── org.eclipse.core.runtime
│ │ └── .settings
│ │ │ ├── org.eclipse.core.resources.prefs
│ │ │ ├── org.eclipse.debug.ui.prefs
│ │ │ ├── org.eclipse.jdt.ui.prefs
│ │ │ ├── org.eclipse.m2e.discovery.prefs
│ │ │ ├── org.eclipse.mylyn.context.core.prefs
│ │ │ ├── org.eclipse.mylyn.monitor.ui.prefs
│ │ │ ├── org.eclipse.mylyn.tasks.ui.prefs
│ │ │ ├── org.eclipse.team.ui.prefs
│ │ │ ├── org.eclipse.ui.editors.prefs
│ │ │ ├── org.eclipse.ui.ide.prefs
│ │ │ ├── org.eclipse.ui.prefs
│ │ │ └── org.eclipse.ui.workbench.prefs
│ ├── org.eclipse.e4.workbench
│ │ └── workbench.xmi
│ ├── org.eclipse.epp.logging.aeri.ide
│ │ └── org.eclipse.epp.logging.aeri.ide.server
│ │ │ ├── local-history
│ │ │ ├── _0.fdt
│ │ │ ├── _0.fdx
│ │ │ ├── _0.fnm
│ │ │ ├── _0.frq
│ │ │ ├── _0.nrm
│ │ │ ├── _0.tii
│ │ │ ├── _0.tis
│ │ │ ├── segments.gen
│ │ │ ├── segments_1
│ │ │ └── write.lock
│ │ │ ├── remote-history
│ │ │ ├── _0.fdt
│ │ │ ├── _0.fdx
│ │ │ ├── _0.fnm
│ │ │ ├── _0.frq
│ │ │ ├── _0.nrm
│ │ │ ├── _0.tii
│ │ │ ├── _0.tis
│ │ │ ├── segments.gen
│ │ │ └── segments_1
│ │ │ └── server-config.json
│ ├── org.eclipse.jdt.core
│ │ ├── assumedExternalFilesCache
│ │ ├── externalFilesCache
│ │ ├── nonChainingJarsCache
│ │ └── variablesAndContainers.dat
│ ├── org.eclipse.jdt.ui
│ │ ├── OpenTypeHistory.xml
│ │ ├── QualifiedTypeNameHistory.xml
│ │ └── dialog_settings.xml
│ ├── org.eclipse.m2e.core.ui
│ │ └── dialog_settings.xml
│ ├── org.eclipse.m2e.core
│ │ ├── nexus
│ │ │ ├── 05b0fe8524860bd73cbb07ef30fb34cc
│ │ │ │ ├── _0.cfs
│ │ │ │ ├── _0_1.del
│ │ │ │ ├── _1.cfs
│ │ │ │ ├── segments.gen
│ │ │ │ ├── segments_3
│ │ │ │ └── write.lock
│ │ │ ├── 830bc118332e77292949ed1e6d2fabe0
│ │ │ │ ├── _0.cfs
│ │ │ │ ├── _0_1.del
│ │ │ │ ├── _1.cfs
│ │ │ │ ├── segments.gen
│ │ │ │ ├── segments_3
│ │ │ │ └── write.lock
│ │ │ └── 8afdd32e8295acd36e7a94f55f1c731e
│ │ │ │ ├── _0.cfs
│ │ │ │ ├── _0_1.del
│ │ │ │ ├── _1.cfs
│ │ │ │ ├── segments.gen
│ │ │ │ ├── segments_3
│ │ │ │ └── write.lock
│ │ └── workspaceState.ser
│ ├── org.eclipse.m2e.logback.configuration
│ │ ├── 0.log
│ │ └── logback.1.6.2.20150902-0002.xml
│ ├── org.eclipse.oomph.setup
│ │ └── workspace.setup
│ ├── org.eclipse.ui.ide
│ │ └── dialog_settings.xml
│ └── org.eclipse.ui.workbench
│ │ ├── dialog_settings.xml
│ │ └── workingsets.xml
└── version.ini
├── ReportsConfig.xml
├── pom.xml
├── readme.md
├── src
├── main
│ ├── java
│ │ └── com
│ │ │ └── framework
│ │ │ ├── commans
│ │ │ └── Commans.java
│ │ │ ├── constants
│ │ │ └── Constants.java
│ │ │ ├── epochdate
│ │ │ ├── EpochDate.java
│ │ │ └── EpochHelper.java
│ │ │ ├── inmemorydatabase
│ │ │ └── InMemoryDatabaseHelper.java
│ │ │ ├── restassured
│ │ │ ├── APIExecutorHelper.java
│ │ │ └── ApiExecutor.java
│ │ │ └── utility
│ │ │ ├── DataUtil.java
│ │ │ ├── DownloadExcelFileHelper.java
│ │ │ ├── ExcelReader.java
│ │ │ ├── ExtentManager.java
│ │ │ ├── FactoryHelper.java
│ │ │ ├── GetDynamicData.java
│ │ │ ├── GetJsonValuesFromResponse.java
│ │ │ ├── Reflection.java
│ │ │ └── RestAssuredHelper.java
│ └── resources
│ │ └── client_secret.json
└── test
│ ├── java
│ └── com
│ │ └── framework
│ │ ├── testcasesbase
│ │ └── testsuite
│ │ │ └── ApiTestFactory.java
│ │ └── testsuite
│ │ └── TestCases.java
│ └── resources
│ ├── ExcelData
│ └── FrameworkSheet.xlsx
│ ├── addplace.json
│ ├── authorizationfailure.json
│ ├── deleteplace.json
│ └── searchplace.json
└── testng.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.txt
2 | /logs/*
3 | /target/*
4 | /Reports/*
5 | /LogIssues/*
6 | /test-output/*
7 | /.classpath
8 | /.project
9 | /.settings/*
10 | /target/
11 | /hsql*
12 | /java_pid*
13 |
--------------------------------------------------------------------------------
/.gitignore~:
--------------------------------------------------------------------------------
1 | *.txt
2 | /logs/*
3 | /target/*
4 | /Reports/*
5 | /LogIssues/*
6 | /test-output/*
7 | /.classpath
8 | /.project
9 | /.settings/*
10 | /target/
11 | /hsql/
12 | /java_pid*
13 |
--------------------------------------------------------------------------------
/.metadata/.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.lock
--------------------------------------------------------------------------------
/.metadata/.mylyn/.taskListIndex/segments.gen:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.mylyn/.taskListIndex/segments.gen
--------------------------------------------------------------------------------
/.metadata/.mylyn/.taskListIndex/segments_1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.mylyn/.taskListIndex/segments_1
--------------------------------------------------------------------------------
/.metadata/.mylyn/.tasks.xml.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.mylyn/.tasks.xml.zip
--------------------------------------------------------------------------------
/.metadata/.mylyn/repositories.xml.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.mylyn/repositories.xml.zip
--------------------------------------------------------------------------------
/.metadata/.mylyn/tasks.xml.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.mylyn/tasks.xml.zip
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index:
--------------------------------------------------------------------------------
1 | / org.eclipse.jdt.core stateVersionNumber 28
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree:
--------------------------------------------------------------------------------
1 | org.eclipse.jdt.core
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | version=1
3 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\n\n
3 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs:
--------------------------------------------------------------------------------
1 | content_assist_proposals_background=255,255,255
2 | content_assist_proposals_foreground=0,0,0
3 | eclipse.preferences.version=1
4 | fontPropagated=true
5 | org.eclipse.jdt.ui.editor.tab.width=
6 | org.eclipse.jdt.ui.formatterprofiles.version=12
7 | org.eclipse.jdt.ui.javadoclocations.migrated=true
8 | org.eclipse.jface.textfont=1|Monospace|10.0|0|GTK|1|;
9 | proposalOrderMigrated=true
10 | spelling_locale_initialized=true
11 | tabWidthPropagated=true
12 | useAnnotationsPrefPage=true
13 | useQuickDiffPrefPage=true
14 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.m2e.discovery.pref.projects=
3 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | mylyn.attention.migrated=true
3 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true
3 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | migrated.task.repositories.secure.store=true
3 | org.eclipse.mylyn.tasks.ui.filters.nonmatching=true
4 | org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true
5 | org.eclipse.mylyn.tasks.ui.welcome.message=true
6 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.team.ui.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.eclipse.team.ui.first_time=false
3 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.editors.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | overviewRuler_migration=migrated_3.1
3 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs:
--------------------------------------------------------------------------------
1 | PROBLEMS_FILTERS_MIGRATE=true
2 | eclipse.preferences.version=1
3 | platformState=1485495626059
4 | quickStart=false
5 | tipsAndTricks=true
6 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | showIntro=false
3 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs:
--------------------------------------------------------------------------------
1 | //org.eclipse.ui.commands/state/org.eclipse.ui.navigator.resources.nested.changeProjectPresentation/org.eclipse.ui.commands.radioState=false
2 | PLUGINS_NOT_ACTIVATED_ON_STARTUP=org.eclipse.m2e.discovery;
3 | eclipse.preferences.version=1
4 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/_0.fdt:
--------------------------------------------------------------------------------
1 | 0.6
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/_0.fdx:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/_0.fnm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/_0.fnm
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/_0.frq:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/_0.frq
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/_0.nrm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/_0.nrm
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/_0.tii:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/_0.tii
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/_0.tis:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/_0.tis
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/segments.gen:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/segments.gen
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/segments_1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/segments_1
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/write.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/local-history/write.lock
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/_0.fdt:
--------------------------------------------------------------------------------
1 | 0.6
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/_0.fdx:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/_0.fnm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/_0.fnm
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/_0.frq:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/_0.frq
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/_0.nrm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/_0.nrm
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/_0.tii:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/_0.tii
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/_0.tis:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/_0.tis
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/segments.gen:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/segments.gen
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/segments_1:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/remote-history/segments_1
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.epp.logging.aeri.ide/org.eclipse.epp.logging.aeri.ide.server/server-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "v1",
3 | "title": "Eclipse",
4 | "timestamp": 1500722779576,
5 | "ttl": 10080,
6 | "helpUrl": "https://dev.eclipse.org/recommenders/community/aeri/v2/help/",
7 | "feedbackUrl": "http://ctrlflow.com/automated-error-reporting",
8 | "aboutUrl": "https://wiki.eclipse.org/EPP/Logging",
9 | "submitUrl": "https://dev.eclipse.org/recommenders/community/confess/0.6/reports/",
10 | "maxReportSize": 262144,
11 | "problemsUrl": "https://www.eclipse.org/downloads/download.php?r\u003d1\u0026file\u003d/technology/epp/logging/problems.zip",
12 | "problemsTtl": 20160,
13 | "connectTimeout": 10,
14 | "socketTimeout": 10,
15 | "acceptedProducts": [
16 | "org.eclipse.*",
17 | "org.fordiac.*"
18 | ],
19 | "acceptedPlugins": [
20 | "org.apache.log4j.*",
21 | "org.eclipse.*",
22 | "org.fordiac.*"
23 | ],
24 | "acceptedPackages": [
25 | "ch.qos.*",
26 | "com.cforcoding.*",
27 | "com.google.*",
28 | "com.gradleware.tooling.*",
29 | "com.mountainminds.eclemma.*",
30 | "com.naef.*",
31 | "com.sun.*",
32 | "java.*",
33 | "javafx.*",
34 | "javax.*",
35 | "org.apache.*",
36 | "org.eclipse.*",
37 | "org.fordiac.*",
38 | "org.gradle.*",
39 | "org.jacoco.*",
40 | "org.osgi.*",
41 | "org.slf4j.*",
42 | "sun.*"
43 | ],
44 | "requiredPackages": [
45 | "com.cforcoding.*",
46 | "com.gradleware.tooling.*",
47 | "com.mountainminds.eclemma.*",
48 | "com.naef.*",
49 | "org.eclipse.*",
50 | "org.fordiac.*",
51 | "org.gradle.*",
52 | "org.jacoco.*"
53 | ],
54 | "acceptOtherPackages": false,
55 | "acceptUiFreezes": true,
56 | "ignoredStatuses": [
57 | ":java.io.IOException:There is not enough space on the disk",
58 | ":java.net.*:",
59 | "org.eclipse.core.filesystem::Could not delete*",
60 | "org.eclipse.core.filesystem::Could not move*",
61 | "org.eclipse.core.resources:org.eclipse.core.internal.resources.ResourceException:Resource is out of sync with the file system*",
62 | "org.eclipse.core.runtime::Invalid input url*",
63 | "org.eclipse.epp.mpc.ui:java.io.IOException:",
64 | "org.eclipse.equinox.p2.*::",
65 | "org.eclipse.jface:java.io.IOException:Unable to resolve plug-in*",
66 | "org.eclipse.oomph.setup.core:$org.apache.http.ConnectionClosedException:",
67 | "org.eclipse.pde.core::The current target platform contains errors*",
68 | "org.eclipse.ui::Conflicting handlers for*"
69 | ],
70 | "problemsZipLastDownloadTimestamp": 0
71 | }
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat:
--------------------------------------------------------------------------------
1 | JRE_LIB TESTNG_HOME JRE_SRC JRE_SRCROOT
2 | JUNIT_HOME JUNIT_SRC_HOME M2_REPO
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core.ui/dialog_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/05b0fe8524860bd73cbb07ef30fb34cc/_0.cfs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/05b0fe8524860bd73cbb07ef30fb34cc/_0.cfs
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/05b0fe8524860bd73cbb07ef30fb34cc/_0_1.del:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/05b0fe8524860bd73cbb07ef30fb34cc/_1.cfs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/05b0fe8524860bd73cbb07ef30fb34cc/_1.cfs
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/05b0fe8524860bd73cbb07ef30fb34cc/segments.gen:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/05b0fe8524860bd73cbb07ef30fb34cc/segments.gen
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/05b0fe8524860bd73cbb07ef30fb34cc/segments_3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/05b0fe8524860bd73cbb07ef30fb34cc/segments_3
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/05b0fe8524860bd73cbb07ef30fb34cc/write.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/05b0fe8524860bd73cbb07ef30fb34cc/write.lock
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/_0.cfs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/_0.cfs
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/_0_1.del:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/_1.cfs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/_1.cfs
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/segments.gen:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/segments.gen
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/segments_3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/segments_3
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/write.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/830bc118332e77292949ed1e6d2fabe0/write.lock
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/8afdd32e8295acd36e7a94f55f1c731e/_0.cfs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/8afdd32e8295acd36e7a94f55f1c731e/_0.cfs
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/8afdd32e8295acd36e7a94f55f1c731e/_0_1.del:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/8afdd32e8295acd36e7a94f55f1c731e/_1.cfs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/8afdd32e8295acd36e7a94f55f1c731e/_1.cfs
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/8afdd32e8295acd36e7a94f55f1c731e/segments.gen:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/8afdd32e8295acd36e7a94f55f1c731e/segments.gen
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/8afdd32e8295acd36e7a94f55f1c731e/segments_3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/8afdd32e8295acd36e7a94f55f1c731e/segments_3
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/nexus/8afdd32e8295acd36e7a94f55f1c731e/write.lock:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/nexus/8afdd32e8295acd36e7a94f55f1c731e/write.lock
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.logback.configuration/0.log:
--------------------------------------------------------------------------------
1 | 2017-07-22 16:58:09,699 [main] INFO c.g.t.t.d.PublishedGradleVersions - Gradle version information cache file is not out-of-date. No remote download required.
2 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.m2e.logback.configuration/logback.1.6.2.20150902-0002.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %date [%thread] %-5level %logger{35} - %msg%n
5 |
6 |
7 | OFF
8 |
9 |
10 |
11 |
12 | ${org.eclipse.m2e.log.dir}/0.log
13 |
14 | ${org.eclipse.m2e.log.dir}/%i.log
15 | 1
16 | 10
17 |
18 |
19 | 100MB
20 |
21 |
22 | %date [%thread] %-5level %logger{35} - %msg%n
23 |
24 |
25 |
26 |
27 |
28 | WARN
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup:
--------------------------------------------------------------------------------
1 |
2 |
7 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
17 |
18 |
--------------------------------------------------------------------------------
/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.metadata/version.ini:
--------------------------------------------------------------------------------
1 | #Sat Jul 22 16:58:02 IST 2017
2 | org.eclipse.core.runtime=2
3 | org.eclipse.platform=4.5.2.v20160212-1500
4 |
--------------------------------------------------------------------------------
/ReportsConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 | UTF-8
10 |
11 |
12 |
13 | https
14 |
15 |
16 |
17 | dark
18 |
19 |
20 | Project: API Testing
21 |
22 |
23 | Regression Suite
24 |
25 |
26 | Of API Testing
27 |
28 |
29 |
30 | yyyy-MM-dd
31 |
32 |
33 |
34 | HH:mm:ss
35 |
36 |
37 |
38 |
43 |
44 |
45 |
46 |
47 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | framework
5 | framework
6 | 0.0.1-SNAPSHOT
7 |
8 |
9 |
10 |
11 |
12 |
13 | UTF-8
14 | 1.8
15 | 1.8
16 |
17 |
18 |
19 |
20 |
21 | src
22 |
23 |
24 |
25 |
26 |
27 | org.apache.maven.plugins
28 | maven-surefire-plugin
29 | 2.19.1
30 |
31 | true
32 |
33 |
34 |
35 | testng.xml
36 |
37 |
38 |
39 |
40 |
41 |
42 | org.apache.maven.plugins
43 | maven-compiler-plugin
44 | 3.6.1
45 |
46 | 1.8
47 | 1.8
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.hsqldb
64 | hsqldb
65 | 2.4.0
66 |
67 |
68 |
69 | org.testng
70 | testng
71 | 6.11
72 |
73 |
74 |
75 | org.seleniumhq.selenium
76 | selenium-java
77 | 3.0.1
78 |
79 |
80 |
81 | org.apache.poi
82 | poi
83 | 3.16
84 |
85 |
86 |
87 | com.jayway.jsonpath
88 | json-path
89 | 2.2.0
90 |
91 |
92 |
93 | com.github.wnameless
94 | json-flattener
95 | 0.2.2
96 |
97 |
98 |
99 | org.apache.poi
100 | poi-ooxml
101 | 3.16
102 |
103 |
104 |
105 |
106 | io.rest-assured
107 | rest-assured
108 | 3.0.3
109 |
110 |
111 | io.rest-assured
112 | json-schema-validator
113 | 3.0.3
114 |
115 |
116 |
117 | log4j
118 | log4j
119 | 1.2.17
120 |
121 |
122 |
123 | org.json
124 | json
125 | 20160810
126 |
127 |
128 |
129 | net.javacrumbs.json-unit
130 | json-unit
131 | 1.17.0
132 |
133 |
134 |
135 | com.relevantcodes
136 | extentreports
137 | 2.41.2
138 |
139 |
140 |
141 | com.google.api-client
142 | google-api-client
143 | 1.22.0
144 |
145 |
146 |
147 | com.google.oauth-client
148 | google-oauth-client-jetty
149 | 1.22.0
150 |
151 |
152 | com.google.apis
153 | google-api-services-drive
154 | v3-rev72-1.22.0
155 |
156 |
157 |
158 |
159 |
160 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # API Framework
2 |
3 |
4 | ## Introduction
5 |
6 | API Framework that does not require you to write code for almost all APIS.
7 |
8 | ## Requirements
9 |
10 | * Java 1.8
11 | * Install maven.
12 |
13 | ## Getting Started
14 |
15 | * Clone repository.
16 | * For running existing example(Excel sheet) follow below steps.
17 | * Generate key from google place [Click here](https://developers.google.com/places/web-service/get-api-key) and click on **GET A KEY** button:
18 | * Go to src/test/resources/ExcelData
19 | * Open Excel **googleplace** sheet and modify $$$$$$$ from parameters column to above generated key.
20 |
21 | For more detail refer guidelines.
22 |
23 | ## Optional Configuration[Google drive support]
24 |
25 | * Delete client_secret.json from src/main/resources.
26 | * Turn on the [Drive api](https://developers.google.com/drive/v2/web/quickstart/java) (Step 1 only)
27 | * Move client_secret.json to src/main/resources and give file name **client_secret.json**
28 | * Go to src/test/resources/ExcelData
29 | * Upload excel file to your drive and open with google spreadsheet.
30 | * Copy **excel id**:
31 | * Go to src/main/java/com/framework/constants >> Constants.java
32 | * Search EXCELFILEPATH variable and change to above **excel id** and save file.
33 | * Modify/check your **Application Name** in com.framework.constants >> Constants.java >> APPLICATIONNAME(As per given in google drive)
34 |
35 |
36 | ## Operators
37 |
38 | Number|Operator | Example | Description
39 | ---|--- | --- | ---
40 | 1| # # |#Sheet Name.Test Id.Path# | Single dynamic value replacement.
41 | 2| @ @ |@Sheet Name.Test Id.Path[0]@ | Single dynamic value replacement from dynamic list.
42 | 3| @ @ |@Sheet Name.Test Id.Path@ | List value replacement for **Assert response** only.
43 |
44 |
45 | ## Guidelines
46 |
47 | ### Run mode for TestFlow:
48 |
49 | Runmode helps for running particular TestFlow.
50 |
51 | Test Id | Test Mode | Test Flow Name | Test Case Name
52 | --- | --- | --- | ---
53 | 1 | Yes | Get Token for users | getAccessTokenForOpsUser
54 | 2 | | | getAccessTokenForWMGJ|
55 | 3 | No |Get To Be Paid Package| getToBePaidPackageGJLP |
56 |
57 | 
58 |
59 | ### Extract response value:
60 |
61 | Extract values from the "**API response**" and use for the next **"Test Cases or Flows**.
62 |
63 | Number|Function |Test Method and json path |Result
64 | ---|---|---|---
65 | 1|extractString|**extractString**:$.responseData.X-Authorization-Token|The X-Authorization-Token Value
66 | 2|extractNumber|**extractNumber**:$.responseData.packages[0].amount|Amount First From Packages.
67 | 3|extractLong|**extractLong**:$.responseData.payment.lpTransaction.transactionDate |The Transaction Date |Value(Epoch form)
68 | 4|extractBoolean|**extractBoolean**:$.status |The Status Value
69 | 5|extractStringList|**extractStringList**:$.responseData.payments[*].lpTransaction.status |All Staus from Payments.
70 | 6|extractLongList |**extractLongList**:$.responseData[*].createdOn|All Created On Dates(Epoch form)
71 |
72 | 
73 |
74 | ### Extract dynamic value for TestCases.
75 |
76 | Extract dynamic values use for **dynamic value replacement** from the "**API response**" for the below column:
77 |
78 | * Test Url
79 | * Test Input Json
80 | * Test Headers
81 | * Test Parameters
82 | * Test Assert Response
83 |
84 | For Example
85 |
86 | Number|Column Name | Syntax | Example | Result
87 | ---|---|---|---|---
88 | 1|All above column|**#Sheet Name.Test Id.path#**|#googleplace.1.lng#| Get 1st Test Id Value from googleplace sheet.
89 | 2|All above column|**@Sheet Name.Test Id.Path[0]@**|@manifest.14.id[0]@|Get 1st Value from List of 14 Test case.
90 | 3|Test Assert Response|**@Sheet Name.Test Id.Path@**|@googleplace.24.status@ |Get All vallue from List of 24 Test Case.
91 |
92 | **Compare more than 2** value in Test Assert Response use "**;**"
93 |
94 | For e.g
95 |
96 | googleplace.15.reconciliationStatus#,#googleplace.14.reconciliationStatus#**;**#googleplace.14.reconciliationStatus#,to_be_paid
97 |
98 | 
99 |
100 | ### Schema validation for response.
101 |
102 | * Add your schema under src/test/resources
103 |
104 | Test Schema Name |
105 | ---|
106 | accesstokensuccess.json|
107 |
108 | #### Epoch Date for parameters:
109 |
110 | **Extract dynamic values for below data**:
111 |
112 | * startdatetoday
113 | * enddatetoday
114 | * startdateyesterday
115 | * enddateyesterday
116 | * startdatethisweek
117 | * startdatelastsevendays
118 | * startdatethismonth
119 | * startdatelastmonth
120 | * enddatelastmonth
121 | * startdatecustomrange
122 |
123 | For Example
124 |
125 | * **Test Parameters**: ?createdFrom=#epoch.0.startdatetoday#&createdTo=#epoch.0.enddatetoday#
126 |
127 | ## Run
128 |
129 | * mvn clean compile test **or** Open testng.xml file and Run As TestNG Suite.
130 | * If user do **Optional configuration** a new window will generate and select previously used email address.
131 | * Click on **Allow** button.
132 |
133 | ## Reports
134 |
135 | * Open Reports folder after running framework.
136 | * Report will generate for each TestFlow.
137 |
138 | 
139 |
140 | ## Limitation
141 |
142 | If user retrieves **List of value** from response for e.g @googleplace.24.status@ and user want to replace all list value to URL,Parameters,Headers is not possible.
143 |
144 | **Alternate**:User can replace with @googleplace.24.status[0]@ or @googleplace.24.status[1]@
--------------------------------------------------------------------------------
/src/main/java/com/framework/commans/Commans.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.commans;
5 |
6 | import java.sql.Connection;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | /**
11 | * @author nikhil
12 | *
13 | */
14 | public class Commans {
15 |
16 | public static class DataUtilCommans {
17 | public static String BASEURL = "";
18 | public static int count = 0;
19 |
20 | }
21 |
22 | public static class InMemoryDatabaseHelperCommans {
23 | public static Connection connectionObj = null;
24 | }
25 |
26 | public static class FactoryHelperCommans {
27 | public static List sheetsName = new ArrayList();
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/framework/constants/Constants.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.constants;
5 |
6 | /**
7 | * @author nikhil
8 | *
9 | */
10 | public class Constants {
11 | public static final String PROJECT_PATH = System.getProperty("user.dir");
12 |
13 | public static final String PROJECT_OS = System.getProperty("os.name");
14 |
15 | public static final String EXCEL_PATH = PROJECT_PATH + java.io.File.separatorChar + "src"
16 | + java.io.File.separatorChar + "test" + java.io.File.separatorChar + "resources"
17 | + java.io.File.separatorChar + "ExcelData" + java.io.File.separatorChar + "FrameworkSheet.xlsx";
18 |
19 | public static final String SCHEMA_PATH = PROJECT_PATH + java.io.File.separatorChar + "target"
20 | + java.io.File.separatorChar + "test-classes" + java.io.File.separatorChar + "schemas"
21 | + java.io.File.separatorChar;
22 |
23 | public static final String LOG4J_PATH = PROJECT_PATH + java.io.File.separatorChar + "log4j.properties";
24 |
25 | public static final String REPORTS_PATH = PROJECT_PATH + java.io.File.separatorChar + "Reports"
26 | + java.io.File.separatorChar;
27 |
28 | public static class DataUtilConstants {
29 | public static final StringBuffer RUNMODE = new StringBuffer("Yes");
30 | }
31 |
32 | public static class FactoryHelperConstants {
33 | public static final StringBuffer SHEETNAME = new StringBuffer("testsuite");
34 | }
35 |
36 | public static class ApiTestFactoryConstants{
37 | public static final StringBuffer SHEETNAME = new StringBuffer("epoch");
38 | }
39 |
40 | public static class DownloadExcelFileHelperConstants {
41 | public static final StringBuffer EXCELFILEPATH = new StringBuffer(
42 | "");
43 | public static final StringBuffer CLIENTSECRETJSON = new StringBuffer("/client_secret.json");
44 | public static final StringBuffer FILETYPE = new StringBuffer(
45 | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
46 | public static final StringBuffer APPLICATIONNAME = new StringBuffer("Drive API Quickstart");
47 | public static final StringBuffer LOCATIONOFCREDENTIAL = new StringBuffer(
48 | ".credentials/loaction/drive-java-quickstart.json");
49 | }
50 |
51 | public static class ApiExecutorConstants {
52 | public static final StringBuffer CONTENTTYPE = new StringBuffer("application/json");
53 | }
54 |
55 | public static class RestAssuredHelperConstant {
56 | public static final String POST = "post";
57 | public static final String GET = "get";
58 | public static final String PUT = "put";
59 | public static final String DELETE = "delete";
60 | public static final String PATCH = "patch";
61 | }
62 |
63 | public static class ExcelColumnNameConstant {
64 | public static final StringBuffer TESTID = new StringBuffer("test id");
65 | public static final StringBuffer TESTMODE = new StringBuffer("test mode");
66 | public static final StringBuffer TESTFLOWNAME = new StringBuffer("test flow name");
67 | public static final StringBuffer TESTCASENAME = new StringBuffer("test case name");
68 | public static final StringBuffer TESTAPITYPE = new StringBuffer("test api type");
69 | public static final StringBuffer TESTURL = new StringBuffer("test url");
70 | public static final StringBuffer TESTINPUTJSON = new StringBuffer("test input json");
71 | public static final StringBuffer TESTHEADERS = new StringBuffer("test headers");
72 | public static final StringBuffer TESTSCHEMANAME = new StringBuffer("test schema name");
73 | public static final StringBuffer TESTEXPECTEDSTATUSCODE = new StringBuffer("test expected status code");
74 | public static final StringBuffer TESTPARAMETERS = new StringBuffer("test parameters");
75 | public static final StringBuffer TESTMETHODANDJSONPATH = new StringBuffer("test method and json path");
76 | public static final StringBuffer TESTASSERTRESPONSE = new StringBuffer("test assert response");
77 | }
78 |
79 | public static class InMemoryDatabaseHelperConstant {
80 | public static final StringBuffer HSQLDBJDBCDRIVER = new StringBuffer("org.hsqldb.jdbc.JDBCDriver");
81 | public static final StringBuffer CREATINGCONNECTIONFORHSQLDB = new StringBuffer("jdbc:hsqldb:mem:.");
82 | public static final StringBuffer TABLENAME = new StringBuffer("testcase_response");
83 | public static final StringBuffer TESTCASEID = new StringBuffer("tcid");
84 | public static final StringBuffer SHEETNAME = new StringBuffer("sheetname");
85 | public static final StringBuffer PATHVALUE = new StringBuffer("pathvalue");
86 | public static final StringBuffer RESPONSEVALUE = new StringBuffer("responsevalue");
87 | }
88 |
89 | public static class RestUtilConstant {
90 | public static final StringBuffer RESTUTILCLASSNAME = new StringBuffer(
91 | "com.framework.utility.GetJsonValuesFromResponse");
92 | }
93 |
94 | public static class EpochDateHelperConstant {
95 | public static final String TESTCASEID = "0";
96 | public static final String STARTTODAY = "startdatetoday";
97 | public static final String ENDTODAY = "enddatetoday";
98 | public static final String STARTYESTERDAY = "startdateyesterday";
99 | public static final String ENDYESTERDAY = "enddateyesterday";
100 | public static final String STARTTHISWEEK = "startdatethisweek";
101 | public static final String STARTLASTSEVENDAYS = "startdatelastsevendays";
102 | public static final String STARTTHISMONTH = "startdatethismonth";
103 | public static final String STARTLASTMONTH = "startdatelastmonth";
104 | public static final String ENDLASTMONTH = "enddatelastmonth";
105 | public static final String STARTCUSTOMRANGE = "startdatecustomrange";
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/java/com/framework/epochdate/EpochDate.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.epochdate;
5 |
6 | import java.util.Date;
7 |
8 | import com.framework.constants.Constants.EpochDateHelperConstant;
9 | import com.framework.constants.Constants.InMemoryDatabaseHelperConstant;
10 | import com.framework.inmemorydatabase.InMemoryDatabaseHelper;
11 |
12 | /**
13 | * @author nikhil
14 | *
15 | */
16 | public class EpochDate {
17 |
18 | InMemoryDatabaseHelper inMemoryDatabaseHelperObj = new InMemoryDatabaseHelper();
19 | String sheetName;
20 |
21 | public EpochDate(String sheetName) {
22 | this.sheetName = sheetName;
23 | }
24 |
25 | public void insertStartToday() {
26 | Date date = EpochHelper.getDateToday();
27 | String epochValue = String.valueOf(EpochHelper.getStartOfDay(date).getTime());
28 | System.out.println("insertStartToday" + epochValue);
29 | inMemoryDatabaseHelperObj.createData(EpochDateHelperConstant.TESTCASEID.toString(), sheetName,
30 | EpochDateHelperConstant.STARTTODAY.toString(), epochValue,
31 | InMemoryDatabaseHelperConstant.TABLENAME.toString());
32 |
33 | }
34 |
35 | public void insertEndToday() {
36 | Date date = EpochHelper.getDateToday();
37 | String epochValue = String.valueOf(EpochHelper.getEndOfDay(date).getTime());
38 | System.out.println("insertEndToday" + epochValue);
39 | inMemoryDatabaseHelperObj.createData(EpochDateHelperConstant.TESTCASEID.toString(),sheetName,
40 | EpochDateHelperConstant.ENDTODAY.toString(), epochValue,
41 | InMemoryDatabaseHelperConstant.TABLENAME.toString());
42 | }
43 |
44 | public void insertStartYesterday() {
45 | Date date = EpochHelper.getDateYesterday();
46 | String epochValue = String.valueOf(EpochHelper.getStartOfDay(date).getTime());
47 | System.out.println("insertStartYesterday" + epochValue);
48 | inMemoryDatabaseHelperObj.createData(EpochDateHelperConstant.TESTCASEID.toString(),sheetName,
49 | EpochDateHelperConstant.STARTYESTERDAY.toString(), epochValue,
50 | InMemoryDatabaseHelperConstant.TABLENAME.toString());
51 | }
52 |
53 | public void insertEndYesterday() {
54 | Date date = EpochHelper.getDateYesterday();
55 | String epochValue = String.valueOf(EpochHelper.getEndOfDay(date).getTime());
56 | System.out.println("insertEndYesterday" + epochValue);
57 | inMemoryDatabaseHelperObj.createData(EpochDateHelperConstant.TESTCASEID.toString(),sheetName,
58 | EpochDateHelperConstant.ENDYESTERDAY.toString(), epochValue,
59 | InMemoryDatabaseHelperConstant.TABLENAME.toString());
60 | }
61 |
62 | public void insertStartThisWeek() {
63 | Date date = EpochHelper.getDateThisWeek();
64 | String epochValue = String.valueOf(EpochHelper.getStartOfDay(date).getTime());
65 | System.out.println("insertStartThisWeek" + epochValue);
66 | inMemoryDatabaseHelperObj.createData(EpochDateHelperConstant.TESTCASEID.toString(),sheetName,
67 | EpochDateHelperConstant.STARTTHISWEEK.toString(), epochValue,
68 | InMemoryDatabaseHelperConstant.TABLENAME.toString());
69 | }
70 |
71 | public void insertStartSevenDays() {
72 | Date date = EpochHelper.getSevenDaysBackDate();
73 | String epochValue = String.valueOf(EpochHelper.getStartOfDay(date).getTime());
74 | System.out.println("insertStartSevenDays" + epochValue);
75 | inMemoryDatabaseHelperObj.createData(EpochDateHelperConstant.TESTCASEID.toString(),sheetName,
76 | EpochDateHelperConstant.STARTLASTSEVENDAYS.toString(), epochValue,
77 | InMemoryDatabaseHelperConstant.TABLENAME.toString());
78 | }
79 |
80 | public void insertStartThisMonth() {
81 | Date date = EpochHelper.getStartDateOfMonth();
82 | String epochValue = String.valueOf(EpochHelper.getStartOfDay(date).getTime());
83 | System.out.println("insertStartThisMonth" + epochValue);
84 | inMemoryDatabaseHelperObj.createData(EpochDateHelperConstant.TESTCASEID.toString(),sheetName,
85 | EpochDateHelperConstant.STARTTHISMONTH.toString(), epochValue,
86 | InMemoryDatabaseHelperConstant.TABLENAME.toString());
87 | }
88 |
89 | public void insertStartLastMonth() {
90 | Date date = EpochHelper.getStartDateOfPreviousMonth();
91 | String epochValue = String.valueOf(EpochHelper.getStartOfDay(date).getTime());
92 | System.out.println("insertStartLastMonth" + epochValue);
93 | inMemoryDatabaseHelperObj.createData(EpochDateHelperConstant.TESTCASEID.toString(),sheetName,
94 | EpochDateHelperConstant.STARTLASTMONTH.toString(), epochValue,
95 | InMemoryDatabaseHelperConstant.TABLENAME.toString());
96 | }
97 |
98 | public void insertEndLastMonth() {
99 | Date date = EpochHelper.getEndDateOfPreviousMonth();
100 | String epochValue = String.valueOf(EpochHelper.getEndOfDay(date).getTime());
101 | System.out.println("insertEndLastMonth" + epochValue);
102 | inMemoryDatabaseHelperObj.createData(EpochDateHelperConstant.TESTCASEID.toString(),sheetName,
103 | EpochDateHelperConstant.ENDLASTMONTH.toString(), epochValue,
104 | InMemoryDatabaseHelperConstant.TABLENAME.toString());
105 | }
106 |
107 | public void insertStartCustomRange() {
108 | Date date = EpochHelper.getStartDateOfThreeMonthBefore();
109 | String epochValue = String.valueOf(EpochHelper.getStartOfDay(date).getTime());
110 | System.out.println("insertStartCustomRange" + epochValue);
111 | inMemoryDatabaseHelperObj.createData(EpochDateHelperConstant.TESTCASEID.toString(),sheetName,
112 | EpochDateHelperConstant.STARTCUSTOMRANGE.toString(), epochValue,
113 | InMemoryDatabaseHelperConstant.TABLENAME.toString());
114 | }
115 |
116 | }
--------------------------------------------------------------------------------
/src/main/java/com/framework/epochdate/EpochHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.epochdate;
5 |
6 | import java.time.Instant;
7 | import java.time.LocalDateTime;
8 | import java.time.LocalTime;
9 | import java.time.ZoneId;
10 | import java.util.Calendar;
11 | import java.util.Date;
12 |
13 | /**
14 | * @author nikhil
15 | *
16 | */
17 | public class EpochHelper {
18 |
19 | /*
20 | * getEndOfDay give epoch time of end of day.
21 | */
22 | public static Date getEndOfDay(Date date) {
23 | LocalDateTime localDateTime = dateToLocalDateTime(date);
24 | LocalDateTime endOfDay = localDateTime.with(LocalTime.MAX);
25 | return localDateTimeToDate(endOfDay);
26 | }
27 |
28 | /*
29 | * getStartOfDay give epoch time of start of day.
30 | */
31 | public static Date getStartOfDay(Date date) {
32 | LocalDateTime localDateTime = dateToLocalDateTime(date);
33 | LocalDateTime startOfDay = localDateTime.with(LocalTime.MIN);
34 | return localDateTimeToDate(startOfDay);
35 | }
36 |
37 | public static Date localDateTimeToDate(LocalDateTime startOfDay) {
38 | return Date.from(startOfDay.atZone(ZoneId.systemDefault()).toInstant());
39 | }
40 |
41 | public static LocalDateTime dateToLocalDateTime(Date date) {
42 | return LocalDateTime.ofInstant(Instant.ofEpochMilli(date.getTime()), ZoneId.systemDefault());
43 | }
44 |
45 | /*
46 | * getDateToday give today date.
47 | */
48 | public static Date getDateToday() {
49 | Date today = new Date();
50 | return today;
51 |
52 | }
53 |
54 | /*
55 | * getDateYesterday give yesterday date.
56 | */
57 | public static Date getDateYesterday() {
58 | Calendar calendar = Calendar.getInstance();
59 |
60 | // Move calendar to yesterday
61 | calendar.add(Calendar.DATE, -1);
62 |
63 | // Get current date of calendar which point to the yesterday now
64 | Date yesterday = calendar.getTime();
65 |
66 | return yesterday;
67 | }
68 |
69 | /*
70 | * getDateThisWeek give start date of this week.
71 | */
72 | public static Date getDateThisWeek() {
73 | Calendar calendar = Calendar.getInstance();
74 |
75 | // Move calendar to monday for this week
76 | calendar.set(Calendar.DAY_OF_WEEK, calendar.MONDAY);
77 | Date thisWeek = calendar.getTime();
78 | return thisWeek;
79 | }
80 |
81 | /*
82 | * getSevenDaysBackDate give seven days back date.
83 | */
84 | public static Date getSevenDaysBackDate() {
85 | Calendar calendar = Calendar.getInstance();
86 | // Move calendar to yesterday
87 | calendar.add(Calendar.DATE, -6);
88 |
89 | // Get current date of calendar which point to the yesterday now
90 | Date sevenDaysBackDate = calendar.getTime();
91 |
92 | return sevenDaysBackDate;
93 | }
94 |
95 | /*
96 | * getStartDateOfMonth give start date of this month.
97 | */
98 | public static Date getStartDateOfMonth() {
99 | Calendar calendar = Calendar.getInstance();
100 | calendar.set(Calendar.DAY_OF_MONTH, 1);
101 | Date startDateOfMonth = calendar.getTime();
102 | return startDateOfMonth;
103 | }
104 |
105 | /*
106 | * getStartDateOfPreviousMonth give start date of previous month.
107 | */
108 | public static Date getStartDateOfPreviousMonth() {
109 | Calendar calendar = Calendar.getInstance();
110 | calendar.set(Calendar.DAY_OF_MONTH, 1);
111 | calendar.add(Calendar.MONTH, -1);
112 | Date startDateOfPreviousMonth = calendar.getTime();
113 | return startDateOfPreviousMonth;
114 | }
115 |
116 | /*
117 | * getEndDateOfPreviousMonth giveEnd date of previous month.
118 | */
119 | public static Date getEndDateOfPreviousMonth() {
120 | Calendar calendar = Calendar.getInstance();
121 | calendar.set(Calendar.DAY_OF_MONTH, 1);
122 | calendar.add(Calendar.DATE, -1);
123 | Date endDateOfPreviousMonth = calendar.getTime();
124 | return endDateOfPreviousMonth;
125 | }
126 |
127 | /*
128 | * getStartDateOfThreeMonthBefore give 3 months before Date.
129 | */
130 | public static Date getStartDateOfThreeMonthBefore() {
131 | Calendar calendar = Calendar.getInstance();
132 | calendar.set(Calendar.DAY_OF_MONTH, 1);
133 | calendar.add(Calendar.MONTH, -3);
134 | Date startDateOfThreeMonthBefore = calendar.getTime();
135 | return startDateOfThreeMonthBefore;
136 | }
137 |
138 | }
139 |
--------------------------------------------------------------------------------
/src/main/java/com/framework/inmemorydatabase/InMemoryDatabaseHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.inmemorydatabase;
5 |
6 |
7 | import java.sql.DriverManager;
8 | import java.sql.ResultSet;
9 | import java.sql.SQLException;
10 | import java.sql.Statement;
11 |
12 | import com.framework.commans.Commans.InMemoryDatabaseHelperCommans;
13 | import com.framework.constants.Constants.InMemoryDatabaseHelperConstant;
14 |
15 | /**
16 | * @author nikhil
17 | *
18 | */
19 | public class InMemoryDatabaseHelper {
20 |
21 | Statement stmt;
22 | int result = 0;
23 |
24 | /*
25 | * create connection to hsqldb database.
26 | */
27 | public void createConnection() {
28 | try {
29 | // Registering the HSQLDB JDBC driver
30 | Class.forName(InMemoryDatabaseHelperConstant.HSQLDBJDBCDRIVER.toString());
31 | // Creating the connection with HSQLDB
32 | InMemoryDatabaseHelperCommans.connectionObj = DriverManager
33 | .getConnection(InMemoryDatabaseHelperConstant.CREATINGCONNECTIONFORHSQLDB.toString());
34 | } catch (Exception e) {
35 | System.out.println("Exception in Database Connection" + e);
36 | }
37 | }
38 |
39 | /*
40 | * Create table for storing data to database.
41 | */
42 | public void createTable() {
43 | try {
44 | createConnection();
45 | stmt = InMemoryDatabaseHelperCommans.connectionObj.createStatement();
46 | result = stmt.executeUpdate("CREATE TABLE " + InMemoryDatabaseHelperConstant.TABLENAME.toString() + "("
47 | + InMemoryDatabaseHelperConstant.TESTCASEID.toString() + " int,"
48 | + InMemoryDatabaseHelperConstant.SHEETNAME.toString() + " VARCHAR(50),"
49 | + InMemoryDatabaseHelperConstant.PATHVALUE.toString() + " VARCHAR(50),"
50 | + InMemoryDatabaseHelperConstant.RESPONSEVALUE.toString() + " VARCHAR(20000) NOT NULL);");
51 |
52 | } catch (Exception e) {
53 | System.out.println("Exception in create Table for Database:" + e);
54 | }
55 |
56 | }
57 |
58 | /*
59 | * Create data to created table.
60 | */
61 | public void createData(String testCaseName, String sheetName,String path, String responseValue, String tableName) {
62 | try {
63 | stmt = InMemoryDatabaseHelperCommans.connectionObj.createStatement();
64 | result = stmt.executeUpdate("INSERT INTO " + tableName + " VALUES ('" + testCaseName + "','" + sheetName + "','" + path + "','"
65 | + responseValue + "')");
66 | } catch (Exception e) {
67 | System.out.println("Exception in create data to Database:" + e);
68 | }
69 | }
70 |
71 | /*
72 | * Get data from database.
73 | */
74 | public String getDataFromDataBase(String sheetName,String testCaseid, String pathValue) throws SQLException {
75 | ResultSet resultFromTable = null;
76 | try {
77 | stmt = InMemoryDatabaseHelperCommans.connectionObj.createStatement();
78 | resultFromTable = stmt.executeQuery("select " + InMemoryDatabaseHelperConstant.TESTCASEID.toString() + ","
79 | + InMemoryDatabaseHelperConstant.PATHVALUE.toString() + ","
80 | + InMemoryDatabaseHelperConstant.RESPONSEVALUE.toString() + " from "
81 | + InMemoryDatabaseHelperConstant.TABLENAME.toString() + " where "
82 | + InMemoryDatabaseHelperConstant.TESTCASEID.toString() + "='" + testCaseid + "' AND "
83 | + InMemoryDatabaseHelperConstant.SHEETNAME.toString() + "='" + sheetName + "' AND "
84 | + InMemoryDatabaseHelperConstant.PATHVALUE.toString() + "='" + pathValue + "'");
85 |
86 | while (resultFromTable.next()) {
87 | System.out.println(resultFromTable.getString(InMemoryDatabaseHelperConstant.TESTCASEID.toString())
88 | + " |" + resultFromTable.getString(InMemoryDatabaseHelperConstant.PATHVALUE.toString()) + "|"
89 | + resultFromTable.getString(InMemoryDatabaseHelperConstant.RESPONSEVALUE.toString()));
90 | return resultFromTable.getString(InMemoryDatabaseHelperConstant.RESPONSEVALUE.toString());
91 | }
92 |
93 | } catch (Exception e) {
94 | System.out.println("Exception in get data from Database:" + e);
95 | }
96 | return resultFromTable.getString(InMemoryDatabaseHelperConstant.RESPONSEVALUE.toString());
97 | }
98 |
99 | }
--------------------------------------------------------------------------------
/src/main/java/com/framework/restassured/APIExecutorHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.restassured;
5 |
6 | import java.util.LinkedHashMap;
7 | import com.framework.commans.Commans.DataUtilCommans;
8 | import com.framework.constants.Constants.ExcelColumnNameConstant;
9 | import com.relevantcodes.extentreports.ExtentTest;
10 | import com.relevantcodes.extentreports.LogStatus;
11 |
12 | /**
13 | * @author nikhil
14 | *
15 | */
16 |
17 | public class APIExecutorHelper {
18 |
19 | /*
20 | * setHeaders methods returns the header map for all test cases.
21 | */
22 | public static LinkedHashMap setHeaders(LinkedHashMap data) {
23 |
24 | LinkedHashMap headersmap = new LinkedHashMap();
25 | String[] headers = data.get(ExcelColumnNameConstant.TESTHEADERS.toString()).split(";");
26 | int headersSize = headers.length;
27 | System.out.println("Total Size" + headersSize);
28 | for (int i = 0; i < headersSize; i++) {
29 | String header = headers[i];
30 | System.out.println("" + header);
31 | String[] headerdata = header.split(":");
32 | StringBuffer key = new StringBuffer(headerdata[0].trim());
33 | StringBuffer value = new StringBuffer(headerdata[1].trim());
34 | headersmap.put(key.toString(), value.toString());
35 | System.out.println("key-->" + key + "value-->" + value);
36 | }
37 | System.out.println(headersmap);
38 | return headersmap;
39 |
40 | }
41 |
42 | /*
43 | * printTestExecutionTime logs the execution time for all test cases.
44 | */
45 | public static void printTestExecutionTime(long executionTimeInMillis, ExtentTest extentTest) {
46 | long executionTimeInSeconds = executionTimeInMillis / 1000;
47 | long executionTimeInMinutes = executionTimeInMillis / 60000;
48 | long executionTimeInHours = executionTimeInMillis / 3600000;
49 | if (executionTimeInMillis > 0 && executionTimeInMillis < 1000)
50 | extentTest.log(LogStatus.INFO, "Test execution time: " + executionTimeInMillis + " ms");
51 | if (executionTimeInMillis > 1000 && executionTimeInMillis < 60000) {
52 | if (executionTimeInSeconds == 1)
53 | extentTest.log(LogStatus.INFO, "Test execution time: " + executionTimeInSeconds + " second");
54 | else
55 | extentTest.log(LogStatus.INFO, "Test execution time: " + executionTimeInSeconds + " seconds");
56 | }
57 | if (executionTimeInMillis > 60000 && executionTimeInMillis < 3600000) {
58 | if (executionTimeInMinutes == 1)
59 | extentTest.log(LogStatus.INFO, "Test execution time: " + executionTimeInMinutes + " minute");
60 | else
61 | extentTest.log(LogStatus.INFO, "Test execution time: " + executionTimeInMinutes + " minutes");
62 | }
63 | if (executionTimeInMillis > 3600000) {
64 | if (executionTimeInHours == 1)
65 | extentTest.log(LogStatus.INFO, "Test execution time: " + executionTimeInHours + " hour");
66 | else
67 | extentTest.log(LogStatus.INFO, "Test execution time: " + executionTimeInHours + " hours");
68 | }
69 | }
70 |
71 | /*
72 | * Create API URL as per selected Environment.
73 | *
74 | */
75 | public static String getUrl(LinkedHashMap data) {
76 | String url = DataUtilCommans.BASEURL + data.get(ExcelColumnNameConstant.TESTURL.toString())
77 | + data.get(ExcelColumnNameConstant.TESTPARAMETERS.toString());
78 | return url;
79 | }
80 |
81 | public static boolean isDynamicValuePresent(String url, LinkedHashMap data) {
82 | boolean flag = false;
83 | if (url.contains("#") || setHeaders(data).toString().contains("#")
84 | || data.get(ExcelColumnNameConstant.TESTINPUTJSON.toString()).contains("#") || url.contains("@")
85 | || setHeaders(data).toString().contains("@")
86 | || data.get(ExcelColumnNameConstant.TESTINPUTJSON.toString()).contains("@")) {
87 | flag = true;
88 | }
89 | return flag;
90 | }
91 |
92 | }
--------------------------------------------------------------------------------
/src/main/java/com/framework/restassured/ApiExecutor.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.restassured;
5 |
6 | import static io.restassured.RestAssured.given;
7 | import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
8 | import static org.hamcrest.MatcherAssert.assertThat;
9 | import java.util.LinkedHashMap;
10 | import org.apache.http.util.TextUtils;
11 | import org.testng.SkipException;
12 |
13 | import com.framework.constants.Constants.ApiExecutorConstants;
14 | import com.framework.constants.Constants.ExcelColumnNameConstant;
15 | import com.relevantcodes.extentreports.ExtentTest;
16 | import com.relevantcodes.extentreports.LogStatus;
17 | import io.restassured.RestAssured;
18 | import io.restassured.config.HttpClientConfig;
19 | import io.restassured.config.RestAssuredConfig;
20 | import io.restassured.response.Response;
21 | import io.restassured.specification.RequestSpecification;
22 |
23 | /**
24 | * @author nikhil
25 | *
26 | */
27 |
28 | public class ApiExecutor {
29 | RestAssuredConfig config = RestAssured.config()
30 | .httpClient(HttpClientConfig.httpClientConfig().setParam("CONNECTION_MANAGER_TIMEOUT", 3000));
31 |
32 | /*
33 | * Rest-Assured is using given/when/then notation. In below section we
34 | * declare things like content type or request body. below method is use for
35 | * getapi.
36 | */
37 | public Response apiGet(LinkedHashMap data, ExtentTest extentTest) {
38 | String url = APIExecutorHelper.getUrl(data);
39 | extentTest.log(LogStatus.INFO, "URL-->" + url);
40 | extentTest.log(LogStatus.INFO, "Input json" + data.get(ExcelColumnNameConstant.TESTINPUTJSON.toString()));
41 | Response resp = null;
42 | try {
43 | RequestSpecification rs = given().contentType(ApiExecutorConstants.CONTENTTYPE.toString())
44 | .body(data.get(ExcelColumnNameConstant.TESTINPUTJSON.toString()));
45 |
46 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTHEADERS.toString()))) {
47 | if (APIExecutorHelper.isDynamicValuePresent(url, data)) {
48 | extentTest.log(LogStatus.SKIP,
49 | "URL,Input Json or Headers dynamic values not replaces with actual value.");
50 | throw new SkipException("Skipping this exception");
51 | } else {
52 | extentTest.log(LogStatus.INFO, "Headers-->" + APIExecutorHelper.setHeaders(data));
53 | rs = rs.given().headers(APIExecutorHelper.setHeaders(data));
54 | }
55 | }
56 |
57 | resp = rs.when().get(url).then().extract().response();
58 | extentTest.log(LogStatus.INFO, "Response" + resp.asString());
59 | long executionTimeInMillis = resp.getTime();
60 | APIExecutorHelper.printTestExecutionTime(executionTimeInMillis, extentTest);
61 |
62 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTSCHEMANAME.toString()))) {
63 | assertThat(resp.asString(),
64 | matchesJsonSchemaInClasspath(data.get(ExcelColumnNameConstant.TESTSCHEMANAME.toString())));
65 | }
66 | } catch (SkipException e) {
67 | extentTest.log(LogStatus.SKIP, "Skip " + e.getMessage());
68 | } catch (Exception e) {
69 | extentTest.log(LogStatus.FAIL, "Fail " + e.getMessage());
70 | org.testng.Assert.fail("*******************************apiGet: " + e.getMessage());
71 | }
72 | return resp;
73 |
74 | }
75 |
76 | /*
77 | * Rest-Assured is using given/when/then notation. In below section we
78 | * declare things like content type or request body. below method is use for
79 | * postapi.
80 | */
81 |
82 | public Response apiPost(LinkedHashMap data, ExtentTest extentTest) {
83 | String url = APIExecutorHelper.getUrl(data);
84 | Response resp = null;
85 | try {
86 | extentTest.log(LogStatus.INFO, "URL-->" + url);
87 | extentTest.log(LogStatus.INFO, "Input json" + data.get(ExcelColumnNameConstant.TESTINPUTJSON.toString()));
88 | RequestSpecification rs = given().contentType(ApiExecutorConstants.CONTENTTYPE.toString())
89 | .body(data.get(ExcelColumnNameConstant.TESTINPUTJSON.toString()));
90 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTHEADERS.toString()))) {
91 | if (APIExecutorHelper.isDynamicValuePresent(url, data)) {
92 | extentTest.log(LogStatus.SKIP,
93 | "URL,Input Json or Headers dynamic values not replaces with actual value.");
94 | throw new SkipException("Skipping this exception");
95 | } else {
96 | extentTest.log(LogStatus.INFO, "Headers-->" + APIExecutorHelper.setHeaders(data));
97 | rs = rs.given().headers(APIExecutorHelper.setHeaders(data));
98 | }
99 | }
100 |
101 | resp = rs.when().post(url).then().extract().response();
102 | extentTest.log(LogStatus.INFO, "Response" + resp.asString());
103 | long executionTimeInMillis = resp.getTime();
104 | APIExecutorHelper.printTestExecutionTime(executionTimeInMillis, extentTest);
105 |
106 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTSCHEMANAME.toString()))) {
107 | assertThat(resp.asString(),
108 | matchesJsonSchemaInClasspath(data.get(ExcelColumnNameConstant.TESTSCHEMANAME.toString())));
109 | }
110 |
111 | } catch (SkipException e) {
112 | extentTest.log(LogStatus.SKIP, "Skip " + e.getMessage());
113 | } catch (Exception e) {
114 | extentTest.log(LogStatus.FAIL, "Fail " + e.getMessage());
115 | org.testng.Assert.fail("*******************************apiPost: " + e.getMessage());
116 | }
117 |
118 | return resp;
119 | }
120 |
121 | /*
122 | * Rest-Assured is using given/when/then notation. In below section we
123 | * declare things like content type or request body. below method is use for
124 | * putapi.
125 | */
126 |
127 | public Response apiPut(LinkedHashMap data, ExtentTest extentTest) {
128 | String url = APIExecutorHelper.getUrl(data);
129 | extentTest.log(LogStatus.INFO, "URL-->" + url);
130 | Response resp = null;
131 | try {
132 | extentTest.log(LogStatus.INFO, "Input json" + data.get(ExcelColumnNameConstant.TESTINPUTJSON.toString()));
133 | RequestSpecification rs = given().contentType(ApiExecutorConstants.CONTENTTYPE.toString())
134 | .body(data.get(ExcelColumnNameConstant.TESTINPUTJSON.toString()));
135 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTHEADERS.toString()))) {
136 | if (APIExecutorHelper.isDynamicValuePresent(url, data)) {
137 | extentTest.log(LogStatus.SKIP,
138 | "URL,Input Json or Headers dynamic values not replaces with actual value.");
139 | throw new SkipException("Skipping this exception");
140 | } else {
141 | extentTest.log(LogStatus.INFO, "Headers-->" + APIExecutorHelper.setHeaders(data));
142 | rs = rs.given().headers(APIExecutorHelper.setHeaders(data));
143 | }
144 | }
145 | resp = rs.when().put(url).then().extract().response();
146 | extentTest.log(LogStatus.INFO, "Response" + resp.asString());
147 | long executionTimeInMillis = resp.getTime();
148 | APIExecutorHelper.printTestExecutionTime(executionTimeInMillis, extentTest);
149 |
150 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTSCHEMANAME.toString()))) {
151 | assertThat(resp.asString(),
152 | matchesJsonSchemaInClasspath(data.get(ExcelColumnNameConstant.TESTSCHEMANAME.toString())));
153 | }
154 |
155 | } catch (SkipException e) {
156 | extentTest.log(LogStatus.SKIP, "Skip " + e.getMessage());
157 | } catch (Exception e) {
158 | extentTest.log(LogStatus.FAIL, "Fail " + e.getMessage());
159 | org.testng.Assert.fail("*******************************apiPut: " + e.getMessage());
160 | }
161 | return resp;
162 | }
163 |
164 | /*
165 | * Rest-Assured is using given/when/then notation. In below section we
166 | * declare things like content type or request body. below method is use for
167 | * deleteapi.
168 | */
169 |
170 | public Response apiDelete(LinkedHashMap data, ExtentTest extentTest) {
171 | String url = APIExecutorHelper.getUrl(data);
172 | extentTest.log(LogStatus.INFO, "URL-->" + url);
173 | Response resp = null;
174 | try {
175 | extentTest.log(LogStatus.INFO, "Input json" + data.get(ExcelColumnNameConstant.TESTINPUTJSON.toString()));
176 | RequestSpecification rs = given().contentType(ApiExecutorConstants.CONTENTTYPE.toString())
177 | .body(data.get(ExcelColumnNameConstant.TESTINPUTJSON.toString()));
178 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTHEADERS.toString()))) {
179 | if (APIExecutorHelper.isDynamicValuePresent(url, data)) {
180 | extentTest.log(LogStatus.SKIP,
181 | "URL,Input Json or Headers dynamic values not replaces with actual value.");
182 | throw new SkipException("Skipping this exception");
183 | } else {
184 | extentTest.log(LogStatus.INFO, "Headers-->" + APIExecutorHelper.setHeaders(data));
185 | rs = rs.given().headers(APIExecutorHelper.setHeaders(data));
186 | }
187 | }
188 | resp = rs.when().delete(url).then().extract().response();
189 | extentTest.log(LogStatus.INFO, "Response" + resp.asString());
190 | long executionTimeInMillis = resp.getTime();
191 | APIExecutorHelper.printTestExecutionTime(executionTimeInMillis, extentTest);
192 |
193 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTSCHEMANAME.toString()))) {
194 | assertThat(resp.asString(),
195 | matchesJsonSchemaInClasspath(data.get(ExcelColumnNameConstant.TESTSCHEMANAME.toString())));
196 | }
197 |
198 | } catch (SkipException e) {
199 | extentTest.log(LogStatus.SKIP, "Skip " + e.getMessage());
200 | } catch (Exception e) {
201 | extentTest.log(LogStatus.FAIL, "Fail " + e.getMessage());
202 | org.testng.Assert.fail("*******************************apiDelete: " + e.getMessage());
203 | }
204 | return resp;
205 | }
206 |
207 | public Response apiPatch(LinkedHashMap data, ExtentTest extentTest) {
208 | String url = APIExecutorHelper.getUrl(data);
209 | extentTest.log(LogStatus.INFO, "URL-->" + url);
210 | Response resp = null;
211 | try {
212 | extentTest.log(LogStatus.INFO, "Input json" + data.get(ExcelColumnNameConstant.TESTINPUTJSON.toString()));
213 | RequestSpecification rs = given().contentType(ApiExecutorConstants.CONTENTTYPE.toString())
214 | .body(data.get(ExcelColumnNameConstant.TESTINPUTJSON.toString()));
215 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTHEADERS.toString()))) {
216 | if (APIExecutorHelper.isDynamicValuePresent(url, data)) {
217 | extentTest.log(LogStatus.SKIP,
218 | "URL,Input Json or Headers dynamic values not replaces with actual value.");
219 | throw new SkipException("Skipping this exception");
220 | } else {
221 | extentTest.log(LogStatus.INFO, "Headers-->" + APIExecutorHelper.setHeaders(data));
222 | rs = rs.given().headers(APIExecutorHelper.setHeaders(data));
223 | }
224 | }
225 | resp = rs.when().patch(url).then().extract().response();
226 | extentTest.log(LogStatus.INFO, "Response" + resp.asString());
227 | long executionTimeInMillis = resp.getTime();
228 | APIExecutorHelper.printTestExecutionTime(executionTimeInMillis, extentTest);
229 |
230 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTSCHEMANAME.toString()))) {
231 | assertThat(resp.asString(),
232 | matchesJsonSchemaInClasspath(data.get(ExcelColumnNameConstant.TESTSCHEMANAME.toString())));
233 | }
234 |
235 | } catch (SkipException e) {
236 | extentTest.log(LogStatus.SKIP, "Skip " + e.getMessage());
237 | } catch (Exception e) {
238 | extentTest.log(LogStatus.FAIL, "Fail " + e.getMessage());
239 | org.testng.Assert.fail("*******************************apiPatch: " + e.getMessage());
240 | }
241 | return resp;
242 | }
243 | }
--------------------------------------------------------------------------------
/src/main/java/com/framework/utility/DataUtil.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.utility;
5 |
6 | import java.util.LinkedHashMap;
7 | import org.apache.poi.xssf.usermodel.XSSFWorkbook;
8 | import org.testng.annotations.DataProvider;
9 | import com.framework.commans.Commans.DataUtilCommans;
10 | import com.framework.commans.Commans.FactoryHelperCommans;
11 | import com.framework.constants.Constants.DataUtilConstants;
12 |
13 | /**
14 | * @author nikhil
15 | *
16 | */
17 | public class DataUtil {
18 | private XSSFWorkbook workbook;
19 | /*
20 | * Data provider class for reading test data and verify method should run or
21 | * not.
22 | *
23 | */
24 |
25 | @DataProvider(name = "getData")
26 | public Object[][] getData() {
27 | Object[][] data = null;
28 | try {
29 | ExcelReader excelread = new ExcelReader();
30 | String sheetName = FactoryHelperCommans.sheetsName.get(DataUtilCommans.count);
31 | DataUtilCommans.count++;
32 |
33 | // get number of rows.
34 | int rows = excelread.getLastRowNumber(sheetName);
35 |
36 | // get number of columns.
37 | int cols = excelread.getLastColNum(sheetName, 1);
38 |
39 | // get count for Runmode=yes.
40 | int count = runModeCount(excelread, sheetName, rows);
41 |
42 | // Set Base URL
43 | DataUtilCommans.BASEURL = excelread.getCellData(sheetName, 1, 0);
44 |
45 | data = new Object[count][1];
46 | LinkedHashMap table = null;
47 | int value = 0;
48 | for (int i = 0; i < rows; i++) {
49 | table = new LinkedHashMap();
50 | if (excelread.getCellData(sheetName, 1, i).toLowerCase().trim()
51 | .equalsIgnoreCase(DataUtilConstants.RUNMODE.toString())) {
52 | table = getTestCaseMap(excelread, sheetName, i, cols, table);
53 | data[value][0] = table;
54 | value++;
55 | while (excelread.getCellData(sheetName, 1, i + 1).toLowerCase().trim().equals("")) {
56 | table = new LinkedHashMap();
57 | if (i + 1 < rows) {
58 | i++;
59 | table = getTestCaseMap(excelread, sheetName, i, cols, table);
60 | data[value][0] = table;
61 | value++;
62 | } else {
63 | break;
64 | }
65 | }
66 | }
67 | }
68 |
69 | if (data == null) {
70 | return new Object[0][0];
71 | }
72 |
73 | } catch (Exception e) {
74 | System.out.println("Exception" + e);
75 | }
76 | return data;
77 | }
78 |
79 | /*
80 | * getTestCaseMap return map of testcase.
81 | */
82 | public LinkedHashMap getTestCaseMap(ExcelReader excelread, String sheetName, int row, int cols,
83 | LinkedHashMap table) {
84 |
85 | try {
86 | for (int j = 0; j < cols; j++) {
87 | StringBuffer key = new StringBuffer(excelread.getCellData(sheetName, j, 1).toLowerCase().trim());
88 | StringBuffer value = new StringBuffer(excelread.getCellData(sheetName, j, row).trim());
89 | table.put(key.toString().trim(), value.toString().trim());
90 | }
91 | } catch (Exception e) {
92 | System.out.println("Exception" + e);
93 | }
94 | return table;
95 | }
96 |
97 | /*
98 | * runModeCount return count for runmode=yes.
99 | */
100 | public int runModeCount(ExcelReader excelread, String sheetName, int rows) {
101 | int count = 0;
102 | for (int i = 1; i < rows; i++) {
103 | if (excelread.getCellData(sheetName, 1, i).toLowerCase().trim()
104 | .equalsIgnoreCase(DataUtilConstants.RUNMODE.toString())) {
105 | System.out.println("----" + excelread.getCellData(sheetName, 1, i).toLowerCase().trim());
106 | count++;
107 | while (excelread.getCellData(sheetName, 1, i + 1).toLowerCase().trim().equals("")) {
108 | if (i + 1 < rows) {
109 | System.out.println("----+1" + excelread.getCellData(sheetName, 1, i + 1).toLowerCase().trim());
110 | i++;
111 | count++;
112 | } else {
113 | break;
114 | }
115 | }
116 | }
117 |
118 | }
119 | return count;
120 | }
121 |
122 | }
--------------------------------------------------------------------------------
/src/main/java/com/framework/utility/DownloadExcelFileHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.utility;
5 |
6 | import java.io.FileOutputStream;
7 | import java.io.IOException;
8 | import java.io.InputStream;
9 | import java.io.InputStreamReader;
10 | import java.io.OutputStream;
11 | import java.util.Arrays;
12 | import java.util.List;
13 | import com.framework.constants.Constants;
14 | import com.framework.constants.Constants.DownloadExcelFileHelperConstants;
15 | import com.google.api.client.auth.oauth2.Credential;
16 | import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
17 | import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
18 | import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
19 | import com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets;
20 | import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
21 | import com.google.api.client.http.HttpTransport;
22 | import com.google.api.client.json.JsonFactory;
23 | import com.google.api.client.json.jackson2.JacksonFactory;
24 | import com.google.api.client.util.store.FileDataStoreFactory;
25 | import com.google.api.services.drive.Drive;
26 | import com.google.api.services.drive.DriveScopes;
27 | import com.google.api.services.drive.model.File;
28 |
29 | /**
30 | * @author nikhil
31 | *
32 | */
33 | public class DownloadExcelFileHelper {
34 | /*
35 | * Application name.
36 | */
37 | private static final String APPLICATION_NAME = DownloadExcelFileHelperConstants.APPLICATIONNAME.toString();
38 |
39 | /*
40 | * Directory to store user credentials for this application.
41 | */
42 | private static final java.io.File DATA_STORE_DIR = new java.io.File(System.getProperty("user.home"),
43 | DownloadExcelFileHelperConstants.LOCATIONOFCREDENTIAL.toString());
44 |
45 | /*
46 | * Global instance of the {@link FileDataStoreFactory}.
47 | */
48 | private static FileDataStoreFactory DATA_STORE_FACTORY;
49 |
50 | /*
51 | * Global instance of the JSON factory.
52 | */
53 | private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
54 |
55 | /*
56 | * Global instance of the HTTP transport.
57 | */
58 | private static HttpTransport HTTP_TRANSPORT;
59 |
60 | /**
61 | * Global instance of the scopes required by this quickstart.
62 | *
63 | * If modifying these scopes, delete your previously saved credentials at
64 | * ~/.credentials/drive-java-quickstart
65 | */
66 | private static final List SCOPES = Arrays.asList(DriveScopes.DRIVE);
67 |
68 | static {
69 | try {
70 | HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
71 | DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR);
72 | } catch (Throwable t) {
73 | t.printStackTrace();
74 | System.exit(1);
75 | }
76 | }
77 |
78 | public static void initialMethod() throws IOException {
79 | // Build a new authorized API client service.
80 | Drive service = getDriveService();
81 | /*
82 | * File id for download.
83 | */
84 | downloadFile(service, DownloadExcelFileHelperConstants.EXCELFILEPATH.toString());
85 | }
86 |
87 | /**
88 | * Creates an authorized Credential object.
89 | *
90 | * @return an authorized Credential object.
91 | * @throws IOException
92 | */
93 | public static Credential authorize() throws IOException {
94 | // Load client secrets.
95 | InputStream in = DownloadExcelFileHelper.class
96 | .getResourceAsStream(DownloadExcelFileHelperConstants.CLIENTSECRETJSON.toString());
97 | GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
98 |
99 | // Build flow and trigger user authorization request.
100 | GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY,
101 | clientSecrets, SCOPES).setDataStoreFactory(DATA_STORE_FACTORY).setAccessType("offline").build();
102 | Credential credential = new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
103 | System.out.println("Credentials saved to " + DATA_STORE_DIR.getAbsolutePath());
104 | return credential;
105 | }
106 |
107 | /**
108 | * Build and return an authorized Drive client service.
109 | *
110 | * @return an authorized Drive client service
111 | * @throws IOException
112 | */
113 | public static Drive getDriveService() throws IOException {
114 | Credential credential = authorize();
115 | return new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName(APPLICATION_NAME).build();
116 | }
117 |
118 | /*
119 | * download file helper.
120 | *
121 | */
122 | private static void downloadFile(Drive service, String fileId) {
123 |
124 | try {
125 | File file = service.files().get(fileId).execute();
126 | System.out.println("Title: " + file.getName());
127 | System.out.println("Description: " + file.getDescription());
128 | System.out.println("MIME type: " + file.getMimeType());
129 | OutputStream outputStream = new FileOutputStream(new java.io.File(Constants.EXCEL_PATH));
130 | service.files().export(fileId, DownloadExcelFileHelperConstants.FILETYPE.toString())
131 | .executeMediaAndDownloadTo(outputStream);
132 | System.out.println(outputStream);
133 | } catch (IOException e) {
134 | System.out.println("An error occurred: " + e);
135 | } catch (Exception e) {
136 | System.out.println("An error occurred: " + e);
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/src/main/java/com/framework/utility/ExcelReader.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.utility;
5 |
6 | import java.io.FileInputStream;
7 | import java.util.LinkedHashMap;
8 |
9 |
10 | import org.apache.poi.ss.usermodel.Cell;
11 | import org.apache.poi.ss.usermodel.DataFormatter;
12 | import org.apache.poi.ss.usermodel.Sheet;
13 | import org.apache.poi.xssf.usermodel.XSSFCell;
14 | import org.apache.poi.xssf.usermodel.XSSFRow;
15 | import org.apache.poi.xssf.usermodel.XSSFSheet;
16 | import org.apache.poi.xssf.usermodel.XSSFWorkbook;
17 |
18 | import com.framework.constants.Constants;
19 |
20 | /**
21 | * @author nikhil
22 | *
23 | */
24 | public class ExcelReader {
25 | /*
26 | * Creates a objects for excel reader
27 | *
28 | */
29 |
30 | public FileInputStream fis = null;
31 | private XSSFWorkbook workbook = null;
32 | private XSSFSheet sheet = null;
33 | private XSSFRow row = null;
34 | private XSSFCell cell = null;
35 | LinkedHashMap testFlowsMap = new LinkedHashMap();
36 | LinkedHashMap testSuiteMap = new LinkedHashMap();
37 |
38 | /*
39 | * Finds the workbook instance for XLSX file and path.
40 | *
41 | */
42 |
43 | public ExcelReader() {
44 | try {
45 | fis = new FileInputStream(Constants.EXCEL_PATH);
46 | // Finds the workbook instance for XLSX file
47 | workbook = new XSSFWorkbook(fis);
48 | } catch (Exception e) {
49 | // TODO Auto-generated catch block
50 | e.printStackTrace();
51 | }
52 | }
53 |
54 |
55 | /*
56 | * Returns the data from a cell.
57 | *
58 | */
59 |
60 | public String getCellData(String sheetName, String colName, int rowNum) {
61 | try {
62 | // Blank rows return empty values
63 | if (rowNum <= 0)
64 | return "";
65 | // get sheet index.
66 | int index = workbook.getSheetIndex(sheetName);
67 | int col_Num = -1;
68 | // If sheet not found return empty values
69 | if (index == -1)
70 | return "";
71 |
72 | sheet = workbook.getSheetAt(index);
73 | row = sheet.getRow(0);
74 | // get column number
75 | for (int i = 0; i < row.getLastCellNum(); i++) {
76 | // System.out.println("------------Test-----------------"+row.getCell(i).getStringCellValue().trim());
77 | if (row.getCell(i).getStringCellValue().trim().equals(colName.trim()))
78 | col_Num = i;
79 | }
80 | if (col_Num == -1)
81 | return "";
82 |
83 | // sheet = workbook.getSheetAt(index);
84 | row = sheet.getRow(rowNum - 1);
85 | if (row == null)
86 | return "";
87 | cell = row.getCell(col_Num);
88 | // System.out.println("++" + cell);
89 | if (cell == null)
90 | return "";
91 | // System.out.println(cell.getCellType());
92 | if (cell.getCellType() == Cell.CELL_TYPE_STRING)
93 | return cell.getStringCellValue();
94 | else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC || cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
95 |
96 | return cell.getStringCellValue().trim();
97 | } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK)
98 | return "";
99 | else
100 | return String.valueOf(cell.getBooleanCellValue());
101 |
102 | } catch (Exception e) {
103 |
104 | e.printStackTrace();
105 | return "row " + rowNum + " or column " + colName + " does not exist in xls";
106 | }
107 | }
108 |
109 | /*
110 | * Returns the data from a cell.
111 | *
112 | */
113 |
114 | public String getCellData(String sheetName, int colNum, int rowNum) {
115 | try {
116 |
117 | int index = workbook.getSheetIndex(sheetName);
118 |
119 | if (index == -1)
120 | return "";
121 |
122 | sheet = workbook.getSheetAt(index);
123 | row = sheet.getRow(rowNum);
124 | if (row == null)
125 | return "";
126 | cell = row.getCell(colNum);
127 | if (cell == null)
128 | return "";
129 |
130 | if (cell.getCellType() == Cell.CELL_TYPE_STRING) {
131 | return cell.getStringCellValue();
132 | } else if (cell.getCellType() == Cell.CELL_TYPE_NUMERIC) {
133 | DataFormatter fmt = new DataFormatter();
134 | // String cellText = String.valueOf(cell.getNumericCellValue());
135 | String cellText = String.valueOf(fmt.formatCellValue(cell));
136 | // cell.setCellType(Cell.CELL_TYPE_STRING);
137 | return cellText;
138 | } else if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
139 | System.out.println(cell.getStringCellValue().trim());
140 | return cell.getStringCellValue().trim();
141 | } else if (cell.getCellType() == Cell.CELL_TYPE_BLANK)
142 | return "";
143 | else
144 | return String.valueOf(cell.getBooleanCellValue());
145 | } catch (Exception e) {
146 |
147 | e.printStackTrace();
148 | return "row " + rowNum + " or column " + colNum + " does not exist in xls";
149 | }
150 | }
151 |
152 | /*
153 | * Returns last row number.
154 | */
155 | public int getLastRowNum(String sheetName) {
156 | int index = workbook.getSheetIndex(sheetName);
157 |
158 | if (index == -1)
159 | return 0;
160 |
161 | Sheet sheet = workbook.getSheetAt(index);
162 |
163 | return sheet.getLastRowNum();
164 | }
165 |
166 | /*
167 | * Returns last column number.
168 | */
169 | public int getLastColNum(String sheetName, int number) {
170 | int index = workbook.getSheetIndex(sheetName);
171 |
172 | if (index == -1)
173 | return 0;
174 |
175 | Sheet sheet = workbook.getSheetAt(index);
176 |
177 | return sheet.getRow(number).getLastCellNum();
178 |
179 | }
180 |
181 | public int getLastRowNumber(String sheetName){
182 | int rows = 0;
183 | while (!getCellData(sheetName, 0, rows).equals("")) {
184 | rows++;
185 | }
186 | return rows;
187 | }
188 |
189 | }
--------------------------------------------------------------------------------
/src/main/java/com/framework/utility/ExtentManager.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.utility;
5 |
6 | import java.io.File;
7 | import java.util.Date;
8 |
9 | import com.framework.constants.Constants;
10 | import com.relevantcodes.extentreports.DisplayOrder;
11 | import com.relevantcodes.extentreports.ExtentReports;
12 |
13 | /**
14 | * @author nikhil
15 | *
16 | */
17 | public class ExtentManager {
18 | private ExtentReports extent;
19 |
20 | /*
21 | * Create Extent report instance and report path.
22 | *
23 | */
24 |
25 | public ExtentReports getInstance(String testName){
26 | if (extent == null) {
27 | Date date = new Date();
28 | String fileName = date.toString().replace(":", "_").replace(" ", "_") +"_"+testName+"_"+".html";
29 | String reportPath = Constants.REPORTS_PATH + fileName;
30 |
31 | extent = new ExtentReports(reportPath, true, DisplayOrder.NEWEST_FIRST);
32 |
33 | extent.loadConfig(new File(System.getProperty("user.dir") + "//ReportsConfig.xml"));
34 | }
35 | return extent;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/com/framework/utility/FactoryHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.utility;
5 |
6 | import com.framework.commans.Commans.FactoryHelperCommans;
7 | import com.framework.constants.Constants.DataUtilConstants;
8 | import com.framework.constants.Constants.FactoryHelperConstants;
9 | import com.framework.epochdate.EpochDate;
10 | import com.framework.inmemorydatabase.InMemoryDatabaseHelper;
11 |
12 | /**
13 | * @author nikhil
14 | *
15 | */
16 | public class FactoryHelper {
17 |
18 | public void downloadFile() {
19 | try {
20 | DownloadExcelFileHelper.initialMethod();
21 | } catch (Exception e) {
22 | // TODO Auto-generated catch block
23 | e.printStackTrace();
24 | }
25 |
26 | }
27 |
28 | public void createTable() {
29 | try {
30 | // TODO Auto-generated method stub
31 | InMemoryDatabaseHelper inMemoryDatabasehelperObj = new InMemoryDatabaseHelper();
32 | inMemoryDatabasehelperObj.createTable();
33 | } catch (Exception e) {
34 | // TODO Auto-generated catch block
35 | e.printStackTrace();
36 | }
37 |
38 | }
39 |
40 | public void addEpochDates(String sheetName) {
41 | try {
42 | EpochDate epochDateObj = new EpochDate(sheetName);
43 | epochDateObj.insertStartToday();
44 | epochDateObj.insertEndToday();
45 | epochDateObj.insertStartYesterday();
46 | epochDateObj.insertEndYesterday();
47 | epochDateObj.insertStartThisWeek();
48 | epochDateObj.insertStartSevenDays();
49 | epochDateObj.insertStartThisMonth();
50 | epochDateObj.insertStartLastMonth();
51 | epochDateObj.insertEndLastMonth();
52 | epochDateObj.insertStartCustomRange();
53 | } catch (Exception e) {
54 | // TODO Auto-generated catch block
55 | e.printStackTrace();
56 | }
57 | }
58 |
59 | public void getRunnableSheets() {
60 | try {
61 | ExcelReader excelread = new ExcelReader();
62 | String sheetName = FactoryHelperConstants.SHEETNAME.toString();
63 | int rows = excelread.getLastRowNumber(sheetName);
64 | for (int i = 1; i < rows; i++) {
65 | if (excelread.getCellData(sheetName, 1, i).equalsIgnoreCase(DataUtilConstants.RUNMODE.toString())) {
66 | FactoryHelperCommans.sheetsName.add(excelread.getCellData(sheetName, 0, i));
67 | }
68 | }
69 | } catch (Exception e) {
70 | // TODO Auto-generated catch block
71 | e.printStackTrace();
72 | }
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/com/framework/utility/GetDynamicData.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.utility;
5 |
6 | import java.sql.SQLException;
7 | import java.util.LinkedHashMap;
8 | import java.util.List;
9 | import java.util.regex.Matcher;
10 | import java.util.regex.Pattern;
11 | import org.apache.http.util.TextUtils;
12 | import org.testng.Assert;
13 | import com.framework.constants.Constants.ExcelColumnNameConstant;
14 | import com.framework.inmemorydatabase.InMemoryDatabaseHelper;
15 | import com.relevantcodes.extentreports.ExtentTest;
16 | import com.relevantcodes.extentreports.LogStatus;
17 |
18 | /**
19 | * @author nikhil
20 | *
21 | */
22 | public class GetDynamicData {
23 |
24 | InMemoryDatabaseHelper inMemoryDatabasehelperObj = new InMemoryDatabaseHelper();
25 | RestAssuredHelper restAssuredHelperObj = new RestAssuredHelper();
26 |
27 | /*
28 | * getDyanmicsValues call the helper method for replacing dynamic values.
29 | */
30 | public void getDynamicValues(LinkedHashMap data, ExtentTest extentTest, String sheetName) {
31 | getSingleDynamicValue(ExcelColumnNameConstant.TESTURL.toString(), extentTest, data);
32 | getSingleDynamicValue(ExcelColumnNameConstant.TESTINPUTJSON.toString(), extentTest, data);
33 | getSingleDynamicValue(ExcelColumnNameConstant.TESTHEADERS.toString(), extentTest, data);
34 | getSingleDynamicValue(ExcelColumnNameConstant.TESTPARAMETERS.toString(), extentTest, data);
35 | getSingleDynamicValue(ExcelColumnNameConstant.TESTMETHODANDJSONPATH.toString(), extentTest, data);
36 | getListDynamicValue(ExcelColumnNameConstant.TESTURL.toString(), extentTest, data);
37 | getListDynamicValue(ExcelColumnNameConstant.TESTINPUTJSON.toString(), extentTest, data);
38 | getListDynamicValue(ExcelColumnNameConstant.TESTHEADERS.toString(), extentTest, data);
39 | getListDynamicValue(ExcelColumnNameConstant.TESTPARAMETERS.toString(), extentTest, data);
40 | getListDynamicValue(ExcelColumnNameConstant.TESTMETHODANDJSONPATH.toString(), extentTest, data);
41 | restAssuredHelperObj.apiExecutorHelper(data, extentTest, sheetName);
42 | }
43 |
44 | /*
45 | * getSingleDynamicValue check whether string contains dynamic parameter i.e
46 | * #
47 | */
48 | public void getSingleDynamicValue(String value, ExtentTest extentTest, LinkedHashMap data) {
49 | try {
50 | if (data.get(value).contains("#")) {
51 | extractSingleValue(value, extentTest, data);
52 | }
53 | } catch (Exception e) {
54 | extentTest.log(LogStatus.ERROR, "Exception for getSingleDynamicValue" + e);
55 | }
56 | }
57 |
58 | /*
59 | * Replace for only assert response.
60 | */
61 | public void getListDynamicValue(String value, ExtentTest extentTest, LinkedHashMap data) {
62 | try {
63 | if (data.get(value).contains("@")
64 | && value.equalsIgnoreCase(ExcelColumnNameConstant.TESTASSERTRESPONSE.toString())) {
65 | extractListValueForAssert(value, extentTest, data);
66 | removeListValues(value, data, extentTest);
67 | } else if (data.get(value).contains("@")) {
68 | extractListValue(value, extentTest, data);
69 | }
70 |
71 | } catch (Exception e) {
72 | extentTest.log(LogStatus.ERROR, "Exception for getSingleDynamicValue" + e);
73 | }
74 |
75 | }
76 |
77 | /*
78 | * assertSingleDynamicValue replace first dynamic values and assert static
79 | * data.
80 | */
81 | public void assertSingleDynamicValue(LinkedHashMap data, ExtentTest extentTest) {
82 | try {
83 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTASSERTRESPONSE.toString()))) {
84 |
85 | getSingleDynamicValue(ExcelColumnNameConstant.TESTASSERTRESPONSE.toString(), extentTest, data);
86 | getListDynamicValue(ExcelColumnNameConstant.TESTASSERTRESPONSE.toString(), extentTest, data);
87 | assertSingleValueStaticData(data, extentTest);
88 |
89 | }
90 | } catch (Exception e) {
91 | extentTest.log(LogStatus.ERROR, "Exception for assertSingleDynamicValue" + e);
92 | }
93 | }
94 |
95 | /*
96 | * extractSingleValue Replace single dynamic value from data base.
97 | */
98 | public void extractSingleValue(String value, ExtentTest extentTest, LinkedHashMap data) {
99 | try {
100 | String regex = "\\#[a-z|A-Z|0-9|\\.|\\-|\\_]+\\#";
101 | Pattern pattern = Pattern.compile(regex);
102 | Matcher matcher = pattern.matcher(data.get(value));
103 |
104 | while (matcher.find()) {
105 | String dynamicValue = matcher.group();
106 | String replaceValueFromDynamicValue = matcher.group().replace("#", "");
107 | String[] splitDynamicValue = replaceValueFromDynamicValue.split("\\.");
108 | String sheetName = splitDynamicValue[0].toLowerCase();
109 | String testCaseid = splitDynamicValue[1];
110 | String pathValue = splitDynamicValue[2].toLowerCase();
111 | System.out.println("sheetName" + sheetName + "id--" + testCaseid + " value--" + pathValue);
112 | String dataBaseValue = inMemoryDatabasehelperObj.getDataFromDataBase(sheetName, testCaseid, pathValue);
113 | data.put(value, data.get(value).replace(dynamicValue, dataBaseValue));
114 | }
115 |
116 | } catch (SQLException e) {
117 | extentTest.log(LogStatus.SKIP, "Row Empty for :" + data.get(value) + " -------------" + e);
118 | } catch (Exception e) {
119 | extentTest.log(LogStatus.ERROR, "Exception for extractSingleValue" + data.get(value) + "-----" + e);
120 | }
121 | }
122 |
123 | /*
124 | * extractListValue Replace dynamic values from data base.
125 | */
126 | public void extractListValueForAssert(String value, ExtentTest extentTest, LinkedHashMap data) {
127 | try {
128 | String regex = "\\@[a-z|A-Z|0-9|\\.|\\-]+\\@";
129 | Pattern pattern = Pattern.compile(regex);
130 | Matcher matcher = pattern.matcher(data.get(value));
131 | int count = 0;
132 | while (matcher.find()) {
133 | String dynamicValue = matcher.group();
134 | String replaceValueFromDynamicValue = matcher.group().replace("@", "");
135 | String[] splitDynamicValue = replaceValueFromDynamicValue.split("\\.");
136 | String sheetName = splitDynamicValue[0].toLowerCase();
137 | String testCaseid = splitDynamicValue[1];
138 | String pathValue = splitDynamicValue[2].toLowerCase();
139 | System.out.println("sheetName--" + sheetName + "id--" + testCaseid + " value--" + pathValue);
140 | String dataBaseValue = inMemoryDatabasehelperObj.getDataFromDataBase(sheetName, testCaseid, pathValue);
141 | if (!TextUtils.isEmpty(dataBaseValue)) {
142 | String[] splitDataBaseValue = dataBaseValue.split("\\,");
143 | System.out.println(splitDataBaseValue.length);
144 | for (int i = 0; i < splitDataBaseValue.length; i++) {
145 | String assertText = data.get(ExcelColumnNameConstant.TESTASSERTRESPONSE.toString());
146 | assertText = assertText.replace(dynamicValue, splitDataBaseValue[i]);
147 | if (assertText.contains(";")) {
148 | String[] splitValueForAssert = assertText.split("\\;");
149 | assertText = splitValueForAssert[count];
150 | System.out.println(assertText);
151 | assertMethod(assertText, extentTest);
152 | } else {
153 | System.out.println(assertText);
154 | assertMethod(assertText, extentTest);
155 | }
156 | }
157 | }
158 | count++;
159 | }
160 |
161 | } catch (SQLException e) {
162 | extentTest.log(LogStatus.SKIP, "Row Empty for :" + data.get(value) + " -------------" + e);
163 | } catch (Exception e) {
164 | extentTest.log(LogStatus.ERROR, "Exception for extractListValue" + e);
165 | }
166 | }
167 |
168 | /*
169 | * assertStaticData assert the values.
170 | */
171 | public void assertSingleValueStaticData(LinkedHashMap data, ExtentTest extentTest) {
172 | try {
173 | String assertText = data.get(ExcelColumnNameConstant.TESTASSERTRESPONSE.toString());
174 | if (!assertText.contains("#"))
175 | assertMethod(assertText, extentTest);
176 | } catch (Exception e) {
177 | extentTest.log(LogStatus.ERROR, "Exception for assertmethod" + e);
178 | }
179 | }
180 |
181 | public void assertMethod(String assertText, ExtentTest extentTest) {
182 | try {
183 | String regex = "[a-z|A-Z|0-9|\\-|\\,|\\_|\\.]+";
184 | Pattern pattern = Pattern.compile(regex);
185 | Matcher matcher = pattern.matcher(assertText);
186 |
187 | while (matcher.find()) {
188 | String values = matcher.group();
189 | String[] splitValues = values.split("\\,");
190 | if (splitValues.length < 3) {
191 | String actual = splitValues[0].toLowerCase();
192 | if (!TextUtils.isEmpty(actual)) {
193 | String expected = splitValues[1].toLowerCase();
194 | Assert.assertEquals(actual, expected);
195 | extentTest.log(LogStatus.INFO,
196 | "Values are correct->" + "actual:" + actual + " expected:" + expected);
197 | }
198 | } else {
199 | long firstValue = Long.valueOf(splitValues[0]);
200 | long secondValue = Long.valueOf(splitValues[1]);
201 | long thirdValue = Long.valueOf(splitValues[2]);
202 | if (secondValue <= firstValue && thirdValue >= firstValue) {
203 | extentTest.log(LogStatus.PASS, "Values are correct->" + " Response Value:" + firstValue
204 | + " Epoch Start:" + secondValue + " Epoch end:" + thirdValue);
205 | } else {
206 | extentTest.log(LogStatus.FAIL, "Error in response->" + " Response Value:" + firstValue
207 | + " Epoch Start:" + secondValue + " Epoch end:" + thirdValue);
208 | }
209 | }
210 | }
211 |
212 | } catch (Exception e) {
213 | extentTest.log(LogStatus.ERROR, "Exception for assertmethod" + e);
214 | }
215 | }
216 |
217 | public void removeListValues(String value, LinkedHashMap data, ExtentTest extentTest) {
218 | String regex = "\\@[a-z|A-Z|0-9|\\.|\\@|\\,|\\_]+";
219 | Pattern pattern = Pattern.compile(regex);
220 | Matcher matcher = pattern.matcher(data.get(value));
221 | while (matcher.find()) {
222 | String values = matcher.group();
223 | data.put(value, data.get(value).replace(values, ""));
224 | System.out.println(data.get(value));
225 | }
226 | }
227 |
228 | public void extractListValue(String value, ExtentTest extentTest, LinkedHashMap data) {
229 | int positionValue = 0;
230 | try {
231 | String regex = "\\@[a-z|A-Z|0-9|\\.|\\[|\\]|\\-|\\_]+\\@";
232 | Pattern pattern = Pattern.compile(regex);
233 | Matcher matcher = pattern.matcher(data.get(value));
234 | while (matcher.find()) {
235 | String dynamicValue = matcher.group();
236 | String replaceUnwantedValue = matcher.group().replace("@", "");
237 | String replaceFirstAngleBracket = replaceUnwantedValue.replace("[", " ");
238 | String replaceSecondAnglrBracket = replaceFirstAngleBracket.replace("]", "");
239 | String[] splitDynamicValue = replaceSecondAnglrBracket.split("\\.");
240 | String sheetName = splitDynamicValue[0].toLowerCase();
241 | String testCaseid = splitDynamicValue[1];
242 | String path = splitDynamicValue[2].toLowerCase();
243 | String[] splitPathValue = path.split(" ");
244 | String pathValue = splitPathValue[0].toLowerCase();
245 | positionValue = Integer.parseInt(splitPathValue[1]);
246 | System.out.println("sheetName" + sheetName + "id--" + testCaseid + " value--" + pathValue);
247 | String dataBaseValue = inMemoryDatabasehelperObj.getDataFromDataBase(sheetName, testCaseid, pathValue);
248 | String[] dataBaseResultList = dataBaseValue.split("\\,");
249 | String finalValue = dataBaseResultList[positionValue];
250 | data.put(value, data.get(value).replace(dynamicValue, finalValue));
251 | }
252 |
253 | } catch (SQLException e) {
254 | extentTest.log(LogStatus.SKIP, "Row Empty for :" + data.get(value) + " -------------" + e);
255 | } catch (ArrayIndexOutOfBoundsException e) {
256 | extentTest.log(LogStatus.SKIP, "Empty for :--" + positionValue+"--" + e);
257 | } catch (Exception e) {
258 | extentTest.log(LogStatus.ERROR, "Exception for extractSingleValue" + data.get(value) + "-----" + e);
259 | }
260 | }
261 |
262 | }
--------------------------------------------------------------------------------
/src/main/java/com/framework/utility/GetJsonValuesFromResponse.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.utility;
5 |
6 | import java.util.ArrayList;
7 | import java.util.LinkedHashMap;
8 | import java.util.List;
9 | import com.framework.constants.Constants.ExcelColumnNameConstant;
10 | import com.framework.constants.Constants.InMemoryDatabaseHelperConstant;
11 | import com.framework.inmemorydatabase.InMemoryDatabaseHelper;
12 | import com.google.common.base.Joiner;
13 | import com.jayway.jsonpath.JsonPath;
14 | import com.jayway.jsonpath.PathNotFoundException;
15 | import com.relevantcodes.extentreports.ExtentTest;
16 | import com.relevantcodes.extentreports.LogStatus;
17 |
18 | import io.restassured.response.Response;
19 |
20 | /**
21 | * @author nikhil
22 | *
23 | */
24 | public class GetJsonValuesFromResponse {
25 | InMemoryDatabaseHelper inMemoryDatabasehelperObj = new InMemoryDatabaseHelper();
26 |
27 | /*
28 | * Get path name for storing in database.
29 | */
30 | public String getJsonPath(String jsonPath, ExtentTest extentTest) {
31 | String result = "";
32 | try {
33 | result = jsonPath.substring(jsonPath.lastIndexOf('.') + 1).trim().toLowerCase();
34 | } catch (Exception e) {
35 | extentTest.log(LogStatus.ERROR, "Exception for getJsonPath:" + e);
36 | }
37 | return result;
38 |
39 | }
40 |
41 | /*
42 | * Return List of String from response. Use for reading response
43 | * dynamically.
44 | *
45 | */
46 |
47 | public void extractStringList(Response response, String jsonPath, LinkedHashMap data,
48 | ExtentTest extentTest, String sheetName) {
49 | try {
50 | String path = getJsonPath(jsonPath, extentTest);
51 | List listValues = JsonPath.read(response.getBody().asString(), jsonPath);
52 | String values = String.join(",", listValues);
53 | inMemoryDatabasehelperObj.createData(data.get(ExcelColumnNameConstant.TESTID.toString()), sheetName, path,
54 | values, InMemoryDatabaseHelperConstant.TABLENAME.toString());
55 | System.out.println(values);
56 | } catch (PathNotFoundException e) {
57 | extentTest.log(LogStatus.SKIP, "Path Not Found :" + e);
58 | } catch (Exception e) {
59 | extentTest.log(LogStatus.ERROR, "Exception for extractStringList:" + e);
60 | }
61 | }
62 |
63 | /*
64 | * Return Number List from response. Use for reading response dynamically.
65 | *
66 | */
67 |
68 | public void extractNumberList(Response response, String jsonPath, LinkedHashMap data,
69 | ExtentTest extentTest, String sheetName) {
70 | try {
71 | String path = getJsonPath(jsonPath, extentTest);
72 | List numberlist = JsonPath.read(response.getBody().asString(), jsonPath);
73 | String values = Joiner.on(',').join(numberlist);
74 | inMemoryDatabasehelperObj.createData(data.get(ExcelColumnNameConstant.TESTID.toString()), sheetName, path,
75 | values, InMemoryDatabaseHelperConstant.TABLENAME.toString());
76 | System.out.println(values);
77 | } catch (PathNotFoundException e) {
78 | extentTest.log(LogStatus.SKIP, "Path Not Found :" + e);
79 | } catch (Exception e) {
80 | extentTest.log(LogStatus.ERROR, "Exception for extractNumberList:" + e);
81 | }
82 | }
83 |
84 | /*
85 | * Return Long List from response. Use for reading response dynamically.
86 | *
87 | */
88 |
89 | public void extractLongList(Response response, String jsonPath, LinkedHashMap data,
90 | ExtentTest extentTest, String sheetName) {
91 | try {
92 | String path = getJsonPath(jsonPath, extentTest);
93 | List longList = JsonPath.read(response.getBody().asString(), jsonPath);
94 | String values = Joiner.on(',').join(longList);
95 | inMemoryDatabasehelperObj.createData(data.get(ExcelColumnNameConstant.TESTID.toString()), sheetName, path,
96 | values, InMemoryDatabaseHelperConstant.TABLENAME.toString());
97 | System.out.println(values);
98 | } catch (PathNotFoundException e) {
99 | extentTest.log(LogStatus.SKIP, "Path Not Found :" + e);
100 | } catch (Exception e) {
101 | extentTest.log(LogStatus.ERROR, "Exception for extractLongList:" + e);
102 | }
103 | }
104 |
105 | /*
106 | * Return Number from response. Use for reading response dynamically.
107 | *
108 | */
109 | public void extractNumber(Response response, String jsonPath, LinkedHashMap data,
110 | ExtentTest extentTest, String sheetName) {
111 | try {
112 | String path = getJsonPath(jsonPath, extentTest);
113 | Number numberValue = JsonPath.read(response.getBody().asString(), jsonPath);
114 | String number = numberValue.toString();
115 | inMemoryDatabasehelperObj.createData(data.get(ExcelColumnNameConstant.TESTID.toString()), sheetName, path,
116 | number, InMemoryDatabaseHelperConstant.TABLENAME.toString());
117 | System.out.println(number);
118 | } catch (PathNotFoundException e) {
119 | extentTest.log(LogStatus.SKIP, "Path Not Found :" + e);
120 | } catch (Exception e) {
121 | extentTest.log(LogStatus.ERROR, "Exception for extractNumber:" + e);
122 | }
123 | }
124 |
125 | /*
126 | * Return String from response. Use for reading response dynamically.
127 | *
128 | */
129 |
130 | public void extractString(Response response, String jsonPath, LinkedHashMap data,
131 | ExtentTest extentTest, String sheetName) {
132 | try {
133 | String path = getJsonPath(jsonPath, extentTest);
134 | String value = JsonPath.read(response.getBody().asString(), jsonPath);
135 | inMemoryDatabasehelperObj.createData(data.get(ExcelColumnNameConstant.TESTID.toString()), sheetName, path,
136 | value, InMemoryDatabaseHelperConstant.TABLENAME.toString());
137 | System.out.println(value);
138 | } catch (PathNotFoundException e) {
139 | extentTest.log(LogStatus.SKIP, "Path Not Found :" + e);
140 | } catch (Exception e) {
141 | extentTest.log(LogStatus.ERROR, "Exception for extractString:" + e);
142 | }
143 | }
144 |
145 | /*
146 | * Return boolean value from response. Use for reading response dynamically.
147 | *
148 | */
149 | public void extractBoolean(Response response, String jsonPath, LinkedHashMap data,
150 | ExtentTest extentTest, String sheetName) {
151 | try {
152 | String path = getJsonPath(jsonPath, extentTest);
153 | Boolean booleanValue = JsonPath.read(response.getBody().asString(), jsonPath);
154 | String value = String.valueOf(booleanValue);
155 | inMemoryDatabasehelperObj.createData(data.get(ExcelColumnNameConstant.TESTID.toString()), sheetName, path,
156 | value, InMemoryDatabaseHelperConstant.TABLENAME.toString());
157 | System.out.println(value);
158 | } catch (PathNotFoundException e) {
159 | extentTest.log(LogStatus.SKIP, "Path Not Found :" + e);
160 | } catch (Exception e) {
161 | extentTest.log(LogStatus.ERROR, "Exception for extractBooleanValue:" + e);
162 | }
163 | }
164 |
165 | /*
166 | * Return Long value from response. Use for reading response dynamically.
167 | */
168 | public void extractLong(Response response, String jsonPath, LinkedHashMap data,
169 | ExtentTest extentTest, String sheetName) {
170 | try {
171 | String path = getJsonPath(jsonPath, extentTest);
172 | Long longvValue = JsonPath.read(response.getBody().asString(), jsonPath);
173 | String value = Long.toString(longvValue);
174 | inMemoryDatabasehelperObj.createData(data.get(ExcelColumnNameConstant.TESTID.toString()), sheetName, path,
175 | value, InMemoryDatabaseHelperConstant.TABLENAME.toString());
176 | System.out.println(value);
177 | } catch (PathNotFoundException e) {
178 | extentTest.log(LogStatus.SKIP, "Path Not Found :" + e);
179 | } catch (Exception e) {
180 | extentTest.log(LogStatus.ERROR, "Exception for extractLong:" + e);
181 | }
182 | }
183 |
184 | /*
185 | * Return List of array list from response. Use for reading response
186 | * dynamically.
187 | *
188 | */
189 |
190 | public void extractListOfLists(Response response, String jsonPath, LinkedHashMap data,
191 | ExtentTest extentTest, String sheetName) {
192 | try {
193 | String path = getJsonPath(jsonPath, extentTest);
194 | List> arrayList = JsonPath.read(response.getBody().asString(), jsonPath);
195 | String values = Joiner.on(',').join(arrayList);
196 | inMemoryDatabasehelperObj.createData(data.get(ExcelColumnNameConstant.TESTID.toString()), sheetName, path,
197 | values, InMemoryDatabaseHelperConstant.TABLENAME.toString());
198 | System.out.println(values);
199 | } catch (PathNotFoundException e) {
200 | extentTest.log(LogStatus.SKIP, "Path Not Found :" + e);
201 | } catch (Exception e) {
202 | extentTest.log(LogStatus.ERROR, "Exception for extractListWithJsonPathForListOfLists:" + e);
203 | }
204 |
205 | }
206 |
207 | }
--------------------------------------------------------------------------------
/src/main/java/com/framework/utility/Reflection.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.utility;
5 |
6 | import java.lang.reflect.Method;
7 | import java.util.LinkedHashMap;
8 | import java.util.Map.Entry;
9 | import com.framework.constants.Constants.ExcelColumnNameConstant;
10 | import com.framework.constants.Constants.RestUtilConstant;
11 | import com.relevantcodes.extentreports.ExtentTest;
12 | import com.relevantcodes.extentreports.LogStatus;
13 |
14 | import io.restassured.response.Response;
15 |
16 | /**
17 | * @author nikhil
18 | *
19 | */
20 | public class Reflection {
21 |
22 | String restUtilClassName;
23 | Class> restutilClass = null;
24 | Object restUtil = null;
25 |
26 | public Reflection() {
27 | restUtilClassName = RestUtilConstant.RESTUTILCLASSNAME.toString();
28 | try {
29 | // convert string classname to class
30 | restutilClass = Class.forName(restUtilClassName);
31 | // invoke empty constructor
32 | restUtil = restutilClass.newInstance();
33 | } catch (Exception e) {
34 | System.out.println("Exception for Reflection---->" + e);
35 | }
36 |
37 | }
38 |
39 | /*
40 | * separateMethodAndJsonPath method seprate the method and json path.
41 | */
42 | public LinkedHashMap separateMethodAndJsonPath(LinkedHashMap data,
43 | ExtentTest extentTest) {
44 | LinkedHashMap methodAndJsonPathMap = new LinkedHashMap();
45 | try {
46 | String[] methodsAndJsonPaths = data.get(ExcelColumnNameConstant.TESTMETHODANDJSONPATH.toString())
47 | .split(";");
48 | int methodsAndJsonPathsSize = methodsAndJsonPaths.length;
49 | System.out.println("Total Size" + methodsAndJsonPathsSize);
50 | for (int i = 0; i < methodsAndJsonPathsSize; i++) {
51 | String[] methodAndJsonPath = methodsAndJsonPaths[i].split(":");
52 | String method = methodAndJsonPath[0];
53 | String jsonPath = methodAndJsonPath[1];
54 | methodAndJsonPathMap.put(jsonPath, method);
55 | }
56 | } catch (Exception e) {
57 | extentTest.log(LogStatus.ERROR, "Exception:" + e);
58 | }
59 | return methodAndJsonPathMap;
60 | }
61 |
62 | /*
63 | * invokeReflection call the helper and separate multiple method calls.
64 | */
65 | public void invokeReflection(LinkedHashMap data, LinkedHashMap methodAndJsonPathMap,
66 | Response resp, ExtentTest extentTest,String sheetName) {
67 | try {
68 | for (Entry entry : methodAndJsonPathMap.entrySet()) {
69 | String jsonPath = entry.getKey();
70 | String methodName = entry.getValue();
71 | reflectionHelper(data, methodName, jsonPath, resp, extentTest,sheetName);
72 | }
73 | } catch (Exception e) {
74 | extentTest.log(LogStatus.ERROR, "Exception:" + e);
75 | }
76 | }
77 |
78 | /*
79 | * Reflection helps to call method runtime.
80 | */
81 | public void reflectionHelper(LinkedHashMap data, String methodName, String jsonPath, Response resp,
82 | ExtentTest extentTest,String sheetName) {
83 | try {
84 | Method setNameMethod = restUtil.getClass().getMethod(methodName, Response.class, String.class,
85 | LinkedHashMap.class, ExtentTest.class,String.class);
86 | setNameMethod.invoke(restUtil, resp, jsonPath, data, extentTest,sheetName);
87 | } catch (Exception e) {
88 | extentTest.log(LogStatus.ERROR, "Exception for reflection:" + e);
89 | }
90 | }
91 |
92 | }
--------------------------------------------------------------------------------
/src/main/java/com/framework/utility/RestAssuredHelper.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.utility;
5 |
6 | import java.util.LinkedHashMap;
7 | import org.apache.http.util.TextUtils;
8 | import org.testng.Assert;
9 | import com.framework.constants.Constants.ExcelColumnNameConstant;
10 | import com.framework.constants.Constants.RestAssuredHelperConstant;
11 | import com.framework.restassured.ApiExecutor;
12 | import com.relevantcodes.extentreports.ExtentTest;
13 | import com.relevantcodes.extentreports.LogStatus;
14 | import io.restassured.response.Response;
15 |
16 | /**
17 | * @author nikhil
18 | *
19 | */
20 | public class RestAssuredHelper {
21 |
22 | ApiExecutor apiObj = new ApiExecutor();
23 | Reflection reflectionObj = new Reflection();
24 |
25 | public void apiExecutorHelper(LinkedHashMap data, ExtentTest extentTest, String sheetName) {
26 |
27 | Response resp;
28 | String apiType = data.get(ExcelColumnNameConstant.TESTAPITYPE.toString());
29 | int expectedResponseCode = Integer
30 | .parseInt(data.get(ExcelColumnNameConstant.TESTEXPECTEDSTATUSCODE.toString()));
31 | switch (apiType.toLowerCase()) {
32 |
33 | case RestAssuredHelperConstant.GET:
34 | resp = apiObj.apiGet(data, extentTest);
35 | if (resp != null) {
36 | Assert.assertEquals(resp.getStatusCode(), expectedResponseCode);
37 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTMETHODANDJSONPATH.toString()))) {
38 | LinkedHashMap methodAndJsonPathMap = reflectionObj.separateMethodAndJsonPath(data,
39 | extentTest);
40 | reflectionObj.invokeReflection(data, methodAndJsonPathMap, resp, extentTest, sheetName);
41 | }
42 | }
43 | break;
44 |
45 | case RestAssuredHelperConstant.POST:
46 | resp = apiObj.apiPost(data, extentTest);
47 | if (resp != null) {
48 | Assert.assertEquals(resp.getStatusCode(), expectedResponseCode);
49 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTMETHODANDJSONPATH.toString()))) {
50 | LinkedHashMap methodAndJsonPathMap = reflectionObj.separateMethodAndJsonPath(data,
51 | extentTest);
52 | reflectionObj.invokeReflection(data, methodAndJsonPathMap, resp, extentTest, sheetName);
53 | }
54 | }
55 | break;
56 | case RestAssuredHelperConstant.PUT:
57 | resp = apiObj.apiPut(data, extentTest);
58 | if (resp != null) {
59 | Assert.assertEquals(resp.getStatusCode(), expectedResponseCode);
60 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTMETHODANDJSONPATH.toString()))) {
61 | LinkedHashMap methodAndJsonPathMap = reflectionObj.separateMethodAndJsonPath(data,
62 | extentTest);
63 | reflectionObj.invokeReflection(data, methodAndJsonPathMap, resp, extentTest, sheetName);
64 | }
65 | }
66 | break;
67 |
68 | case RestAssuredHelperConstant.DELETE:
69 | resp = apiObj.apiDelete(data, extentTest);
70 | if (resp != null) {
71 | Assert.assertEquals(resp.getStatusCode(), expectedResponseCode);
72 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTMETHODANDJSONPATH.toString()))) {
73 | LinkedHashMap methodAndJsonPathMap = reflectionObj.separateMethodAndJsonPath(data,
74 | extentTest);
75 | reflectionObj.invokeReflection(data, methodAndJsonPathMap, resp, extentTest, sheetName);
76 | }
77 | }
78 | break;
79 |
80 | case RestAssuredHelperConstant.PATCH:
81 | resp = apiObj.apiPatch(data, extentTest);
82 | if (resp != null) {
83 | Assert.assertEquals(resp.getStatusCode(), expectedResponseCode);
84 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTMETHODANDJSONPATH.toString()))) {
85 | LinkedHashMap methodAndJsonPathMap = reflectionObj.separateMethodAndJsonPath(data,
86 | extentTest);
87 | reflectionObj.invokeReflection(data, methodAndJsonPathMap, resp, extentTest, sheetName);
88 | }
89 | }
90 | break;
91 |
92 | default:
93 | extentTest.log(LogStatus.ERROR, "No Case Matched For API Type:");
94 | break;
95 | }
96 | }
97 |
98 | }
--------------------------------------------------------------------------------
/src/main/resources/client_secret.json:
--------------------------------------------------------------------------------
1 | {"installed":{"client_id":"*******************************.apps.googleusercontent.com","project_id":"crypto-eon-174511","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"*****************","redirect_uris":["****************************","http://localhost"]}}
--------------------------------------------------------------------------------
/src/test/java/com/framework/testcasesbase/testsuite/ApiTestFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.testcasesbase.testsuite;
5 |
6 | import org.apache.http.util.TextUtils;
7 | import org.testng.annotations.Factory;
8 |
9 | import com.framework.commans.Commans.FactoryHelperCommans;
10 | import com.framework.constants.Constants.ApiTestFactoryConstants;
11 | import com.framework.constants.Constants.DownloadExcelFileHelperConstants;
12 | import com.framework.testsuite.TestCases;
13 | import com.framework.utility.FactoryHelper;
14 |
15 | /**
16 | * @author nikhil
17 | *
18 | */
19 | public class ApiTestFactory {
20 | FactoryHelper factoryHelperObj = new FactoryHelper();
21 |
22 | @Factory
23 | public Object[] runSheet() {
24 | Object[] res = null;
25 | try {
26 | // download file from google drive.
27 | if (!TextUtils.isEmpty(DownloadExcelFileHelperConstants.EXCELFILEPATH.toString()))
28 | factoryHelperObj.downloadFile();
29 |
30 | // create table.
31 | factoryHelperObj.createTable();
32 |
33 | // Add epoch dates to database.
34 | factoryHelperObj.addEpochDates(ApiTestFactoryConstants.SHEETNAME.toString());
35 |
36 | // Get Runnable sheets from excel.
37 | factoryHelperObj.getRunnableSheets();
38 |
39 | res = new Object[FactoryHelperCommans.sheetsName.size()];
40 | for (int i = 0; i < FactoryHelperCommans.sheetsName.size(); i++) {
41 | res[i] = new TestCases();
42 | }
43 | } catch (Exception e) {
44 | // TODO Auto-generated catch block
45 | e.printStackTrace();
46 | }
47 | return res;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/test/java/com/framework/testsuite/TestCases.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package com.framework.testsuite;
5 |
6 | import java.util.LinkedHashMap;
7 |
8 | import org.apache.http.util.TextUtils;
9 | import org.testng.annotations.AfterClass;
10 | import org.testng.annotations.AfterMethod;
11 | import org.testng.annotations.Test;
12 |
13 | import com.framework.commans.Commans.DataUtilCommans;
14 | import com.framework.commans.Commans.FactoryHelperCommans;
15 | import com.framework.constants.Constants.ExcelColumnNameConstant;
16 | import com.framework.utility.DataUtil;
17 | import com.framework.utility.ExtentManager;
18 | import com.framework.utility.GetDynamicData;
19 | import com.framework.utility.RestAssuredHelper;
20 | import com.relevantcodes.extentreports.ExtentReports;
21 | import com.relevantcodes.extentreports.ExtentTest;
22 | import com.relevantcodes.extentreports.LogStatus;
23 |
24 | /**
25 | * @author nikhil
26 | *
27 | */
28 | public class TestCases {
29 | ExtentManager extentReportObj = new ExtentManager();
30 | GetDynamicData getDynamicData = new GetDynamicData();
31 | RestAssuredHelper restAssuredHelperObj = new RestAssuredHelper();
32 | public ExtentReports extentReport;
33 | public ExtentTest extentTest;
34 |
35 | @Test(priority = 1, dataProvider = "getData", dataProviderClass = DataUtil.class)
36 | public void testMethod(LinkedHashMap data) {
37 | String sheetName = FactoryHelperCommans.sheetsName.get(DataUtilCommans.count - 1).toLowerCase();
38 | extentReport = extentReportObj.getInstance(sheetName);
39 | try {
40 | if (!TextUtils.isEmpty(data.get(ExcelColumnNameConstant.TESTFLOWNAME.toString()))) {
41 | extentTest = extentReport.startTest(data.get(ExcelColumnNameConstant.TESTFLOWNAME.toString()));
42 | }
43 | extentTest.log(LogStatus.INFO,
44 | "Test Case Name:->>" + data.get(ExcelColumnNameConstant.TESTCASENAME.toString()));
45 | getDynamicData.getDynamicValues(data, extentTest, sheetName);
46 | getDynamicData.assertSingleDynamicValue(data, extentTest);
47 | } catch (AssertionError e) {
48 | extentTest.log(LogStatus.FAIL,
49 | "Fail " + data.get(ExcelColumnNameConstant.TESTCASENAME.toString()) + e.getMessage());
50 | org.testng.Assert
51 | .fail("Fail for" + data.get(ExcelColumnNameConstant.TESTCASENAME.toString()) + e.getMessage());
52 | } catch (Exception e) {
53 | extentTest.log(LogStatus.FAIL,
54 | "Fail " + data.get(ExcelColumnNameConstant.TESTCASENAME.toString()) + e.getMessage());
55 | org.testng.Assert
56 | .fail("Fail for" + data.get(ExcelColumnNameConstant.TESTCASENAME.toString()) + e.getMessage());
57 | }
58 | }
59 |
60 | @AfterMethod
61 | public void afterMethod() {
62 | if (extentReport != null) {
63 | extentReport.endTest(extentTest);
64 | extentReport.flush();
65 | }
66 | }
67 |
68 | @AfterClass(alwaysRun = true)
69 | public void afterClass() {
70 | extentReport.close();
71 | }
72 |
73 | }
--------------------------------------------------------------------------------
/src/test/resources/ExcelData/FrameworkSheet.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nike14/Generic-Automated-Test-Framework-For-API-Testing/66039c5a70853e9794eeb79ab48a3e6afe078e2e/src/test/resources/ExcelData/FrameworkSheet.xlsx
--------------------------------------------------------------------------------
/src/test/resources/addplace.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "additionalProperties": false,
4 | "definitions": {},
5 | "id": "https://maps.googleapis.com/maps/api/place/add/json",
6 | "properties": {
7 | "id": {
8 | "id": "/properties/id",
9 | "type": "string"
10 | },
11 | "place_id": {
12 | "id": "/properties/place_id",
13 | "type": "string"
14 | },
15 | "reference": {
16 | "id": "/properties/reference",
17 | "type": "string"
18 | },
19 | "scope": {
20 | "id": "/properties/scope",
21 | "type": "string"
22 | },
23 | "status": {
24 | "id": "/properties/status",
25 | "type": "string",
26 | "enum": ["OK"]
27 | }
28 | },
29 | "required": [
30 | "status",
31 | "scope",
32 | "place_id",
33 | "id",
34 | "reference"
35 | ],
36 | "type": "object"
37 | }
--------------------------------------------------------------------------------
/src/test/resources/authorizationfailure.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "definitions": {},
4 | "properties": {
5 | "message": {
6 | "id": "/properties/message",
7 | "type": "string",
8 | "enum": ["Authorization Failure","Not a Franchise User","Unauthorized.","Object not Found","Something went wrong","Action Not Allowed","Not Allowed To Undo"]
9 | },
10 | "responseData": {
11 | "id": "/properties/responseData",
12 | "properties": {},
13 | "type": "object"
14 | },
15 | "status": {
16 | "id": "/properties/status",
17 | "type": "boolean",
18 | "enum": [false]
19 | }
20 | },
21 | "required": [
22 | "status",
23 | "responseData",
24 | "message"
25 | ],
26 | "type": "object"
27 | }
--------------------------------------------------------------------------------
/src/test/resources/deleteplace.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "additionalProperties": false,
4 | "definitions": {},
5 | "id": "https://maps.googleapis.com/maps/api/place/add/json",
6 | "properties": {
7 | "status": {
8 | "id": "/properties/status",
9 | "type": "string",
10 | "enum": ["OK"]
11 | }
12 | },
13 | "required": [
14 | "status"
15 | ],
16 | "type": "object"
17 | }
--------------------------------------------------------------------------------
/src/test/resources/searchplace.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "additionalProperties": false,
4 | "definitions": {},
5 | "id": "https://maps.googleapis.com/maps/api/place/textsearch/json",
6 | "properties": {
7 | "html_attributions": {
8 | "id": "/properties/html_attributions",
9 | "items": {},
10 | "type": "array"
11 | },
12 | "next_page_token": {
13 | "id": "/properties/next_page_token",
14 | "type": "string"
15 | },
16 | "results": {
17 | "id": "/properties/results",
18 | "items": {
19 | "additionalProperties": false,
20 | "id": "/properties/results/items",
21 | "properties": {
22 | "formatted_address": {
23 | "id": "/properties/results/items/properties/formatted_address",
24 | "type": "string"
25 | },
26 | "geometry": {
27 | "additionalProperties": false,
28 | "id": "/properties/results/items/properties/geometry",
29 | "properties": {
30 | "location": {
31 | "additionalProperties": false,
32 | "id": "/properties/results/items/properties/geometry/properties/location",
33 | "properties": {
34 | "lat": {
35 | "id": "/properties/results/items/properties/geometry/properties/location/properties/lat",
36 | "type": "number"
37 | },
38 | "lng": {
39 | "id": "/properties/results/items/properties/geometry/properties/location/properties/lng",
40 | "type": "number"
41 | }
42 | },
43 | "required": [
44 | "lat",
45 | "lng"
46 | ],
47 | "type": "object"
48 | },
49 | "viewport": {
50 | "additionalProperties": false,
51 | "id": "/properties/results/items/properties/geometry/properties/viewport",
52 | "properties": {
53 | "northeast": {
54 | "additionalProperties": false,
55 | "id": "/properties/results/items/properties/geometry/properties/viewport/properties/northeast",
56 | "properties": {
57 | "lat": {
58 | "id": "/properties/results/items/properties/geometry/properties/viewport/properties/northeast/properties/lat",
59 | "type": "number"
60 | },
61 | "lng": {
62 | "id": "/properties/results/items/properties/geometry/properties/viewport/properties/northeast/properties/lng",
63 | "type": "number"
64 | }
65 | },
66 | "required": [
67 | "lat",
68 | "lng"
69 | ],
70 | "type": "object"
71 | },
72 | "southwest": {
73 | "additionalProperties": false,
74 | "id": "/properties/results/items/properties/geometry/properties/viewport/properties/southwest",
75 | "properties": {
76 | "lat": {
77 | "id": "/properties/results/items/properties/geometry/properties/viewport/properties/southwest/properties/lat",
78 | "type": "number"
79 | },
80 | "lng": {
81 | "id": "/properties/results/items/properties/geometry/properties/viewport/properties/southwest/properties/lng",
82 | "type": "number"
83 | }
84 | },
85 | "required": [
86 | "lat",
87 | "lng"
88 | ],
89 | "type": "object"
90 | }
91 | },
92 | "required": [
93 | "northeast",
94 | "southwest"
95 | ],
96 | "type": "object"
97 | }
98 | },
99 | "required": [
100 | "location",
101 | "viewport"
102 | ],
103 | "type": "object"
104 | },
105 | "icon": {
106 | "id": "/properties/results/items/properties/icon",
107 | "type": "string"
108 | },
109 | "id": {
110 | "id": "/properties/results/items/properties/id",
111 | "type": "string"
112 | },
113 | "name": {
114 | "id": "/properties/results/items/properties/name",
115 | "type": "string"
116 | },
117 | "opening_hours": {
118 | "additionalProperties": false,
119 | "id": "/properties/results/items/properties/opening_hours",
120 | "properties": {
121 | "open_now": {
122 | "id": "/properties/results/items/properties/opening_hours/properties/open_now",
123 | "type": "boolean"
124 | },
125 | "weekday_text": {
126 | "id": "/properties/results/items/properties/opening_hours/properties/weekday_text",
127 | "items": {},
128 | "type": "array"
129 | }
130 | },
131 | "required": [
132 | "weekday_text",
133 | "open_now"
134 | ],
135 | "type": "object"
136 | },
137 | "photos": {
138 | "id": "/properties/results/items/properties/photos",
139 | "items": {
140 | "additionalProperties": false,
141 | "id": "/properties/results/items/properties/photos/items",
142 | "properties": {
143 | "height": {
144 | "id": "/properties/results/items/properties/photos/items/properties/height",
145 | "type": "integer"
146 | },
147 | "html_attributions": {
148 | "id": "/properties/results/items/properties/photos/items/properties/html_attributions",
149 | "items": {
150 | "id": "/properties/results/items/properties/photos/items/properties/html_attributions/items",
151 | "type": "string"
152 | },
153 | "type": "array"
154 | },
155 | "photo_reference": {
156 | "id": "/properties/results/items/properties/photos/items/properties/photo_reference",
157 | "type": "string"
158 | },
159 | "width": {
160 | "id": "/properties/results/items/properties/photos/items/properties/width",
161 | "type": "integer"
162 | }
163 | },
164 | "required": [
165 | "photo_reference",
166 | "width",
167 | "html_attributions",
168 | "height"
169 | ],
170 | "type": "object"
171 | },
172 | "type": "array"
173 | },
174 | "place_id": {
175 | "id": "/properties/results/items/properties/place_id",
176 | "type": "string"
177 | },
178 | "rating": {
179 | "id": "/properties/results/items/properties/rating",
180 | "type": "number"
181 | },
182 | "reference": {
183 | "id": "/properties/results/items/properties/reference",
184 | "type": "string"
185 | },
186 | "types": {
187 | "id": "/properties/results/items/properties/types",
188 | "items": {
189 | "id": "/properties/results/items/properties/types/items",
190 | "type": "string"
191 | },
192 | "type": "array"
193 | }
194 | },
195 | "required": [
196 | "name",
197 | "reference",
198 | "geometry",
199 | "place_id",
200 | "formatted_address",
201 | "id",
202 | "types",
203 | "icon"
204 | ],
205 | "type": "object"
206 | },
207 | "type": "array"
208 | },
209 | "status": {
210 | "id": "/properties/status",
211 | "type": "string",
212 | "enum": ["OK"]
213 | }
214 | },
215 | "required": [
216 | "status",
217 | "next_page_token",
218 | "html_attributions",
219 | "results"
220 | ],
221 | "type": "object"
222 | }
--------------------------------------------------------------------------------
/testng.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------