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

package com.azure.resourcemanager.kubernetesconfiguration.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.kubernetesconfiguration.models.FluxComplianceState;
import com.azure.resourcemanager.kubernetesconfiguration.models.HelmReleasePropertiesDefinition;
import com.azure.resourcemanager.kubernetesconfiguration.models.ObjectReferenceDefinition;
import com.azure.resourcemanager.kubernetesconfiguration.models.ObjectStatusConditionDefinition;
import com.azure.resourcemanager.kubernetesconfiguration.models.ObjectStatusDefinition;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ObjectStatusDefinitionTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ObjectStatusDefinition model =
            BinaryData
                .fromString(
                    "{\"name\":\"byxqabn\",\"namespace\":\"cpc\",\"kind\":\"hurzafblj\",\"complianceState\":\"Pending\",\"appliedBy\":{\"name\":\"oq\",\"namespace\":\"mkljavb\"},\"statusConditions\":[{\"lastTransitionTime\":\"2021-05-13T19:23:23Z\",\"message\":\"jzyulpk\",\"reason\":\"jkrlkhbzhfepg\",\"status\":\"qex\",\"type\":\"ocxscpaierhhbcs\"},{\"lastTransitionTime\":\"2021-06-03T06:29:13Z\",\"message\":\"majtjaod\",\"reason\":\"bnbdxkqpxokajion\",\"status\":\"mexgstxgcp\",\"type\":\"gmaajrm\"},{\"lastTransitionTime\":\"2021-03-11T04:53:43Z\",\"message\":\"zrlovmclwhijcoej\",\"reason\":\"bzaqsqsycbkbfk\",\"status\":\"kdkexxp\",\"type\":\"fmxa\"},{\"lastTransitionTime\":\"2021-06-05T20:06:24Z\",\"message\":\"pg\",\"reason\":\"toc\",\"status\":\"xhvpmoue\",\"type\":\"dzxibqeojnxqbzvd\"}],\"helmReleaseProperties\":{\"lastRevisionApplied\":2783260712694826920,\"helmChartRef\":{\"name\":\"icbtwnpzao\",\"namespace\":\"uhrhcffcyddgl\"},\"failureCount\":52347448504645703,\"installFailureCount\":4471545183112008716,\"upgradeFailureCount\":6943639735240918018}}")
                .toObject(ObjectStatusDefinition.class);
        Assertions.assertEquals("byxqabn", model.name());
        Assertions.assertEquals("cpc", model.namespace());
        Assertions.assertEquals("hurzafblj", model.kind());
        Assertions.assertEquals(FluxComplianceState.PENDING, model.complianceState());
        Assertions.assertEquals("oq", model.appliedBy().name());
        Assertions.assertEquals("mkljavb", model.appliedBy().namespace());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-05-13T19:23:23Z"), model.statusConditions().get(0).lastTransitionTime());
        Assertions.assertEquals("jzyulpk", model.statusConditions().get(0).message());
        Assertions.assertEquals("jkrlkhbzhfepg", model.statusConditions().get(0).reason());
        Assertions.assertEquals("qex", model.statusConditions().get(0).status());
        Assertions.assertEquals("ocxscpaierhhbcs", model.statusConditions().get(0).type());
        Assertions.assertEquals(2783260712694826920L, model.helmReleaseProperties().lastRevisionApplied());
        Assertions.assertEquals("icbtwnpzao", model.helmReleaseProperties().helmChartRef().name());
        Assertions.assertEquals("uhrhcffcyddgl", model.helmReleaseProperties().helmChartRef().namespace());
        Assertions.assertEquals(52347448504645703L, model.helmReleaseProperties().failureCount());
        Assertions.assertEquals(4471545183112008716L, model.helmReleaseProperties().installFailureCount());
        Assertions.assertEquals(6943639735240918018L, model.helmReleaseProperties().upgradeFailureCount());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ObjectStatusDefinition model =
            new ObjectStatusDefinition()
                .withName("byxqabn")
                .withNamespace("cpc")
                .withKind("hurzafblj")
                .withComplianceState(FluxComplianceState.PENDING)
                .withAppliedBy(new ObjectReferenceDefinition().withName("oq").withNamespace("mkljavb"))
                .withStatusConditions(
                    Arrays
                        .asList(
                            new ObjectStatusConditionDefinition()
                                .withLastTransitionTime(OffsetDateTime.parse("2021-05-13T19:23:23Z"))
                                .withMessage("jzyulpk")
                                .withReason("jkrlkhbzhfepg")
                                .withStatus("qex")
                                .withType("ocxscpaierhhbcs"),
                            new ObjectStatusConditionDefinition()
                                .withLastTransitionTime(OffsetDateTime.parse("2021-06-03T06:29:13Z"))
                                .withMessage("majtjaod")
                                .withReason("bnbdxkqpxokajion")
                                .withStatus("mexgstxgcp")
                                .withType("gmaajrm"),
                            new ObjectStatusConditionDefinition()
                                .withLastTransitionTime(OffsetDateTime.parse("2021-03-11T04:53:43Z"))
                                .withMessage("zrlovmclwhijcoej")
                                .withReason("bzaqsqsycbkbfk")
                                .withStatus("kdkexxp")
                                .withType("fmxa"),
                            new ObjectStatusConditionDefinition()
                                .withLastTransitionTime(OffsetDateTime.parse("2021-06-05T20:06:24Z"))
                                .withMessage("pg")
                                .withReason("toc")
                                .withStatus("xhvpmoue")
                                .withType("dzxibqeojnxqbzvd")))
                .withHelmReleaseProperties(
                    new HelmReleasePropertiesDefinition()
                        .withLastRevisionApplied(2783260712694826920L)
                        .withHelmChartRef(
                            new ObjectReferenceDefinition().withName("icbtwnpzao").withNamespace("uhrhcffcyddgl"))
                        .withFailureCount(52347448504645703L)
                        .withInstallFailureCount(4471545183112008716L)
                        .withUpgradeFailureCount(6943639735240918018L));
        model = BinaryData.fromObject(model).toObject(ObjectStatusDefinition.class);
        Assertions.assertEquals("byxqabn", model.name());
        Assertions.assertEquals("cpc", model.namespace());
        Assertions.assertEquals("hurzafblj", model.kind());
        Assertions.assertEquals(FluxComplianceState.PENDING, model.complianceState());
        Assertions.assertEquals("oq", model.appliedBy().name());
        Assertions.assertEquals("mkljavb", model.appliedBy().namespace());
        Assertions
            .assertEquals(
                OffsetDateTime.parse("2021-05-13T19:23:23Z"), model.statusConditions().get(0).lastTransitionTime());
        Assertions.assertEquals("jzyulpk", model.statusConditions().get(0).message());
        Assertions.assertEquals("jkrlkhbzhfepg", model.statusConditions().get(0).reason());
        Assertions.assertEquals("qex", model.statusConditions().get(0).status());
        Assertions.assertEquals("ocxscpaierhhbcs", model.statusConditions().get(0).type());
        Assertions.assertEquals(2783260712694826920L, model.helmReleaseProperties().lastRevisionApplied());
        Assertions.assertEquals("icbtwnpzao", model.helmReleaseProperties().helmChartRef().name());
        Assertions.assertEquals("uhrhcffcyddgl", model.helmReleaseProperties().helmChartRef().namespace());
        Assertions.assertEquals(52347448504645703L, model.helmReleaseProperties().failureCount());
        Assertions.assertEquals(4471545183112008716L, model.helmReleaseProperties().installFailureCount());
        Assertions.assertEquals(6943639735240918018L, model.helmReleaseProperties().upgradeFailureCount());
    }
}
