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

package com.azure.resourcemanager.storagepool.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.storagepool.models.Acl;
import com.azure.resourcemanager.storagepool.models.IscsiLun;
import com.azure.resourcemanager.storagepool.models.IscsiTargetUpdate;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class IscsiTargetUpdateTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        IscsiTargetUpdate model =
            BinaryData
                .fromString(
                    "{\"properties\":{\"staticAcls\":[{\"initiatorIqn\":\"medjvcslynqwwncw\",\"mappedLuns\":[]},{\"initiatorIqn\":\"zhxgktrmgucn\",\"mappedLuns\":[]},{\"initiatorIqn\":\"pkteo\",\"mappedLuns\":[]}],\"luns\":[{\"name\":\"wptfdy\",\"managedDiskAzureResourceId\":\"pfqbuaceopzf\",\"lun\":1219903446},{\"name\":\"huaoppp\",\"managedDiskAzureResourceId\":\"qeqxo\",\"lun\":280761286}]},\"managedBy\":\"hzxct\",\"managedByExtended\":[\"bkdmo\",\"zpostmgrcfbu\",\"rmfqjhhkxbpvj\"],\"id\":\"mjh\",\"name\":\"xjyngudivk\",\"type\":\"tswb\"}")
                .toObject(IscsiTargetUpdate.class);
        Assertions.assertEquals("hzxct", model.managedBy());
        Assertions.assertEquals("bkdmo", model.managedByExtended().get(0));
        Assertions.assertEquals("medjvcslynqwwncw", model.staticAcls().get(0).initiatorIqn());
        Assertions.assertEquals("wptfdy", model.luns().get(0).name());
        Assertions.assertEquals("pfqbuaceopzf", model.luns().get(0).managedDiskAzureResourceId());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        IscsiTargetUpdate model =
            new IscsiTargetUpdate()
                .withManagedBy("hzxct")
                .withManagedByExtended(Arrays.asList("bkdmo", "zpostmgrcfbu", "rmfqjhhkxbpvj"))
                .withStaticAcls(
                    Arrays
                        .asList(
                            new Acl().withInitiatorIqn("medjvcslynqwwncw").withMappedLuns(Arrays.asList()),
                            new Acl().withInitiatorIqn("zhxgktrmgucn").withMappedLuns(Arrays.asList()),
                            new Acl().withInitiatorIqn("pkteo").withMappedLuns(Arrays.asList())))
                .withLuns(
                    Arrays
                        .asList(
                            new IscsiLun().withName("wptfdy").withManagedDiskAzureResourceId("pfqbuaceopzf"),
                            new IscsiLun().withName("huaoppp").withManagedDiskAzureResourceId("qeqxo")));
        model = BinaryData.fromObject(model).toObject(IscsiTargetUpdate.class);
        Assertions.assertEquals("hzxct", model.managedBy());
        Assertions.assertEquals("bkdmo", model.managedByExtended().get(0));
        Assertions.assertEquals("medjvcslynqwwncw", model.staticAcls().get(0).initiatorIqn());
        Assertions.assertEquals("wptfdy", model.luns().get(0).name());
        Assertions.assertEquals("pfqbuaceopzf", model.luns().get(0).managedDiskAzureResourceId());
    }
}
