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

package com.azure.resourcemanager.paloaltonetworks.ngfw.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.paloaltonetworks.ngfw.fluent.models.RuleCounterInner;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.AppSeenData;
import com.azure.resourcemanager.paloaltonetworks.ngfw.models.AppSeenInfo;
import java.time.OffsetDateTime;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class RuleCounterInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        RuleCounterInner model =
            BinaryData
                .fromString(
                    "{\"priority\":\"e\",\"ruleStackName\":\"sgzvahapjyzhpv\",\"ruleListName\":\"zcjrvxdjzlmwlx\",\"firewallName\":\"ug\",\"ruleName\":\"hzovawjvzunlut\",\"hitCount\":44966714,\"appSeen\":{\"count\":1845273018,\"appSeenList\":[{\"title\":\"xipeilpjzuaejx\",\"category\":\"ultskzbbtdz\",\"subCategory\":\"mv\",\"risk\":\"ekg\",\"tag\":\"wozuhkf\",\"technology\":\"bsjyofdx\",\"standardPorts\":\"uusdttouwa\"},{\"title\":\"oekqvk\",\"category\":\"lns\",\"subCategory\":\"vbxwyjsflhh\",\"risk\":\"aalnjixi\",\"tag\":\"xyawj\",\"technology\":\"yaqcslyjpkiidz\",\"standardPorts\":\"exznelixhnr\"}]},\"timestamp\":\"2021-05-07T02:19:01Z\",\"requestTimestamp\":\"2021-01-29T16:29:48Z\",\"lastUpdatedTimestamp\":\"2021-05-23T04:05:07Z\"}")
                .toObject(RuleCounterInner.class);
        Assertions.assertEquals("e", model.priority());
        Assertions.assertEquals("sgzvahapjyzhpv", model.ruleStackName());
        Assertions.assertEquals("zcjrvxdjzlmwlx", model.ruleListName());
        Assertions.assertEquals("ug", model.firewallName());
        Assertions.assertEquals("hzovawjvzunlut", model.ruleName());
        Assertions.assertEquals(44966714, model.hitCount());
        Assertions.assertEquals(1845273018, model.appSeen().count());
        Assertions.assertEquals("xipeilpjzuaejx", model.appSeen().appSeenList().get(0).title());
        Assertions.assertEquals("ultskzbbtdz", model.appSeen().appSeenList().get(0).category());
        Assertions.assertEquals("mv", model.appSeen().appSeenList().get(0).subCategory());
        Assertions.assertEquals("ekg", model.appSeen().appSeenList().get(0).risk());
        Assertions.assertEquals("wozuhkf", model.appSeen().appSeenList().get(0).tag());
        Assertions.assertEquals("bsjyofdx", model.appSeen().appSeenList().get(0).technology());
        Assertions.assertEquals("uusdttouwa", model.appSeen().appSeenList().get(0).standardPorts());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-07T02:19:01Z"), model.timestamp());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-29T16:29:48Z"), model.requestTimestamp());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-23T04:05:07Z"), model.lastUpdatedTimestamp());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        RuleCounterInner model =
            new RuleCounterInner()
                .withPriority("e")
                .withRuleStackName("sgzvahapjyzhpv")
                .withRuleListName("zcjrvxdjzlmwlx")
                .withFirewallName("ug")
                .withRuleName("hzovawjvzunlut")
                .withHitCount(44966714)
                .withAppSeen(
                    new AppSeenData()
                        .withCount(1845273018)
                        .withAppSeenList(
                            Arrays
                                .asList(
                                    new AppSeenInfo()
                                        .withTitle("xipeilpjzuaejx")
                                        .withCategory("ultskzbbtdz")
                                        .withSubCategory("mv")
                                        .withRisk("ekg")
                                        .withTag("wozuhkf")
                                        .withTechnology("bsjyofdx")
                                        .withStandardPorts("uusdttouwa"),
                                    new AppSeenInfo()
                                        .withTitle("oekqvk")
                                        .withCategory("lns")
                                        .withSubCategory("vbxwyjsflhh")
                                        .withRisk("aalnjixi")
                                        .withTag("xyawj")
                                        .withTechnology("yaqcslyjpkiidz")
                                        .withStandardPorts("exznelixhnr"))))
                .withTimestamp(OffsetDateTime.parse("2021-05-07T02:19:01Z"))
                .withRequestTimestamp(OffsetDateTime.parse("2021-01-29T16:29:48Z"))
                .withLastUpdatedTimestamp(OffsetDateTime.parse("2021-05-23T04:05:07Z"));
        model = BinaryData.fromObject(model).toObject(RuleCounterInner.class);
        Assertions.assertEquals("e", model.priority());
        Assertions.assertEquals("sgzvahapjyzhpv", model.ruleStackName());
        Assertions.assertEquals("zcjrvxdjzlmwlx", model.ruleListName());
        Assertions.assertEquals("ug", model.firewallName());
        Assertions.assertEquals("hzovawjvzunlut", model.ruleName());
        Assertions.assertEquals(44966714, model.hitCount());
        Assertions.assertEquals(1845273018, model.appSeen().count());
        Assertions.assertEquals("xipeilpjzuaejx", model.appSeen().appSeenList().get(0).title());
        Assertions.assertEquals("ultskzbbtdz", model.appSeen().appSeenList().get(0).category());
        Assertions.assertEquals("mv", model.appSeen().appSeenList().get(0).subCategory());
        Assertions.assertEquals("ekg", model.appSeen().appSeenList().get(0).risk());
        Assertions.assertEquals("wozuhkf", model.appSeen().appSeenList().get(0).tag());
        Assertions.assertEquals("bsjyofdx", model.appSeen().appSeenList().get(0).technology());
        Assertions.assertEquals("uusdttouwa", model.appSeen().appSeenList().get(0).standardPorts());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-07T02:19:01Z"), model.timestamp());
        Assertions.assertEquals(OffsetDateTime.parse("2021-01-29T16:29:48Z"), model.requestTimestamp());
        Assertions.assertEquals(OffsetDateTime.parse("2021-05-23T04:05:07Z"), model.lastUpdatedTimestamp());
    }
}
