// 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.EventInner;
import com.azure.resourcemanager.resourcehealth.models.EventLevelValues;
import com.azure.resourcemanager.resourcehealth.models.EventSourceValues;
import com.azure.resourcemanager.resourcehealth.models.EventStatusValues;
import com.azure.resourcemanager.resourcehealth.models.EventTypeValues;
import com.azure.resourcemanager.resourcehealth.models.Events;
import com.azure.resourcemanager.resourcehealth.models.LevelValues;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class EventsTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        Events model =
            BinaryData
                .fromString(
                    "{\"value\":[{\"properties\":{\"eventType\":\"ServiceIssue\",\"eventSource\":\"ResourceHealth\",\"status\":\"Active\",\"title\":\"otwmcyn\",\"summary\":\"lbjnpgacftadehx\",\"header\":\"tyfsoppusuesn\",\"level\":\"Critical\",\"eventLevel\":\"Warning\",\"externalIncidentId\":\"avo\",\"reason\":\"zdmohctbqvu\",\"links\":[],\"impactStartTime\":\"2021-10-27T15:38:07Z\",\"impactMitigationTime\":\"2021-10-24T14:50:51Z\",\"impact\":[],\"faqs\":[],\"isHIR\":true,\"enableMicrosoftSupport\":true,\"description\":\"gwdkcglhsl\",\"platformInitiated\":true,\"enableChatWithUs\":true,\"priority\":2006960320,\"lastUpdateTime\":\"2021-08-29T22:22:31Z\",\"hirStage\":\"ixhbkuofqweykhm\",\"duration\":1631259925,\"impactType\":\"yexfwh\"},\"id\":\"cibvyvdcsitynn\",\"name\":\"amdecte\",\"type\":\"f\"},{\"properties\":{\"eventType\":\"EmergingIssues\",\"eventSource\":\"ServiceHealth\",\"status\":\"Active\",\"title\":\"hezrkgq\",\"summary\":\"jrefovgmkqsle\",\"header\":\"vxyqjpkcattpngjc\",\"level\":\"Warning\",\"eventLevel\":\"Warning\",\"externalIncidentId\":\"pjhvmdajvnys\",\"reason\":\"nqecanoaeup\",\"links\":[],\"impactStartTime\":\"2021-02-13T21:17:53Z\",\"impactMitigationTime\":\"2021-06-23T07:18:27Z\",\"impact\":[],\"faqs\":[],\"isHIR\":true,\"enableMicrosoftSupport\":false,\"description\":\"atuokthfuiu\",\"platformInitiated\":true,\"enableChatWithUs\":false,\"priority\":397485144,\"lastUpdateTime\":\"2021-06-22T02:08:06Z\",\"hirStage\":\"odpuozmyzydag\",\"duration\":1113167460,\"impactType\":\"ezyiuokktwhrdxw\"},\"id\":\"wqsmbsur\",\"name\":\"xim\",\"type\":\"ryocfsfksymdd\"},{\"properties\":{\"eventType\":\"SecurityAdvisory\",\"eventSource\":\"ServiceHealth\",\"status\":\"Resolved\",\"title\":\"qyud\",\"summary\":\"rrqnbpoczvyifqrv\",\"header\":\"vjsllrmvvdfw\",\"level\":\"Warning\",\"eventLevel\":\"Critical\",\"externalIncidentId\":\"ulexxbczwtr\",\"reason\":\"iqzbq\",\"links\":[],\"impactStartTime\":\"2021-11-22T16:46:16Z\",\"impactMitigationTime\":\"2021-03-01T06:44:22Z\",\"impact\":[],\"faqs\":[],\"isHIR\":true,\"enableMicrosoftSupport\":false,\"description\":\"lhzdobp\",\"platformInitiated\":false,\"enableChatWithUs\":false,\"priority\":206207279,\"lastUpdateTime\":\"2021-10-31T23:11:15Z\",\"hirStage\":\"hrk\",\"duration\":1990259381,\"impactType\":\"zjuqkhrsaj\"},\"id\":\"ku\",\"name\":\"foskghsauuimj\",\"type\":\"vxieduugidyj\"}],\"nextLink\":\"f\"}")
                .toObject(Events.class);
        Assertions.assertEquals(EventTypeValues.SERVICE_ISSUE, model.value().get(0).eventType());
        Assertions.assertEquals(EventSourceValues.RESOURCE_HEALTH, model.value().get(0).eventSource());
        Assertions.assertEquals(EventStatusValues.ACTIVE, model.value().get(0).status());
        Assertions.assertEquals("otwmcyn", model.value().get(0).title());
        Assertions.assertEquals("lbjnpgacftadehx", model.value().get(0).summary());
        Assertions.assertEquals("tyfsoppusuesn", model.value().get(0).headerProperty());
        Assertions.assertEquals(LevelValues.CRITICAL, model.value().get(0).level());
        Assertions.assertEquals(EventLevelValues.WARNING, model.value().get(0).eventLevel());
        Assertions.assertEquals("avo", model.value().get(0).externalIncidentId());
        Assertions.assertEquals("zdmohctbqvu", model.value().get(0).reason());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-27T15:38:07Z"), model.value().get(0).impactStartTime());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-10-24T14:50:51Z"), model.value().get(0).impactMitigationTime());
        Assertions.assertEquals(true, model.value().get(0).isHir());
        Assertions.assertEquals(true, model.value().get(0).enableMicrosoftSupport());
        Assertions.assertEquals("gwdkcglhsl", model.value().get(0).description());
        Assertions.assertEquals(true, model.value().get(0).platformInitiated());
        Assertions.assertEquals(true, model.value().get(0).enableChatWithUs());
        Assertions.assertEquals(2006960320, model.value().get(0).priority());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-29T22:22:31Z"), model.value().get(0).lastUpdateTime());
        Assertions.assertEquals("ixhbkuofqweykhm", model.value().get(0).hirStage());
        Assertions.assertEquals(1631259925, model.value().get(0).duration());
        Assertions.assertEquals("yexfwh", model.value().get(0).impactType());
        Assertions.assertEquals("f", model.nextLink());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        Events model =
            new Events()
                .withValue(
                    Arrays
                        .asList(
                            new EventInner()
                                .withEventType(EventTypeValues.SERVICE_ISSUE)
                                .withEventSource(EventSourceValues.RESOURCE_HEALTH)
                                .withStatus(EventStatusValues.ACTIVE)
                                .withTitle("otwmcyn")
                                .withSummary("lbjnpgacftadehx")
                                .withHeaderProperty("tyfsoppusuesn")
                                .withLevel(LevelValues.CRITICAL)
                                .withEventLevel(EventLevelValues.WARNING)
                                .withExternalIncidentId("avo")
                                .withReason("zdmohctbqvu")
                                .withLinks(Arrays.asList())
                                .withImpactStartTime(OffsetDateTime.parse("2021-10-27T15:38:07Z"))
                                .withImpactMitigationTime(OffsetDateTime.parse("2021-10-24T14:50:51Z"))
                                .withImpact(Arrays.asList())
                                .withFaqs(Arrays.asList())
                                .withIsHir(true)
                                .withEnableMicrosoftSupport(true)
                                .withDescription("gwdkcglhsl")
                                .withPlatformInitiated(true)
                                .withEnableChatWithUs(true)
                                .withPriority(2006960320)
                                .withLastUpdateTime(OffsetDateTime.parse("2021-08-29T22:22:31Z"))
                                .withHirStage("ixhbkuofqweykhm")
                                .withDuration(1631259925)
                                .withImpactType("yexfwh"),
                            new EventInner()
                                .withEventType(EventTypeValues.EMERGING_ISSUES)
                                .withEventSource(EventSourceValues.SERVICE_HEALTH)
                                .withStatus(EventStatusValues.ACTIVE)
                                .withTitle("hezrkgq")
                                .withSummary("jrefovgmkqsle")
                                .withHeaderProperty("vxyqjpkcattpngjc")
                                .withLevel(LevelValues.WARNING)
                                .withEventLevel(EventLevelValues.WARNING)
                                .withExternalIncidentId("pjhvmdajvnys")
                                .withReason("nqecanoaeup")
                                .withLinks(Arrays.asList())
                                .withImpactStartTime(OffsetDateTime.parse("2021-02-13T21:17:53Z"))
                                .withImpactMitigationTime(OffsetDateTime.parse("2021-06-23T07:18:27Z"))
                                .withImpact(Arrays.asList())
                                .withFaqs(Arrays.asList())
                                .withIsHir(true)
                                .withEnableMicrosoftSupport(false)
                                .withDescription("atuokthfuiu")
                                .withPlatformInitiated(true)
                                .withEnableChatWithUs(false)
                                .withPriority(397485144)
                                .withLastUpdateTime(OffsetDateTime.parse("2021-06-22T02:08:06Z"))
                                .withHirStage("odpuozmyzydag")
                                .withDuration(1113167460)
                                .withImpactType("ezyiuokktwhrdxw"),
                            new EventInner()
                                .withEventType(EventTypeValues.SECURITY_ADVISORY)
                                .withEventSource(EventSourceValues.SERVICE_HEALTH)
                                .withStatus(EventStatusValues.RESOLVED)
                                .withTitle("qyud")
                                .withSummary("rrqnbpoczvyifqrv")
                                .withHeaderProperty("vjsllrmvvdfw")
                                .withLevel(LevelValues.WARNING)
                                .withEventLevel(EventLevelValues.CRITICAL)
                                .withExternalIncidentId("ulexxbczwtr")
                                .withReason("iqzbq")
                                .withLinks(Arrays.asList())
                                .withImpactStartTime(OffsetDateTime.parse("2021-11-22T16:46:16Z"))
                                .withImpactMitigationTime(OffsetDateTime.parse("2021-03-01T06:44:22Z"))
                                .withImpact(Arrays.asList())
                                .withFaqs(Arrays.asList())
                                .withIsHir(true)
                                .withEnableMicrosoftSupport(false)
                                .withDescription("lhzdobp")
                                .withPlatformInitiated(false)
                                .withEnableChatWithUs(false)
                                .withPriority(206207279)
                                .withLastUpdateTime(OffsetDateTime.parse("2021-10-31T23:11:15Z"))
                                .withHirStage("hrk")
                                .withDuration(1990259381)
                                .withImpactType("zjuqkhrsaj")))
                .withNextLink("f");
        model = BinaryData.fromObject(model).toObject(Events.class);
        Assertions.assertEquals(EventTypeValues.SERVICE_ISSUE, model.value().get(0).eventType());
        Assertions.assertEquals(EventSourceValues.RESOURCE_HEALTH, model.value().get(0).eventSource());
        Assertions.assertEquals(EventStatusValues.ACTIVE, model.value().get(0).status());
        Assertions.assertEquals("otwmcyn", model.value().get(0).title());
        Assertions.assertEquals("lbjnpgacftadehx", model.value().get(0).summary());
        Assertions.assertEquals("tyfsoppusuesn", model.value().get(0).headerProperty());
        Assertions.assertEquals(LevelValues.CRITICAL, model.value().get(0).level());
        Assertions.assertEquals(EventLevelValues.WARNING, model.value().get(0).eventLevel());
        Assertions.assertEquals("avo", model.value().get(0).externalIncidentId());
        Assertions.assertEquals("zdmohctbqvu", model.value().get(0).reason());
        Assertions.assertEquals(OffsetDateTime.parse("2021-10-27T15:38:07Z"), model.value().get(0).impactStartTime());
        Assertions
            .assertEquals(OffsetDateTime.parse("2021-10-24T14:50:51Z"), model.value().get(0).impactMitigationTime());
        Assertions.assertEquals(true, model.value().get(0).isHir());
        Assertions.assertEquals(true, model.value().get(0).enableMicrosoftSupport());
        Assertions.assertEquals("gwdkcglhsl", model.value().get(0).description());
        Assertions.assertEquals(true, model.value().get(0).platformInitiated());
        Assertions.assertEquals(true, model.value().get(0).enableChatWithUs());
        Assertions.assertEquals(2006960320, model.value().get(0).priority());
        Assertions.assertEquals(OffsetDateTime.parse("2021-08-29T22:22:31Z"), model.value().get(0).lastUpdateTime());
        Assertions.assertEquals("ixhbkuofqweykhm", model.value().get(0).hirStage());
        Assertions.assertEquals(1631259925, model.value().get(0).duration());
        Assertions.assertEquals("yexfwh", model.value().get(0).impactType());
        Assertions.assertEquals("f", model.nextLink());
    }
}
