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

package com.azure.resourcemanager.elastic.generated;

import com.azure.core.util.BinaryData;
import com.azure.resourcemanager.elastic.fluent.models.ElasticTrafficFilterResponseInner;
import com.azure.resourcemanager.elastic.models.ElasticTrafficFilter;
import com.azure.resourcemanager.elastic.models.Type;
import java.util.Arrays;
import org.junit.jupiter.api.Assertions;

public final class ElasticTrafficFilterResponseInnerTests {
    @org.junit.jupiter.api.Test
    public void testDeserialize() throws Exception {
        ElasticTrafficFilterResponseInner model =
            BinaryData
                .fromString(
                    "{\"rulesets\":[{\"id\":\"pyeicxm\",\"name\":\"iwqvhkh\",\"description\":\"uigdtopbobjog\",\"region\":\"e\",\"type\":\"ip\",\"includeByDefault\":false,\"rules\":[]}]}")
                .toObject(ElasticTrafficFilterResponseInner.class);
        Assertions.assertEquals("pyeicxm", model.rulesets().get(0).id());
        Assertions.assertEquals("iwqvhkh", model.rulesets().get(0).name());
        Assertions.assertEquals("uigdtopbobjog", model.rulesets().get(0).description());
        Assertions.assertEquals("e", model.rulesets().get(0).region());
        Assertions.assertEquals(Type.IP, model.rulesets().get(0).type());
        Assertions.assertEquals(false, model.rulesets().get(0).includeByDefault());
    }

    @org.junit.jupiter.api.Test
    public void testSerialize() throws Exception {
        ElasticTrafficFilterResponseInner model =
            new ElasticTrafficFilterResponseInner()
                .withRulesets(
                    Arrays
                        .asList(
                            new ElasticTrafficFilter()
                                .withId("pyeicxm")
                                .withName("iwqvhkh")
                                .withDescription("uigdtopbobjog")
                                .withRegion("e")
                                .withType(Type.IP)
                                .withIncludeByDefault(false)
                                .withRules(Arrays.asList())));
        model = BinaryData.fromObject(model).toObject(ElasticTrafficFilterResponseInner.class);
        Assertions.assertEquals("pyeicxm", model.rulesets().get(0).id());
        Assertions.assertEquals("iwqvhkh", model.rulesets().get(0).name());
        Assertions.assertEquals("uigdtopbobjog", model.rulesets().get(0).description());
        Assertions.assertEquals("e", model.rulesets().get(0).region());
        Assertions.assertEquals(Type.IP, model.rulesets().get(0).type());
        Assertions.assertEquals(false, model.rulesets().get(0).includeByDefault());
    }
}
