// 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.PolicyAssignmentSummary;
import com.azure.resourcemanager.policyinsights.models.PolicyDefinitionSummary;
import com.azure.resourcemanager.policyinsights.models.PolicyGroupSummary;
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 PolicyAssignmentSummaryTests {
    @Test
    public void testDeserialize() {
        PolicyAssignmentSummary model =
            BinaryData
                .fromString(
                    "{\"policyAssignmentId\":\"mjh\",\"policySetDefinitionId\":\"j\",\"results\":{\"queryResultsUri\":\"u\",\"nonCompliantResources\":709411733,\"nonCompliantPolicies\":258725864,\"resourceDetails\":[{\"complianceState\":\"bxqz\",\"count\":668834645},{\"complianceState\":\"fauvjfdxx\",\"count\":57389374}],\"policyDetails\":[{\"complianceState\":\"cqaqtdoqmcbx\",\"count\":1289805860},{\"complianceState\":\"yslqbhsfx\",\"count\":693295515},{\"complianceState\":\"tkblmpewww\",\"count\":1577221415}],\"policyGroupDetails\":[{\"complianceState\":\"nsvs\",\"count\":2131802432},{\"complianceState\":\"hxcr\",\"count\":1416358219},{\"complianceState\":\"vasrruvwb\",\"count\":818264004},{\"complianceState\":\"sub\",\"count\":540005244}]},\"policyDefinitions\":[{\"policyDefinitionId\":\"xb\",\"policyDefinitionReferenceId\":\"bsrfbj\",\"policyDefinitionGroupNames\":[\"w\"],\"effect\":\"otftpvjzbexilz\",\"results\":{\"queryResultsUri\":\"qqnvwpmq\",\"nonCompliantResources\":1628769376,\"nonCompliantPolicies\":1284168772,\"resourceDetails\":[],\"policyDetails\":[],\"policyGroupDetails\":[]}}],\"policyGroups\":[{\"policyGroupName\":\"hwqytj\",\"results\":{\"queryResultsUri\":\"n\",\"nonCompliantResources\":524895743,\"nonCompliantPolicies\":1598094804,\"resourceDetails\":[],\"policyDetails\":[],\"policyGroupDetails\":[]}},{\"policyGroupName\":\"rvnaenqpeh\",\"results\":{\"queryResultsUri\":\"oygmift\",\"nonCompliantResources\":1092081926,\"nonCompliantPolicies\":2033787842,\"resourceDetails\":[],\"policyDetails\":[],\"policyGroupDetails\":[]}}]}")
                .toObject(PolicyAssignmentSummary.class);
        Assertions.assertEquals("mjh", model.policyAssignmentId());
        Assertions.assertEquals("j", model.policySetDefinitionId());
        Assertions.assertEquals("u", model.results().queryResultsUri());
        Assertions.assertEquals(709411733, model.results().nonCompliantResources());
        Assertions.assertEquals(258725864, model.results().nonCompliantPolicies());
        Assertions.assertEquals("bxqz", model.results().resourceDetails().get(0).complianceState());
        Assertions.assertEquals(668834645, model.results().resourceDetails().get(0).count());
        Assertions.assertEquals("cqaqtdoqmcbx", model.results().policyDetails().get(0).complianceState());
        Assertions.assertEquals(1289805860, model.results().policyDetails().get(0).count());
        Assertions.assertEquals("nsvs", model.results().policyGroupDetails().get(0).complianceState());
        Assertions.assertEquals(2131802432, model.results().policyGroupDetails().get(0).count());
        Assertions.assertEquals("xb", model.policyDefinitions().get(0).policyDefinitionId());
        Assertions.assertEquals("bsrfbj", model.policyDefinitions().get(0).policyDefinitionReferenceId());
        Assertions.assertEquals("w", model.policyDefinitions().get(0).policyDefinitionGroupNames().get(0));
        Assertions.assertEquals("otftpvjzbexilz", model.policyDefinitions().get(0).effect());
        Assertions.assertEquals("qqnvwpmq", model.policyDefinitions().get(0).results().queryResultsUri());
        Assertions.assertEquals(1628769376, model.policyDefinitions().get(0).results().nonCompliantResources());
        Assertions.assertEquals(1284168772, model.policyDefinitions().get(0).results().nonCompliantPolicies());
        Assertions.assertEquals("hwqytj", model.policyGroups().get(0).policyGroupName());
        Assertions.assertEquals("n", model.policyGroups().get(0).results().queryResultsUri());
        Assertions.assertEquals(524895743, model.policyGroups().get(0).results().nonCompliantResources());
        Assertions.assertEquals(1598094804, model.policyGroups().get(0).results().nonCompliantPolicies());
    }

    @Test
    public void testSerialize() {
        PolicyAssignmentSummary model =
            new PolicyAssignmentSummary()
                .withPolicyAssignmentId("mjh")
                .withPolicySetDefinitionId("j")
                .withResults(
                    new SummaryResults()
                        .withQueryResultsUri("u")
                        .withNonCompliantResources(709411733)
                        .withNonCompliantPolicies(258725864)
                        .withResourceDetails(
                            Arrays
                                .asList(
                                    new ComplianceDetail().withComplianceState("bxqz").withCount(668834645),
                                    new ComplianceDetail().withComplianceState("fauvjfdxx").withCount(57389374)))
                        .withPolicyDetails(
                            Arrays
                                .asList(
                                    new ComplianceDetail().withComplianceState("cqaqtdoqmcbx").withCount(1289805860),
                                    new ComplianceDetail().withComplianceState("yslqbhsfx").withCount(693295515),
                                    new ComplianceDetail().withComplianceState("tkblmpewww").withCount(1577221415)))
                        .withPolicyGroupDetails(
                            Arrays
                                .asList(
                                    new ComplianceDetail().withComplianceState("nsvs").withCount(2131802432),
                                    new ComplianceDetail().withComplianceState("hxcr").withCount(1416358219),
                                    new ComplianceDetail().withComplianceState("vasrruvwb").withCount(818264004),
                                    new ComplianceDetail().withComplianceState("sub").withCount(540005244))))
                .withPolicyDefinitions(
                    Arrays
                        .asList(
                            new PolicyDefinitionSummary()
                                .withPolicyDefinitionId("xb")
                                .withPolicyDefinitionReferenceId("bsrfbj")
                                .withPolicyDefinitionGroupNames(Arrays.asList("w"))
                                .withEffect("otftpvjzbexilz")
                                .withResults(
                                    new SummaryResults()
                                        .withQueryResultsUri("qqnvwpmq")
                                        .withNonCompliantResources(1628769376)
                                        .withNonCompliantPolicies(1284168772)
                                        .withResourceDetails(Arrays.asList())
                                        .withPolicyDetails(Arrays.asList())
                                        .withPolicyGroupDetails(Arrays.asList()))))
                .withPolicyGroups(
                    Arrays
                        .asList(
                            new PolicyGroupSummary()
                                .withPolicyGroupName("hwqytj")
                                .withResults(
                                    new SummaryResults()
                                        .withQueryResultsUri("n")
                                        .withNonCompliantResources(524895743)
                                        .withNonCompliantPolicies(1598094804)
                                        .withResourceDetails(Arrays.asList())
                                        .withPolicyDetails(Arrays.asList())
                                        .withPolicyGroupDetails(Arrays.asList())),
                            new PolicyGroupSummary()
                                .withPolicyGroupName("rvnaenqpeh")
                                .withResults(
                                    new SummaryResults()
                                        .withQueryResultsUri("oygmift")
                                        .withNonCompliantResources(1092081926)
                                        .withNonCompliantPolicies(2033787842)
                                        .withResourceDetails(Arrays.asList())
                                        .withPolicyDetails(Arrays.asList())
                                        .withPolicyGroupDetails(Arrays.asList()))));
        model = BinaryData.fromObject(model).toObject(PolicyAssignmentSummary.class);
        Assertions.assertEquals("mjh", model.policyAssignmentId());
        Assertions.assertEquals("j", model.policySetDefinitionId());
        Assertions.assertEquals("u", model.results().queryResultsUri());
        Assertions.assertEquals(709411733, model.results().nonCompliantResources());
        Assertions.assertEquals(258725864, model.results().nonCompliantPolicies());
        Assertions.assertEquals("bxqz", model.results().resourceDetails().get(0).complianceState());
        Assertions.assertEquals(668834645, model.results().resourceDetails().get(0).count());
        Assertions.assertEquals("cqaqtdoqmcbx", model.results().policyDetails().get(0).complianceState());
        Assertions.assertEquals(1289805860, model.results().policyDetails().get(0).count());
        Assertions.assertEquals("nsvs", model.results().policyGroupDetails().get(0).complianceState());
        Assertions.assertEquals(2131802432, model.results().policyGroupDetails().get(0).count());
        Assertions.assertEquals("xb", model.policyDefinitions().get(0).policyDefinitionId());
        Assertions.assertEquals("bsrfbj", model.policyDefinitions().get(0).policyDefinitionReferenceId());
        Assertions.assertEquals("w", model.policyDefinitions().get(0).policyDefinitionGroupNames().get(0));
        Assertions.assertEquals("otftpvjzbexilz", model.policyDefinitions().get(0).effect());
        Assertions.assertEquals("qqnvwpmq", model.policyDefinitions().get(0).results().queryResultsUri());
        Assertions.assertEquals(1628769376, model.policyDefinitions().get(0).results().nonCompliantResources());
        Assertions.assertEquals(1284168772, model.policyDefinitions().get(0).results().nonCompliantPolicies());
        Assertions.assertEquals("hwqytj", model.policyGroups().get(0).policyGroupName());
        Assertions.assertEquals("n", model.policyGroups().get(0).results().queryResultsUri());
        Assertions.assertEquals(524895743, model.policyGroups().get(0).results().nonCompliantResources());
        Assertions.assertEquals(1598094804, model.policyGroups().get(0).results().nonCompliantPolicies());
    }
}
