How to use Map.shouldNotBeEmpty method of io.kotest.matchers.maps.matchers class

Best Kotest code snippet using io.kotest.matchers.maps.matchers.Map.shouldNotBeEmpty

matchers.kt

Source:matchers.kt Github

copy

Full Screen

1package tutorial.kotest2import io.kotest.assertions.throwables.shouldThrow3import io.kotest.assertions.throwables.shouldThrowAny4import io.kotest.assertions.throwables.shouldThrowExactly5import io.kotest.core.spec.style.DescribeSpec6import io.kotest.core.test.AssertionMode7import io.kotest.matchers.booleans.shouldBeTrue8import io.kotest.matchers.collections.shouldBeIn9import io.kotest.matchers.collections.shouldBeOneOf10import io.kotest.matchers.collections.shouldBeSameSizeAs11import io.kotest.matchers.collections.shouldBeSingleton12import io.kotest.matchers.collections.shouldBeSmallerThan13import io.kotest.matchers.collections.shouldBeSorted14import io.kotest.matchers.collections.shouldBeUnique15import io.kotest.matchers.collections.shouldContain16import io.kotest.matchers.collections.shouldContainAll17import io.kotest.matchers.collections.shouldContainAnyOf18import io.kotest.matchers.collections.shouldContainDuplicates19import io.kotest.matchers.collections.shouldContainExactly20import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder21import io.kotest.matchers.collections.shouldContainInOrder22import io.kotest.matchers.collections.shouldContainNull23import io.kotest.matchers.collections.shouldEndWith24import io.kotest.matchers.collections.shouldHaveAtLeastSize25import io.kotest.matchers.collections.shouldHaveLowerBound26import io.kotest.matchers.collections.shouldHaveSingleElement27import io.kotest.matchers.collections.shouldHaveSize28import io.kotest.matchers.collections.shouldHaveUpperBound29import io.kotest.matchers.collections.shouldNotContainAnyOf30import io.kotest.matchers.collections.shouldNotHaveElementAt31import io.kotest.matchers.collections.shouldStartWith32import io.kotest.matchers.comparables.shouldBeEqualComparingTo33import io.kotest.matchers.comparables.shouldBeLessThanOrEqualTo34import io.kotest.matchers.date.shouldBeToday35import io.kotest.matchers.date.shouldHaveSameHoursAs36import io.kotest.matchers.doubles.Percentage37import io.kotest.matchers.doubles.beNaN38import io.kotest.matchers.doubles.plusOrMinus39import io.kotest.matchers.doubles.shouldBeNaN40import io.kotest.matchers.doubles.shouldNotBeNaN41import io.kotest.matchers.equality.shouldBeEqualToComparingFields42import io.kotest.matchers.equality.shouldBeEqualToComparingFieldsExcept43import io.kotest.matchers.equality.shouldBeEqualToIgnoringFields44import io.kotest.matchers.equality.shouldBeEqualToUsingFields45import io.kotest.matchers.file.shouldBeADirectory46import io.kotest.matchers.file.shouldBeAbsolute47import io.kotest.matchers.file.shouldExist48import io.kotest.matchers.file.shouldNotBeEmpty49import io.kotest.matchers.ints.beOdd50import io.kotest.matchers.ints.shouldBeBetween51import io.kotest.matchers.ints.shouldBeInRange52import io.kotest.matchers.ints.shouldBeLessThan53import io.kotest.matchers.ints.shouldBeLessThanOrEqual54import io.kotest.matchers.ints.shouldBeOdd55import io.kotest.matchers.ints.shouldBePositive56import io.kotest.matchers.ints.shouldBeZero57import io.kotest.matchers.iterator.shouldBeEmpty58import io.kotest.matchers.iterator.shouldHaveNext59import io.kotest.matchers.maps.shouldBeEmpty60import io.kotest.matchers.maps.shouldContain61import io.kotest.matchers.maps.shouldContainAll62import io.kotest.matchers.maps.shouldContainExactly63import io.kotest.matchers.maps.shouldContainKey64import io.kotest.matchers.nulls.shouldBeNull65import io.kotest.matchers.nulls.shouldNotBeNull66import io.kotest.matchers.shouldBe67import io.kotest.matchers.shouldNot68import io.kotest.matchers.shouldNotBe69import io.kotest.matchers.string.beEmpty70import io.kotest.matchers.string.shouldBeBlank71import io.kotest.matchers.string.shouldBeEmpty72import io.kotest.matchers.string.shouldBeEqualIgnoringCase73import io.kotest.matchers.string.shouldBeInteger74import io.kotest.matchers.string.shouldBeLowerCase75import io.kotest.matchers.string.shouldBeUpperCase76import io.kotest.matchers.string.shouldContain77import io.kotest.matchers.string.shouldContainADigit78import io.kotest.matchers.string.shouldContainIgnoringCase79import io.kotest.matchers.string.shouldContainOnlyDigits80import io.kotest.matchers.string.shouldContainOnlyOnce81import io.kotest.matchers.string.shouldEndWith82import io.kotest.matchers.string.shouldHaveLength83import io.kotest.matchers.string.shouldHaveLineCount84import io.kotest.matchers.string.shouldHaveMaxLength85import io.kotest.matchers.string.shouldHaveMinLength86import io.kotest.matchers.string.shouldHaveSameLengthAs87import io.kotest.matchers.string.shouldMatch88import io.kotest.matchers.string.shouldNotBeEmpty89import io.kotest.matchers.string.shouldStartWith90import io.kotest.matchers.throwable.shouldHaveCause91import io.kotest.matchers.throwable.shouldHaveCauseInstanceOf92import io.kotest.matchers.throwable.shouldHaveCauseOfType93import io.kotest.matchers.throwable.shouldHaveMessage94import io.kotest.matchers.types.shouldBeInstanceOf95import io.kotest.matchers.types.shouldBeSameInstanceAs96import io.kotest.matchers.types.shouldBeTypeOf97import io.kotest.matchers.uri.shouldHaveHost98import io.kotest.matchers.uri.shouldHavePort99import io.kotest.matchers.uri.shouldHaveScheme100import java.io.File101import java.net.URI102import java.time.LocalDate103import java.time.LocalTime104// https://kotest.io/docs/assertions/core-matchers.html105class MatchersTest : DescribeSpec({106 describe("general") {107 it("basics") {108 (1 == 1).shouldBeTrue()109 (2 + 2) shouldBe 4110 val foo: Any = "foobar"111 foo.shouldBeTypeOf<String>() shouldContain "fo"112 "".shouldBeEmpty()113 "x".shouldNot(beEmpty()) // manually negate114 "x".shouldNotBeEmpty() // reusable115 URI("https://tba") shouldHaveHost "tba"116 URI("https://tba:81") shouldHavePort 81117 URI("https://tba") shouldHaveScheme "https"118 File("/").apply {119 shouldExist()120 shouldBeADirectory()121 shouldBeAbsolute()122 shouldNotBeEmpty()123 }124 // executable, hidden, readable, smaller, writeable, containFile, extension, path, ...125 LocalDate.now().shouldBeToday()126 // before/after, within, same, between, have year/month/day/hour/...127 LocalTime.now().shouldHaveSameHoursAs(LocalTime.now())128 // before/after/between, sameMinute/Seconds/Nanos129 }130 it("numbers") {131 1 shouldBeLessThan 2132 1 shouldBeLessThanOrEqual 1 // Int-based; returns this133 1 shouldBeLessThanOrEqualTo 1 // Comparble-based; void134 1 shouldBeEqualComparingTo 1 // Comparable-based135 1.shouldBeBetween(0, 2)136 1 shouldBeInRange 0..2137 0.shouldBeZero()138 1.shouldBePositive()139 1.shouldBeOdd()140 (1.2).shouldBe(1.20001.plusOrMinus(Percentage(20.0)))141 (1.2).shouldNotBeNaN()142 }143 it("strings") {144 // generic: "abc" shouldBe "abc"145 "aBc" shouldBeEqualIgnoringCase "abc"146 "".shouldBeEmpty()147 " ".shouldBeBlank() // empty or whitespace148 "abc" shouldContain ("b")149 "aBc" shouldContainIgnoringCase "bc"150 "x-a-x" shouldContain """\-[a-z]\-""".toRegex()151 "-a-" shouldMatch """\-[a-z]\-""".toRegex()152 "abc" shouldStartWith ("a")153 "abc" shouldEndWith ("c")154 "ab aa" shouldContainOnlyOnce "aa"155 "abc".shouldBeLowerCase()156 "ABC".shouldBeUpperCase()157 "abc" shouldHaveLength 3158 "a\nb" shouldHaveLineCount 2159 "ab" shouldHaveMinLength 1 shouldHaveMaxLength 3160 "abc" shouldHaveSameLengthAs "foo"161 "1".shouldBeInteger()162 "12".shouldContainOnlyDigits()163 "abc1".shouldContainADigit() // at least one164 }165 it("types") {166 @Connotation167 open class SuperType()168 class SubType : SuperType()169 val sameRef = SuperType()170 sameRef.shouldBeSameInstanceAs(sameRef)171 val superType: SuperType = SubType()172 superType.shouldBeTypeOf<SubType>() // exact runtime match (SuperType won't work!)173 superType.shouldBeInstanceOf<SuperType>() // T or below174// SubType().shouldHaveAnnotation(Connotation::class)175 val nullable: String? = null176 nullable.shouldBeNull()177 }178 it("collections") {179 emptyList<Int>().iterator().shouldBeEmpty()180 listOf(1).iterator().shouldHaveNext()181 listOf(1, 2) shouldContain 1 // at least182 listOf(1, 2) shouldContainExactly listOf(1, 2) // in-order; not more183 listOf(1, 2) shouldContainExactlyInAnyOrder listOf(2, 1) // out-order; not more184 listOf(0, 3, 0, 4, 0).shouldContainInOrder(3, 4) // possible items in between185 listOf(1) shouldNotContainAnyOf listOf(2, 3) // black list186 listOf(1, 2, 3) shouldContainAll listOf(3, 2) // out-order; more187 listOf(1, 2, 3).shouldBeUnique() // no duplicates188 listOf(1, 2, 2).shouldContainDuplicates() // at least one duplicate189 listOf(1, 2).shouldNotHaveElementAt(1, 3)190 listOf(1, 2) shouldStartWith 1191 listOf(1, 2) shouldEndWith 2192 listOf(1, 2) shouldContainAnyOf listOf(2, 3)193 val x = SomeType(1)194 x shouldBeOneOf listOf(x) // by reference/instance195 x shouldBeIn listOf(SomeType(1)) // by equality/structural196 listOf(1, 2, null).shouldContainNull()197 listOf(1) shouldHaveSize 1198 listOf(1).shouldBeSingleton() // size == 1199 listOf(1).shouldBeSingleton {200 it.shouldBeOdd()201 }202 listOf(1).shouldHaveSingleElement {203 beOdd().test(it).passed() // have to return a boolean here :-/204 }205 listOf(2, 3) shouldHaveLowerBound 1 shouldHaveUpperBound 4206 listOf(1) shouldBeSmallerThan listOf(1, 2)207 listOf(1) shouldBeSameSizeAs listOf(2)208 listOf(1, 2) shouldHaveAtLeastSize 1209 listOf(1, 2).shouldBeSorted()210 mapOf(1 to "a").shouldContain(1, "a") // at least this211 mapOf(1 to "a") shouldContainAll mapOf(1 to "a") // at least those212 mapOf(1 to "a") shouldContainExactly mapOf(1 to "a") // not more213 mapOf(1 to "a") shouldContainKey 1214 emptyMap<Any, Any>().shouldBeEmpty()215 }216 it("exceptions") {217 class SubException() : Exception()218 Exception("a") shouldHaveMessage "a" // same (not contains!)219 Exception("abc").message shouldContain "b"220 Exception("", Exception()).shouldHaveCause()221 Exception("symptom", Exception("cause")).shouldHaveCause {222 it.message shouldBe "cause"223 }224 Exception("", SubException()).shouldHaveCauseInstanceOf<Exception>() // T or subclass225 Exception("", SubException()).shouldHaveCauseOfType<SubException>() // exactly T226 shouldThrow<Exception> { // type or subtype227 throw SubException()228 }229 shouldThrowExactly<Exception> { // exactly that type (no subtype!)230 throw Exception()231 }232 shouldThrowAny { // don't care which233 throw Exception()234 }235 }236 }237 describe("advanced") {238 it("selective matcheres") {239 data class Foo(val p1: Int, val p2: Int)240 val foo1 = Foo(1, 1)241 val foo2 = Foo(1, 2)242 foo1.shouldBeEqualToUsingFields(foo2, Foo::p1)243 foo1.shouldBeEqualToIgnoringFields(foo2, Foo::p2)244 class Bar(val p1: Int, val p2: Int) // not a data class! no equals.245 val bar1a = Bar(1, 1)246 val bar1b = Bar(1, 1)247 bar1a shouldNotBe bar1b248 bar1a shouldBeEqualToComparingFields bar1b // "fake equals" (ignoring private properties)249 bar1a.shouldBeEqualToComparingFields(bar1b, false) // explicitly also check private props250 val bar2 = Bar(1, 2)251 bar1a.shouldBeEqualToComparingFieldsExcept(bar2, Bar::p2)252 }253 }254 // channels255 // concurrent, futures256 // result, optional257 // threads258 // reflection259 // statistic, regex260})261private data class SomeType(val value: Int = 1)262private annotation class Connotation...

Full Screen

Full Screen

BrokerCallServiceIntegrationTest.kt

Source:BrokerCallServiceIntegrationTest.kt Github

copy

Full Screen

1package de.hennihaus.services.callservices2import de.hennihaus.configurations.BrokerConfiguration.ACTIVE_MQ_HEADER_AUTHORIZATION3import de.hennihaus.configurations.BrokerConfiguration.ACTIVE_MQ_HEADER_ORIGIN4import de.hennihaus.configurations.BrokerConfiguration.ACTIVE_MQ_HOST5import de.hennihaus.configurations.BrokerConfiguration.ACTIVE_MQ_PORT6import de.hennihaus.configurations.BrokerConfiguration.ACTIVE_MQ_PROTOCOL7import de.hennihaus.configurations.BrokerConfiguration.ACTIVE_MQ_RETRIES8import de.hennihaus.configurations.BrokerConfiguration.brokerModule9import de.hennihaus.containers.BrokerContainer10import de.hennihaus.models.generated.GetQueuesResponse11import de.hennihaus.models.generated.GetTopicsResponse12import de.hennihaus.models.generated.Queue13import de.hennihaus.models.generated.Topic14import de.hennihaus.objectmothers.BrokerContainerObjectMother.OBJECT_NAME_DEFAULT_PREFIX15import de.hennihaus.objectmothers.BrokerContainerObjectMother.QUEUE_OBJECT_NAME_SUFFIX16import de.hennihaus.objectmothers.BrokerContainerObjectMother.TOPIC_OBJECT_NAME_SUFFIX17import de.hennihaus.objectmothers.BrokerContainerObjectMother.getTestJobs18import de.hennihaus.objectmothers.BrokerContainerObjectMother.getTestQueues19import de.hennihaus.objectmothers.BrokerContainerObjectMother.getTestTopics20import de.hennihaus.objectmothers.BrokerObjectMother.JMS_BANK_A_QUEUE21import de.hennihaus.plugins.BrokerException22import de.hennihaus.plugins.ErrorMessage.BROKER_EXCEPTION_DEFAULT_MESSAGE23import de.hennihaus.plugins.initKoin24import de.hennihaus.services.BrokerServiceImpl.Companion.DESTINATION_NAME_DELIMITER25import de.hennihaus.services.BrokerServiceImpl.Companion.DESTINATION_TYPE_DELIMITER26import io.kotest.assertions.ktor.client.shouldHaveStatus27import io.kotest.assertions.throwables.shouldThrow28import io.kotest.matchers.collections.shouldBeEmpty29import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder30import io.kotest.matchers.collections.shouldHaveSize31import io.kotest.matchers.collections.shouldNotBeEmpty32import io.kotest.matchers.collections.shouldNotContain33import io.kotest.matchers.maps.shouldNotBeEmpty34import io.kotest.matchers.nulls.shouldNotBeNull35import io.kotest.matchers.should36import io.kotest.matchers.shouldBe37import io.kotest.matchers.shouldNotBe38import io.kotest.matchers.string.shouldContain39import io.kotest.matchers.types.beInstanceOf40import io.ktor.client.statement.HttpResponse41import io.ktor.client.statement.bodyAsText42import io.ktor.http.HttpStatusCode43import kotlinx.coroutines.runBlocking44import org.junit.jupiter.api.AfterAll45import org.junit.jupiter.api.BeforeEach46import org.junit.jupiter.api.Nested47import org.junit.jupiter.api.Test48import org.junit.jupiter.api.TestInstance49import org.junit.jupiter.api.extension.RegisterExtension50import org.koin.core.context.stopKoin51import org.koin.ksp.generated.defaultModule52import org.koin.test.KoinTest53import org.koin.test.inject54import org.koin.test.junit5.KoinTestExtension55@TestInstance(TestInstance.Lifecycle.PER_CLASS)56class BrokerCallServiceIntegrationTest : KoinTest {57 private val brokerContainer = BrokerContainer.INSTANCE58 private val classUnderTest: BrokerCallService by inject()59 @JvmField60 @RegisterExtension61 @Suppress("unused")62 val koinTestInstance = KoinTestExtension.create {63 initKoin(64 properties = mapOf(65 ACTIVE_MQ_PROTOCOL to BrokerContainer.ACTIVE_MQ_PROTOCOL.name,66 ACTIVE_MQ_HOST to brokerContainer.host,67 ACTIVE_MQ_PORT to brokerContainer.firstMappedPort.toString(),68 ACTIVE_MQ_RETRIES to BrokerContainer.ACTIVE_MQ_RETRIES.toString(),69 ACTIVE_MQ_HEADER_AUTHORIZATION to BrokerContainer.ACTIVE_MQ_AUTHORIZATION_HEADER,70 ACTIVE_MQ_HEADER_ORIGIN to BrokerContainer.ACTIVE_MQ_ORIGIN_HEADER71 ),72 modules = listOf(defaultModule, brokerModule)73 )74 }75 @BeforeEach76 fun init() = BrokerContainer.resetState()77 @AfterAll78 fun cleanUp() = stopKoin()79 @Nested80 inner class GetAllQueues {81 @Test82 fun `should return 200 and a queue list containing correct objectName`() = runBlocking<Unit> {83 BrokerContainer.addTestData(queues = getTestQueues())84 val result: GetQueuesResponse = classUnderTest.getAllQueues()85 result.shouldNotBeNull()86 result.status shouldBe HttpStatusCode.OK.value87 result.value shouldHaveSize getTestQueues().size88 result.value shouldContainExactlyInAnyOrder getTestQueues().map {89 Queue(90 objectName = """91 $OBJECT_NAME_DEFAULT_PREFIX92 $DESTINATION_NAME_DELIMITER93 $it94 $DESTINATION_TYPE_DELIMITER95 $QUEUE_OBJECT_NAME_SUFFIX96 """.trimIndent().replace("\n", "")97 )98 }99 }100 @Test101 fun `should return 200 and an empty list when no queues available`() = runBlocking<Unit> {102 BrokerContainer.addTestData(queues = emptyList())103 val result: GetQueuesResponse = classUnderTest.getAllQueues()104 result.shouldNotBeNull()105 result.status shouldBe HttpStatusCode.OK.value106 result.value.shouldBeEmpty()107 }108 }109 @Nested110 inner class GetAllTopics {111 @Test112 fun `should return 200 and a topic list containing correct objectName`() = runBlocking<Unit> {113 BrokerContainer.addTestData(topics = getTestTopics())114 val result: GetTopicsResponse = classUnderTest.getAllTopics()115 result.shouldNotBeNull()116 result.status shouldBe HttpStatusCode.OK.value117 result.value shouldHaveSize getTestTopics().size118 result.value shouldContainExactlyInAnyOrder getTestTopics().map {119 Topic(120 objectName = """121 $OBJECT_NAME_DEFAULT_PREFIX122 $DESTINATION_NAME_DELIMITER123 $it124 $DESTINATION_TYPE_DELIMITER125 $TOPIC_OBJECT_NAME_SUFFIX126 """.trimIndent().replace("\n", "")127 )128 }129 }130 @Test131 fun `should return 200 and an empty list when no topics available`() = runBlocking<Unit> {132 BrokerContainer.addTestData(topics = emptyList())133 val result: GetTopicsResponse = classUnderTest.getAllTopics()134 result.shouldNotBeNull()135 result.status shouldBe HttpStatusCode.OK.value136 result.value.shouldBeEmpty()137 }138 }139 @Nested140 inner class DeleteAllJobs {141 @Test142 fun `should return 200 and delete all open jobs in broker`() = runBlocking {143 BrokerContainer.addTestData(jobs = getTestJobs())144 BrokerContainer.getTestJobs().value.shouldNotBeEmpty()145 val response: HttpResponse = classUnderTest.deleteAllJobs()146 response shouldHaveStatus HttpStatusCode.OK147 response.bodyAsText() shouldContain HTTP_STATUS_OK148 BrokerContainer.getTestJobs().value shouldBe emptyMap()149 }150 @Test151 fun `should return 200 and not throw an exception when no jobs is in broker`() = runBlocking {152 BrokerContainer.addTestData(jobs = emptyMap())153 val response: HttpResponse = classUnderTest.deleteAllJobs()154 response shouldHaveStatus HttpStatusCode.OK155 response.bodyAsText() shouldContain HTTP_STATUS_OK156 BrokerContainer.getTestJobs().value shouldBe emptyMap()157 }158 }159 @Nested160 inner class DeleteQueueByName {161 @Test162 fun `should delete a queue by name`() = runBlocking<Unit> {163 BrokerContainer.addTestData(queues = listOf(JMS_BANK_A_QUEUE))164 BrokerContainer.getTestQueues().value.shouldNotBeEmpty()165 val response: HttpResponse = classUnderTest.deleteQueueByName(name = JMS_BANK_A_QUEUE)166 response shouldHaveStatus HttpStatusCode.OK167 response.bodyAsText() shouldContain HTTP_STATUS_OK168 BrokerContainer.getTestQueues().value.shouldBeEmpty()169 }170 @Test171 fun `should return 200 and not throw an exception when queue was not found`() = runBlocking<Unit> {172 val name = "unknownQueue"173 val response: HttpResponse = classUnderTest.deleteQueueByName(name = name)174 response shouldHaveStatus HttpStatusCode.OK175 response.bodyAsText() shouldContain HTTP_STATUS_OK176 BrokerContainer.getTestQueues().value.shouldBeEmpty()177 }178 @Test179 fun `should throw an exception when queue in request is empty`() = runBlocking {180 val name = ""181 val response = shouldThrow<BrokerException> { classUnderTest.deleteQueueByName(name = name) }182 response should beInstanceOf<BrokerException>()183 response.message shouldNotBe BROKER_EXCEPTION_DEFAULT_MESSAGE184 }185 }186 @Nested187 inner class DeleteTopicByName {188 @Test189 fun `should delete a topic by name`() = runBlocking<Unit> {190 BrokerContainer.addTestData(topics = listOf(JMS_BANK_A_QUEUE))191 BrokerContainer.getTestTopics().value.shouldNotBeEmpty()192 val response: HttpResponse = classUnderTest.deleteTopicByName(name = JMS_BANK_A_QUEUE)193 response shouldHaveStatus HttpStatusCode.OK194 response.bodyAsText() shouldContain HTTP_STATUS_OK195 BrokerContainer.getTestTopics().value shouldNotContain Topic(196 objectName = """197 $OBJECT_NAME_DEFAULT_PREFIX198 $DESTINATION_NAME_DELIMITER199 $JMS_BANK_A_QUEUE200 $DESTINATION_TYPE_DELIMITER201 $TOPIC_OBJECT_NAME_SUFFIX202 """.trimIndent().replace("\n", "")203 )204 }205 @Test206 fun `should return 200 and not throw an exception when topic was not found`() = runBlocking<Unit> {207 val name = "unknownTopic"208 val response: HttpResponse = classUnderTest.deleteTopicByName(name = name)209 response shouldHaveStatus HttpStatusCode.OK210 response.bodyAsText() shouldContain HTTP_STATUS_OK211 BrokerContainer.getTestTopics().value.shouldBeEmpty()212 }213 @Test214 fun `should throw an exception when topic in request is empty`() = runBlocking {215 val name = ""216 val response = shouldThrow<BrokerException> { classUnderTest.deleteTopicByName(name = name) }217 response should beInstanceOf<BrokerException>()218 response.message shouldNotBe BROKER_EXCEPTION_DEFAULT_MESSAGE219 }220 }221 companion object {222 const val HTTP_STATUS_OK = """"status":200"""223 }224}...

Full Screen

Full Screen

ApplicationsTest.kt

Source:ApplicationsTest.kt Github

copy

Full Screen

1package app.civa.vaccination.domain2import io.kotest.assertions.throwables.shouldNotThrowAny3import io.kotest.assertions.throwables.shouldThrowExactly4import io.kotest.core.spec.style.BehaviorSpec5import io.kotest.data.forAll6import io.kotest.data.row7import io.kotest.matchers.maps.shouldBeEmpty8import io.kotest.matchers.maps.shouldContain9import io.kotest.matchers.maps.shouldNotBeEmpty10import io.kotest.matchers.maps.shouldNotContain11import io.kotest.matchers.nulls.shouldNotBeNull12import io.kotest.matchers.shouldBe13import io.kotest.matchers.types.shouldBeSameInstanceAs14import io.mockk.every15import io.mockk.mockk16import io.mockk.verify17import org.junit.jupiter.api.assertDoesNotThrow18import java.util.*19class ApplicationsTest : BehaviorSpec({20 given("a vaccine application to be added") {21 `when`("it is the first application of that name") {22 then("it should be added successfully") {23 val vaccineMock = mockk<Vaccine>()24 every { vaccineMock.makeKey() } returns "Name Test"25 val applications = Applications()26 shouldNotThrowAny {27 val application = application {28 id = mockk()29 vaccine = vaccineMock30 createdOn = mockk()31 petWeight = mockk()32 }33 applications add application34 applications.shouldNotBeNull().shouldNotBeEmpty()35 applications shouldContain ("Name Test" to listOf(application))36 applications.size shouldBe 137 }38 verify { vaccineMock.makeKey() }39 }40 }41 `when`("it is not the first application of that name") {42 and("it has happened after interval") {43 then("it should be added to applications successfully") {44 val vaccineMock = mockk<Vaccine>()45 every { vaccineMock.makeKey() } returns "Name Test"46 val vaccineApplicationMock = mockk<VaccineApplication>()47 every {48 vaccineApplicationMock mapStatusFrom any()49 } returns DateTimeStatus.VALID50 every { vaccineApplicationMock.getKey() } returns "Name Test"51 val applications = Applications()52 applications add vaccineApplicationMock53 shouldNotThrowAny {54 val application = application {55 id = mockk()56 vaccine = vaccineMock57 createdOn = mockk()58 petWeight = mockk()59 }60 applications add application61 applications.shouldNotBeNull().shouldNotBeEmpty()62 applications.size shouldBe 163 applications shouldContain ("Name Test" to listOf(64 vaccineApplicationMock,65 application66 ))67 }68 verify {69 vaccineApplicationMock.getKey()70 vaccineMock.makeKey()71 vaccineApplicationMock mapStatusFrom any()72 }73 }74 }75 and("it is not valid") {76 then("it should not be added") {77 forAll(78 row(DateTimeStatus.BEFORE),79 row(DateTimeStatus.SAME),80 row(DateTimeStatus.INTERVAL)81 ) {82 val vaccineMock = mockk<Vaccine>()83 every { vaccineMock.makeKey() } returns "Name Test"84 val vaccineApplicationMock = mockk<VaccineApplication>()85 every { vaccineApplicationMock mapStatusFrom any() } returns it86 every { vaccineApplicationMock.getKey() } returns "Name Test"87 val applications = Applications()88 applications add vaccineApplicationMock89 shouldThrowExactly<InvalidApplicationException> {90 val application = application {91 id = mockk()92 vaccine = vaccineMock93 createdOn = mockk()94 petWeight = mockk()95 }96 applications add application97 applications.shouldNotBeNull().shouldNotBeEmpty()98 applications.size shouldBe 199 applications shouldNotContain ("Name Test" to listOf(100 vaccineApplicationMock,101 application102 ))103 }104 verify {105 vaccineApplicationMock.getKey()106 vaccineMock.makeKey()107 vaccineApplicationMock mapStatusFrom any()108 }109 }110 }111 }112 }113 }114 given("an application id to be removed") {115 `when`("the application is found") {116 and("there's only one application with certain name") {117 then("it should be removed successfully") {118 val vaccineMock = mockk<Vaccine>()119 every { vaccineMock.makeKey() } returns "Name Test"120 val uuid = UUID.randomUUID()121 val vaccineApplication = application {122 id = uuid123 vaccine = vaccineMock124 createdOn = mockk()125 petWeight = mockk()126 }127 val applications = Applications()128 applications add vaccineApplication129 assertDoesNotThrow { applications deleteBy uuid }130 applications.shouldNotBeNull().shouldBeEmpty()131 applications shouldNotContain ("Name Test" to listOf(vaccineApplication))132 verify { vaccineMock.makeKey() }133 }134 }135 and("there's more than one application with the same name") {136 then("it should be removed successfully") {137 val vaccineMock = mockk<Vaccine>()138 every { vaccineMock.makeKey() } returns "Name Test"139 val createdOnMock = mockk<ApplicationDateTime>()140 every { createdOnMock mapStatus any() } returns DateTimeStatus.VALID141 val uuid = UUID.randomUUID()142 val vaccineApplication = application {143 id = uuid144 vaccine = vaccineMock145 createdOn = createdOnMock146 petWeight = mockk()147 }148 val applications = Applications()149 applications add vaccineApplication150 applications add application {151 id = UUID.randomUUID()152 vaccine = vaccineMock153 createdOn = mockk()154 petWeight = mockk()155 }156 assertDoesNotThrow { applications deleteBy uuid }157 applications.shouldNotBeNull().shouldNotBeEmpty()158 applications shouldNotContain ("Name Test" to listOf(vaccineApplication))159 verify { vaccineMock.makeKey() }160 }161 }162 }163 `when`("applications is empty") {164 then("there won't be any to remove") {165 val applications = Applications()166 shouldThrowExactly<ApplicationNotFoundException> {167 applications deleteBy UUID.randomUUID()168 }169 applications.shouldNotBeNull().shouldBeEmpty()170 }171 }172 }173 given("an application id to be found") {174 `when`("the application is present") {175 then("it must be retrieved") {176 val vaccineMock = mockk<Vaccine>()177 every { vaccineMock.makeKey() } returns "Vaccine Key"178 val uuid = UUID.randomUUID()179 val vaccineApplication = application {180 id = uuid181 vaccine = vaccineMock182 createdOn = mockk()183 petWeight = mockk()184 }185 val applications = Applications()186 applications add vaccineApplication187 shouldNotThrowAny {188 val foundApplication = applications findBy uuid189 foundApplication shouldBeSameInstanceAs vaccineApplication190 }191 }192 }193 `when`("the application is not found") {194 then("it should not be retrieved") {195 val applications = Applications()196 shouldThrowExactly<ApplicationNotFoundException> {197 applications findBy UUID.randomUUID()198 }199 }200 }201 }202})...

Full Screen

Full Screen

ReplVarsTest.kt

Source:ReplVarsTest.kt Github

copy

Full Screen

1package org.jetbrains.kotlinx.jupyter.test.repl2import io.kotest.matchers.collections.shouldBeEmpty3import io.kotest.matchers.collections.shouldContain4import io.kotest.matchers.maps.shouldBeEmpty5import io.kotest.matchers.maps.shouldContainValue6import io.kotest.matchers.maps.shouldHaveSize7import io.kotest.matchers.maps.shouldNotBeEmpty8import io.kotest.matchers.shouldBe9import org.jetbrains.kotlinx.jupyter.api.VariableStateImpl10import org.jetbrains.kotlinx.jupyter.test.getStringValue11import org.jetbrains.kotlinx.jupyter.test.getValue12import org.jetbrains.kotlinx.jupyter.test.mapToStringValues13import org.junit.jupiter.api.Test14class ReplVarsTest : AbstractSingleReplTest() {15 override val repl = makeSimpleRepl()16 private val varState get() = repl.notebook.variablesState17 private val cellVars get() = repl.notebook.cellVariables18 private fun cellVarsAt(i: Int) = cellVars[i]!!19 private val firstCellVars get() = cellVarsAt(0)20 private val secondCellVars get() = cellVarsAt(1)21 @Test22 fun testVarsStateConsistency() {23 varState.shouldBeEmpty()24 eval(25 """26 val x = 1 27 val y = 028 val z = 4729 """.trimIndent()30 )31 varState.mapToStringValues() shouldBe mutableMapOf(32 "x" to "1",33 "y" to "0",34 "z" to "47"35 )36 varState.getStringValue("x") shouldBe "1"37 varState.getStringValue("y") shouldBe "0"38 varState.getValue("z") shouldBe 4739 (varState["z"] as VariableStateImpl).update()40 varState.getValue("z") shouldBe 4741 }42 @Test43 fun testVarsEmptyState() {44 val res = eval("3+2")45 val strState = varState.mapToStringValues()46 varState.shouldBeEmpty()47 res.metadata.evaluatedVariablesState shouldBe strState48 }49 @Test50 fun testVarsCapture() {51 eval(52 """53 val x = 1 54 val y = "abc"55 val z = x56 """.trimIndent()57 )58 varState.mapToStringValues() shouldBe mapOf("x" to "1", "y" to "abc", "z" to "1")59 varState.getValue("x") shouldBe 160 varState.getStringValue("y") shouldBe "abc"61 varState.getStringValue("z") shouldBe "1"62 }63 @Test64 fun testVarsCaptureSeparateCells() {65 eval(66 """67 val x = 1 68 val y = "abc"69 val z = x70 """.trimIndent()71 )72 varState.shouldNotBeEmpty()73 eval(74 """75 val x = "abc" 76 var y = 12377 val z = x78 """.trimIndent(),79 jupyterId = 180 )81 varState shouldHaveSize 382 varState.getStringValue("x") shouldBe "abc"83 varState.getValue("y") shouldBe 12384 varState.getStringValue("z") shouldBe "abc"85 eval(86 """87 val x = 1024 88 y += 12389 """.trimIndent(),90 jupyterId = 291 )92 varState shouldHaveSize 393 varState.getStringValue("x") shouldBe "1024"94 varState.getStringValue("y") shouldBe "${123 * 2}"95 varState.getValue("z") shouldBe "abc"96 }97 @Test98 fun testPrivateVarsCapture() {99 eval(100 """101 private val x = 1 102 private val y = "abc"103 val z = x104 """.trimIndent()105 )106 varState.mapToStringValues() shouldBe mapOf("x" to "1", "y" to "abc", "z" to "1")107 varState.getValue("x") shouldBe 1108 }109 @Test110 fun testPrivateVarsCaptureSeparateCells() {111 eval(112 """113 private val x = 1 114 private val y = "abc"115 private val z = x116 """.trimIndent()117 )118 varState.shouldNotBeEmpty()119 eval(120 """121 private val x = "abc" 122 var y = 123123 private val z = x124 """.trimIndent(),125 jupyterId = 1126 )127 varState shouldHaveSize 3128 varState.getStringValue("x") shouldBe "abc"129 varState.getValue("y") shouldBe 123130 varState.getStringValue("z") shouldBe "abc"131 eval(132 """133 private val x = 1024 134 y += x135 """.trimIndent(),136 jupyterId = 2137 )138 varState shouldHaveSize 3139 varState.getStringValue("x") shouldBe "1024"140 varState.getValue("y") shouldBe 123 + 1024141 varState.getStringValue("z") shouldBe "abc"142 }143 @Test144 fun testVarsUsageConsistency() {145 eval("3+2")146 cellVars shouldHaveSize 1147 cellVars.values.first().shouldBeEmpty()148 }149 @Test150 fun testVarsDefsUsage() {151 eval(152 """153 val x = 1154 val z = "abcd"155 var f = 47156 """.trimIndent()157 )158 cellVars shouldContainValue setOf("z", "f", "x")159 }160 @Test161 fun testVarsDefNRefUsage() {162 eval(163 """164 val x = "abcd"165 var f = 47166 """.trimIndent()167 )168 cellVars.shouldNotBeEmpty()169 eval(170 """171 val z = 1172 f += f173 """.trimIndent()174 )175 cellVars shouldContainValue setOf("z", "f", "x")176 }177 @Test178 fun testPrivateVarsDefNRefUsage() {179 eval(180 """181 val x = 124182 private var f = "abcd"183 """.trimIndent()184 )185 cellVars.shouldNotBeEmpty()186 eval(187 """188 private var z = 1189 z += x190 """.trimIndent()191 )192 cellVars shouldContainValue setOf("z", "f", "x")193 }194 @Test195 fun testSeparateDefsUsage() {196 eval(197 """198 val x = "abcd"199 var f = 47200 """.trimIndent(),201 jupyterId = 1202 )203 firstCellVars shouldContain "x"204 eval(205 """206 val x = 341207 var f = "abcd"208 """.trimIndent(),209 jupyterId = 2210 )211 cellVars.shouldNotBeEmpty()212 firstCellVars.shouldBeEmpty()213 secondCellVars shouldBe setOf("x", "f")214 }215 @Test216 fun testSeparatePrivateDefsUsage() {217 eval(218 """219 private val x = "abcd"220 private var f = 47221 """.trimIndent(),222 jupyterId = 1223 )224 firstCellVars shouldContain "x"225 eval(226 """227 val x = 341228 private var f = "abcd"229 """.trimIndent(),230 jupyterId = 2231 )232 cellVars.shouldNotBeEmpty()233 firstCellVars.shouldBeEmpty()234 secondCellVars shouldBe setOf("x", "f")235 }236 @Test237 fun testRecursiveVarsState() {238 eval(239 """240 val l = mutableListOf<Any>()241 l.add(listOf(l))242 243 val m = mapOf(1 to l)244 245 val z = setOf(1, 2, 4)246 """.trimIndent(),247 jupyterId = 1248 )249 varState.getStringValue("l") shouldBe "ArrayList: [exception thrown: java.lang.StackOverflowError]"250 varState.getStringValue("m") shouldBe "SingletonMap: [exception thrown: java.lang.StackOverflowError]"251 varState.getStringValue("z") shouldBe "[1, 2, 4]"252 }253 @Test254 fun testSeparatePrivateCellsUsage() {255 eval(256 """257 private val x = "abcd"258 var f = 47259 internal val z = 47260 """.trimIndent(),261 jupyterId = 1262 )263 firstCellVars shouldContain "x"264 firstCellVars shouldContain "z"265 eval(266 """267 private val x = 341268 f += x269 protected val z = "abcd"270 """.trimIndent(),271 jupyterId = 2272 )273 cellVars.shouldNotBeEmpty()274 firstCellVars shouldBe setOf("f")275 secondCellVars shouldBe setOf("x", "f", "z")276 }277 @Test278 fun testVariableModification() {279 eval("var x = sqrt(25.0)", jupyterId = 1)280 varState.getStringValue("x") shouldBe "5.0"281 varState.getValue("x") shouldBe 5.0282 eval("x = x * x", jupyterId = 2)283 varState.getStringValue("x") shouldBe "25.0"284 varState.getValue("x") shouldBe 25.0285 }286}...

Full Screen

Full Screen

BeverageWithoutIdValidatorTest.kt

Source:BeverageWithoutIdValidatorTest.kt Github

copy

Full Screen

1package io.teapot.usecase.beverages.validator2import io.kotest.core.spec.style.DescribeSpec3import io.kotest.data.row4import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder5import io.kotest.matchers.maps.shouldBeEmpty6import io.kotest.matchers.maps.shouldContainKey7import io.kotest.matchers.maps.shouldHaveSize8import io.kotest.matchers.maps.shouldNotBeEmpty9import io.teapot.domain.entity.BeverageWithoutId10import io.teapot.usecase.validation.ValidationErrors11class BeverageWithoutIdValidatorTest : DescribeSpec({12 describe("validate") {13 val validName = "Valid Beverage"14 describe("when BeverageWithoutId is valid") {15 it("returns empty validation errors") {16 val validBeverageWithoutId = BeverageWithoutId(validName)17 val validationErrors: ValidationErrors = BeverageWithoutIdValidator.validate(validBeverageWithoutId)18 validationErrors.shouldBeEmpty()19 }20 }21 describe("when BeverageWithoutId is invalid") {22 val emptyString = ""23 val blankString = " "24 val oversizeString = "a".repeat(256)25 val validString = "valid-string"26 val blankMessage = "must not be blank"27 val oversizeMessage = "size must be between 1 and 255"28 listOf(29 row(30 "when name is empty",31 "name",32 BeverageWithoutId(emptyString),33 listOf(blankMessage, oversizeMessage)34 ),35 row(36 "when name is blank",37 "name",38 BeverageWithoutId(blankString),39 listOf(blankMessage)40 ),41 row(42 "when name has more than 255 characters",43 "name",44 BeverageWithoutId(oversizeString),45 listOf(oversizeMessage)46 ),47 row(48 "when settings key is empty",49 "settings<K>[$emptyString].<map key>",50 BeverageWithoutId(validName, mapOf(emptyString to "value")),51 listOf(blankMessage, oversizeMessage)52 ),53 row(54 "when settings key is blank",55 "settings<K>[$blankString].<map key>",56 BeverageWithoutId(validName, mapOf(blankString to validString)),57 listOf(blankMessage)58 ),59 row(60 "when settings key has more than 255 characters",61 "settings<K>[$oversizeString].<map key>",62 BeverageWithoutId(validName, mapOf(oversizeString to validString)),63 listOf(oversizeMessage)64 ),65 row(66 "when settings value is empty",67 "settings[$validString].<map value>",68 BeverageWithoutId(validName, mapOf(validString to emptyString)),69 listOf(blankMessage, oversizeMessage)70 ),71 row(72 "when settings value is blank",73 "settings[$validString].<map value>",74 BeverageWithoutId(validName, mapOf(validString to blankString)),75 listOf(blankMessage)76 ),77 row(78 "when settings value has more than 255 characters",79 "settings[$validString].<map value>",80 BeverageWithoutId(validName, mapOf(validString to oversizeString)),81 listOf(oversizeMessage)82 ),83 row(84 "when settings has more than 5 elements",85 "settings",86 BeverageWithoutId(87 validName,88 listOf("1", "2", "3", "4", "5", "6").associateWith { it }89 ),90 listOf("size must be between 0 and 5")91 )92 ).map { (93 context: String,94 field: String,95 invalidBeverageWithoutId: BeverageWithoutId,96 expectedErrors: List<String>97 ) ->98 describe(context) {99 it("returns error messages: $expectedErrors") {100 val validationErrors: ValidationErrors = BeverageWithoutIdValidator101 .validate(invalidBeverageWithoutId)102 validationErrors.apply {103 shouldNotBeEmpty()104 shouldHaveSize(1)105 shouldContainKey(field)106 }107 val actualErrors: List<String> = validationErrors[field]!!108 actualErrors.shouldContainExactlyInAnyOrder(expectedErrors)109 }110 }111 }112 }113 }114})...

Full Screen

Full Screen

OrderWithoutIdValidatorTest.kt

Source:OrderWithoutIdValidatorTest.kt Github

copy

Full Screen

1package io.teapot.usecase.beverages.validator2import io.kotest.core.spec.style.DescribeSpec3import io.kotest.data.row4import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder5import io.kotest.matchers.maps.shouldBeEmpty6import io.kotest.matchers.maps.shouldContainKey7import io.kotest.matchers.maps.shouldHaveSize8import io.kotest.matchers.maps.shouldNotBeEmpty9import io.teapot.domain.entity.OrderSize10import io.teapot.domain.entity.OrderWithoutId11import io.teapot.usecase.validation.ValidationErrors12class OrderWithoutIdValidatorTest : DescribeSpec({13 describe("validate") {14 val validBeverage = "Valid Order"15 val validUsername = "teadrinker"16 describe("when OrderWithoutId is valid") {17 it("returns empty validation errors") {18 val validOrderWithoutId = OrderWithoutId(validBeverage, validUsername, OrderSize.S.toString())19 val validationErrors: ValidationErrors = OrderWithoutIdValidator.validate(validOrderWithoutId)20 validationErrors.shouldBeEmpty()21 }22 }23 describe("when OrderWithoutId is invalid") {24 val emptyString = ""25 val blankString = " "26 val oversizeString = "a".repeat(256)27 val blankMessage = "must not be blank"28 val oversizeMessage = "size must be between 1 and 255"29 listOf(30 row(31 "when beverage is empty",32 "beverage",33 OrderWithoutId(emptyString, validUsername, OrderSize.S.toString()),34 listOf(blankMessage, oversizeMessage)35 ),36 row(37 "when beverage is blank",38 "beverage",39 OrderWithoutId(blankString, validUsername, OrderSize.M.toString()),40 listOf(blankMessage)41 ),42 row(43 "when beverage has more than 255 characters",44 "beverage",45 OrderWithoutId(oversizeString, validUsername, OrderSize.L.toString()),46 listOf(oversizeMessage)47 ),48 row(49 "when username is empty",50 "username",51 OrderWithoutId(validBeverage, emptyString, OrderSize.L.toString()),52 listOf(blankMessage, oversizeMessage)53 ),54 row(55 "when username is blank",56 "username",57 OrderWithoutId(validBeverage, blankString, OrderSize.M.toString()),58 listOf(blankMessage)59 ),60 row(61 "when username has more than 255 characters",62 "username",63 OrderWithoutId(validBeverage, oversizeString, OrderSize.S.toString()),64 listOf(oversizeMessage)65 ),66 row(67 "when size is not S, M or L",68 "size",69 OrderWithoutId(validBeverage, validUsername, "XL"),70 listOf("must be S, M or L")71 ),72 ).map { (73 context: String,74 field: String,75 invalidOrderWithoutId: OrderWithoutId,76 expectedErrors: List<String>77 ) ->78 describe(context) {79 it("returns error messages: $expectedErrors") {80 val validationErrors: ValidationErrors = OrderWithoutIdValidator81 .validate(invalidOrderWithoutId)82 validationErrors.apply {83 shouldNotBeEmpty()84 shouldHaveSize(1)85 shouldContainKey(field)86 }87 val actualErrors: List<String> = validationErrors[field]!!88 actualErrors.shouldContainExactlyInAnyOrder(expectedErrors)89 }90 }91 }92 }93 }94})...

Full Screen

Full Screen

AssetsTest.kt

Source:AssetsTest.kt Github

copy

Full Screen

1package io.blockfrost.sdk_kotlin.itests2import io.blockfrost.sdk_kotlin.api.CardanoAssetsApi3import io.blockfrost.sdk_kotlin.infrastructure.BlockfrostConfig4import io.blockfrost.sdk_kotlin.models.AssetHistory5import io.kotest.core.spec.style.DescribeSpec6import io.kotest.matchers.collections.shouldContainExactly7import io.kotest.matchers.collections.shouldNotBeEmpty8import io.kotest.matchers.ints.shouldBeGreaterThan9import io.kotest.matchers.maps.shouldContainExactly10import io.kotest.matchers.nulls.shouldBeNull11import io.kotest.matchers.nulls.shouldNotBeNull12import io.kotest.matchers.shouldBe13import io.kotest.matchers.string.shouldNotBeBlank14import kotlin.properties.Delegates15import kotlin.time.Duration16import kotlin.time.ExperimentalTime17@OptIn(ExperimentalTime::class)18class AssetsTest : DescribeSpec({19 var api: CardanoAssetsApi by Delegates.notNull()20 System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "INFO")21 describe("load assets"){22 beforeTest {23 api = CardanoAssetsApi(config = BlockfrostConfig.defaulMainNetConfig)24 }25 it("all").config(timeout = Duration.Companion.seconds(10)){26 val r = api.getAssets()27 r.shouldNotBeNull()28 }29 it("by id").config(timeout = Duration.Companion.seconds(10)){30 val r = api.getAsset("b863bc7369f46136ac1048adb2fa7dae3af944c3bbb2be2f216a8d4f42657272795361707068697265")31 r.shouldNotBeNull()32 r.asset.shouldBe("b863bc7369f46136ac1048adb2fa7dae3af944c3bbb2be2f216a8d4f42657272795361707068697265")33 r.assetName.shouldBe("42657272795361707068697265")34 r.fingerprint.shouldBe("asset1hwnpal5vap799t6kkjmjf6myhse4zl2vu4ahzz")35 r.initialMintTxHash.shouldBe("6556b532acf59835084f62d30675f3a55b78c61959bca44a86ea02c320fbf822")36 r.metadata.shouldBeNull()37 r.mintOrBurnCount.shouldBe(1)38 r.onchainMetadata.shouldNotBeNull()39 r.onchainMetadata!!.shouldContainExactly(mapOf(40 "color" to "#0F52BA",41 "image" to "ipfs://ipfs/QmWxK9BvEbLGFZuQHL8zbHXSv469JrqnX3kUcZafjsoka4",42 "name" to "Berry Sapphire",43 ))44 r.policyId.shouldBe("b863bc7369f46136ac1048adb2fa7dae3af944c3bbb2be2f216a8d4f")45 r.quantity.shouldBe("1")46 }47 it("history").config(timeout = Duration.Companion.seconds(10)){48 val r = api.getAssetHistory("00000002df633853f6a47465c9496721d2d5b1291b8398016c0e87ae6e7574636f696e")49 r.shouldNotBeEmpty()50 r.shouldContainExactly(51 AssetHistory(txHash = "e252be4c7e40d35919f741c9649ff207c3e49d53bb819e5c1cb458055fd363ed", action = AssetHistory.Action.minted, amount = "1"),52 )53 }54 it("historyAll").config(timeout = Duration.Companion.seconds(120)){55 val r = api.getAssetHistoryAllList("d894897411707efa755a76deb66d26dfd50593f2e70863e1661e98a07370616365636f696e73")56 r.shouldNotBeEmpty()57 r.size.shouldBeGreaterThan(2320)58 r.forEach {59 it.txHash.shouldNotBeBlank()60 it.amount.shouldNotBeBlank()61 }62 }63 it("transactions").config(timeout = Duration.Companion.seconds(10)){64 val r = api.getAssetTransactions("00000002df633853f6a47465c9496721d2d5b1291b8398016c0e87ae6e7574636f696e")65 r.shouldNotBeEmpty()66 }67 it("addresses").config(timeout = Duration.Companion.seconds(10)){68 val r = api.getAssetAddresses("00000002df633853f6a47465c9496721d2d5b1291b8398016c0e87ae6e7574636f696e")69 r.shouldNotBeEmpty()70 }71 it("policy").config(timeout = Duration.Companion.seconds(10)){72 val r = api.getPolicyAssets("b863bc7369f46136ac1048adb2fa7dae3af944c3bbb2be2f216a8d4f")73 r.shouldNotBeEmpty()74 }75 }76})...

Full Screen

Full Screen

Map.kt

Source:Map.kt Github

copy

Full Screen

1package io.opengood.extensions.kotest.matcher2import io.kotest.matchers.collections.shouldNotBeEmpty3import io.kotest.matchers.maps.shouldContain4import io.kotest.matchers.shouldBe5fun <K : Any, V : Any> List<Map<K, V>>.shouldBeEqualIgnoringKeys(6 expected: List<Map<K, V>>,7 vararg keys: K8) {9 shouldNotBeEmpty()10 size shouldBe expected.size11 expected.forEachIndexed { i, expectedMap ->12 val actualMap = this[i]13 expectedMap.forEach { (key, value) ->14 if (!keys.contains(key))15 actualMap.shouldContain(key, value)16 }17 }18}19infix fun <K : Any, V : Any> Map.Entry<K, V>.shouldBeMapEntry(20 expected: Map.Entry<K, V>21) {22 key shouldBe expected.key23 value shouldBe expected.value24}...

Full Screen

Full Screen

Map.shouldNotBeEmpty

Using AI Code Generation

copy

Full Screen

1val map = mapOf("a" to 1, "b" to 2, "c" to 3)2map.shouldNotBeEmpty()3val map = mapOf("a" to 1, "b" to 2, "c" to 3)4map.shouldContainKey("b")5val map = mapOf("a" to 1, "b" to 2, "c" to 3)6map.shouldContainValue(2)7val map = mapOf("a" to 1, "b" to 2, "c" to 3)8map.shouldContain("b" to 2)9val map = mapOf("a" to 1, "b" to 2, "c" to 3)10map.shouldContainAll(listOf("a" to 1, "b" to 2))11val map = mapOf("a" to 1, "b" to 2, "c" to 3)12map.shouldNotContainKey("d")13val map = mapOf("a" to 1, "b" to 2, "c" to 3)14map.shouldNotContainValue(4)15val map = mapOf("a" to 1, "b" to 2, "c" to 3)16map.shouldNotContain("d" to 4)17val map = mapOf("a" to 1, "b" to 2, "c" to 3)18map.shouldNotContainAll(listOf("d" to 4, "e"

Full Screen

Full Screen

Map.shouldNotBeEmpty

Using AI Code Generation

copy

Full Screen

1val map = mapOf( "a" to 1, "b" to 2)2map.shouldNotBeEmpty()3val map = mapOf( "a" to 1, "b" to 2)4map.shouldContainKey( "a" )5val map = mapOf( "a" to 1, "b" to 2)6map.shouldContainValue( 1 )7val map = mapOf( "a" to 1, "b" to 2)8map.shouldContainAll( "a" to 1, "b" to 2)9val map = mapOf( "a" to 1, "b" to 2)10map.shouldContainExactly( "a" to 1, "b" to 2)11val map = mapOf( "a" to 1, "b" to 2)12map.shouldNotContainKey( "c" )13val map = mapOf( "a" to 1, "b" to 2)14map.shouldNotContainValue( 3 )15val map = mapOf( "a" to 1, "b" to 2)16map.shouldNotContainAll( "a" to 1, "c" to 3)17val map = mapOf( "a" to 1, "b" to 2)18map.shouldNotContainExactly( "a" to 1, "c" to 3)

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful