All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.kotlin.ch.tutteli.atrium.logic.impl.DefaultCharSequenceAssertions.kt Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package ch.tutteli.atrium.logic.impl

import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.core.ExperimentalNewExpectTypes
import ch.tutteli.atrium.creating.AssertionContainer
import ch.tutteli.atrium.logic.CharSequenceAssertions
import ch.tutteli.atrium.logic._logic
import ch.tutteli.atrium.logic.createDescriptiveAssertion
import ch.tutteli.atrium.logic.creating.charsequence.contains.CharSequenceContains
import ch.tutteli.atrium.logic.creating.charsequence.contains.searchbehaviours.NoOpSearchBehaviour
import ch.tutteli.atrium.logic.creating.charsequence.contains.searchbehaviours.NotSearchBehaviour
import ch.tutteli.atrium.logic.creating.charsequence.contains.searchbehaviours.impl.NoOpSearchBehaviourImpl
import ch.tutteli.atrium.logic.creating.charsequence.contains.searchbehaviours.impl.NotSearchBehaviourImpl
import ch.tutteli.atrium.logic.creating.charsequence.contains.steps.NotCheckerStep
import ch.tutteli.atrium.logic.creating.charsequence.contains.steps.impl.EntryPointStepImpl
import ch.tutteli.atrium.logic.creating.charsequence.contains.steps.notCheckerStep
import ch.tutteli.atrium.translations.DescriptionBasic.NOT_TO_BE
import ch.tutteli.atrium.translations.DescriptionBasic.TO_BE
import ch.tutteli.atrium.translations.DescriptionCharSequenceExpectation.*

class DefaultCharSequenceAssertions : CharSequenceAssertions {
    override fun  containsBuilder(
        container: AssertionContainer
    ): CharSequenceContains.EntryPointStep =
        EntryPointStepImpl(container, NoOpSearchBehaviourImpl())

    @Suppress("DEPRECATION" /* OptIn is only available since 1.3.70 which we cannot use if we want to support 1.2 */)
    @UseExperimental(ExperimentalNewExpectTypes::class)
    override fun  containsNotBuilder(
        container: AssertionContainer
    ): NotCheckerStep =
        EntryPointStepImpl(container, NotSearchBehaviourImpl())._logic.notCheckerStep()

    override fun  startsWith(container: AssertionContainer, expected: CharSequence): Assertion =
        container.createDescriptiveAssertion(TO_START_WITH, expected) { it.startsWith(expected) }

    override fun  startsNotWith(container: AssertionContainer, expected: CharSequence): Assertion =
        container.createDescriptiveAssertion(NOT_TO_START_WITH, expected) { !it.startsWith(expected) }

    override fun  endsWith(container: AssertionContainer, expected: CharSequence): Assertion =
        container.createDescriptiveAssertion(TO_END_WITH, expected) { it.endsWith(expected) }

    override fun  endsNotWith(container: AssertionContainer, expected: CharSequence): Assertion =
        container.createDescriptiveAssertion(NOT_TO_END_WITH, expected) { !it.endsWith(expected) }

    override fun  isEmpty(container: AssertionContainer): Assertion =
        container.createDescriptiveAssertion(TO_BE, EMPTY) { it.isEmpty() }

    override fun  isNotEmpty(container: AssertionContainer): Assertion =
        container.createDescriptiveAssertion(NOT_TO_BE, EMPTY) { it.isNotEmpty() }

    override fun  isNotBlank(container: AssertionContainer): Assertion =
        container.createDescriptiveAssertion(NOT_TO_BE, BLANK) { it.isNotBlank() }

    override fun  matches(container: AssertionContainer, expected: Regex): Assertion =
        container.createDescriptiveAssertion(TO_MATCH, expected) { it.matches(expected) }

    override fun  mismatches(container: AssertionContainer, expected: Regex): Assertion =
        container.createDescriptiveAssertion(NOT_TO_MATCH, expected) { !it.matches(expected) }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy