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

package com.azure.resourcemanager.iothub.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.iothub.models.AuthenticationType;
import com.azure.resourcemanager.iothub.models.ManagedIdentity;
import com.azure.resourcemanager.iothub.models.StorageEndpointProperties;
import java.time.Duration;
import org.junit.jupiter.api.Assertions;

public final class StorageEndpointPropertiesTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        StorageEndpointProperties model =
            BinaryData
                .fromString(
                    "{\"sasTtlAsIso8601\":\"PT227H21M53S\",\"connectionString\":\"hkaetcktvfc\",\"containerName\":\"vf\",\"authenticationType\":\"identityBased\",\"identity\":{\"userAssignedIdentity\":\"uctqhjfbe\"}}")
                .toObject(StorageEndpointProperties.class);
        Assertions.assertEquals(Duration.parse("PT227H21M53S"), model.sasTtlAsIso8601());
        Assertions.assertEquals("hkaetcktvfc", model.connectionString());
        Assertions.assertEquals("vf", model.containerName());
        Assertions.assertEquals(AuthenticationType.IDENTITY_BASED, model.authenticationType());
        Assertions.assertEquals("uctqhjfbe", model.identity().userAssignedIdentity());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        StorageEndpointProperties model =
            new StorageEndpointProperties()
                .withSasTtlAsIso8601(Duration.parse("PT227H21M53S"))
                .withConnectionString("hkaetcktvfc")
                .withContainerName("vf")
                .withAuthenticationType(AuthenticationType.IDENTITY_BASED)
                .withIdentity(new ManagedIdentity().withUserAssignedIdentity("uctqhjfbe"));
        model = BinaryData.fromObject(model).toObject(StorageEndpointProperties.class);
        Assertions.assertEquals(Duration.parse("PT227H21M53S"), model.sasTtlAsIso8601());
        Assertions.assertEquals("hkaetcktvfc", model.connectionString());
        Assertions.assertEquals("vf", model.containerName());
        Assertions.assertEquals(AuthenticationType.IDENTITY_BASED, model.authenticationType());
        Assertions.assertEquals("uctqhjfbe", model.identity().userAssignedIdentity());
    }
}
