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

package com.azure.resourcemanager.deviceupdate.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.deviceupdate.fluent.models.InstanceProperties;
import com.azure.resourcemanager.deviceupdate.models.AuthenticationType;
import com.azure.resourcemanager.deviceupdate.models.DiagnosticStorageProperties;
import com.azure.resourcemanager.deviceupdate.models.IotHubSettings;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class InstancePropertiesTests {
    @Test
    public void testDeserialize() {
        InstanceProperties model =
            BinaryData
                .fromString(
                    "{\"provisioningState\":\"Failed\",\"accountName\":\"vzwdzuhtymwis\",\"iotHubs\":[{\"resourceId\":\"thwxmnteiwaopvkm\"},{\"resourceId\":\"jcmmxdcufufsrp\"},{\"resourceId\":\"mzidnsezcxtb\"}],\"enableDiagnostics\":false,\"diagnosticStorageProperties\":{\"authenticationType\":\"KeyBased\",\"connectionString\":\"cs\",\"resourceId\":\"ewmdw\"}}")
                .toObject(InstanceProperties.class);
        Assertions.assertEquals("thwxmnteiwaopvkm", model.iotHubs().get(0).resourceId());
        Assertions.assertEquals(false, model.enableDiagnostics());
        Assertions.assertEquals(AuthenticationType.KEY_BASED, model.diagnosticStorageProperties().authenticationType());
        Assertions.assertEquals("cs", model.diagnosticStorageProperties().connectionString());
        Assertions.assertEquals("ewmdw", model.diagnosticStorageProperties().resourceId());
    }

    @Test
    public void testSerialize() {
        InstanceProperties model =
            new InstanceProperties()
                .withIotHubs(
                    Arrays
                        .asList(
                            new IotHubSettings().withResourceId("thwxmnteiwaopvkm"),
                            new IotHubSettings().withResourceId("jcmmxdcufufsrp"),
                            new IotHubSettings().withResourceId("mzidnsezcxtb")))
                .withEnableDiagnostics(false)
                .withDiagnosticStorageProperties(
                    new DiagnosticStorageProperties()
                        .withAuthenticationType(AuthenticationType.KEY_BASED)
                        .withConnectionString("cs")
                        .withResourceId("ewmdw"));
        model = BinaryData.fromObject(model).toObject(InstanceProperties.class);
        Assertions.assertEquals("thwxmnteiwaopvkm", model.iotHubs().get(0).resourceId());
        Assertions.assertEquals(false, model.enableDiagnostics());
        Assertions.assertEquals(AuthenticationType.KEY_BASED, model.diagnosticStorageProperties().authenticationType());
        Assertions.assertEquals("cs", model.diagnosticStorageProperties().connectionString());
        Assertions.assertEquals("ewmdw", model.diagnosticStorageProperties().resourceId());
    }
}
