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

package com.azure.resourcemanager.resourcehealth.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.resourcehealth.fluent.models.AvailabilityStatusInner;
import com.azure.resourcemanager.resourcehealth.models.AvailabilityStateValues;
import com.azure.resourcemanager.resourcehealth.models.AvailabilityStatusListResult;
import com.azure.resourcemanager.resourcehealth.models.AvailabilityStatusProperties;
import com.azure.resourcemanager.resourcehealth.models.ReasonChronicityTypes;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class AvailabilityStatusListResultTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        AvailabilityStatusListResult model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"id\":\"hq\",\"name\":\"gjxpybczmehmt\",\"type\":\"pbsphrupidgs\",\"location\":\"bejhphoycmsxa\",\"properties\":{\"availabilityState\":\"Degraded\",\"title\":\"bmtqioq\",\"summary\":\"ehtbm\",\"detailedStatus\":\"p\",\"reasonType\":\"noi\",\"context\":\"wlrxyb\",\"category\":\"oqijgkdmbpaz\",\"articleId\":\"bc\",\"rootCauseAttributionTime\":\"2021-08-16T12:22:59Z\",\"healthEventType\":\"znrb\",\"healthEventCause\":\"qqjnqgl\",\"healthEventCategory\":\"gnufoooj\",\"healthEventId\":\"ifsqesaagdfmg\",\"resolutionETA\":\"2021-05-15T08:16:53Z\",\"occuredTime\":\"2021-07-04T01:57:27Z\",\"reasonChronicity\":\"Transient\",\"reportedTime\":\"2021-05-21T02:09:04Z\",\"recommendedActions\":[],\"serviceImpactingEvents\":[]}},{\"id\":\"vktsizntocipao\",\"name\":\"jpsq\",\"type\":\"mpoyfd\",\"location\":\"ogknygjofjdd\",\"properties\":{\"availabilityState\":\"Available\",\"title\":\"eupewnwreitjz\",\"summary\":\"lusarh\",\"detailedStatus\":\"fcqhsmyurkd\",\"reasonType\":\"lx\",\"context\":\"kuksjtxukcdm\",\"category\":\"rcryuanzwuxzdxta\",\"articleId\":\"lhmwhfpmrqobm\",\"rootCauseAttributionTime\":\"2021-05-19T00:26:38Z\",\"healthEventType\":\"nryrtihf\",\"healthEventCause\":\"ijbpzvgnwzsymgl\",\"healthEventCategory\":\"fcyzkohdbihanufh\",\"healthEventId\":\"bj\",\"resolutionETA\":\"2021-10-05T18:31:22Z\",\"occuredTime\":\"2021-11-25T18:32:18Z\",\"reasonChronicity\":\"Transient\",\"reportedTime\":\"2021-03-22T18:05:05Z\",\"recommendedActions\":[],\"serviceImpactingEvents\":[]}},{\"id\":\"fpikxwczb\",\"name\":\"cnpqxuhivyqniwby\",\"type\":\"k\",\"location\":\"dumjgrtfwvuk\",\"properties\":{\"availabilityState\":\"Degraded\",\"title\":\"ccsnhsjc\",\"summary\":\"ejhkry\",\"detailedStatus\":\"napczwlokjy\",\"reasonType\":\"kkvnipjox\",\"context\":\"nchgej\",\"category\":\"odmailzyd\",\"articleId\":\"o\",\"rootCauseAttributionTime\":\"2021-05-10T11:45:10Z\",\"healthEventType\":\"huxinpmqnj\",\"healthEventCause\":\"wixjsprozvcp\",\"healthEventCategory\":\"eg\",\"healthEventId\":\"wmfdatscmdvpjhul\",\"resolutionETA\":\"2021-11-19T18:36:28Z\",\"occuredTime\":\"2021-05-03T23:04:21Z\",\"reasonChronicity\":\"Persistent\",\"reportedTime\":\"2021-09-20T02:03:10Z\",\"recommendedActions\":[],\"serviceImpactingEvents\":[]}}],\"nextLink\":\"ndiodjpslwejdpv\"}")
                .toObject(AvailabilityStatusListResult.class);
        Assertions.assertEquals("hq", model.value().get(0).id());
        Assertions.assertEquals("gjxpybczmehmt", model.value().get(0).name());
        Assertions.assertEquals("pbsphrupidgs", model.value().get(0).type());
        Assertions.assertEquals("bejhphoycmsxa", model.value().get(0).location());
        Assertions
            .assertEquals(AvailabilityStateValues.DEGRADED, model.value().get(0).properties().availabilityState());
        Assertions.assertEquals("bmtqioq", model.value().get(0).properties().title());
        Assertions.assertEquals("ehtbm", model.value().get(0).properties().summary());
        Assertions.assertEquals("p", model.value().get(0).properties().detailedStatus());
        Assertions.assertEquals("noi", model.value().get(0).properties().reasonType());
        Assertions.assertEquals("wlrxyb", model.value().get(0).properties().context());
        Assertions.assertEquals("oqijgkdmbpaz", model.value().get(0).properties().category());
        Assertions.assertEquals("bc", model.value().get(0).properties().articleId());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-08-16T12:22:59Z"),
                model.value().get(0).properties().rootCauseAttributionTime());
        Assertions.assertEquals("znrb", model.value().get(0).properties().healthEventType());
        Assertions.assertEquals("qqjnqgl", model.value().get(0).properties().healthEventCause());
        Assertions.assertEquals("gnufoooj", model.value().get(0).properties().healthEventCategory());
        Assertions.assertEquals("ifsqesaagdfmg", model.value().get(0).properties().healthEventId());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-05-15T08:16:53Z"), model.value().get(0).properties().resolutionEta());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-07-04T01:57:27Z"), model.value().get(0).properties().occuredTime());
        Assertions.assertEquals(ReasonChronicityTypes.TRANSIENT, model.value().get(0).properties().reasonChronicity());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-05-21T02:09:04Z"), model.value().get(0).properties().reportedTime());
        Assertions.assertEquals("ndiodjpslwejdpv", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        AvailabilityStatusListResult model =
            new AvailabilityStatusListResult()
                .withValue(
                    Arrays
                        .asList(
                            new AvailabilityStatusInner()
                                .withId("hq")
                                .withName("gjxpybczmehmt")
                                .withType("pbsphrupidgs")
                                .withLocation("bejhphoycmsxa")
                                .withProperties(
                                    new AvailabilityStatusProperties()
                                        .withAvailabilityState(AvailabilityStateValues.DEGRADED)
                                        .withTitle("bmtqioq")
                                        .withSummary("ehtbm")
                                        .withDetailedStatus("p")
                                        .withReasonType("noi")
                                        .withContext("wlrxyb")
                                        .withCategory("oqijgkdmbpaz")
                                        .withArticleId("bc")
                                        .withRootCauseAttributionTime(OffsetDateTime.parse("2021-08-16T12:22:59Z"))
                                        .withHealthEventType("znrb")
                                        .withHealthEventCause("qqjnqgl")
                                        .withHealthEventCategory("gnufoooj")
                                        .withHealthEventId("ifsqesaagdfmg")
                                        .withResolutionEta(OffsetDateTime.parse("2021-05-15T08:16:53Z"))
                                        .withOccuredTime(OffsetDateTime.parse("2021-07-04T01:57:27Z"))
                                        .withReasonChronicity(ReasonChronicityTypes.TRANSIENT)
                                        .withReportedTime(OffsetDateTime.parse("2021-05-21T02:09:04Z"))
                                        .withRecommendedActions(Arrays.asList())
                                        .withServiceImpactingEvents(Arrays.asList())),
                            new AvailabilityStatusInner()
                                .withId("vktsizntocipao")
                                .withName("jpsq")
                                .withType("mpoyfd")
                                .withLocation("ogknygjofjdd")
                                .withProperties(
                                    new AvailabilityStatusProperties()
                                        .withAvailabilityState(AvailabilityStateValues.AVAILABLE)
                                        .withTitle("eupewnwreitjz")
                                        .withSummary("lusarh")
                                        .withDetailedStatus("fcqhsmyurkd")
                                        .withReasonType("lx")
                                        .withContext("kuksjtxukcdm")
                                        .withCategory("rcryuanzwuxzdxta")
                                        .withArticleId("lhmwhfpmrqobm")
                                        .withRootCauseAttributionTime(OffsetDateTime.parse("2021-05-19T00:26:38Z"))
                                        .withHealthEventType("nryrtihf")
                                        .withHealthEventCause("ijbpzvgnwzsymgl")
                                        .withHealthEventCategory("fcyzkohdbihanufh")
                                        .withHealthEventId("bj")
                                        .withResolutionEta(OffsetDateTime.parse("2021-10-05T18:31:22Z"))
                                        .withOccuredTime(OffsetDateTime.parse("2021-11-25T18:32:18Z"))
                                        .withReasonChronicity(ReasonChronicityTypes.TRANSIENT)
                                        .withReportedTime(OffsetDateTime.parse("2021-03-22T18:05:05Z"))
                                        .withRecommendedActions(Arrays.asList())
                                        .withServiceImpactingEvents(Arrays.asList())),
                            new AvailabilityStatusInner()
                                .withId("fpikxwczb")
                                .withName("cnpqxuhivyqniwby")
                                .withType("k")
                                .withLocation("dumjgrtfwvuk")
                                .withProperties(
                                    new AvailabilityStatusProperties()
                                        .withAvailabilityState(AvailabilityStateValues.DEGRADED)
                                        .withTitle("ccsnhsjc")
                                        .withSummary("ejhkry")
                                        .withDetailedStatus("napczwlokjy")
                                        .withReasonType("kkvnipjox")
                                        .withContext("nchgej")
                                        .withCategory("odmailzyd")
                                        .withArticleId("o")
                                        .withRootCauseAttributionTime(OffsetDateTime.parse("2021-05-10T11:45:10Z"))
                                        .withHealthEventType("huxinpmqnj")
                                        .withHealthEventCause("wixjsprozvcp")
                                        .withHealthEventCategory("eg")
                                        .withHealthEventId("wmfdatscmdvpjhul")
                                        .withResolutionEta(OffsetDateTime.parse("2021-11-19T18:36:28Z"))
                                        .withOccuredTime(OffsetDateTime.parse("2021-05-03T23:04:21Z"))
                                        .withReasonChronicity(ReasonChronicityTypes.PERSISTENT)
                                        .withReportedTime(OffsetDateTime.parse("2021-09-20T02:03:10Z"))
                                        .withRecommendedActions(Arrays.asList())
                                        .withServiceImpactingEvents(Arrays.asList()))))
                .withNextLink("ndiodjpslwejdpv");
        model = BinaryData.fromObject(model).toObject(AvailabilityStatusListResult.class);
        Assertions.assertEquals("hq", model.value().get(0).id());
        Assertions.assertEquals("gjxpybczmehmt", model.value().get(0).name());
        Assertions.assertEquals("pbsphrupidgs", model.value().get(0).type());
        Assertions.assertEquals("bejhphoycmsxa", model.value().get(0).location());
        Assertions
            .assertEquals(AvailabilityStateValues.DEGRADED, model.value().get(0).properties().availabilityState());
        Assertions.assertEquals("bmtqioq", model.value().get(0).properties().title());
        Assertions.assertEquals("ehtbm", model.value().get(0).properties().summary());
        Assertions.assertEquals("p", model.value().get(0).properties().detailedStatus());
        Assertions.assertEquals("noi", model.value().get(0).properties().reasonType());
        Assertions.assertEquals("wlrxyb", model.value().get(0).properties().context());
        Assertions.assertEquals("oqijgkdmbpaz", model.value().get(0).properties().category());
        Assertions.assertEquals("bc", model.value().get(0).properties().articleId());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-08-16T12:22:59Z"),
                model.value().get(0).properties().rootCauseAttributionTime());
        Assertions.assertEquals("znrb", model.value().get(0).properties().healthEventType());
        Assertions.assertEquals("qqjnqgl", model.value().get(0).properties().healthEventCause());
        Assertions.assertEquals("gnufoooj", model.value().get(0).properties().healthEventCategory());
        Assertions.assertEquals("ifsqesaagdfmg", model.value().get(0).properties().healthEventId());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-05-15T08:16:53Z"), model.value().get(0).properties().resolutionEta());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-07-04T01:57:27Z"), model.value().get(0).properties().occuredTime());
        Assertions.assertEquals(ReasonChronicityTypes.TRANSIENT, model.value().get(0).properties().reasonChronicity());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-05-21T02:09:04Z"), model.value().get(0).properties().reportedTime());
        Assertions.assertEquals("ndiodjpslwejdpv", model.nextLink());
    }
}
