|
| 1 | +package com.microsoft.graph.serializer; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 4 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 5 | +import static org.mockito.Mockito.mock; |
| 6 | + |
| 7 | +import com.microsoft.graph.logger.ILogger; |
| 8 | + |
| 9 | +import org.junit.jupiter.api.Test; |
| 10 | + |
| 11 | +class CollectionResponseOfPrimitivesTests { |
| 12 | + @Test |
| 13 | + void DeserializesCollectionOfStrings() { |
| 14 | + final var serializer = new DefaultSerializer(mock(ILogger.class)); |
| 15 | + final var serializedValue = "{\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#Collection(Edm.String)\",\"value\": [\"b72e90c8-3d3a-457e-8ca0-0fdde204d320\"]}"; |
| 16 | + final var result = serializer.deserializeObject(serializedValue, CollectionResponseOfString.class); |
| 17 | + assertNotNull(result); |
| 18 | + assertNotNull(result.value); |
| 19 | + assertNotNull(result.additionalDataManager()); |
| 20 | + assertEquals("https://graph.microsoft.com/v1.0/$metadata#Collection(Edm.String)", result.additionalDataManager().get("@odata.context").getAsString()); |
| 21 | + assertEquals(1, result.value.size()); |
| 22 | + } |
| 23 | + @Test |
| 24 | + void DeserializesCollectionOfBooleans() { |
| 25 | + final var serializer = new DefaultSerializer(mock(ILogger.class)); |
| 26 | + final var serializedValue = "{\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#Collection(Edm.Boolean)\",\"value\": [true]}"; |
| 27 | + final var result = serializer.deserializeObject(serializedValue, CollectionResponseOfBoolean.class); |
| 28 | + assertNotNull(result); |
| 29 | + assertNotNull(result.value); |
| 30 | + assertEquals(1, result.value.size()); |
| 31 | + } |
| 32 | + @Test |
| 33 | + void DeserializesCollectionOfLongs() { |
| 34 | + final var serializer = new DefaultSerializer(mock(ILogger.class)); |
| 35 | + final var serializedValue = "{\"@odata.context\": \"https://graph.microsoft.com/v1.0/$metadata#Collection(Edm.Long)\",\"value\": [42]}"; |
| 36 | + final var result = serializer.deserializeObject(serializedValue, CollectionResponseOfLong.class); |
| 37 | + assertNotNull(result); |
| 38 | + assertNotNull(result.value); |
| 39 | + assertEquals(1, result.value.size()); |
| 40 | + } |
| 41 | +} |
0 commit comments