Skip to content

Commit

Permalink
Addressed review issues zalando#725
Browse files Browse the repository at this point in the history
  • Loading branch information
roxspring committed Jun 14, 2018
1 parent 5ae0037 commit 62d4c3b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions server/src/main/java/de/zalando/zally/rule/Context.kt
Expand Up @@ -53,8 +53,8 @@ class Context(openApi: OpenAPI, swagger: Swagger? = null) {
* @param pointer an existing pointer or null
* @return the new Violation
*/
fun violations(description: String, pointer: JsonPointer? = null): List<Violation> =
listOf(Violation(description, pointer as JsonPointer))
fun violations(description: String, pointer: JsonPointer?): List<Violation> =
listOf(violation(description, pointer))

/**
* Creates a Violation with a pointer to the OpenAPI or Swagger model node specified,
Expand Down
Expand Up @@ -4,6 +4,7 @@ import de.zalando.zally.rule.api.Violation
import org.assertj.core.api.AbstractAssert
import org.assertj.core.api.StringAssert

@Suppress("UndocumentedPublicClass")
class ViolationAssert(actual: Violation?) : AbstractAssert<ViolationAssert, Violation?>(actual, ViolationAssert::class.java) {

fun descriptionEqualTo(description: String): ViolationAssert {
Expand Down
11 changes: 3 additions & 8 deletions server/src/test/java/de/zalando/zally/rule/ViolationsAssert.kt
@@ -1,11 +1,11 @@
package de.zalando.zally.rule

import com.fasterxml.jackson.core.JsonPointer
import de.zalando.zally.rule.api.Violation
import org.assertj.core.api.AbstractListAssert
import org.assertj.core.api.ListAssert
import org.assertj.core.api.ObjectAssert

@Suppress("UndocumentedPublicClass", "SpreadOperator")
class ViolationsAssert(violations: List<Violation>?) : AbstractListAssert<ViolationsAssert, List<Violation>, Violation, ObjectAssert<Violation>>(violations, ViolationsAssert::class.java) {

override fun toAssert(value: Violation?, description: String?): ObjectAssert<Violation> {
Expand All @@ -22,19 +22,14 @@ class ViolationsAssert(violations: List<Violation>?) : AbstractListAssert<Violat
return this
}

fun descriptions(): ListAssert<String> {
private fun descriptions(): ListAssert<String> {
isNotNull
return ListAssert(actual.map { it.description }).`as`("descriptions")
}

fun pointers(): ListAssert<JsonPointer?> {
isNotNull
return ListAssert(actual.map { it.pointer }).`as`("pointers")
}

fun pointersEqualTo(vararg pointers: String): ViolationsAssert {
isNotNull
ListAssert(actual.map { it.pointer!!.toString() }).`as`("pointers").containsExactly(*pointers)
ListAssert(actual.map { it.pointer?.toString() }).`as`("pointers").containsExactly(*pointers)
return this
}
}
3 changes: 3 additions & 0 deletions server/src/test/java/de/zalando/zally/rule/ZallyAssertions.kt
Expand Up @@ -2,9 +2,12 @@ package de.zalando.zally.rule

import de.zalando.zally.rule.api.Violation

@Suppress("UndocumentedPublicClass")
class ZallyAssertions {
companion object {

fun assertThat(actual: Violation?): ViolationAssert = ViolationAssert(actual)

fun assertThat(actual: List<Violation>?): ViolationsAssert = ViolationsAssert(actual)
}
}
Expand Up @@ -4,6 +4,7 @@ import de.zalando.zally.rule.Context
import de.zalando.zally.rule.ZallyAssertions.Companion.assertThat
import org.junit.Test

@Suppress("StringLiteralDuplication", "UndocumentedPublicClass", "UnsafeCallOnNullableType")
class AvoidTrailingSlashesRuleTest {

private val rule = AvoidTrailingSlashesRule()
Expand Down

0 comments on commit 62d4c3b

Please sign in to comment.