// 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.fluent.models.TimeSeriesDatabaseConnectionInner;
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 TimeSeriesDatabaseConnectionInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        TimeSeriesDatabaseConnectionInner model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"connectionType\":\"TimeSeriesDatabaseConnectionProperties\",\"provisioningState\":\"Failed\",\"identity\":{\"type\":\"UserAssigned\",\"userAssignedIdentity\":\"cktvfcivfsnkymuc\"}},\"id\":\"hjfbebrjcxe\",\"name\":\"fuwutttxf\",\"type\":\"jrbirphxepcyv\"}")
                .toObject(TimeSeriesDatabaseConnectionInner.class);
        Assertions.assertEquals(IdentityType.USER_ASSIGNED, model.properties().identity().type());
        Assertions.assertEquals("cktvfcivfsnkymuc", model.properties().identity().userAssignedIdentity());
    }

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