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

package com.azure.resourcemanager.managednetworkfabric.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.managednetworkfabric.models.AggregateRouteConfiguration;
import com.azure.resourcemanager.managednetworkfabric.models.L3IsolationDomainPatch;
import com.azure.resourcemanager.managednetworkfabric.models.L3IsolationDomainPatchPropertiesConnectedSubnetRoutePolicy;
import com.azure.resourcemanager.managednetworkfabric.models.RedistributeConnectedSubnets;
import com.azure.resourcemanager.managednetworkfabric.models.RedistributeStaticRoutes;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class L3IsolationDomainPatchTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        L3IsolationDomainPatch model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"redistributeConnectedSubnets\":\"False\",\"redistributeStaticRoutes\":\"False\",\"aggregateRouteConfiguration\":{\"ipv4Routes\":[],\"ipv6Routes\":[]},\"description\":\"ccm\",\"connectedSubnetRoutePolicy\":{\"exportRoutePolicyId\":\"dxyt\",\"administrativeState\":\"Disabled\"}},\"tags\":{\"fudwpznt\":\"xv\"}}")
                .toObject(L3IsolationDomainPatch.class);
        Assertions.assertEquals("xv", model.tags().get("fudwpznt"));
        Assertions.assertEquals(RedistributeConnectedSubnets.FALSE, model.redistributeConnectedSubnets());
        Assertions.assertEquals(RedistributeStaticRoutes.FALSE, model.redistributeStaticRoutes());
        Assertions.assertEquals("ccm", model.description());
        Assertions.assertEquals("dxyt", model.connectedSubnetRoutePolicy().exportRoutePolicyId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        L3IsolationDomainPatch model =
            new L3IsolationDomainPatch()
                .withTags(mapOf("fudwpznt", "xv"))
                .withRedistributeConnectedSubnets(RedistributeConnectedSubnets.FALSE)
                .withRedistributeStaticRoutes(RedistributeStaticRoutes.FALSE)
                .withAggregateRouteConfiguration(
                    new AggregateRouteConfiguration().withIpv4Routes(Arrays.asList()).withIpv6Routes(Arrays.asList()))
                .withDescription("ccm")
                .withConnectedSubnetRoutePolicy(
                    new L3IsolationDomainPatchPropertiesConnectedSubnetRoutePolicy().withExportRoutePolicyId("dxyt"));
        model = BinaryData.fromObject(model).toObject(L3IsolationDomainPatch.class);
        Assertions.assertEquals("xv", model.tags().get("fudwpznt"));
        Assertions.assertEquals(RedistributeConnectedSubnets.FALSE, model.redistributeConnectedSubnets());
        Assertions.assertEquals(RedistributeStaticRoutes.FALSE, model.redistributeStaticRoutes());
        Assertions.assertEquals("ccm", model.description());
        Assertions.assertEquals("dxyt", model.connectedSubnetRoutePolicy().exportRoutePolicyId());
    }

    @SuppressWarnings("unchecked")
    private static <T> Map<String, T> mapOf(Object... inputs) {
        Map<String, T> map = new HashMap<>();
        for (int i = 0; i < inputs.length; i += 2) {
            String key = (String) inputs[i];
            T value = (T) inputs[i + 1];
            map.put(key, value);
        }
        return map;
    }
}
