1 // This file was automatically generated from polymorphism.md by Knit tool. Do not edit. 2 package example.test 3 4 import org.junit.Test 5 import kotlinx.knit.test.* 6 7 class PolymorphismTest { 8 @Test testExamplePoly01null9 fun testExamplePoly01() { 10 captureOutput("ExamplePoly01") { example.examplePoly01.main() }.verifyOutputLines( 11 "{\"name\":\"kotlinx.coroutines\"}" 12 ) 13 } 14 15 @Test testExamplePoly02null16 fun testExamplePoly02() { 17 captureOutput("ExamplePoly02") { example.examplePoly02.main() }.verifyOutputLinesStart( 18 "Exception in thread \"main\" kotlinx.serialization.SerializationException: Serializer for class 'OwnedProject' is not found.", 19 "Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied." 20 ) 21 } 22 23 @Test testExamplePoly03null24 fun testExamplePoly03() { 25 captureOutput("ExamplePoly03") { example.examplePoly03.main() }.verifyOutputLinesStart( 26 "Exception in thread \"main\" kotlinx.serialization.SerializationException: Serializer for subclass 'OwnedProject' is not found in the polymorphic scope of 'Project'.", 27 "Check if class with serial name 'OwnedProject' exists and serializer is registered in a corresponding SerializersModule.", 28 "To be registered automatically, class 'OwnedProject' has to be '@Serializable', and the base class 'Project' has to be sealed and '@Serializable'." 29 ) 30 } 31 32 @Test testExamplePoly04null33 fun testExamplePoly04() { 34 captureOutput("ExamplePoly04") { example.examplePoly04.main() }.verifyOutputLines( 35 "{\"type\":\"example.examplePoly04.OwnedProject\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}" 36 ) 37 } 38 39 @Test testExamplePoly05null40 fun testExamplePoly05() { 41 captureOutput("ExamplePoly05") { example.examplePoly05.main() }.verifyOutputLines( 42 "{\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}" 43 ) 44 } 45 46 @Test testExamplePoly06null47 fun testExamplePoly06() { 48 captureOutput("ExamplePoly06") { example.examplePoly06.main() }.verifyOutputLines( 49 "{\"type\":\"owned\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}" 50 ) 51 } 52 53 @Test testExamplePoly07null54 fun testExamplePoly07() { 55 captureOutput("ExamplePoly07") { example.examplePoly07.main() }.verifyOutputLines( 56 "{\"type\":\"owned\",\"status\":\"open\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}" 57 ) 58 } 59 60 @Test testExamplePoly08null61 fun testExamplePoly08() { 62 captureOutput("ExamplePoly08") { example.examplePoly08.main() }.verifyOutputLines( 63 "[{\"type\":\"example.examplePoly08.EmptyResponse\"},{\"type\":\"example.examplePoly08.TextResponse\",\"text\":\"OK\"}]" 64 ) 65 } 66 67 @Test testExamplePoly09null68 fun testExamplePoly09() { 69 captureOutput("ExamplePoly09") { example.examplePoly09.main() }.verifyOutputLines( 70 "{\"type\":\"owned\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}" 71 ) 72 } 73 74 @Test testExamplePoly10null75 fun testExamplePoly10() { 76 captureOutput("ExamplePoly10") { example.examplePoly10.main() }.verifyOutputLinesStart( 77 "{\"type\":\"owned\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}" 78 ) 79 } 80 81 @Test testExamplePoly11null82 fun testExamplePoly11() { 83 captureOutput("ExamplePoly11") { example.examplePoly11.main() }.verifyOutputLines( 84 "{\"project\":{\"type\":\"owned\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}}" 85 ) 86 } 87 88 @Test testExamplePoly12null89 fun testExamplePoly12() { 90 captureOutput("ExamplePoly12") { example.examplePoly12.main() }.verifyOutputLinesStart( 91 "Exception in thread \"main\" kotlinx.serialization.SerializationException: Serializer for class 'Any' is not found.", 92 "Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied." 93 ) 94 } 95 96 @Test testExamplePoly13null97 fun testExamplePoly13() { 98 captureOutput("ExamplePoly13") { example.examplePoly13.main() }.verifyOutputLinesStart( 99 "Exception in thread \"main\" kotlinx.serialization.SerializationException: Serializer for class 'Any' is not found.", 100 "Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied." 101 ) 102 } 103 104 @Test testExamplePoly14null105 fun testExamplePoly14() { 106 captureOutput("ExamplePoly14") { example.examplePoly14.main() }.verifyOutputLines( 107 "{\"type\":\"owned\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}" 108 ) 109 } 110 111 @Test testExamplePoly15null112 fun testExamplePoly15() { 113 captureOutput("ExamplePoly15") { example.examplePoly15.main() }.verifyOutputLines( 114 "{\"project\":{\"type\":\"owned\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}}" 115 ) 116 } 117 118 @Test testExamplePoly16null119 fun testExamplePoly16() { 120 captureOutput("ExamplePoly16") { example.examplePoly16.main() }.verifyOutputLines( 121 "{\"project\":{\"type\":\"owned\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"},\"any\":{\"type\":\"owned\",\"name\":\"kotlinx.coroutines\",\"owner\":\"kotlin\"}}" 122 ) 123 } 124 125 @Test testExamplePoly17null126 fun testExamplePoly17() { 127 captureOutput("ExamplePoly17") { example.examplePoly17.main() }.verifyOutputLines( 128 "{\"type\":\"OkResponse\",\"data\":{\"type\":\"OwnedProject\",\"name\":\"kotlinx.serialization\",\"owner\":\"kotlin\"}}", 129 "OkResponse(data=OwnedProject(name=kotlinx.serialization, owner=kotlin))" 130 ) 131 } 132 133 @Test testExamplePoly18null134 fun testExamplePoly18() { 135 captureOutput("ExamplePoly18") { example.examplePoly18.main() }.verifyOutputLinesStart( 136 "Exception in thread \"main\" kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 0: Serializer for subclass 'unknown' is not found in the polymorphic scope of 'Project' at path: $", 137 "Check if class with serial name 'unknown' exists and serializer is registered in a corresponding SerializersModule." 138 ) 139 } 140 141 @Test testExamplePoly19null142 fun testExamplePoly19() { 143 captureOutput("ExamplePoly19") { example.examplePoly19.main() }.verifyOutputLines( 144 "[BasicProject(name=example, type=unknown), OwnedProject(name=kotlinx.serialization, owner=kotlin)]" 145 ) 146 } 147 148 @Test testExamplePoly20null149 fun testExamplePoly20() { 150 captureOutput("ExamplePoly20") { example.examplePoly20.main() }.verifyOutputLines( 151 "{\"type\":\"Cat\",\"catType\":\"Tabby\"}" 152 ) 153 } 154 } 155