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

package com.azure.resourcemanager.mobilenetwork.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.mobilenetwork.models.Ambr;
import com.azure.resourcemanager.mobilenetwork.models.DataNetworkConfiguration;
import com.azure.resourcemanager.mobilenetwork.models.DataNetworkResourceId;
import com.azure.resourcemanager.mobilenetwork.models.PduSessionType;
import com.azure.resourcemanager.mobilenetwork.models.PreemptionCapability;
import com.azure.resourcemanager.mobilenetwork.models.PreemptionVulnerability;
import com.azure.resourcemanager.mobilenetwork.models.ServiceResourceId;
import com.azure.resourcemanager.mobilenetwork.models.SliceConfiguration;
import com.azure.resourcemanager.mobilenetwork.models.SliceResourceId;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class SliceConfigurationTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        SliceConfiguration model =
            BinaryData
                .fromString(
                    "{\"slice\":{\"id\":\"ocxvdfffwafqr\"},\"defaultDataNetwork\":{\"id\":\"udaspavehh\"},\"dataNetworkConfigurations\":[{\"dataNetwork\":{\"id\":\"kbunzoz\"},\"sessionAmbr\":{\"uplink\":\"dhcxgkmoy\",\"downlink\":\"cdyuibhmfdnbzyd\"},\"5qi\":1872796730,\"allocationAndRetentionPriorityLevel\":1709322147,\"preemptionCapability\":\"NotPreempt\",\"preemptionVulnerability\":\"Preemptable\",\"defaultSessionType\":\"IPv4\",\"additionalAllowedSessionTypes\":[\"IPv6\",\"IPv6\"],\"allowedServices\":[{\"id\":\"gorf\"},{\"id\":\"ukiscvwmzhw\"},{\"id\":\"lefaxvxilcbtgn\"}],\"maximumNumberOfBufferedPackets\":2012963266},{\"dataNetwork\":{\"id\":\"eyqxtjjfzql\"},\"sessionAmbr\":{\"uplink\":\"hycav\",\"downlink\":\"dggxdbeesmi\"},\"5qi\":1356434972,\"allocationAndRetentionPriorityLevel\":420094918,\"preemptionCapability\":\"NotPreempt\",\"preemptionVulnerability\":\"Preemptable\",\"defaultSessionType\":\"IPv6\",\"additionalAllowedSessionTypes\":[\"IPv4\",\"IPv4\",\"IPv6\",\"IPv4\"],\"allowedServices\":[{\"id\":\"qfby\"},{\"id\":\"yr\"},{\"id\":\"giagtcojo\"},{\"id\":\"qwogfnzjvus\"}],\"maximumNumberOfBufferedPackets\":359002746},{\"dataNetwork\":{\"id\":\"dmozu\"},\"sessionAmbr\":{\"uplink\":\"ylfsbtk\",\"downlink\":\"dp\"},\"5qi\":737232948,\"allocationAndRetentionPriorityLevel\":1774852320,\"preemptionCapability\":\"MayPreempt\",\"preemptionVulnerability\":\"NotPreemptable\",\"defaultSessionType\":\"IPv4\",\"additionalAllowedSessionTypes\":[\"IPv6\"],\"allowedServices\":[{\"id\":\"cto\"},{\"id\":\"cmisofie\"},{\"id\":\"pe\"}],\"maximumNumberOfBufferedPackets\":419692653}]}")
                .toObject(SliceConfiguration.class);
        Assertions.assertEquals("ocxvdfffwafqr", model.slice().id());
        Assertions.assertEquals("udaspavehh", model.defaultDataNetwork().id());
        Assertions.assertEquals("kbunzoz", model.dataNetworkConfigurations().get(0).dataNetwork().id());
        Assertions.assertEquals("dhcxgkmoy", model.dataNetworkConfigurations().get(0).sessionAmbr().uplink());
        Assertions.assertEquals("cdyuibhmfdnbzyd", model.dataNetworkConfigurations().get(0).sessionAmbr().downlink());
        Assertions.assertEquals(1872796730, model.dataNetworkConfigurations().get(0).fiveQi());
        Assertions
            .assertEquals(1709322147, model.dataNetworkConfigurations().get(0).allocationAndRetentionPriorityLevel());
        Assertions
            .assertEquals(
                PreemptionCapability.NOT_PREEMPT, model.dataNetworkConfigurations().get(0).preemptionCapability());
        Assertions
            .assertEquals(
                PreemptionVulnerability.PREEMPTABLE,
                model.dataNetworkConfigurations().get(0).preemptionVulnerability());
        Assertions.assertEquals(PduSessionType.IPV4, model.dataNetworkConfigurations().get(0).defaultSessionType());
        Assertions
            .assertEquals(
                PduSessionType.IPV6, model.dataNetworkConfigurations().get(0).additionalAllowedSessionTypes().get(0));
        Assertions.assertEquals("gorf", model.dataNetworkConfigurations().get(0).allowedServices().get(0).id());
        Assertions.assertEquals(2012963266, model.dataNetworkConfigurations().get(0).maximumNumberOfBufferedPackets());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        SliceConfiguration model =
            new SliceConfiguration()
                .withSlice(new SliceResourceId().withId("ocxvdfffwafqr"))
                .withDefaultDataNetwork(new DataNetworkResourceId().withId("udaspavehh"))
                .withDataNetworkConfigurations(
                    Arrays
                        .asList(
                            new DataNetworkConfiguration()
                                .withDataNetwork(new DataNetworkResourceId().withId("kbunzoz"))
                                .withSessionAmbr(new Ambr().withUplink("dhcxgkmoy").withDownlink("cdyuibhmfdnbzyd"))
                                .withFiveQi(1872796730)
                                .withAllocationAndRetentionPriorityLevel(1709322147)
                                .withPreemptionCapability(PreemptionCapability.NOT_PREEMPT)
                                .withPreemptionVulnerability(PreemptionVulnerability.PREEMPTABLE)
                                .withDefaultSessionType(PduSessionType.IPV4)
                                .withAdditionalAllowedSessionTypes(
                                    Arrays.asList(PduSessionType.IPV6, PduSessionType.IPV6))
                                .withAllowedServices(
                                    Arrays
                                        .asList(
                                            new ServiceResourceId().withId("gorf"),
                                            new ServiceResourceId().withId("ukiscvwmzhw"),
                                            new ServiceResourceId().withId("lefaxvxilcbtgn")))
                                .withMaximumNumberOfBufferedPackets(2012963266),
                            new DataNetworkConfiguration()
                                .withDataNetwork(new DataNetworkResourceId().withId("eyqxtjjfzql"))
                                .withSessionAmbr(new Ambr().withUplink("hycav").withDownlink("dggxdbeesmi"))
                                .withFiveQi(1356434972)
                                .withAllocationAndRetentionPriorityLevel(420094918)
                                .withPreemptionCapability(PreemptionCapability.NOT_PREEMPT)
                                .withPreemptionVulnerability(PreemptionVulnerability.PREEMPTABLE)
                                .withDefaultSessionType(PduSessionType.IPV6)
                                .withAdditionalAllowedSessionTypes(
                                    Arrays
                                        .asList(
                                            PduSessionType.IPV4,
                                            PduSessionType.IPV4,
                                            PduSessionType.IPV6,
                                            PduSessionType.IPV4))
                                .withAllowedServices(
                                    Arrays
                                        .asList(
                                            new ServiceResourceId().withId("qfby"),
                                            new ServiceResourceId().withId("yr"),
                                            new ServiceResourceId().withId("giagtcojo"),
                                            new ServiceResourceId().withId("qwogfnzjvus")))
                                .withMaximumNumberOfBufferedPackets(359002746),
                            new DataNetworkConfiguration()
                                .withDataNetwork(new DataNetworkResourceId().withId("dmozu"))
                                .withSessionAmbr(new Ambr().withUplink("ylfsbtk").withDownlink("dp"))
                                .withFiveQi(737232948)
                                .withAllocationAndRetentionPriorityLevel(1774852320)
                                .withPreemptionCapability(PreemptionCapability.MAY_PREEMPT)
                                .withPreemptionVulnerability(PreemptionVulnerability.NOT_PREEMPTABLE)
                                .withDefaultSessionType(PduSessionType.IPV4)
                                .withAdditionalAllowedSessionTypes(Arrays.asList(PduSessionType.IPV6))
                                .withAllowedServices(
                                    Arrays
                                        .asList(
                                            new ServiceResourceId().withId("cto"),
                                            new ServiceResourceId().withId("cmisofie"),
                                            new ServiceResourceId().withId("pe")))
                                .withMaximumNumberOfBufferedPackets(419692653)));
        model = BinaryData.fromObject(model).toObject(SliceConfiguration.class);
        Assertions.assertEquals("ocxvdfffwafqr", model.slice().id());
        Assertions.assertEquals("udaspavehh", model.defaultDataNetwork().id());
        Assertions.assertEquals("kbunzoz", model.dataNetworkConfigurations().get(0).dataNetwork().id());
        Assertions.assertEquals("dhcxgkmoy", model.dataNetworkConfigurations().get(0).sessionAmbr().uplink());
        Assertions.assertEquals("cdyuibhmfdnbzyd", model.dataNetworkConfigurations().get(0).sessionAmbr().downlink());
        Assertions.assertEquals(1872796730, model.dataNetworkConfigurations().get(0).fiveQi());
        Assertions
            .assertEquals(1709322147, model.dataNetworkConfigurations().get(0).allocationAndRetentionPriorityLevel());
        Assertions
            .assertEquals(
                PreemptionCapability.NOT_PREEMPT, model.dataNetworkConfigurations().get(0).preemptionCapability());
        Assertions
            .assertEquals(
                PreemptionVulnerability.PREEMPTABLE,
                model.dataNetworkConfigurations().get(0).preemptionVulnerability());
        Assertions.assertEquals(PduSessionType.IPV4, model.dataNetworkConfigurations().get(0).defaultSessionType());
        Assertions
            .assertEquals(
                PduSessionType.IPV6, model.dataNetworkConfigurations().get(0).additionalAllowedSessionTypes().get(0));
        Assertions.assertEquals("gorf", model.dataNetworkConfigurations().get(0).allowedServices().get(0).id());
        Assertions.assertEquals(2012963266, model.dataNetworkConfigurations().get(0).maximumNumberOfBufferedPackets());
    }
}
