Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
12af242
Package change for Base module
Jan 28, 2022
f85546c
Package change for Selenium module
Jan 28, 2022
d995ec8
Package change for Utilities module
Jan 28, 2022
5c59ecb
Package change for Cucumber module
Jan 28, 2022
0959edb
Package change for Database module
Jan 28, 2022
5951640
Package change for Database module
Jan 28, 2022
8c4a62b
Package change for Appium module
Jan 28, 2022
30d6f29
Package change for WebService modules
Jan 28, 2022
c2fbfae
Module rename - Base
Jan 28, 2022
289bc51
Module rename - Utilities
Jan 28, 2022
80e2e34
Module rename - Appium
Jan 28, 2022
9bb6b19
Module rename - Selenium
Jan 28, 2022
db3b2ba
Module rename - Database
Jan 28, 2022
4a1a552
Module rename - Cucumber
Jan 28, 2022
572182c
Module rename - Accessibility
Jan 28, 2022
bd3cd50
Module rename - WebServices
Jan 28, 2022
ca5beac
Module rename - Jacoco
Jan 28, 2022
ced5980
Switched over POM module references
Jan 28, 2022
a6ae7cc
Copyright year and company changes
Jan 28, 2022
fae9fbe
Supporting config file changes
Jan 28, 2022
2609f5d
updated checkstyle docs
jredingcsv Jan 31, 2022
736f5bf
got rid of outdated import statement
jredingcsv Jan 31, 2022
51bcf1f
corrected order of import statements
jredingcsv Jan 31, 2022
97ed3cf
corrected order of import statements
jredingcsv Jan 31, 2022
8147472
updated base unit test output
jredingcsv Jan 31, 2022
14ea845
updated failing accessibility unit tests file path
jredingcsv Jan 31, 2022
2f865d5
updated imports on HtmlReporter.java
jredingcsv Jan 31, 2022
dc8cf46
updated database issues
jredingcsv Jan 31, 2022
283b360
updated configs MagenicMaqs tag to GlobalMaqs
jredingcsv Jan 31, 2022
4fde5aa
updated configs
jredingcsv Feb 1, 2022
be09656
CodeOwners modified for new repo
Feb 1, 2022
670b31a
docker components moved over from maqs-dotnet
Feb 1, 2022
ffdd54d
disabled Mail and Mongo set up until needed
Feb 1, 2022
13fbe4c
changed the connection string
Feb 1, 2022
3a89f69
unit test fixes
Feb 10, 2022
b571e19
temporarily disabled webservices to complete builds
Feb 18, 2022
235a656
made the version number static for new release
Feb 18, 2022
fda0d5e
starting to plan property paths
Feb 18, 2022
f743b7a
More properties added
Feb 18, 2022
7b904ad
Merge branch 'main' into feature/PropertyMapping
jredingcsv May 6, 2022
a4beb6c
added other config types
jredingcsv May 10, 2022
af7ba98
Merge branch 'main' into feature/PropertyMapping
jredingcsv Sep 12, 2022
cfb77f0
add config check
jredingcsv Sep 28, 2022
3990fb9
Merge branch 'main' into feature/PropertyMapping
jredingcsv Nov 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
maqs.global.timeout = 500
maqs.global.waitTime = 100
maqs.global.log = true
maqs.global.log.level = VERBOSE
maqs.global.log.type = TXT
maqs.global.log.path = ./target/logs

maqs.selenium.screenshot.softAssertOnFailure = true
maqs.selenium.screenshot.format = jpeg
maqs.selenium.pageSource.OnFailure = true


maqs.selenium.browser = HEADLESSCHROME
maqs.selenium.browser.waitTime = 1000
maqs.selenium.browser.timeout = 20000
maqs.selenium.browser.size = 1920x1080


maqs.selenium.browser.remote = Chrome
maqs.selenium.browser.remote.name = Chrome
maqs.selenium.browser.remote.url = http://ondemand.saucelabs.com:80/wd/hub
maqs.selenium.browser.remote.platform = OS X 10.11
maqs.selenium.website.url = http://magenicautomation.azurewebsites.net/

maqs.selenium.remote.capabilities

maqs.webservices.url = http://localhost:8080/maqs/services/

maqs.appium.url = http://localhost:4723/wd/hub

maqs.database.url = jdbc:mysql://localhost:3306/maqs

maqs.cucumber.features = features

maqs.accessibility.url = http://localhost:8080/maqs/accessibility/
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import com.cognizantsoftvision.maqs.appium.exceptions.AppiumConfigException;
import com.cognizantsoftvision.maqs.utilities.helper.Config;
import com.cognizantsoftvision.maqs.utilities.helper.ConfigSection;
import com.cognizantsoftvision.maqs.utilities.helper.ConfigValidation;
import com.cognizantsoftvision.maqs.utilities.helper.StringProcessor;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.Duration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -31,7 +33,19 @@ public class AppiumConfig {
private static final ConfigSection APPIUM_CAPS_SECTION = ConfigSection.APPIUM_CAPS_MAQS;

private AppiumConfig() {
}

static {
checkConfig();
}

/**
* Ensure required fields are in the config
*/
private static void checkConfig() {
var validator = new ConfigValidation();
validator.setRequiredOneOfFields(Arrays.asList("App", "BrowserName"));
Config.validate(ConfigSection.APPIUM_MAQS, validator);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,32 @@
import com.cognizantsoftvision.maqs.database.providers.SQLiteProvider;
import com.cognizantsoftvision.maqs.utilities.helper.Config;
import com.cognizantsoftvision.maqs.utilities.helper.ConfigSection;
import com.cognizantsoftvision.maqs.utilities.helper.ConfigValidation;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
* The type Database config.
* The Database Config class.
*/
public class DatabaseConfig {

private DatabaseConfig() {
}

static {
checkConfig();
}

/**
* Ensure required fields are in the config
*/
private static void checkConfig() {
var validator = new ConfigValidation();
validator.setRequiredOneOfFields(Arrays.asList("DataBaseConnectionString", "DataBaseProviderType"));
Config.validate(ConfigSection.DATABASE_MAQS, validator);
}

/**
* The Database section.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package com.cognizantsoftvision.maqs.database;

import com.cognizantsoftvision.maqs.base.BaseGenericTest;
import com.cognizantsoftvision.maqs.database.constants.DataProviderType;
import com.cognizantsoftvision.maqs.database.providers.IDataSourceProvider;
import com.cognizantsoftvision.maqs.database.providers.SQLProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package com.cognizantsoftvision.maqs.database;

import com.cognizantsoftvision.maqs.base.BaseGenericTest;
import com.cognizantsoftvision.maqs.database.entities.StatesEntity;
import com.cognizantsoftvision.maqs.utilities.helper.TestCategories;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package com.cognizantsoftvision.maqs.database;

import com.cognizantsoftvision.maqs.base.BaseGenericTest;
import com.cognizantsoftvision.maqs.utilities.helper.TestCategories;
import org.testng.Assert;
import org.testng.annotations.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

import com.cognizantsoftvision.maqs.utilities.helper.Config;
import com.cognizantsoftvision.maqs.utilities.helper.ConfigSection;
import com.cognizantsoftvision.maqs.utilities.helper.ConfigValidation;
import java.awt.Dimension;
import java.util.Collections;

/**
* The Playwright Config class.
Expand All @@ -19,6 +21,19 @@ public class PlaywrightConfig {
protected PlaywrightConfig() {
}

static {
checkConfig();
}

/**
* Ensure required fields are in the config.
*/
private static void checkConfig() {
var validator = new ConfigValidation();
validator.setRequiredOneOfFields(Collections.singletonList("Timeout"));
Config.validate(ConfigSection.PLAYWRIGHT_MAQS, validator);
}

/**
* Get the website base url.
* @return The website base url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import com.cognizantsoftvision.maqs.selenium.constants.RemoteBrowserType;
import com.cognizantsoftvision.maqs.utilities.helper.Config;
import com.cognizantsoftvision.maqs.utilities.helper.ConfigSection;
import com.cognizantsoftvision.maqs.utilities.helper.ConfigValidation;
import com.cognizantsoftvision.maqs.utilities.helper.StringProcessor;
import java.time.Duration;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -22,7 +24,19 @@ public final class SeleniumConfig {
* Private constructor.
*/
private SeleniumConfig() {
}

static {
checkConfig();
}

/**
* Ensure required fields are in the config.
*/
private static void checkConfig() {
ConfigValidation validator = new ConfigValidation();
validator.setRequiredFields(Collections.singletonList("BrowserTimeout"));
Config.validate(ConfigSection.SELENIUM_MAQS, validator);
}

/**
Expand Down
53 changes: 53 additions & 0 deletions maqs-utilities/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"GlobalMaqs": {
"WaitTime": "100",
"Timeout": "1000",
"Log": "OnFail",
"LogLevel": "INFORMATION",
"LogType": "TXT",
"Grog": "WillFailWithoutRunSettingOverride",
"SectionOverrideCore": "WillFailWithoutRunSettingOverride",
"SimpleOverride": "simple",
"Override": "base",
"Override2": "base2",
"ConfigJsonEnvRunOverride": "JSON",
"ConfigJsonEnvRun": "JSON",
"ConfigJsonEnv": "JSON",
"ConfigJson": "JSON",
"JsonOnly": "JSON",
"low": { "JSON": "lowerJson" },
"compound:key": "compound",
"compound:key:lower": "compoundEvenLower"
},
"RemoteSeleniumCapsMaqs": {
"MultiLevel": {
"MoreLevels": {
"seven": "7",
"lowest": {
"nine": "9"
}
}
},
"MuliLevel:MoreLevels": {
"four": "4",
"five": "5"
},
"MuliLevel:MoreLevels:six": "6"
},
"TopTest": {
"MidTest": [
{
"LowerTest": "A",
"Lower": {
"LowestTest": "Lowest"
}
},
{
"LowerTest": "B"
}
],
"AnotherMid": {
"Lowerest": "AnotherLow"
}
}
}
35 changes: 35 additions & 0 deletions maqs-utilities/config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
maqs.global.timeout = 500
maqs.global.waitTime = 100
maqs.global.log = true
maqs.global.log.level = VERBOSE
maqs.global.log.type = TXT
maqs.global.log.path = ./target/logs

maqs.selenium.screenshot.softAssertOnFailure = true
maqs.selenium.screenshot.format = jpeg
maqs.selenium.pageSource.OnFailure = true


maqs.selenium.browser = HEADLESSCHROME
maqs.selenium.browser.waitTime = 1000
maqs.selenium.browser.timeout = 20000
maqs.selenium.browser.size = 1920x1080


maqs.selenium.browser.remote = Chrome
maqs.selenium.browser.remote.name = Chrome
maqs.selenium.browser.remote.url = http://ondemand.saucelabs.com:80/wd/hub
maqs.selenium.browser.remote.platform = OS X 10.11
maqs.selenium.website.url = https://cognizantopensource.github.io/maqs-dotnet-templates/Static/Automation/

maqs.selenium.remote.capabilities

maqs.webservices.url = http://localhost:8080/maqs/services/

maqs.appium.url = http://localhost:4723/wd/hub

maqs.database.url = jdbc:mysql://localhost:3306/maqs

maqs.cucumber.features = features

maqs.accessibility.url = http://localhost:8080/maqs/accessibility/
34 changes: 34 additions & 0 deletions maqs-utilities/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

GlobalMaqs:
timeout: 500
waitTime: 100
log: true
level: "VERBOSE"
type: "TXT"
path: "./target/logs"

SeleniumMaqs:
softAssertOnFailure: true
format: "jpeg"
OnFailure: true
browser: "HEADLESSCHROME"
waitTime: 1000
browser.timeout: 20000
browser.size: 1920x1080
remote: "Chrome"
remote.name: "Chrome"
remote.url: "http://ondemand.saucelabs.com:80/wd/hub"
remote.platform: "OS X 10.11"
website.url: "https://cognizantopensource.github.io/maqs-dotnet-templates/Static/Automation/"

#maqs.selenium.remote.capabilities

WebServiceMaqs:
url: http://localhost:8080/maqs/services/


AppiumCapsMaqs:
url: http://localhost:4723/wd/hub

DatabaseMaqs:
url: jdbc:mysql://localhost:3306/maqs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

package com.cognizantsoftvision.maqs.utilities.helper;

import com.cognizantsoftvision.maqs.utilities.helper.exceptions.FrameworkConfigurationException;
import com.cognizantsoftvision.maqs.utilities.helper.exceptions.MaqsConfigException;
import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.*;

import org.apache.commons.configuration2.XMLConfiguration;
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Configurations;
Expand Down Expand Up @@ -61,11 +60,56 @@ private Config() {
overrideConfig = new XMLConfiguration();
overrideConfig.setSynchronizer(new ReadWriteSynchronizer());
} catch (ConfigurationException exception) {
throw new FrameworkConfigurationException(StringProcessor.safeFormatter(
throw new MaqsConfigException(StringProcessor.safeFormatter(
"Exception creating the xml configuration object from the file : %s", exception));
}
}

/**
* Validates the app config section by ensuring required values are present.
* @param configSection The config section to be validated
* @param configValidation A list of strings containing the required field names
*/
public static void validate(ConfigSection configSection, ConfigValidation configValidation) {
// Don't run the validation if the user has decided to skip the validation
if (getGeneralValue("SkipConfigValidation").equals("Yes")) {
return;
}

if (configValidation == null) {
throw new MaqsConfigException("The value passed in for configValidation (required fields in a config) is null");
}

var configSectionPassed = getSection(configSection);
List<String> exceptions = new ArrayList<>();

// Check if we have any required fields
if (configValidation.getRequiredFields() != null && !configValidation.getRequiredFields().isEmpty()) {
for(var requiredField : configValidation.getRequiredFields()) {
if (!configSectionPassed.containsKey(requiredField)) {
exceptions.add("Key missing: " + requiredField);
}
}
}

// Check if we have any one of required fields
if (configValidation.getRequiredOneOfFields() != null && configValidation.getRequiredOneOfFields().size() > 0) {
// && !configValidation.getRequiredOneOfFields().Any(x -> configSectionPassed.containsKey(x))){
// We have one of fields and didn't find any of them
exceptions.add("Need at least one of the following keys: " + String.join(", ", configValidation.getRequiredOneOfFields()));
}

if (!exceptions.isEmpty()) {
StringBuilder message = new StringBuilder();
for (var exception : exceptions) {
message.append(exception);
}

message.append("*This check can be skipped by setting the 'SkipConfigValidation' configuration value to 'Yes'.");
throw new MaqsConfigException(message.toString());
}
}

/**
* Gets a section from the configuration.
*
Expand Down Expand Up @@ -276,4 +320,8 @@ public static boolean doesKeyExist(String key, String section) {
public static boolean doesGeneralKeyExist(String key) {
return doesKeyExist(key, DEFAULT_MAQS_SECTION);
}

private static String getConfigFile() {
PropertyManager.get("maqs.config.location", "config.xml");
}
}
Loading