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

package com.azure.resourcemanager.digitaltwins.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.digitaltwins.models.IdentityType;
import com.azure.resourcemanager.digitaltwins.models.ManagedIdentityReference;
import com.azure.resourcemanager.digitaltwins.models.TimeSeriesDatabaseConnectionProperties;
import org.junit.jupiter.api.Assertions;

public final class TimeSeriesDatabaseConnectionPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        TimeSeriesDatabaseConnectionProperties model =
            BinaryData
                .fromString(
                    "{\"connectionType\":\"TimeSeriesDatabaseConnectionProperties\",\"provisioningState\":\"Canceled\",\"identity\":{\"type\":\"SystemAssigned\",\"userAssignedIdentity\":\"yq\"}}")
                .toObject(TimeSeriesDatabaseConnectionProperties.class);
        Assertions.assertEquals(IdentityType.SYSTEM_ASSIGNED, model.identity().type());
        Assertions.assertEquals("yq", model.identity().userAssignedIdentity());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        TimeSeriesDatabaseConnectionProperties model =
            new TimeSeriesDatabaseConnectionProperties()
                .withIdentity(
                    new ManagedIdentityReference()
                        .withType(IdentityType.SYSTEM_ASSIGNED)
                        .withUserAssignedIdentity("yq"));
        model = BinaryData.fromObject(model).toObject(TimeSeriesDatabaseConnectionProperties.class);
        Assertions.assertEquals(IdentityType.SYSTEM_ASSIGNED, model.identity().type());
        Assertions.assertEquals("yq", model.identity().userAssignedIdentity());
    }
}
