Skip to content

Commit

Permalink
* Fix - Applied Scala CamelCase to enumaration contants.
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpojer committed Nov 2, 2023
1 parent 236cbae commit 4e0d029
Show file tree
Hide file tree
Showing 16 changed files with 190 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package africa.absa.testing.scapi.model.suite.types
object SuiteResultType extends Enumeration {
type SuiteResultType = Value

val BEFORE_TEST_SET: SuiteResultType.Value = Value("before-test-set")
val TEST_SET: SuiteResultType.Value = Value("test-set")
val AFTER_TEST_SET: SuiteResultType.Value = Value("after-test-set")
val BeforeTestSet: SuiteResultType.Value = Value("before-test-set")
val TestSet: SuiteResultType.Value = Value("test-set")
val AfterTestSet: SuiteResultType.Value = Value("after-test-set")
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ object StdOutReporter {

printHeader("Simple Text Report")

val successCount = testResults.count(r => r.isSuccess && r.resultType == SuiteResultType.TEST_SET)
val failureCount = testResults.count(r => !r.isSuccess && r.resultType == SuiteResultType.TEST_SET)
val successCount = testResults.count(r => r.isSuccess && r.resultType == SuiteResultType.TestSet)
val failureCount = testResults.count(r => !r.isSuccess && r.resultType == SuiteResultType.TestSet)

println(s"Number of tests run: ${successCount + failureCount}")
println(s"Number of successful tests: $successCount")
println(s"Number of failed tests: $failureCount")

if (testResults.nonEmpty) {
val suiteSummary = testResults
.filter(_.resultType == SuiteResultType.TEST_SET)
.filter(_.resultType == SuiteResultType.TestSet)
.groupBy(_.suiteName).map {
case (suiteName, results) =>
(suiteName, results.size, results.count(_.isSuccess))
Expand All @@ -84,7 +84,7 @@ object StdOutReporter {
printTableRowSplitter()
println(s"| %-${maxSuiteLength}s | %-${maxTestLength}s | %-13s | %-7s | %-${maxTestCategoriesLength}s | ".format("Suite Name", "Test Name", "Duration (ms)", "Status", "Categories"))
printTableRowSplitter()
val resultsList = testResults.filter(_.resultType == SuiteResultType.TEST_SET)
val resultsList = testResults.filter(_.resultType == SuiteResultType.TestSet)
resultsList.zipWithIndex.foreach { case (result, index) =>
val duration = result.duration.map(_.toString).getOrElse("NA")
println(s"| %-${maxSuiteLength}s | %-${maxTestLength}s | %13s | %-7s | %-${maxTestCategoriesLength}s | ".format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ object Response {
*/
def validate(responseAction: ResponseAction): Unit = {
responseAction.group match {
case ResponseActionGroupType.ASSERT => AssertionResponseAction.validateContent(responseAction)
case ResponseActionGroupType.EXTRACT_JSON => ExtractJsonResponseAction.validateContent(responseAction)
case ResponseActionGroupType.LOG => LogResponseAction.validateContent(responseAction)
case ResponseActionGroupType.Assert => AssertionResponseAction.validateContent(responseAction)
case ResponseActionGroupType.ExtractJson => ExtractJsonResponseAction.validateContent(responseAction)
case ResponseActionGroupType.Log => LogResponseAction.validateContent(responseAction)
case _ => throw new IllegalArgumentException(s"Unsupported assertion group: ${responseAction.group}")
}
}
Expand Down Expand Up @@ -85,9 +85,9 @@ object Response {
Logger.debug(s"Response-${resolvedResponseAction.group}: '${resolvedResponseAction.name}' - Started.")

val res: Try[Unit] = resolvedResponseAction.group match {
case ResponseActionGroupType.ASSERT => AssertionResponseAction.performResponseAction(response, assertion)
case ResponseActionGroupType.EXTRACT_JSON => ExtractJsonResponseAction.performResponseAction(response, assertion)
case ResponseActionGroupType.LOG => LogResponseAction.performResponseAction(response, assertion)
case ResponseActionGroupType.Assert => AssertionResponseAction.performResponseAction(response, assertion)
case ResponseActionGroupType.ExtractJson => ExtractJsonResponseAction.performResponseAction(response, assertion)
case ResponseActionGroupType.Log => LogResponseAction.performResponseAction(response, assertion)
case _ => Failure(new IllegalArgumentException(s"Unsupported assertion group: ${assertion.group}"))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,58 +44,58 @@ object AssertionResponseAction extends ResponseActions {
action match {

// response-time-...
case RESPONSE_TIME_IS_BELOW | RESPONSE_TIME_IS_ABOVE =>
case ResponseTimeIsBelow | ResponseTimeIsAbove =>
responseAction.params.getOrElse("limit", None) match {
case limit: String => ContentValidator.validateLongString(limit, s"ResponseAssertion.${responseAction.name}.limit")
case None => throw new IllegalArgumentException(s"Missing required 'limit' parameter for assertion ${responseAction.name} logic.")
}

// status-code-...
case STATUS_CODE_EQUALS =>
case StatusCodeEquals =>
responseAction.params.getOrElse("code", None) match {
case code: String => ContentValidator.validateIntegerString(code, s"ResponseAssertion.$STATUS_CODE_EQUALS.code")
case None => throw new IllegalArgumentException(s"Missing required 'code' parameter for assertion $STATUS_CODE_EQUALS logic.")
case code: String => ContentValidator.validateIntegerString(code, s"ResponseAssertion.$StatusCodeEquals.code")
case None => throw new IllegalArgumentException(s"Missing required 'code' parameter for assertion $StatusCodeEquals logic.")
}
case STATUS_CODE_IS_SUCCESS | STATUS_CODE_IS_CLIENT_ERROR | STATUS_CODE_IS_SERVER_ERROR => ()
case StatusCodeIsSuccess | StatusCodeIsClientError | StatusCodeIsServerError => ()

// header-...
case HEADER_EXISTS | HEADER_VALUE_EQUALS =>
case HeaderExists | HeaderValueEquals =>
responseAction.params.getOrElse("headerName", None) match {
case headerName: String => ContentValidator.validateNonEmptyString(headerName, s"ResponseAssertion.${responseAction.name}.headerName")
case None => throw new IllegalArgumentException(s"Missing required 'headerName' parameter for assertion ${responseAction.name} logic.")
}
action match {
case HEADER_VALUE_EQUALS =>
case HeaderValueEquals =>
responseAction.params.getOrElse("expectedValue", None) match {
case expectedValue: String => ContentValidator.validateNonEmptyString(expectedValue, s"ResponseAssertion.$HEADER_VALUE_EQUALS.expectedValue")
case None => throw new IllegalArgumentException(s"Missing required 'expectedValue' parameter for assertion $HEADER_VALUE_EQUALS logic.")
case expectedValue: String => ContentValidator.validateNonEmptyString(expectedValue, s"ResponseAssertion.$HeaderValueEquals.expectedValue")
case None => throw new IllegalArgumentException(s"Missing required 'expectedValue' parameter for assertion $HeaderValueEquals logic.")
}
case _ => ()
}

// content-type-...
case CONTENT_TYPE_IS_JSON | CONTENT_TYPE_IS_XML | CONTENT_TYPE_IS_HTML => ()
case ContentTypeIsJson | ContentTypeIsXml | ContentTypeIsHtml => ()

// cookies-...
case COOKIE_EXISTS | COOKIE_VALUE_EQUALS | COOKIE_IS_SECURED | COOKIE_IS_NOT_SECURED =>
case CookieExists | CookieValueEquals | CookieIsSecured | CookieIsNotSecured =>
responseAction.params.getOrElse("cookieName", None) match {
case cookieName: String => ContentValidator.validateNonEmptyString(cookieName, s"ResponseAssertion.${responseAction.name}.cookieName")
case None => throw new IllegalArgumentException(s"Missing required 'cookieName' parameter for assertion ${responseAction.name} logic.")
}
action match {
case COOKIE_VALUE_EQUALS =>
case CookieValueEquals =>
responseAction.params.getOrElse("expectedValue", None) match {
case expectedValue: String => ContentValidator.validateNonEmptyString(expectedValue, s"ResponseAssertion.$COOKIE_VALUE_EQUALS.expectedValue")
case None => throw new IllegalArgumentException(s"Missing required 'expectedValue' parameter for assertion $COOKIE_VALUE_EQUALS logic.")
case expectedValue: String => ContentValidator.validateNonEmptyString(expectedValue, s"ResponseAssertion.$CookieValueEquals.expectedValue")
case None => throw new IllegalArgumentException(s"Missing required 'expectedValue' parameter for assertion $CookieValueEquals logic.")
}
case _ => ()
}

// body-...
case BODY_CONTAINS_TEXT =>
case BodyContainsText =>
responseAction.params.getOrElse("text", None) match {
case text: String => ContentValidator.validateNonEmptyString(text, s"ResponseAssertion.$BODY_CONTAINS_TEXT.text")
case None => throw new IllegalArgumentException(s"Missing required 'text' parameter for assertion $BODY_CONTAINS_TEXT logic.")
case text: String => ContentValidator.validateNonEmptyString(text, s"ResponseAssertion.$BodyContainsText.text")
case None => throw new IllegalArgumentException(s"Missing required 'text' parameter for assertion $BodyContainsText logic.")
}
case _ => throw UndefinedResponseActionTypeException(responseAction.name)
}
Expand All @@ -114,50 +114,50 @@ object AssertionResponseAction extends ResponseActions {
action match {

// response-time-...
case RESPONSE_TIME_IS_BELOW | RESPONSE_TIME_IS_ABOVE =>
case ResponseTimeIsBelow | ResponseTimeIsAbove =>
val limit = responseAction.params("limit")
action match {
case RESPONSE_TIME_IS_BELOW => assertResponseTimeIsBelow(response, limit)
case RESPONSE_TIME_IS_ABOVE => assertResponseTimeIsAbove(response, limit)
case ResponseTimeIsBelow => assertResponseTimeIsBelow(response, limit)
case ResponseTimeIsAbove => assertResponseTimeIsAbove(response, limit)
}

// status-code-...
case STATUS_CODE_EQUALS =>
case StatusCodeEquals =>
val code = responseAction.params("code")
assertStatusCodeEquals(response, code)
case STATUS_CODE_IS_SUCCESS => assertStatusCodeSuccess(response)
case STATUS_CODE_IS_CLIENT_ERROR => assertStatusCodeIsClientError(response)
case STATUS_CODE_IS_SERVER_ERROR => assertStatusCodeIsServerError(response)
case StatusCodeIsSuccess => assertStatusCodeSuccess(response)
case StatusCodeIsClientError => assertStatusCodeIsClientError(response)
case StatusCodeIsServerError => assertStatusCodeIsServerError(response)

// header-...
case HEADER_EXISTS | HEADER_VALUE_EQUALS =>
case HeaderExists | HeaderValueEquals =>
val headerName = responseAction.params("headerName")
action match {
case HEADER_EXISTS => assertHeaderExists(response, headerName)
case HEADER_VALUE_EQUALS =>
case HeaderExists => assertHeaderExists(response, headerName)
case HeaderValueEquals =>
val expectedValue = responseAction.params("expectedValue")
assertHeaderValueEquals(response, headerName, expectedValue)
}

// content-type-...
case CONTENT_TYPE_IS_JSON => assertContentTypeIsJson(response)
case CONTENT_TYPE_IS_XML => assertContentTypeIsXml(response)
case CONTENT_TYPE_IS_HTML => assertContentTypeIsHtml(response)
case ContentTypeIsJson => assertContentTypeIsJson(response)
case ContentTypeIsXml => assertContentTypeIsXml(response)
case ContentTypeIsHtml => assertContentTypeIsHtml(response)

// cookies-...
case COOKIE_EXISTS | COOKIE_VALUE_EQUALS | COOKIE_IS_SECURED | COOKIE_IS_NOT_SECURED =>
case CookieExists | CookieValueEquals | CookieIsSecured | CookieIsNotSecured =>
val cookieName = responseAction.params("cookieName")
action match {
case COOKIE_EXISTS => assertCookieExists(response, cookieName)
case COOKIE_VALUE_EQUALS =>
case CookieExists => assertCookieExists(response, cookieName)
case CookieValueEquals =>
val expectedValue = responseAction.params("expectedValue")
assertCookieValueEquals(response, cookieName, expectedValue)
case COOKIE_IS_SECURED => assertCookieIsSecured(response, cookieName)
case COOKIE_IS_NOT_SECURED => assertCookieIsNotSecured(response, cookieName)
case CookieIsSecured => assertCookieIsSecured(response, cookieName)
case CookieIsNotSecured => assertCookieIsNotSecured(response, cookieName)
}

// body-...
case BODY_CONTAINS_TEXT =>
case BodyContainsText =>
val text = responseAction.params("text")
assertBodyContainsText(response, text)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object ExtractJsonResponseAction extends ResponseActions {
def validateContent(responseAction: ResponseAction): Unit = {
val action = fromString(responseAction.name.toLowerCase).getOrElse(None)
action match {
case STRING_FROM_LIST => validateStringFromList(responseAction)
case StringFromList => validateStringFromList(responseAction)
case _ => throw UndefinedResponseActionTypeException(responseAction.name)
}
}
Expand All @@ -57,7 +57,7 @@ object ExtractJsonResponseAction extends ResponseActions {
def performResponseAction(response: Response, responseAction: ResponseAction): Try[Unit] = {
val action = fromString(responseAction.name.toLowerCase).getOrElse(None)
action match {
case STRING_FROM_LIST =>
case StringFromList =>
val cacheKey = responseAction.params("cacheKey")
val listIndex = responseAction.params("listIndex").toInt
val jsonKey = responseAction.params("jsonKey")
Expand Down Expand Up @@ -119,17 +119,17 @@ object ExtractJsonResponseAction extends ResponseActions {
* @param assertion The ResponseAction instance containing the response action details.
*/
private def validateStringFromList(assertion: ResponseAction): Unit = {
val cacheKey = assertion.params.getOrElse("cacheKey", throw new IllegalArgumentException(s"Missing required 'cacheKey' parameter for extract $STRING_FROM_LIST logic"))
val listIndex = assertion.params.getOrElse("listIndex", throw new IllegalArgumentException(s"Missing required 'listIndex' parameter for extract $STRING_FROM_LIST logic"))
val jsonKey = assertion.params.getOrElse("jsonKey", throw new IllegalArgumentException(s"Missing required 'jsonKey' parameter for extract $STRING_FROM_LIST logic"))
val cacheLevel = assertion.params.getOrElse("cacheLevel", throw new IllegalArgumentException(s"Missing required 'cacheLevel' parameter for extract $STRING_FROM_LIST logic"))
val cacheKey = assertion.params.getOrElse("cacheKey", throw new IllegalArgumentException(s"Missing required 'cacheKey' parameter for extract $StringFromList logic"))
val listIndex = assertion.params.getOrElse("listIndex", throw new IllegalArgumentException(s"Missing required 'listIndex' parameter for extract $StringFromList logic"))
val jsonKey = assertion.params.getOrElse("jsonKey", throw new IllegalArgumentException(s"Missing required 'jsonKey' parameter for extract $StringFromList logic"))
val cacheLevel = assertion.params.getOrElse("cacheLevel", throw new IllegalArgumentException(s"Missing required 'cacheLevel' parameter for extract $StringFromList logic"))

ContentValidator.validateNonEmptyString(cacheKey, s"ExtractJson.$STRING_FROM_LIST.cacheKey")
ContentValidator.validateNonEmptyString(listIndex, s"ExtractJson.$STRING_FROM_LIST.listIndex")
ContentValidator.validateNonEmptyString(jsonKey, s"ExtractJson.$STRING_FROM_LIST.jsonKey")
ContentValidator.validateNonEmptyString(cacheLevel, s"ExtractJson.$STRING_FROM_LIST.cacheLevel")
ContentValidator.validateNonEmptyString(cacheKey, s"ExtractJson.$StringFromList.cacheKey")
ContentValidator.validateNonEmptyString(listIndex, s"ExtractJson.$StringFromList.listIndex")
ContentValidator.validateNonEmptyString(jsonKey, s"ExtractJson.$StringFromList.jsonKey")
ContentValidator.validateNonEmptyString(cacheLevel, s"ExtractJson.$StringFromList.cacheLevel")

ContentValidator.validateIntegerString(listIndex, s"ExtractJson.$STRING_FROM_LIST.listIndex")
ContentValidator.validateIntegerString(listIndex, s"ExtractJson.$StringFromList.listIndex")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object LogResponseAction extends ResponseActions {
def validateContent(responseAction: ResponseAction): Unit = {
val action = fromString(responseAction.name.toLowerCase).getOrElse(None)
action match {
case ERROR | WARN | INFO | DEBUG =>
case Error | Warn | Info | Debug =>
responseAction.params.get("message") match {
case Some(message) => ContentValidator.validateNonEmptyString(message, s"ResponseLog.${responseAction.name}.message")
case None => throw new IllegalArgumentException(s"Missing required 'message' for assertion ${responseAction.name} logic.")
Expand All @@ -62,10 +62,10 @@ object LogResponseAction extends ResponseActions {
val action = fromString(responseAction.name.toLowerCase).getOrElse(None)
Try {
action match {
case ERROR => logError(message)
case WARN => logWarn(message)
case INFO => logInfo(message)
case DEBUG => logDebug(message)
case Error => logError(message)
case Warn => logWarn(message)
case Info => logInfo(message)
case Debug => logDebug(message)
case _ => Failure(UndefinedResponseActionTypeException(s"Unsupported log method [group: log]: ${responseAction.name}"))
}
}
Expand Down
Loading

0 comments on commit 4e0d029

Please sign in to comment.