// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.orbital.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.orbital.fluent.models.ContactInner;
import com.azure.resourcemanager.orbital.models.ContactListResult;
import com.azure.resourcemanager.orbital.models.ContactsPropertiesProvisioningState;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ContactListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ContactListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"provisioningState\":\"deleting\",\"status\":\"scheduled\",\"reservationStartTime\":\"2021-05-23T21:52:10Z\",\"reservationEndTime\":\"2021-04-23T06:59:32Z\",\"rxStartTime\":\"2021-06-09T13:25:48Z\",\"rxEndTime\":\"2021-10-01T17:55:32Z\",\"txStartTime\":\"2021-07-20T07:16:34Z\",\"txEndTime\":\"2021-06-03T01:11:12Z\",\"errorMessage\":\"qpjwnzlljfm\",\"maximumElevationDegrees\":60.49188,\"startAzimuthDegrees\":96.80877,\"endAzimuthDegrees\":35.639126,\"groundStationName\":\"gxsabkyq\",\"startElevationDegrees\":46.562542,\"endElevationDegrees\":48.109997},\"id\":\"jczdzevndh\",\"name\":\"rwpdappdsbdkvwrw\",\"type\":\"feusnhut\"},{\"properties\":{\"provisioningState\":\"updating\",\"status\":\"succeeded\",\"reservationStartTime\":\"2021-04-28T11:05:16Z\",\"reservationEndTime\":\"2021-09-02T13:45:05Z\",\"rxStartTime\":\"2021-02-21T19:30:31Z\",\"rxEndTime\":\"2021-04-29T05:25:28Z\",\"txStartTime\":\"2021-06-14T04:16:37Z\",\"txEndTime\":\"2021-10-02T10:39:21Z\",\"errorMessage\":\"tqxhocdgeab\",\"maximumElevationDegrees\":22.124004,\"startAzimuthDegrees\":91.44667,\"endAzimuthDegrees\":89.55463,\"groundStationName\":\"cndvkaozwyiftyhx\",\"startElevationDegrees\":30.237473,\"endElevationDegrees\":5.188751},\"id\":\"yxolniwp\",\"name\":\"cukjf\",\"type\":\"giawx\"},{\"properties\":{\"provisioningState\":\"canceled\",\"status\":\"providerCancelled\",\"reservationStartTime\":\"2021-02-17T21:17:55Z\",\"reservationEndTime\":\"2021-07-12T14:06:09Z\",\"rxStartTime\":\"2021-10-07T14:36:38Z\",\"rxEndTime\":\"2021-01-09T07:49:41Z\",\"txStartTime\":\"2021-11-03T18:10:18Z\",\"txEndTime\":\"2021-01-04T06:33:38Z\",\"errorMessage\":\"ddhsgcbacphe\",\"maximumElevationDegrees\":8.63505,\"startAzimuthDegrees\":98.08329,\"endAzimuthDegrees\":49.27169,\"groundStationName\":\"gou\",\"startElevationDegrees\":30.246729,\"endElevationDegrees\":74.8389},\"id\":\"wyqkgfgibm\",\"name\":\"dgak\",\"type\":\"qsrxybzqqed\"},{\"properties\":{\"provisioningState\":\"creating\",\"status\":\"cancelled\",\"reservationStartTime\":\"2021-07-02T01:03:40Z\",\"reservationEndTime\":\"2021-07-06T13:26:28Z\",\"rxStartTime\":\"2021-07-23T02:13:33Z\",\"rxEndTime\":\"2021-06-11T15:05:30Z\",\"txStartTime\":\"2021-02-10T20:24:35Z\",\"txEndTime\":\"2021-03-13T18:03:58Z\",\"errorMessage\":\"zsm\",\"maximumElevationDegrees\":56.270576,\"startAzimuthDegrees\":44.037903,\"endAzimuthDegrees\":34.71329,\"groundStationName\":\"gpbkwtmut\",\"startElevationDegrees\":86.815414,\"endElevationDegrees\":6.7403197},\"id\":\"spwgcuertumkdosv\",\"name\":\"whbmd\",\"type\":\"bbjfddgmbmbexp\"}],\"nextLink\":\"htqqrolfp\"}")
                .toObject(ContactListResult.class);
        Assertions.assertEquals(ContactsPropertiesProvisioningState.DELETING, model.value().get(0).provisioningState());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-05-23T21:52:10Z"), model.value().get(0).reservationStartTime());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-04-23T06:59:32Z"), model.value().get(0).reservationEndTime());
        Assertions.assertEquals("gxsabkyq", model.value().get(0).groundStationName());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ContactListResult model =
            new ContactListResult()
                .withValue(
                    Arrays
                        .asList(
                            new ContactInner()
                                .withProvisioningState(ContactsPropertiesProvisioningState.DELETING)
                                .withReservationStartTime(OffsetDateTime.parse("2021-05-23T21:52:10Z"))
                                .withReservationEndTime(OffsetDateTime.parse("2021-04-23T06:59:32Z"))
                                .withGroundStationName("gxsabkyq"),
                            new ContactInner()
                                .withProvisioningState(ContactsPropertiesProvisioningState.UPDATING)
                                .withReservationStartTime(OffsetDateTime.parse("2021-04-28T11:05:16Z"))
                                .withReservationEndTime(OffsetDateTime.parse("2021-09-02T13:45:05Z"))
                                .withGroundStationName("cndvkaozwyiftyhx"),
                            new ContactInner()
                                .withProvisioningState(ContactsPropertiesProvisioningState.CANCELED)
                                .withReservationStartTime(OffsetDateTime.parse("2021-02-17T21:17:55Z"))
                                .withReservationEndTime(OffsetDateTime.parse("2021-07-12T14:06:09Z"))
                                .withGroundStationName("gou"),
                            new ContactInner()
                                .withProvisioningState(ContactsPropertiesProvisioningState.CREATING)
                                .withReservationStartTime(OffsetDateTime.parse("2021-07-02T01:03:40Z"))
                                .withReservationEndTime(OffsetDateTime.parse("2021-07-06T13:26:28Z"))
                                .withGroundStationName("gpbkwtmut")));
        model = BinaryData.fromObject(model).toObject(ContactListResult.class);
        Assertions.assertEquals(ContactsPropertiesProvisioningState.DELETING, model.value().get(0).provisioningState());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-05-23T21:52:10Z"), model.value().get(0).reservationStartTime());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-04-23T06:59:32Z"), model.value().get(0).reservationEndTime());
        Assertions.assertEquals("gxsabkyq", model.value().get(0).groundStationName());
    }
}
