|
1 | 1 | package io.sentry.rnsentryandroidtester |
2 | 2 |
|
| 3 | +import android.content.Context |
3 | 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 |
4 | 5 | import androidx.test.platform.app.InstrumentationRegistry |
5 | 6 | import com.facebook.react.bridge.Arguments |
6 | 7 | import com.facebook.soloader.SoLoader |
7 | 8 | import io.sentry.react.RNSentryMapConverter |
8 | | -import org.junit.Assert.* |
| 9 | +import org.junit.Assert.assertEquals |
| 10 | +import org.junit.Assert.assertNull |
| 11 | +import org.junit.Before |
9 | 12 | import org.junit.Test |
10 | 13 | import org.junit.runner.RunWith |
11 | | -import android.content.Context; |
12 | | -import org.junit.Before |
13 | 14 | import java.math.BigDecimal |
14 | 15 | import java.math.BigInteger |
15 | 16 |
|
16 | 17 | class Unknown |
17 | 18 |
|
18 | | - |
19 | 19 | @RunWith(AndroidJUnit4::class) |
20 | 20 | class MapConverterTest { |
21 | | - |
22 | 21 | @Before |
23 | 22 | fun setUp() { |
24 | 23 | val context: Context = InstrumentationRegistry.getInstrumentation().targetContext |
@@ -103,95 +102,95 @@ class MapConverterTest { |
103 | 102 | @Test |
104 | 103 | fun convertsMapWithUnknownValueKey() { |
105 | 104 | val actualMap = RNSentryMapConverter.convertToWritable(mapOf("unknown" to Unknown())) |
106 | | - val expectedMap = Arguments.createMap(); |
| 105 | + val expectedMap = Arguments.createMap() |
107 | 106 | expectedMap.putNull("unknown") |
108 | 107 | assertEquals(expectedMap, actualMap) |
109 | 108 | } |
110 | 109 |
|
111 | 110 | @Test |
112 | 111 | fun convertsMapWithNullKey() { |
113 | 112 | val actualMap = RNSentryMapConverter.convertToWritable(mapOf("null" to null)) |
114 | | - val expectedMap = Arguments.createMap(); |
| 113 | + val expectedMap = Arguments.createMap() |
115 | 114 | expectedMap.putNull("null") |
116 | 115 | assertEquals(expectedMap, actualMap) |
117 | 116 | } |
118 | 117 |
|
119 | 118 | @Test |
120 | 119 | fun convertsMapWithBooleanKey() { |
121 | 120 | val actualMap = RNSentryMapConverter.convertToWritable(mapOf("boolean" to true)) |
122 | | - val expectedMap = Arguments.createMap(); |
| 121 | + val expectedMap = Arguments.createMap() |
123 | 122 | expectedMap.putBoolean("boolean", true) |
124 | 123 | assertEquals(expectedMap, actualMap) |
125 | 124 | } |
126 | 125 |
|
127 | 126 | @Test |
128 | 127 | fun convertsMapWithDoubleKey() { |
129 | 128 | val actualMap = RNSentryMapConverter.convertToWritable(mapOf("double" to Double.MAX_VALUE)) |
130 | | - val expectedMap = Arguments.createMap(); |
| 129 | + val expectedMap = Arguments.createMap() |
131 | 130 | expectedMap.putDouble("double", Double.MAX_VALUE) |
132 | 131 | assertEquals(expectedMap, actualMap) |
133 | 132 | } |
134 | 133 |
|
135 | 134 | @Test |
136 | 135 | fun convertsMapWithIntegerKey() { |
137 | 136 | val actualMap = RNSentryMapConverter.convertToWritable(mapOf("integer" to Integer.MAX_VALUE)) |
138 | | - val expectedMap = Arguments.createMap(); |
| 137 | + val expectedMap = Arguments.createMap() |
139 | 138 | expectedMap.putInt("integer", Integer.MAX_VALUE) |
140 | 139 | assertEquals(expectedMap, actualMap) |
141 | 140 | } |
142 | 141 |
|
143 | 142 | @Test |
144 | 143 | fun convertsMapWithByteKey() { |
145 | 144 | val actualMap = RNSentryMapConverter.convertToWritable(mapOf("byte" to Byte.MAX_VALUE)) |
146 | | - val expectedMap = Arguments.createMap(); |
| 145 | + val expectedMap = Arguments.createMap() |
147 | 146 | expectedMap.putInt("byte", Byte.MAX_VALUE.toInt()) |
148 | 147 | assertEquals(expectedMap, actualMap) |
149 | 148 | } |
150 | 149 |
|
151 | 150 | @Test |
152 | 151 | fun convertsMapWithShortKey() { |
153 | 152 | val actualMap = RNSentryMapConverter.convertToWritable(mapOf("short" to Short.MAX_VALUE)) |
154 | | - val expectedMap = Arguments.createMap(); |
| 153 | + val expectedMap = Arguments.createMap() |
155 | 154 | expectedMap.putInt("short", Short.MAX_VALUE.toInt()) |
156 | 155 | assertEquals(expectedMap, actualMap) |
157 | 156 | } |
158 | 157 |
|
159 | 158 | @Test |
160 | 159 | fun convertsMapWithFloatKey() { |
161 | 160 | val actualMap = RNSentryMapConverter.convertToWritable(mapOf("float" to Float.MAX_VALUE)) |
162 | | - val expectedMap = Arguments.createMap(); |
| 161 | + val expectedMap = Arguments.createMap() |
163 | 162 | expectedMap.putDouble("float", Float.MAX_VALUE.toDouble()) |
164 | 163 | assertEquals(expectedMap, actualMap) |
165 | 164 | } |
166 | 165 |
|
167 | 166 | @Test |
168 | 167 | fun convertsMapWithLongKey() { |
169 | 168 | val actualMap = RNSentryMapConverter.convertToWritable(mapOf("long" to Long.MAX_VALUE)) |
170 | | - val expectedMap = Arguments.createMap(); |
| 169 | + val expectedMap = Arguments.createMap() |
171 | 170 | expectedMap.putDouble("long", Long.MAX_VALUE.toDouble()) |
172 | 171 | assertEquals(expectedMap, actualMap) |
173 | 172 | } |
174 | 173 |
|
175 | 174 | @Test |
176 | 175 | fun convertsMapWithInBigDecimalKey() { |
177 | 176 | val actualMap = RNSentryMapConverter.convertToWritable(mapOf("big_decimal" to BigDecimal.TEN)) |
178 | | - val expectedMap = Arguments.createMap(); |
| 177 | + val expectedMap = Arguments.createMap() |
179 | 178 | expectedMap.putDouble("big_decimal", BigDecimal.TEN.toDouble()) |
180 | 179 | assertEquals(expectedMap, actualMap) |
181 | 180 | } |
182 | 181 |
|
183 | 182 | @Test |
184 | 183 | fun convertsMapWithBigIntKey() { |
185 | 184 | val actualMap = RNSentryMapConverter.convertToWritable(mapOf("big_int" to BigInteger.TEN)) |
186 | | - val expectedMap = Arguments.createMap(); |
| 185 | + val expectedMap = Arguments.createMap() |
187 | 186 | expectedMap.putDouble("big_int", BigInteger.TEN.toDouble()) |
188 | 187 | assertEquals(expectedMap, actualMap) |
189 | 188 | } |
190 | 189 |
|
191 | 190 | @Test |
192 | 191 | fun convertsMapWithStringKey() { |
193 | 192 | val actualMap = RNSentryMapConverter.convertToWritable(mapOf("string" to "string")) |
194 | | - val expectedMap = Arguments.createMap(); |
| 193 | + val expectedMap = Arguments.createMap() |
195 | 194 | expectedMap.putString("string", "string") |
196 | 195 | assertEquals(expectedMap, actualMap) |
197 | 196 | } |
@@ -304,26 +303,32 @@ class MapConverterTest { |
304 | 303 |
|
305 | 304 | @Test |
306 | 305 | fun convertsComplexMapCorrectly() { |
307 | | - val actual = RNSentryMapConverter.convertToWritable(mapOf( |
308 | | - "integer" to Integer.MAX_VALUE, |
309 | | - "string" to "string1", |
310 | | - "map" to mapOf( |
311 | | - "integer" to Integer.MAX_VALUE, |
312 | | - "string" to "string2", |
313 | | - "map" to mapOf( |
314 | | - "integer" to Integer.MAX_VALUE, |
315 | | - "string" to "string3" |
316 | | - ) |
317 | | - ), |
318 | | - "list" to listOf( |
319 | | - Integer.MAX_VALUE, |
| 306 | + val actual = |
| 307 | + RNSentryMapConverter.convertToWritable( |
320 | 308 | mapOf( |
321 | 309 | "integer" to Integer.MAX_VALUE, |
322 | | - "string" to "string4", |
| 310 | + "string" to "string1", |
| 311 | + "map" to |
| 312 | + mapOf( |
| 313 | + "integer" to Integer.MAX_VALUE, |
| 314 | + "string" to "string2", |
| 315 | + "map" to |
| 316 | + mapOf( |
| 317 | + "integer" to Integer.MAX_VALUE, |
| 318 | + "string" to "string3", |
| 319 | + ), |
| 320 | + ), |
| 321 | + "list" to |
| 322 | + listOf( |
| 323 | + Integer.MAX_VALUE, |
| 324 | + mapOf( |
| 325 | + "integer" to Integer.MAX_VALUE, |
| 326 | + "string" to "string4", |
| 327 | + ), |
| 328 | + "string5", |
| 329 | + ), |
323 | 330 | ), |
324 | | - "string5", |
325 | | - ), |
326 | | - )) |
| 331 | + ) |
327 | 332 |
|
328 | 333 | val expectedMap1 = Arguments.createMap() |
329 | 334 | val expectedMap2 = Arguments.createMap() |
|
0 commit comments