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

package com.azure.resourcemanager.networkfunction.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.networkfunction.fluent.models.CollectorPolicyPropertiesFormat;
import com.azure.resourcemanager.networkfunction.models.EmissionPoliciesPropertiesFormat;
import com.azure.resourcemanager.networkfunction.models.EmissionType;
import com.azure.resourcemanager.networkfunction.models.IngestionPolicyPropertiesFormat;
import com.azure.resourcemanager.networkfunction.models.IngestionSourcesPropertiesFormat;
import com.azure.resourcemanager.networkfunction.models.IngestionType;
import com.azure.resourcemanager.networkfunction.models.SourceType;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public final class CollectorPolicyPropertiesFormatTests {
    @Test
    public void testDeserialize() {
        CollectorPolicyPropertiesFormat model =
            BinaryData
                .fromString(
                    "{\"ingestionPolicy\":{\"ingestionType\":\"IPFIX\",\"ingestionSources\":[{\"sourceType\":\"Resource\",\"resourceId\":\"uflmm\"},{\"sourceType\":\"Resource\",\"resourceId\":\"modmglougpb\"},{\"sourceType\":\"Resource\",\"resourceId\":\"utduqktapspwgcu\"}]},\"emissionPolicies\":[{\"emissionType\":\"IPFIX\",\"emissionDestinations\":[]},{\"emissionType\":\"IPFIX\",\"emissionDestinations\":[]},{\"emissionType\":\"IPFIX\",\"emissionDestinations\":[]},{\"emissionType\":\"IPFIX\",\"emissionDestinations\":[]}],\"provisioningState\":\"Succeeded\"}")
                .toObject(CollectorPolicyPropertiesFormat.class);
        Assertions.assertEquals(IngestionType.IPFIX, model.ingestionPolicy().ingestionType());
        Assertions.assertEquals(SourceType.RESOURCE, model.ingestionPolicy().ingestionSources().get(0).sourceType());
        Assertions.assertEquals("uflmm", model.ingestionPolicy().ingestionSources().get(0).resourceId());
        Assertions.assertEquals(EmissionType.IPFIX, model.emissionPolicies().get(0).emissionType());
    }

    @Test
    public void testSerialize() {
        CollectorPolicyPropertiesFormat model =
            new CollectorPolicyPropertiesFormat()
                .withIngestionPolicy(
                    new IngestionPolicyPropertiesFormat()
                        .withIngestionType(IngestionType.IPFIX)
                        .withIngestionSources(
                            Arrays
                                .asList(
                                    new IngestionSourcesPropertiesFormat()
                                        .withSourceType(SourceType.RESOURCE)
                                        .withResourceId("uflmm"),
                                    new IngestionSourcesPropertiesFormat()
                                        .withSourceType(SourceType.RESOURCE)
                                        .withResourceId("modmglougpb"),
                                    new IngestionSourcesPropertiesFormat()
                                        .withSourceType(SourceType.RESOURCE)
                                        .withResourceId("utduqktapspwgcu"))))
                .withEmissionPolicies(
                    Arrays
                        .asList(
                            new EmissionPoliciesPropertiesFormat()
                                .withEmissionType(EmissionType.IPFIX)
                                .withEmissionDestinations(Arrays.asList()),
                            new EmissionPoliciesPropertiesFormat()
                                .withEmissionType(EmissionType.IPFIX)
                                .withEmissionDestinations(Arrays.asList()),
                            new EmissionPoliciesPropertiesFormat()
                                .withEmissionType(EmissionType.IPFIX)
                                .withEmissionDestinations(Arrays.asList()),
                            new EmissionPoliciesPropertiesFormat()
                                .withEmissionType(EmissionType.IPFIX)
                                .withEmissionDestinations(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(CollectorPolicyPropertiesFormat.class);
        Assertions.assertEquals(IngestionType.IPFIX, model.ingestionPolicy().ingestionType());
        Assertions.assertEquals(SourceType.RESOURCE, model.ingestionPolicy().ingestionSources().get(0).sourceType());
        Assertions.assertEquals("uflmm", model.ingestionPolicy().ingestionSources().get(0).resourceId());
        Assertions.assertEquals(EmissionType.IPFIX, model.emissionPolicies().get(0).emissionType());
    }
}
