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

package com.azure.resourcemanager.policyinsights.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.policyinsights.models.ComplianceDetail;
import com.azure.resourcemanager.policyinsights.models.PolicyDefinitionSummary;
import com.azure.resourcemanager.policyinsights.models.SummaryResults;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class PolicyDefinitionSummaryTests {
    @Test
    public void testDeserialize() {
        PolicyDefinitionSummary model =
            BinaryData
                .fromString(
                    "{\"policyDefinitionId\":\"nayqi\",\"policyDefinitionReferenceId\":\"nduhavhqlkthum\",\"policyDefinitionGroupNames\":[\"lbg\",\"cdui\",\"r\",\"gccymvaolpssl\"],\"effect\":\"fmmdnbbg\",\"results\":{\"queryResultsUri\":\"swiydmcwyhzdx\",\"nonCompliantResources\":1314424917,\"nonCompliantPolicies\":759374962,\"resourceDetails\":[{\"complianceState\":\"vdfznudaodvxzb\",\"count\":364348069},{\"complianceState\":\"ylpstdbhhxsrzdz\",\"count\":241843348}],\"policyDetails\":[{\"complianceState\":\"dntnevf\",\"count\":2060062752},{\"complianceState\":\"ygtdsslswt\",\"count\":478767297},{\"complianceState\":\"iofz\",\"count\":158092972}],\"policyGroupDetails\":[{\"complianceState\":\"wab\",\"count\":334511461},{\"complianceState\":\"hhszh\",\"count\":1422875618}]}}")
                .toObject(PolicyDefinitionSummary.class);
        Assertions.assertEquals("nayqi", model.policyDefinitionId());
        Assertions.assertEquals("nduhavhqlkthum", model.policyDefinitionReferenceId());
        Assertions.assertEquals("lbg", model.policyDefinitionGroupNames().get(0));
        Assertions.assertEquals("fmmdnbbg", model.effect());
        Assertions.assertEquals("swiydmcwyhzdx", model.results().queryResultsUri());
        Assertions.assertEquals(1314424917, model.results().nonCompliantResources());
        Assertions.assertEquals(759374962, model.results().nonCompliantPolicies());
        Assertions.assertEquals("vdfznudaodvxzb", model.results().resourceDetails().get(0).complianceState());
        Assertions.assertEquals(364348069, model.results().resourceDetails().get(0).count());
        Assertions.assertEquals("dntnevf", model.results().policyDetails().get(0).complianceState());
        Assertions.assertEquals(2060062752, model.results().policyDetails().get(0).count());
        Assertions.assertEquals("wab", model.results().policyGroupDetails().get(0).complianceState());
        Assertions.assertEquals(334511461, model.results().policyGroupDetails().get(0).count());
    }

    @Test
    public void testSerialize() {
        PolicyDefinitionSummary model =
            new PolicyDefinitionSummary()
                .withPolicyDefinitionId("nayqi")
                .withPolicyDefinitionReferenceId("nduhavhqlkthum")
                .withPolicyDefinitionGroupNames(Arrays.asList("lbg", "cdui", "r", "gccymvaolpssl"))
                .withEffect("fmmdnbbg")
                .withResults(
                    new SummaryResults()
                        .withQueryResultsUri("swiydmcwyhzdx")
                        .withNonCompliantResources(1314424917)
                        .withNonCompliantPolicies(759374962)
                        .withResourceDetails(
                            Arrays
                                .asList(
                                    new ComplianceDetail().withComplianceState("vdfznudaodvxzb").withCount(364348069),
                                    new ComplianceDetail().withComplianceState("ylpstdbhhxsrzdz").withCount(241843348)))
                        .withPolicyDetails(
                            Arrays
                                .asList(
                                    new ComplianceDetail().withComplianceState("dntnevf").withCount(2060062752),
                                    new ComplianceDetail().withComplianceState("ygtdsslswt").withCount(478767297),
                                    new ComplianceDetail().withComplianceState("iofz").withCount(158092972)))
                        .withPolicyGroupDetails(
                            Arrays
                                .asList(
                                    new ComplianceDetail().withComplianceState("wab").withCount(334511461),
                                    new ComplianceDetail().withComplianceState("hhszh").withCount(1422875618))));
        model = BinaryData.fromObject(model).toObject(PolicyDefinitionSummary.class);
        Assertions.assertEquals("nayqi", model.policyDefinitionId());
        Assertions.assertEquals("nduhavhqlkthum", model.policyDefinitionReferenceId());
        Assertions.assertEquals("lbg", model.policyDefinitionGroupNames().get(0));
        Assertions.assertEquals("fmmdnbbg", model.effect());
        Assertions.assertEquals("swiydmcwyhzdx", model.results().queryResultsUri());
        Assertions.assertEquals(1314424917, model.results().nonCompliantResources());
        Assertions.assertEquals(759374962, model.results().nonCompliantPolicies());
        Assertions.assertEquals("vdfznudaodvxzb", model.results().resourceDetails().get(0).complianceState());
        Assertions.assertEquals(364348069, model.results().resourceDetails().get(0).count());
        Assertions.assertEquals("dntnevf", model.results().policyDetails().get(0).complianceState());
        Assertions.assertEquals(2060062752, model.results().policyDetails().get(0).count());
        Assertions.assertEquals("wab", model.results().policyGroupDetails().get(0).complianceState());
        Assertions.assertEquals(334511461, model.results().policyGroupDetails().get(0).count());
    }
}
