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

package com.azure.resourcemanager.orbital.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.orbital.fluent.models.ContactProfileInner;
import com.azure.resourcemanager.orbital.models.AutoTrackingConfiguration;
import com.azure.resourcemanager.orbital.models.ContactProfileLink;
import com.azure.resourcemanager.orbital.models.ContactProfileThirdPartyConfiguration;
import com.azure.resourcemanager.orbital.models.ContactProfilesPropertiesNetworkConfiguration;
import com.azure.resourcemanager.orbital.models.ContactProfilesPropertiesProvisioningState;
import com.azure.resourcemanager.orbital.models.Direction;
import com.azure.resourcemanager.orbital.models.Polarization;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Assertions;

public final class ContactProfileInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ContactProfileInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"provisioningState\":\"deleting\",\"minimumViableContactDuration\":\"mjthjqkwp\",\"minimumElevationDegrees\":21.441769,\"autoTrackingConfiguration\":\"disabled\",\"eventHubUri\":\"qciwqvhkhixuigdt\",\"networkConfiguration\":{\"subnetId\":\"pbobjo\"},\"thirdPartyConfigurations\":[{\"providerName\":\"e\",\"missionConfiguration\":\"u\"}],\"links\":[{\"name\":\"a\",\"polarization\":\"linearHorizontal\",\"direction\":\"Uplink\",\"gainOverTemperature\":59.897835,\"eirpdBW\":64.31821,\"channels\":[]}]},\"location\":\"t\",\"tags\":{\"ftutqxlngxlefgu\":\"dfgiot\",\"qmi\":\"nxkrx\"},\"id\":\"tthzrvqd\",\"name\":\"abhjybi\",\"type\":\"ehoqfbowskan\"}")
                .toObject(ContactProfileInner.class);
        Assertions.assertEquals("t", model.location());
        Assertions.assertEquals("dfgiot", model.tags().get("ftutqxlngxlefgu"));
        Assertions.assertEquals(ContactProfilesPropertiesProvisioningState.DELETING, model.provisioningState());
        Assertions.assertEquals("mjthjqkwp", model.minimumViableContactDuration());
        Assertions.assertEquals(21.441769F, model.minimumElevationDegrees());
        Assertions.assertEquals(AutoTrackingConfiguration.DISABLED, model.autoTrackingConfiguration());
        Assertions.assertEquals("qciwqvhkhixuigdt", model.eventHubUri());
        Assertions.assertEquals("pbobjo", model.networkConfiguration().subnetId());
        Assertions.assertEquals("e", model.thirdPartyConfigurations().get(0).providerName());
        Assertions.assertEquals("u", model.thirdPartyConfigurations().get(0).missionConfiguration());
        Assertions.assertEquals("a", model.links().get(0).name());
        Assertions.assertEquals(Polarization.LINEAR_HORIZONTAL, model.links().get(0).polarization());
        Assertions.assertEquals(Direction.UPLINK, model.links().get(0).direction());
        Assertions.assertEquals(59.897835F, model.links().get(0).gainOverTemperature());
        Assertions.assertEquals(64.31821F, model.links().get(0).eirpdBW());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ContactProfileInner model =
            new ContactProfileInner()
                .withLocation("t")
                .withTags(mapOf("ftutqxlngxlefgu", "dfgiot", "qmi", "nxkrx"))
                .withProvisioningState(ContactProfilesPropertiesProvisioningState.DELETING)
                .withMinimumViableContactDuration("mjthjqkwp")
                .withMinimumElevationDegrees(21.441769F)
                .withAutoTrackingConfiguration(AutoTrackingConfiguration.DISABLED)
                .withEventHubUri("qciwqvhkhixuigdt")
                .withNetworkConfiguration(new ContactProfilesPropertiesNetworkConfiguration().withSubnetId("pbobjo"))
                .withThirdPartyConfigurations(
                    Arrays
                        .asList(
                            new ContactProfileThirdPartyConfiguration()
                                .withProviderName("e")
                                .withMissionConfiguration("u")))
                .withLinks(
                    Arrays
                        .asList(
                            new ContactProfileLink()
                                .withName("a")
                                .withPolarization(Polarization.LINEAR_HORIZONTAL)
                                .withDirection(Direction.UPLINK)
                                .withGainOverTemperature(59.897835F)
                                .withEirpdBW(64.31821F)
                                .withChannels(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(ContactProfileInner.class);
        Assertions.assertEquals("t", model.location());
        Assertions.assertEquals("dfgiot", model.tags().get("ftutqxlngxlefgu"));
        Assertions.assertEquals(ContactProfilesPropertiesProvisioningState.DELETING, model.provisioningState());
        Assertions.assertEquals("mjthjqkwp", model.minimumViableContactDuration());
        Assertions.assertEquals(21.441769F, model.minimumElevationDegrees());
        Assertions.assertEquals(AutoTrackingConfiguration.DISABLED, model.autoTrackingConfiguration());
        Assertions.assertEquals("qciwqvhkhixuigdt", model.eventHubUri());
        Assertions.assertEquals("pbobjo", model.networkConfiguration().subnetId());
        Assertions.assertEquals("e", model.thirdPartyConfigurations().get(0).providerName());
        Assertions.assertEquals("u", model.thirdPartyConfigurations().get(0).missionConfiguration());
        Assertions.assertEquals("a", model.links().get(0).name());
        Assertions.assertEquals(Polarization.LINEAR_HORIZONTAL, model.links().get(0).polarization());
        Assertions.assertEquals(Direction.UPLINK, model.links().get(0).direction());
        Assertions.assertEquals(59.897835F, model.links().get(0).gainOverTemperature());
        Assertions.assertEquals(64.31821F, model.links().get(0).eirpdBW());
    }

    @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;
    }
}
