web-api-commander/build.gradle

333 lines
12 KiB
Groovy

import java.text.DateFormat
import java.text.SimpleDateFormat
plugins {
// Apply the java plugin to add support for Java
id 'java'
// Apply the application plugin to add support for building an application
id 'application'
}
// Define the main class for the application
mainClassName = 'org.reso.commander.Main'
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
compile 'com.google.guava:guava:28.2-jre'
compile 'com.google.inject:guice:4.2.3'
compile 'commons-cli:commons-cli:1.4'
compile 'org.apache.logging.log4j:log4j-api:2.13.0'
compile 'org.apache.logging.log4j:log4j-slf4j-impl:2.13.0'
compile 'org.apache.logging.log4j:log4j-1.2-api:2.13.0'
compile 'org.apache.logging.log4j:log4j-core:2.13.0'
compile 'org.apache.olingo:odata-client-api:4.8.0'
compile 'org.apache.olingo:odata-commons-core:4.8.0'
compile 'org.apache.olingo:odata-client-core:4.8.0'
compile 'org.apache.poi:poi:3.17'
compile 'org.apache.poi:poi-ooxml:3.17'
compile 'io.rest-assured:rest-assured:4.2.0'
compile 'io.rest-assured:json-path:4.2.0'
compile 'io.rest-assured:json-schema-validator:4.2.0'
compile 'io.cucumber:cucumber-java8:5.4.0'
compile 'io.cucumber:cucumber-java:5.4.0'
compile 'io.cucumber:cucumber-junit:5.4.0'
compile 'io.cucumber:cucumber-guice:5.4.0'
compile 'io.cucumber:cucumber-core:5.4.0'
compile 'net.masterthought:cucumber-reporting:5.1.1'
compile 'com.networknt:json-schema-validator:1.0.35'
compile 'com.google.code.gson:gson:2.8.6'
compile 'org.apache.commons:commons-text:1.9'
}
configurations {
cucumberRuntime {
extendsFrom compile
}
}
jar {
manifest {
attributes(
'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
'Main-Class': 'org.reso.commander.App'
)
}
// generate "fat jar" by default
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
// don't suppress warnings or deprecation notices
tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:unchecked'
options.deprecation = true
}
String pathToMetadata = null,
pathToRESOScript = null,
certFileName = null,
certOutputDir = null,
certJsonPath = null
// task for Web API Server 1.0.2 Core Testing
task testWebApiServer_1_0_2_Core() {
group = 'RESO Certification'
description = 'Runs Web API Core 1.0.2 Automated Acceptance Tests.' +
'\n Example: ' +
'\n $ ./gradlew testWebApiServer_1_0_2_Core -DpathToRESOScript=/path/to/web-api-core-1.0.2.resoscript -DshowResponses=true\n' +
'\n Note: by default the Web API tests assume Collection(Edm.EnumType).' +
'\n Pass -DuseCollections=false if using OData IsFlags.\n'
dependsOn jar
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
systemProperties = System.getProperties()
args = [
'--strict',
'--plugin',
'pretty',
'--plugin',
'json:build/web-api-server.core.1.0.2.json',
'--plugin',
'html:build/web-api-server.core.1.0.2.html',
'--glue',
'org.reso.certification.stepdefs#WebAPIServer_1_0_2',
'src/main/java/org/reso/certification/features/web-api',
'--tags',
'@core-endorsement'
]
}
}
}
// task for Data Dictionary 1.7
task testDataDictionary_1_7() {
group = 'RESO Certification'
description = 'Runs Data Dictionary 1.7 Automated Acceptance Tests and generates a "raw" report.' +
'\n RESOScript Example:' +
'\n ./gradlew testDataDictionary_1_7 -DpathToRESOScript=/path/to/dd17.resoscript -DshowResponses=true -Dcucumber.filter.tags=""' +
'\n Metadata File Example:' +
'\n ./gradlew testDataDictionary_1_7 -DpathToMetadata=/path/to/RESODataDictionary-1.7.xml -Dcucumber.filter.tags=""' +
'\n To enable strict mode, pass -Dstrict=true. All applicants MUST pass strict mode tests to be certified.\n'
dependsOn jar
doLast {
javaexec {
main = 'io.cucumber.core.cli.Main'
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
systemProperties = System.getProperties()
pathToMetadata = System.getProperty('pathToMetadata', null)
pathToRESOScript = System.getProperty('pathToRESOScript', null)
if (pathToMetadata != null) {
certFileName = pathToMetadata
.substring(Math.max(pathToMetadata.lastIndexOf(File.separator)+1, 0), pathToMetadata.lastIndexOf('.'))
} else if (pathToRESOScript != null) {
certFileName = pathToRESOScript
.substring(Math.max(pathToRESOScript.lastIndexOf(File.separator)+1, 0), pathToRESOScript.lastIndexOf('.'))
}
DateFormat df = new SimpleDateFormat("yyyyMMddHHMMssS")
certOutputDir = 'DD1.7-results' + (certFileName != null ? '-' + certFileName : '') + '-' + df.format(new Date())
certJsonPath = certOutputDir + '/data-dictionary-1.7.json'
args = [
'--strict',
'--plugin',
'pretty',
'--plugin',
'json:' + certJsonPath,
'--plugin',
'html:' + certOutputDir + '/data-dictionary-1.7.html',
'--glue',
'org.reso.certification.stepdefs#DataDictionary',
'src/main/java/org/reso/certification/features/data-dictionary/v1-7-0',
'--tags',
(systemProperties.get('cucumber.filter.tags', '').toString().trim().length() > 0
? systemProperties.get('cucumber.filter.tags') : '')
]
}
}
}
task generateCertificationReport_DD_1_7() {
group = 'RESO Certification'
description = 'Runs Data Dictionary 1.7 tests and creates a certification report' +
'\n RESOScript Example:' +
'\n ./gradlew generateCertificationReport_DD_1_7 -DpathToRESOScript=/path/to/dd17.resoscript -Dminimal=true -Dstrict=true' +
'\n Metadata File Example:' +
'\n ./gradlew generateCertificationReport_DD_1_7 -DpathToMetadata=/path/to/RESODataDictionary-1.7.xml -Dminimal=true -Dstrict=true' +
'\n To enable strict mode, pass -Dstrict=true. All applicants MUST pass strict mode tests to be certified.\n'
dependsOn testDataDictionary_1_7
doLast {
javaexec {
System.setProperty('pathToJsonResults', certJsonPath)
System.setProperty('reportDescription', 'RESO Data Dictionary 1.7 Certification Report')
systemProperties = System.getProperties()
classpath = sourceSets.main.runtimeClasspath
main = 'org.reso.certification.reporting.CertificationReportGenerator'
}
}
}
task testDataDictionaryReferenceMetadata_1_7() {
group = 'RESO Certification'
description = 'Runs Data Dictionary tests against reference metadata\n'
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
System.setProperty('pathToMetadata', 'src/main/resources/RESODataDictionary-1.7.xml')
systemProperties = System.getProperties()
args = [
'--strict',
'--plugin',
'pretty',
'--glue',
'org.reso.certification.stepdefs#DataDictionary',
'src/main/java/org/reso/certification/features/data-dictionary/v1-7-0'
]
}
}
}
//used for internal Commander Web API acceptance testing
test {
dependsOn assemble, compileTestJava, testDataDictionaryReferenceMetadata_1_7
doLast {
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['--strict',
'--plugin',
'pretty',
'--glue',
'org.reso.commander.test.stepdefs',
'src/test/java/org/reso/commander/test/features'
]
}
}
}
// task for Data Dictionary 1.7 in Jenkins
// TODO: consolidate this with the DD tests it was copied from after further testing.
task _jenkins_testDataDictionary_1_7() {
group = 'RESO Certification - Jenkins'
description = 'Runs Data Dictionary 1.7 Automated Acceptance Tests in a way that plays well with various Jenkins Plugins' +
"\n Commands used in this case are the same as self-testing locally, they're just passed to a Jenkins-specific config." +
"\n NOTE: Most people should never have to use this option unless they're using Jenkins for builds." +
'\n RESOScript Example:' +
'\n ./gradlew _jenkins_testDataDictionary_1_7() -DpathToRESOScript=/path/to/dd17.resoscript -DshowResponses=true -Dcucumber.filter.tags=""' +
'\n Metadata File Example:' +
'\n ./gradlew _jenkins_testDataDictionary_1_7() -DpathToMetadata=/path/to/RESODataDictionary-1.7.xml -Dcucumber.filter.tags=""' +
'\n To enable strict mode, pass -Dstrict=true. All applicants MUST pass strict mode tests to be certified.\n'
dependsOn jar
doLast {
certJsonPath = 'build/data-dictionary-1.7.jenkins.json'
javaexec {
main = 'io.cucumber.core.cli.Main'
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
systemProperties = System.getProperties()
pathToMetadata = System.getProperty('pathToMetadata', null)
pathToRESOScript = System.getProperty('pathToRESOScript', null)
if (pathToMetadata != null) {
certFileName = pathToMetadata
.substring(Math.max(pathToMetadata.lastIndexOf(File.separator) + 1, 0), pathToMetadata.lastIndexOf('.'))
} else if (pathToRESOScript != null) {
certFileName = pathToRESOScript
.substring(Math.max(pathToRESOScript.lastIndexOf(File.separator) + 1, 0), pathToRESOScript.lastIndexOf('.'))
}
args = [
'--strict',
'--plugin',
'json:' + certJsonPath,
'--glue',
'org.reso.certification.stepdefs#DataDictionary',
'src/main/java/org/reso/certification/features/data-dictionary/v1-7-0',
'--tags',
(systemProperties.get('cucumber.filter.tags', '').toString().trim().length() > 0
? systemProperties.get('cucumber.filter.tags') : '')
]
}
javaexec {
System.setProperty('pathToJsonResults', certJsonPath)
systemProperties = System.getProperties()
classpath = sourceSets.main.runtimeClasspath
main = 'org.reso.certification.reporting.CertificationReportGenerator'
}
}
}
// task for Web API Server 1.0.2 Core Testing specific to Jenkins
task _jenkins_testWebApiServer_1_0_2_Core() {
group = 'RESO Certification'
description = 'Runs Web API Server 1.0.2 Core Automated Acceptance Tests in a way that plays well with various Jenkins Plugins' +
"\n Commands used in this case are the same as self-testing locally, they're just passed to a Jenkins-specific config." +
"\n NOTE: Most people should never have to use this option unless they're using Jenkins for builds." +
'\n RESOScript Example:' +
'\n $ ./gradlew _jenkins_testWebApiServer_1_0_2_Core -DpathToRESOScript=/path/to/web-api-core-1.0.2.resoscript -DshowResponses=true\n' +
'\n Note: by default the Web API tests assume Collection(Edm.EnumType).' +
'\n Pass -DuseCollections=false if using OData IsFlags=true.\n'
dependsOn jar
doLast {
certJsonPath = 'build/web-api-server.core.1.0.2.jenkins.json'
javaexec {
main = "io.cucumber.core.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
systemProperties = System.getProperties()
args = [
'--strict',
'--plugin',
'json:' + certJsonPath,
'--glue',
'org.reso.certification.stepdefs#WebAPIServer_1_0_2',
'src/main/java/org/reso/certification/features/web-api',
'--tags',
'@core-endorsement'
]
}
javaexec {
System.setProperty('pathToJsonResults', certJsonPath)
systemProperties = System.getProperties()
classpath = sourceSets.main.runtimeClasspath
main = 'org.reso.certification.reporting.CertificationReportGenerator'
}
}
}