// 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.Summary;
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 SummaryTests {
    @Test
    public void testDeserialize() {
        Summary model =
            BinaryData
                .fromString(
                    "{\"@odata.id\":\"zunlu\",\"@odata.context\":\"nnprn\",\"results\":{\"queryResultsUri\":\"eilpjzuaejxdu\",\"nonCompliantResources\":1310045138,\"nonCompliantPolicies\":1027905525,\"resourceDetails\":[{\"complianceState\":\"dzumveekg\",\"count\":1817395780},{\"complianceState\":\"uh\",\"count\":102600378},{\"complianceState\":\"sjyofdx\",\"count\":301470768}],\"policyDetails\":[{\"complianceState\":\"touwaboekqv\",\"count\":628545796},{\"complianceState\":\"smv\",\"count\":1952282875},{\"complianceState\":\"jsflhhcaalnjix\",\"count\":1143509001},{\"complianceState\":\"awjoyaqcslyjp\",\"count\":1793705984}],\"policyGroupDetails\":[{\"complianceState\":\"exznelixhnr\",\"count\":644635434},{\"complianceState\":\"lhbnxkna\",\"count\":2019040636}]},\"policyAssignments\":[{\"policyAssignmentId\":\"ggdtpnapnyiro\",\"policySetDefinitionId\":\"hpigv\",\"results\":{\"queryResultsUri\":\"lgqg\",\"nonCompliantResources\":327718055,\"nonCompliantPolicies\":613009021,\"resourceDetails\":[],\"policyDetails\":[],\"policyGroupDetails\":[]},\"policyDefinitions\":[],\"policyGroups\":[]}]}")
                .toObject(Summary.class);
        Assertions.assertEquals("eilpjzuaejxdu", model.results().queryResultsUri());
        Assertions.assertEquals(1310045138, model.results().nonCompliantResources());
        Assertions.assertEquals(1027905525, model.results().nonCompliantPolicies());
        Assertions.assertEquals("dzumveekg", model.results().resourceDetails().get(0).complianceState());
        Assertions.assertEquals(1817395780, model.results().resourceDetails().get(0).count());
        Assertions.assertEquals("touwaboekqv", model.results().policyDetails().get(0).complianceState());
        Assertions.assertEquals(628545796, model.results().policyDetails().get(0).count());
        Assertions.assertEquals("exznelixhnr", model.results().policyGroupDetails().get(0).complianceState());
        Assertions.assertEquals(644635434, model.results().policyGroupDetails().get(0).count());
        Assertions.assertEquals("ggdtpnapnyiro", model.policyAssignments().get(0).policyAssignmentId());
        Assertions.assertEquals("hpigv", model.policyAssignments().get(0).policySetDefinitionId());
        Assertions.assertEquals("lgqg", model.policyAssignments().get(0).results().queryResultsUri());
        Assertions.assertEquals(327718055, model.policyAssignments().get(0).results().nonCompliantResources());
        Assertions.assertEquals(613009021, model.policyAssignments().get(0).results().nonCompliantPolicies());
    }

    @Test
    public void testSerialize() {
        Summary model =
            new Summary()
                .withResults(
                    new SummaryResults()
                        .withQueryResultsUri("eilpjzuaejxdu")
                        .withNonCompliantResources(1310045138)
                        .withNonCompliantPolicies(1027905525)
                        .withResourceDetails(
                            Arrays
                                .asList(
                                    new ComplianceDetail().withComplianceState("dzumveekg").withCount(1817395780),
                                    new ComplianceDetail().withComplianceState("uh").withCount(102600378),
                                    new ComplianceDetail().withComplianceState("sjyofdx").withCount(301470768)))
                        .withPolicyDetails(
                            Arrays
                                .asList(
                                    new ComplianceDetail().withComplianceState("touwaboekqv").withCount(628545796),
                                    new ComplianceDetail().withComplianceState("smv").withCount(1952282875),
                                    new ComplianceDetail().withComplianceState("jsflhhcaalnjix").withCount(1143509001),
                                    new ComplianceDetail().withComplianceState("awjoyaqcslyjp").withCount(1793705984)))
                        .withPolicyGroupDetails(
                            Arrays
                                .asList(
                                    new ComplianceDetail().withComplianceState("exznelixhnr").withCount(644635434),
                                    new ComplianceDetail().withComplianceState("lhbnxkna").withCount(2019040636))))
                .withPolicyAssignments(
                    Arrays
                        .asList(
                            new PolicyAssignmentSummary()
                                .withPolicyAssignmentId("ggdtpnapnyiro")
                                .withPolicySetDefinitionId("hpigv")
                                .withResults(
                                    new SummaryResults()
                                        .withQueryResultsUri("lgqg")
                                        .withNonCompliantResources(327718055)
                                        .withNonCompliantPolicies(613009021)
                                        .withResourceDetails(Arrays.asList())
                                        .withPolicyDetails(Arrays.asList())
                                        .withPolicyGroupDetails(Arrays.asList()))
                                .withPolicyDefinitions(Arrays.asList())
                                .withPolicyGroups(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(Summary.class);
        Assertions.assertEquals("eilpjzuaejxdu", model.results().queryResultsUri());
        Assertions.assertEquals(1310045138, model.results().nonCompliantResources());
        Assertions.assertEquals(1027905525, model.results().nonCompliantPolicies());
        Assertions.assertEquals("dzumveekg", model.results().resourceDetails().get(0).complianceState());
        Assertions.assertEquals(1817395780, model.results().resourceDetails().get(0).count());
        Assertions.assertEquals("touwaboekqv", model.results().policyDetails().get(0).complianceState());
        Assertions.assertEquals(628545796, model.results().policyDetails().get(0).count());
        Assertions.assertEquals("exznelixhnr", model.results().policyGroupDetails().get(0).complianceState());
        Assertions.assertEquals(644635434, model.results().policyGroupDetails().get(0).count());
        Assertions.assertEquals("ggdtpnapnyiro", model.policyAssignments().get(0).policyAssignmentId());
        Assertions.assertEquals("hpigv", model.policyAssignments().get(0).policySetDefinitionId());
        Assertions.assertEquals("lgqg", model.policyAssignments().get(0).results().queryResultsUri());
        Assertions.assertEquals(327718055, model.policyAssignments().get(0).results().nonCompliantResources());
        Assertions.assertEquals(613009021, model.policyAssignments().get(0).results().nonCompliantPolicies());
    }
}
