text:
package org.onosproject.yms.app.ych;

import org.junit.Test;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.CombinedOpParam;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.AsNum;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.Attributes;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.DefaultAttributes;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.Metric;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.PathId;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.Aigp;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.BgpParameters;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultAigp;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultBgpParameters;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultLocalPref;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultMultiExitDisc;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultOrigin;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.DefaultUnrecognizedAttributes;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.LocalPref;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.MultiExitDisc;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.Origin;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.UnrecognizedAttributes;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.aigp.AigpTlv;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.aigp.DefaultAigpTlv;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.DefaultOptionalCapabilities;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.OptionalCapabilities;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.optionalcapabilities.Cparameters;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.optionalcapabilities.DefaultCparameters;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.optionalcapabilities.cparameters.As4BytesCapability;
import org.onosproject.yang.gen.v1.ych.combined.rev20160524.combined.attributes.bgpparameters.optionalcapabilities.cparameters.DefaultAs4BytesCapability;
import org.onosproject.yang.gen.v1.ych.empty.container.rev20160524.EmptyContainerOpParam;
import org.onosproject.yang.gen.v1.ych.empty.container.rev20160524.emptycontainer.EmptyContainer;
import org.onosproject.yang.gen.v1.ych.purchasing.supervisor.rev20160524.YchPurchasingsupervisorOpParam;
import org.onosproject.yang.gen.v1.ych.purchasing.supervisor.rev20160524.ychpurchasingsupervisor.DefaultYchPurchasingSupervisor;
import org.onosproject.yang.gen.v1.ych.purchasing.supervisor.rev20160524.ychpurchasingsupervisor.YchPurchasingSupervisor;
import org.onosproject.yang.gen.v1.ych.purchasing.supervisor.rev20160524.YchPurchasingsupervisor.OnosYangOpType;
import org.onosproject.yang.gen.v1.ydt.customs.supervisor.rev20160524.CustomssupervisorOpParam;
import org.onosproject.yang.gen.v1.ydt.material.supervisor.rev20160524.MaterialsupervisorOpParam;
import org.onosproject.yang.gen.v1.ydt.material.supervisor.rev20160524.materialsupervisor.DefaultSupervisor;
import org.onosproject.yang.gen.v1.ydt.material.supervisor.rev20160524.materialsupervisor.Supervisor;
import org.onosproject.yang.gen.v1.ydt.merchandiser.supervisor.rev20160524.MerchandisersupervisorOpParam;
import org.onosproject.yang.gen.v1.ydt.root.rev20160524.LogisticsManagerOpParam;
import org.onosproject.yang.gen.v1.ydt.trading.supervisor.rev20160524.TradingsupervisorOpParam;
import org.onosproject.yms.app.ych.defaultcodecs.YangCodecRegistry;
import org.onosproject.yms.app.ysr.DefaultYangSchemaRegistry;
import org.onosproject.yms.app.ysr.TestYangSchemaNodeProvider;
import org.onosproject.yms.ych.YangCompositeEncoding;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.onosproject.yms.ych.YangProtocolEncodingFormat.XML;
import static org.onosproject.yms.ydt.YmsOperationType.QUERY_CONFIG_REQUEST;
import static org.onosproject.yms.ydt.YmsOperationType.QUERY_REQUEST;

/**
 * Unit test case for default codec handler.
 */
public class DefaultYangCodecHandlerTest {
    private TestYangSchemaNodeProvider testYangSchemaNodeProvider =
            new TestYangSchemaNodeProvider();
    private static final String AM_XML = "Incorrect XML generated: ";
    private static final String AM_OBJ = "Incorrect object generated: ";
    private static final String EMPTY_CONTAINER = "EmptyContainerOpParam";
    private static final String LOGISTIC_MOD = "LogisticsManagerOpParam";
    private static final String MERCHA_MOD = "MerchandisersupervisorOpParam";

    /**
     * Returns the xml string for customssupervisor module.
     *
     * @return the xml string for customssupervisor module
     */
    private static String customsXml() {
        return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
                "<supervisor xmlns=\"ydt.customs-supervisor\">" +
                "Customssupervisor</supervisor>" +
                "</filter>";
    }

    /**
     * Returns the xml string for merchandisersupervisor module.
     *
     * @return the xml string for merchandisersupervisor module
     */
    private static String merchandXml() {
        return "<config xmlns=\"ydt.root\" " +
                "xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
                "<supervisor xmlns=\"ydt.Merchandiser-supervisor\">" +
                "Merchandisersupervisor</supervisor>" +
                "</config>";
    }

    /**
     * Returns the xml string for tradingsupervisor module.
     *
     * @return the xml string for tradingsupervisor module
     */
    private static String tradingXml() {
        return "<config xmlns=\"ydt.root\" " +
                "xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
                "<supervisor xmlns=\"ydt.trading-supervisor\">" +
                "Tradingsupervisor</supervisor>" +
                "</config>";
    }

    /**
     * Returns the xml string for customssupervisor module.
     *
     * @return the xml string for customssupervisor module
     */
    private static String customsCompositeXml() {
        return "<filter xmlns=\"ydt.filter-type\">" +
                "<supervisor xmlns=\"ydt.customs-supervisor\">" +
                "Customssupervisor</supervisor></filter>";
    }

    /**
     * Returns the xml string for customssupervisor module with filter-type.
     *
     * @return the xml string for customssupervisor module with filter-type
     */
    private static String customsEmptyXml() {
        return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
                "</filter>";
    }

    /**
     * Returns the xml string for materialsupervisor module.
     *
     * @return the xml string for materialsupervisor module
     */
    private static String materialXml() {
        return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
                "<supervisor xmlns=\"ydt.material-supervisor\">" +
                "<name>abc1</name><departmentId>xyz1</departmentId>" +
                "</supervisor>" +
                "<supervisor xmlns=\"ydt.material-supervisor\"" +
                "><name>abc2</name><departmentId>xyz2</departmentId>" +
                "</supervisor>" +
                "<supervisor xmlns=\"ydt.material-supervisor\"" +
                "><name>abc3</name><departmentId>xyz3</departmentId>" +
                "</supervisor>" +
                "<supervisor xmlns=\"ydt.material-supervisor\"" +
                "><name>abc4</name><departmentId>xyz4</departmentId>" +
                "</supervisor>" +
                "<supervisor xmlns=\"ydt.material-supervisor\"" +
                "><name>abc5</name><departmentId>xyz5</departmentId>" +
                "</supervisor>" +
                "</filter>";
    }

    /**
     * Returns the xml string for EmptyContainer module.
     *
     * @return the xml string for EmptyContainer module
     */
    private static String containerEmptyXml() {
        return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
                "</filter>";
    }

    /**
     * Returns the xml string for Combined module.
     *
     * @return the xml string for Combined module
     */
    private static String listTestXml() {
        return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\">" +
                "<attributes xmlns=\"ych:combined\">" +
                "<origin><value>123</value></origin>" +
                "<multi-exit-disc><med>456</med></multi-exit-disc>" +
                "<local-pref><pref>23</pref></local-pref>" +
                "<aigp><aigp-tlv><metric>456</metric></aigp-tlv></aigp>" +
                "<unrecognized-attributes><partial>false</partial>" +
                "<transitive>false</transitive><type>1</type>" +
                "<value>QUJD</value></unrecognized-attributes>" +
                "<unrecognized-attributes><partial>true</partial>" +
                "<transitive>true</transitive><type>2</type>" +
                "<value>QUJD</value></unrecognized-attributes>" +
                "<unrecognized-attributes><partial>true</partial>" +
                "<transitive>false</transitive><type>3</type>" +
                "<value>QUJD</value></unrecognized-attributes>" +
                "<unrecognized-attributes><partial>false</partial>" +
                "<transitive>true</transitive><type>4</type>" +
                "<value>QUJD</value></unrecognized-attributes>" +
                "<bgp-parameters><optional-capabilities><c-parameters>" +
                "<as4-bytes-capability><as-number>11</as-number>" +
                "</as4-bytes-capability></c-parameters>" +
                "</optional-capabilities><optional-capabilities>" +
                "<c-parameters><as4-bytes-capability>" +
                "<as-number>22</as-number></as4-bytes-capability>" +
                "</c-parameters></optional-capabilities>" +
                "<optional-capabilities><c-parameters><as4-bytes-capability>" +
                "<as-number>33</as-number></as4-bytes-capability>" +
                "</c-parameters></optional-capabilities></bgp-parameters>" +
                "<bgp-parameters><optional-capabilities><c-parameters>" +
                "<as4-bytes-capability><as-number>11</as-number>" +
                "</as4-bytes-capability></c-parameters>" +
                "</optional-capabilities><optional-capabilities>" +
                "<c-parameters><as4-bytes-capability>" +
                "<as-number>22</as-number></as4-bytes-capability>" +
                "</c-parameters></optional-capabilities>" +
                "<optional-capabilities><c-parameters><as4-bytes-capability>" +
                "<as-number>33</as-number></as4-bytes-capability>" +
                "</c-parameters></optional-capabilities>" +
                "</bgp-parameters></attributes></filter>";
    }

    /**
     * Returns the xml string for ych-purchasingsupervisor module.
     *
     * @return the XML string for ych-purchasingsupervisor module
     */
    private static String purchaseXml() {
        return "<config xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" " +
                "xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\">" +
                "<ych-purchasing-supervisor xmlns=\"ych.purchasing-supervisor\" " +
                "nc:operation=\"create\">" +
                "<ych-purchasing-specialist>purchasingSpecialist" +
                "</ych-purchasing-specialist>" +
                "<ych-purchasing-support>support</ych-purchasing-support>" +
                "</ych-purchasing-supervisor>" +
                "</config>";
    }

    /**
     * Returns the xml string for employeeid module.
     *
     * @return the xml string for employeeid module
     */
    private static String emplyIdXml() {
        return "<config xmlns=\"ydt.root\">" +
                "<employeeid xmlns=\"ydt.employee-id\">" +
                "<employeeid>Employ1</employeeid>" +
                "<employeeid>Employ2</employeeid>" +
                "<employeeid>Employ3</employeeid>" +
                "<employeeid>Employ4</employeeid>" +
                "<employeeid>Employ5</employeeid>" +
                "</employeeid>" +
                "</config>";
    }

    /**
     * Returns the xml string for warehousesupervisor module.
     *
     * @return the xml string for warehousesupervisor module
     */
    private static String wareHseXml() {
        return "<config xmlns=\"ydt.root\">" +
                "<warehousesupervisor xmlns=\"ydt.warehouse-supervisor\">" +
                "<supervisor>supervisor1</supervisor>" +
                "<supervisor>supervisor2</supervisor>" +
                "<supervisor>supervisor3</supervisor>" +
                "<supervisor>supervisor4</supervisor>" +
                "<supervisor>supervisor5</supervisor>" +
                "</warehousesupervisor>" +
                "</config>";
    }

    /**
     * Returns the xml string for more than one module.
     *
     * @return the xml string for more than one module
     */
    private static String multiModuleXml() {
        return "<config xmlns=\"ydt.root\">" +
                "<customssupervisor xmlns=\"ydt.customs-supervisor\">" +
                "<supervisor>Customssupervisor</supervisor>" +
                "</customssupervisor>" +
                "<merchandisersupervisor xmlns=\"ydt.Merchandiser-supervisor\">" +
                "<supervisor>Merchandisersupervisor</supervisor>" +
                "</merchandisersupervisor>" +
                "<materialsupervisor xmlns=\"ydt.material-supervisor\">" +
                "<supervisor>" +
                "<name>abc1</name>" +
                "<departmentId>xyz1</departmentId>" +
                "</supervisor>" +
                "<supervisor>" +
                "<name>abc2</name>" +
                "<departmentId>xyz2</departmentId>" +
                "</supervisor>" +
                "<supervisor>" +
                "<name>abc3</name>" +
                "<departmentId>xyz3</departmentId>" +
                "</supervisor>" +
                "<supervisor>" +
                "<name>abc4</name>" +
                "<departmentId>xyz4</departmentId>" +
                "</supervisor>" +
                "<supervisor>" +
                "<name>abc5</name>" +
                "<departmentId>xyz5</departmentId>" +
                "</supervisor>" +
                "</materialsupervisor>" +
                "<ych-purchasingsupervisor xmlns=\"ych.purchasing-supervisor\">" +
                "<ych-purchasing-supervisor>" +
                "<ych-purchasing-specialist>purchasingSpecialist" +
                "</ych-purchasing-specialist>" +
                "<ych-purchasing-support>support</ych-purchasing-support>" +
                "</ych-purchasing-supervisor>" +
                "</ych-purchasingsupervisor>" +
                "<warehousesupervisor xmlns=\"ydt.warehouse-supervisor\">" +
                "<supervisor>supervisor1</supervisor>" +
                "<supervisor>supervisor2</supervisor>" +
                "<supervisor>supervisor3</supervisor>" +
                "<supervisor>supervisor4</supervisor>" +
                "<supervisor>supervisor5</supervisor>" +
                "</warehousesupervisor>" +
                "<tradingsupervisor xmlns=\"ydt.trading-supervisor\">" +
                "<supervisor>Tradingsupervisor</supervisor>" +
                "</tradingsupervisor>" +
                "<employeeid xmlns=\"ydt.employee-id\">" +
                "<employeeid>Employ1</employeeid>" +
                "<employeeid>Employ2</employeeid>" +
                "<employeeid>Employ3</employeeid>" +
                "<employeeid>Employ4</employeeid>" +
                "<employeeid>Employ5</employeeid>" +
                "</employeeid>" +
                "</config>";
    }

    /**
     * Returns the xml string for more than one module.
     *
     * @return the xml string for more than one module
     */
    private String multipleAppxml() {
        return "<filter xmlns=\"ydt.filter-type\" type=\"subtree\"><supervisor" +
                " xmlns=\"ydt.customs-supervisor\">Customssupervisor" +
                "</supervisor><supervisor xmlns=\"ydt.material-supervisor\"" +
                "><name>abc1</name><departmentId>xyz1</departmentId" +
                "></supervisor><supervisor xmlns=\"ydt.material-supervisor\">" +
                "<name>abc2</name><departmentId>xyz2</departmentId>" +
                "</supervisor><supervisor xmlns=\"ydt" +
                ".material-supervisor\"><name>abc3</name><departmentId>xyz3" +
                "</departmentId></supervisor><supervisor xmlns=\"ydt" +
                ".material-supervisor\"><name>abc4</name><departmentId>xyz4" +
                "</departmentId></supervisor><supervisor xmlns=\"ydt" +
                ".material-supervisor\"><name>abc5</name><departmentId>xyz5" +
                "</departmentId></supervisor></filter>";
    }

    /**
     * Unit test case in which verifying xml string for module object with leaf
     * for composite encode.
     */
    @Test
    public void proceessCodecHandlerForCompositeEnc() {
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry = testYangSchemaNodeProvider
                .getDefaultYangSchemaRegistry();

        // Creating the object
        Object object = CustomssupervisorOpParam.builder()
                .supervisor("Customssupervisor").build();

        // Get the xml string and compare
        Map<String, String> tagAttr = new HashMap<String, String>();
        tagAttr.put("type", "subtree");

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler defaultYangCodecHandler =
                new DefaultYangCodecHandler(schemaRegistry);
        YangCompositeEncoding xml =
                defaultYangCodecHandler
                        .encodeCompositeOperation("filter", "ydt.filter-type",
                                                  object, XML, null);

        assertNull("customs-super: resource id not null",
                   xml.getResourceIdentifier());
        assertEquals(AM_XML + "customs-super: comp res info",
                     customsCompositeXml(), xml.getResourceInformation());

        // Creating the object
        object = MerchandisersupervisorOpParam.builder()
                .supervisor("Merchandisersupervisor").build();

        // Get the xml string and compare
        xml = defaultYangCodecHandler.encodeCompositeOperation("config",
                                                               "ydt.root",
                                                               object, XML,
                                                               null);
        assertNull("merch-super: res id not null", xml.getResourceIdentifier());
        assertEquals(AM_XML + "merch-super: comp res info",
                     merchandXml(), xml.getResourceInformation());

        // Creating the object
        object = TradingsupervisorOpParam.builder()
                .supervisor("Tradingsupervisor").build();

        // Get the xml string and compare
        xml = defaultYangCodecHandler
                .encodeCompositeOperation("config", "ydt.root", object, XML,
                                          null);
        assertNull("trading-super: res id not null",
                   xml.getResourceIdentifier());
        assertEquals(AM_XML + "trading-super: comp res info",
                     tradingXml(), xml.getResourceInformation());
    }

    /**
     * Unit test case in which verifying xml string for module object with leaf.
     */
    @Test
    public void proceessCodecHandlerForLeaf() {
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry = testYangSchemaNodeProvider
                .getDefaultYangSchemaRegistry();
        List<Object> yangModuleList = new ArrayList<>();

        // Creating the object
        Object object = CustomssupervisorOpParam.builder()
                .supervisor("Customssupervisor").build();
        yangModuleList.add(object);

        // Get the xml string and compare
        Map<String, String> tagAttr = new HashMap<String, String>();
        tagAttr.put("type", "subtree");

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler defaultYangCodecHandler =
                new DefaultYangCodecHandler(schemaRegistry);
        String xml =
                defaultYangCodecHandler.encodeOperation("filter",
                                                        "ydt.filter-type",
                                                        tagAttr, yangModuleList,
                                                        XML, null);

        assertEquals(AM_XML + "customs-super: leaf info", customsXml(), xml);

        // Creating the object
        object = MerchandisersupervisorOpParam.builder()
                .supervisor("Merchandisersupervisor").build();
        yangModuleList.clear();
        yangModuleList.add(object);

        // Get the xml string and compare
        xml = defaultYangCodecHandler.encodeOperation("config", "ydt.root",
                                                      null, yangModuleList,
                                                      XML, null);
        assertEquals(AM_XML + "merchandiser-super: leaf info", merchandXml(),
                     xml);

        // Creating the object
        object = TradingsupervisorOpParam.builder()
                .supervisor("Tradingsupervisor").build();
        yangModuleList.clear();
        yangModuleList.add(object);

        // Get the xml string and compare
        xml = defaultYangCodecHandler.encodeOperation("config", "ydt.root",
                                                      null, yangModuleList,
                                                      XML, null);
        assertEquals(AM_XML + "trading-super: leaf info", tradingXml(), xml);
    }

    /**
     * Unit test case in which verifying xml string for module object with
     * empty leaf.
     */
    @Test
    public void proceessCodecHandlerForEmptyLeaf() {
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry = testYangSchemaNodeProvider
                .getDefaultYangSchemaRegistry();
        List<Object> yangModuleList = new ArrayList<>();

        // Creating the object
        Object object = CustomssupervisorOpParam.builder().supervisor("")
                .build();
        yangModuleList.add(object);

        // Get the xml string and compare
        Map<String, String> tagAttr = new HashMap<String, String>();
        tagAttr.put("type", "subtree");

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler codecHandler =
                new DefaultYangCodecHandler(schemaRegistry);
        String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
                                                  tagAttr, yangModuleList,
                                                  XML, null);

        assertEquals(AM_XML + "customs-super: leaf is not empty",
                     customsEmptyXml(), xml);
    }

    /**
     * Unit test case in which verifying xml string for more than one module
     * object.
     */
    @Test
    public void proceessCodecHandlerForMultipleApp() {
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry = testYangSchemaNodeProvider
                .getDefaultYangSchemaRegistry();
        List<Object> yangModuleList = new ArrayList<>();

        // Creating the object
        Object object = CustomssupervisorOpParam.builder()
                .supervisor("Customssupervisor").build();
        yangModuleList.add(object);

        // Creating the object
        Supervisor supervisor1 = new DefaultSupervisor.SupervisorBuilder()
                .name("abc1").departmentId("xyz1").build();
        Supervisor supervisor2 = new DefaultSupervisor.SupervisorBuilder()
                .name("abc2").departmentId("xyz2").build();
        Supervisor supervisor3 = new DefaultSupervisor.SupervisorBuilder()
                .name("abc3").departmentId("xyz3").build();
        Supervisor supervisor4 = new DefaultSupervisor.SupervisorBuilder()
                .name("abc4").departmentId("xyz4").build();
        Supervisor supervisor5 = new DefaultSupervisor.SupervisorBuilder()
                .name("abc5").departmentId("xyz5").build();

        Object object1 = MaterialsupervisorOpParam.builder()
                .addToSupervisor(supervisor1)
                .addToSupervisor(supervisor2)
                .addToSupervisor(supervisor3)
                .addToSupervisor(supervisor4)
                .addToSupervisor(supervisor5).build();
        yangModuleList.add(object1);

        // Get the xml string and compare
        Map<String, String> tagAttr = new HashMap<String, String>();
        tagAttr.put("type", "subtree");

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler codecHandler =
                new DefaultYangCodecHandler(schemaRegistry);
        String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
                                                  tagAttr, yangModuleList,
                                                  XML, null);

        assertEquals(AM_XML + "for multiple applications",
                     multipleAppxml(), xml);
    }

    /**
     * Unit test case in which verifying xml string for module object with list.
     */
    @Test
    public void proceessCodecHandlerForList() {
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry =
                testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
        List<Object> yangModuleList = new ArrayList<>();

        // Creating the object
        Supervisor supervisor1 = new DefaultSupervisor.SupervisorBuilder()
                .name("abc1").departmentId("xyz1").build();
        Supervisor supervisor2 = new DefaultSupervisor.SupervisorBuilder()
                .name("abc2").departmentId("xyz2").build();
        Supervisor supervisor3 = new DefaultSupervisor.SupervisorBuilder()
                .name("abc3").departmentId("xyz3").build();
        Supervisor supervisor4 = new DefaultSupervisor.SupervisorBuilder()
                .name("abc4").departmentId("xyz4").build();
        Supervisor supervisor5 = new DefaultSupervisor.SupervisorBuilder()
                .name("abc5").departmentId("xyz5").build();

        Object object = MaterialsupervisorOpParam.builder()
                .addToSupervisor(supervisor1)
                .addToSupervisor(supervisor2)
                .addToSupervisor(supervisor3)
                .addToSupervisor(supervisor4)
                .addToSupervisor(supervisor5).build();

        yangModuleList.add(object);

        // Get the xml string and compare
        Map<String, String> tagAttr = new HashMap<String, String>();
        tagAttr.put("type", "subtree");

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler codecHandler =
                new DefaultYangCodecHandler(schemaRegistry);
        String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
                                                  tagAttr, yangModuleList,
                                                  XML, null);
        assertEquals(AM_XML + "material-super: list info", materialXml(), xml);
    }

    /**
     * Unit test case in which verifying xml string for module object with
     * empty container.
     */
    @Test
    public void proceessCodecHandlerForEmptyContainer() {
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry =
                testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
        List<Object> yangModuleList = new ArrayList<>();

        // Creating the object
        EmptyContainer emptyContainer = EmptyContainerOpParam.builder()
                .emptyContainer();
        Object object = EmptyContainerOpParam.builder()
                .emptyContainer(emptyContainer).build();

        yangModuleList.add(object);

        // Get the xml string and compare
        Map<String, String> tagAttr = new HashMap<String, String>();
        tagAttr.put("type", "subtree");

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler codecHandler =
                new DefaultYangCodecHandler(schemaRegistry);
        String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
                                                  tagAttr, yangModuleList,
                                                  XML, null);
        assertEquals(AM_XML + "empty-contain: container is not empty",
                     containerEmptyXml(), xml);
    }

    /**
     * Unit test case in which verifying xml string for module object with list
     * inside list.
     */
    @Test
    public void proceessCodecHandlerForListInsideList() {
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry =
                testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
        List<Object> yangModuleList = new ArrayList<>();

        // Creating the object
        PathId pathId = new PathId(123);
        Origin origin = new DefaultOrigin.OriginBuilder().value(pathId)
                .build();
        MultiExitDisc multiExitDisc = new DefaultMultiExitDisc
                .MultiExitDiscBuilder().med(456).build();
        LocalPref localPref = new DefaultLocalPref.LocalPrefBuilder()
                .pref(23).build();
        Metric metric = new Metric(456);
        AigpTlv aigpTlv = new DefaultAigpTlv.AigpTlvBuilder().metric(metric)
                .build();
        Aigp aigp = new DefaultAigp.AigpBuilder().aigpTlv(aigpTlv).build();

        UnrecognizedAttributes unrecognizedAttributes1 =
                new DefaultUnrecognizedAttributes
                        .UnrecognizedAttributesBuilder()
                        .partial(false).transitive(false).type((short) 1)
                        .value("ABC".getBytes()).build();

        UnrecognizedAttributes unrecognizedAttributes2 =
                new DefaultUnrecognizedAttributes
                        .UnrecognizedAttributesBuilder()
                        .partial(true).transitive(true).type((short) 2)
                        .value("ABC".getBytes())
                        .build();

        UnrecognizedAttributes unrecognizedAttributes3 =
                new DefaultUnrecognizedAttributes
                        .UnrecognizedAttributesBuilder()
                        .partial(true).transitive(false).type((short) 3)
                        .value("ABC".getBytes())
                        .build();

        UnrecognizedAttributes unrecognizedAttributes4 =
                new DefaultUnrecognizedAttributes
                        .UnrecognizedAttributesBuilder()
                        .partial(false).transitive(true).type((short) 4)
                        .value("ABC".getBytes()).build();

        AsNum asNum1 = new AsNum(11);
        As4BytesCapability as4BytesCapability1 =
                new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
                        .asNumber(asNum1).build();
        Cparameters cparameters1 = new DefaultCparameters.CparametersBuilder()
                .as4BytesCapability(as4BytesCapability1)
                .build();
        OptionalCapabilities optionalCapabilities1 =
                new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
                        .cParameters(cparameters1).build();

        AsNum asNum2 = new AsNum(22);
        As4BytesCapability as4BytesCapability2 =
                new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
                        .asNumber(asNum2).build();
        Cparameters cparameters2 = new DefaultCparameters.CparametersBuilder()
                .as4BytesCapability(as4BytesCapability2)
                .build();
        OptionalCapabilities optionalCapabilities2 =
                new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
                        .cParameters(cparameters2).build();

        AsNum asNum3 = new AsNum(33);
        As4BytesCapability as4BytesCapability3 =
                new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
                        .asNumber(asNum3).build();
        Cparameters cparameters3 = new DefaultCparameters.CparametersBuilder()
                .as4BytesCapability(as4BytesCapability3)
                .build();
        OptionalCapabilities optionalCapabilities3 =
                new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
                        .cParameters(cparameters3).build();

        BgpParameters bgpParameters1 =
                new DefaultBgpParameters.BgpParametersBuilder()
                        .addToOptionalCapabilities(optionalCapabilities1)
                        .addToOptionalCapabilities(optionalCapabilities2)
                        .addToOptionalCapabilities(optionalCapabilities3)
                        .build();

        AsNum asNum4 = new AsNum(11);
        As4BytesCapability as4BytesCapability4 = new DefaultAs4BytesCapability
                .As4BytesCapabilityBuilder()
                .asNumber(asNum4).build();
        Cparameters cparameters4 = new DefaultCparameters.CparametersBuilder()
                .as4BytesCapability(as4BytesCapability4)
                .build();
        OptionalCapabilities optionalCapabilities4 =
                new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
                        .cParameters(cparameters4).build();

        AsNum asNum5 = new AsNum(22);
        As4BytesCapability as4BytesCapability5 =
                new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
                        .asNumber(asNum5).build();
        Cparameters cparameters5 =
                new DefaultCparameters.CparametersBuilder()
                        .as4BytesCapability(as4BytesCapability5)
                        .build();
        OptionalCapabilities optionalCapabilities5 =
                new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
                        .cParameters(cparameters5).build();

        AsNum asNum6 = new AsNum(33);
        As4BytesCapability as4BytesCapability6 =
                new DefaultAs4BytesCapability.As4BytesCapabilityBuilder()
                        .asNumber(asNum6).build();
        Cparameters cparameters6 =
                new DefaultCparameters.CparametersBuilder()
                        .as4BytesCapability(as4BytesCapability6)
                        .build();
        OptionalCapabilities optionalCapabilities6 =
                new DefaultOptionalCapabilities.OptionalCapabilitiesBuilder()
                        .cParameters(cparameters6).build();

        BgpParameters bgpParameters2 =
                new DefaultBgpParameters.BgpParametersBuilder()
                        .addToOptionalCapabilities(optionalCapabilities4)
                        .addToOptionalCapabilities(optionalCapabilities5)
                        .addToOptionalCapabilities(optionalCapabilities6)
                        .build();

        Attributes attributes = new DefaultAttributes.AttributesBuilder()
                .origin(origin)
                .multiExitDisc(multiExitDisc)
                .localPref(localPref)
                .aigp(aigp)
                .addToUnrecognizedAttributes(unrecognizedAttributes1)
                .addToUnrecognizedAttributes(unrecognizedAttributes2)
                .addToUnrecognizedAttributes(unrecognizedAttributes3)
                .addToUnrecognizedAttributes(unrecognizedAttributes4)
                .addToBgpParameters(bgpParameters1)
                .addToBgpParameters(bgpParameters2).build();
        Object object = CombinedOpParam.builder().attributes(attributes)
                .build();

        yangModuleList.add(object);

        // Get the xml string and compare
        Map<String, String> tagAttr = new HashMap<String, String>();
        tagAttr.put("type", "subtree");

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler codecHandler =
                new DefaultYangCodecHandler(schemaRegistry);
        String xml = codecHandler.encodeOperation("filter", "ydt.filter-type",
                                                  tagAttr, yangModuleList,
                                                  XML, null);
        assertEquals(AM_XML + "combined: list info", listTestXml(), xml);
    }

//    TODO negative scenario will be handled later
    /**
     * Unit test case in which verifying xml string for module object with
     * container.
     */
    @Test
    public void proceessCodecHandlerForContainer() {
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry =
                testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
        List<Object> yangModuleList = new ArrayList<>();

        // Creating the object
        YchPurchasingSupervisor supervisor =
                new DefaultYchPurchasingSupervisor
                        .YchPurchasingSupervisorBuilder()
                        .ychPurchasingSpecialist("purchasingSpecialist")
                        .ychPurchasingSupport("support")
                        .yangYchPurchasingSupervisorOpType(OnosYangOpType.CREATE).build();
        Object object = YchPurchasingsupervisorOpParam.builder()
                .ychPurchasingSupervisor(supervisor).build();
        yangModuleList.add(object);

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler codecHandler =
                new DefaultYangCodecHandler(schemaRegistry);
        String xml = codecHandler.encodeOperation("config", "urn:ietf:params:xml:ns:netconf:base:1.0",
                                                  null, yangModuleList,
                                                  XML, null);
        assertEquals(AM_XML + "puchas-super: container info", purchaseXml(),
                     xml);
    }

//    /**
//     * Unit test case in which verifying xml string for module object with
//     * leaf list.
//     */
//    @Test
//    public void proceessCodecHandlerForLeafList() {
//        testYangSchemaNodeProvider.processSchemaRegistry(null);
//        DefaultYangSchemaRegistry schemaRegistry =
//                testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
//        List<Object> yangModuleList = new ArrayList<>();
//
//        // Creating the object
//        EmployeeidOpParam.EmployeeidBuilder employeeidBuilder =
//                EmployeeidOpParam.builder();
//        employeeidBuilder.addToEmployeeid("Employ1");
//        employeeidBuilder.addToEmployeeid("Employ2");
//        employeeidBuilder.addToEmployeeid("Employ3");
//        employeeidBuilder.addToEmployeeid("Employ4");
//        employeeidBuilder.addToEmployeeid("Employ5");
//
//        Object object = employeeidBuilder.build();
//        yangModuleList.add(object);
//
//        // Get the xml string and compare
//        YangCodecRegistry.initializeDefaultCodec();
//        DefaultYangCodecHandler codecHandler =
//                new DefaultYangCodecHandler(schemaRegistry);
//        String xml = codecHandler.encodeOperation("config", "ydt.root", null,
//                                                  yangModuleList, XML, null);
//        assertEquals(AM_XML + "employ-id: leaf-list info", emplyIdXml(), xml);
//        WarehousesupervisorOpParam.WarehousesupervisorBuilder warehsebldr =
//                WarehousesupervisorOpParam.builder();
//        warehsebldr.addToSupervisor("supervisor1");
//        warehsebldr.addToSupervisor("supervisor2");
//        warehsebldr.addToSupervisor("supervisor3");
//        warehsebldr.addToSupervisor("supervisor4");
//        warehsebldr.addToSupervisor("supervisor5");
//
//        object = warehsebldr.build();
//        yangModuleList.clear();
//        yangModuleList.add(object);
//
//
//        // Get the xml string and compare
//        xml = codecHandler.encodeOperation("config", "ydt.root", null,
//                                           yangModuleList, XML, null);
//
//        assertEquals(AM_XML + "warehouse-super: leaf-list info", wareHseXml(),
//                     xml);
//    }

//    /**
//     * Unit test case in which verifying xml string for multiple module object.
//     */
//    @Test
//    public void proceessCodecHandlerForMultipleModule() {
//        testYangSchemaNodeProvider.processSchemaRegistry(null);
//        DefaultYangSchemaRegistry schemaRegistry =
//                testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
//
//        List<Object> yangModuleList = new ArrayList<>();
//        YangCodecRegistry.initializeDefaultCodec();
//        DefaultYangCodecHandler codecHandler =
//                new DefaultYangCodecHandler(schemaRegistry);
//
//        // Creating the object for customssupervisor module
//        Object object = CustomssupervisorOpParam.builder()
//                .supervisor("Customssupervisor").build();
//        yangModuleList.add(object);
//
//        // Creating the object for merchandisersupervisor module
//        object = MerchandisersupervisorOpParam.builder()
//                .supervisor("Merchandisersupervisor").build();
//        yangModuleList.add(object);
//
//        // Creating the object for materialsupervisor module
//        Supervisor supervisor1 = new DefaultSupervisor.SupervisorBuilder()
//                .name("abc1").departmentId("xyz1").build();
//        Supervisor supervisor2 = new DefaultSupervisor.SupervisorBuilder()
//                .name("abc2").departmentId("xyz2").build();
//        Supervisor supervisor3 = new DefaultSupervisor.SupervisorBuilder()
//                .name("abc3").departmentId("xyz3").build();
//        Supervisor supervisor4 = new DefaultSupervisor.SupervisorBuilder()
//                .name("abc4").departmentId("xyz4").build();
//        Supervisor supervisor5 = new DefaultSupervisor.SupervisorBuilder()
//                .name("abc5").departmentId("xyz5").build();
//
//        object = MaterialsupervisorOpParam.builder()
//                .addToSupervisor(supervisor1)
//                .addToSupervisor(supervisor2)
//                .addToSupervisor(supervisor3)
//                .addToSupervisor(supervisor4)
//                .addToSupervisor(supervisor5).build();
//
//        yangModuleList.add(object);
//
//        // Creating the object for YchPurchasingsupervisor module
//        YchPurchasingSupervisor purSupervisor =
//                new DefaultYchPurchasingSupervisor
//                        .YchPurchasingSupervisorBuilder()
//                        .ychPurchasingSpecialist("purchasingSpecialist")
//                        .ychPurchasingSupport("support").build();
//        object = YchPurchasingsupervisorOpParam.builder()
//                .ychPurchasingSupervisor(purSupervisor).build();
//        yangModuleList.add(object);
//
//        // Creating the object for warehousesupervisor module
//        WarehousesupervisorOpParam.WarehousesupervisorBuilder warehsebldr =
//                WarehousesupervisorOpParam.builder();
//        warehsebldr.addToSupervisor("supervisor1");
//        warehsebldr.addToSupervisor("supervisor2");
//        warehsebldr.addToSupervisor("supervisor3");
//        warehsebldr.addToSupervisor("supervisor4");
//        warehsebldr.addToSupervisor("supervisor5");
//
//        object = warehsebldr.build();
//        yangModuleList.add(object);
//
//        // Creating the object for tradingsupervisor module
//        object = TradingsupervisorOpParam.builder()
//                .supervisor("Tradingsupervisor").build();
//        yangModuleList.add(object);
//
//        List<String> employeeid = EmployeeidOpParam.builder().employeeid();
//        if (employeeid == null) {
//            employeeid = new ArrayList<>();
//        }
//        employeeid.add("Employ1");
//        employeeid.add("Employ2");
//        employeeid.add("Employ3");
//        employeeid.add("Employ4");
//        employeeid.add("Employ5");
//
//        // Creating the object for employeeid module
//        object = EmployeeidOpParam.builder().employeeid(employeeid).build();
//        yangModuleList.add(object);
//
//        // Get the xml string and compare
//        String xml = codecHandler.encodeOperation("config", "ydt.root", null,
//                                                  yangModuleList, XML, null);
//        assertEquals(AM_XML + "multiple: module info", multiModuleXml(), xml);
//    }

    /**
     * Unit test case in which verifying object for xml string with config as
     * root name and multiple module.
     */
    @Test
    public void proceessCodecDecodeFunctionForListInsideList() {
        String path = "src/test/resources/ychTestResourceFiles/combinedrootname.xml";
        StringBuilder sb = new StringBuilder();
        String sCurrentLine;
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry =
                testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler defaultYangCodecHandler =
                new DefaultYangCodecHandler(schemaRegistry);

        try (BufferedReader br = new BufferedReader(new FileReader(path))) {

            while ((sCurrentLine = br.readLine()) != null) {
                sb.append(sCurrentLine);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        // TODO YOB and YTB need to do some changes for binary
        // Verify the received object list
        /*objectList = defaultYangCodecHandler.decode(sb.toString(),
                                                    XML_ENCODING,
                                                    EDIT_CONFIG_REQUEST);
        Iterator<Object> iterator = objectList.iterator();
        while (iterator.hasNext()) {
            Object object = iterator.next();
            if (object.getClass().getSimpleName().equals("CombinedOpParam")) {
                CombinedOpParam combinedOpParam = (CombinedOpParam) object;

                PathId pathId = new PathId(123);
                Origin origin = new DefaultOrigin.OriginBuilder()
                        .value(pathId).build();
                assertTrue(combinedOpParam.attributes().origin()
                                   .equals(origin));

                MultiExitDisc multiExitDisc = new DefaultMultiExitDisc
                        .MultiExitDiscBuilder().med(456).build();
                assertTrue(combinedOpParam.attributes().multiExitDisc()
                                   .equals(multiExitDisc));

                LocalPref localPref = new DefaultLocalPref.LocalPrefBuilder()
                        .pref(23).build();
                assertTrue(combinedOpParam.attributes().localPref()
                                   .equals(localPref));

                Metric metric = new Metric(456);
                AigpTlv aigpTlv = new DefaultAigpTlv.AigpTlvBuilder()
                        .metric(metric).build();
                Aigp aigp = new DefaultAigp.AigpBuilder().aigpTlv(aigpTlv)
                        .build();
                assertTrue(combinedOpParam.attributes().aigp().equals(aigp));

                UnrecognizedAttributes unrecognizedAttributes1 =
                        new DefaultUnrecognizedAttributes
                                .UnrecognizedAttributesBuilder()
                                .partial(false).transitive(false).type((short) 1)
                                .value("ABC".getBytes()).build();

                UnrecognizedAttributes unrecognizedAttributes2 =
                        new DefaultUnrecognizedAttributes
                                .UnrecognizedAttributesBuilder()
                                .partial(true).transitive(true).type((short) 2)
                                .value("BCA".getBytes()).build();

                UnrecognizedAttributes unrecognizedAttributes3 =
                        new DefaultUnrecognizedAttributes
                                .UnrecognizedAttributesBuilder()
                                .partial(true).transitive(false).type((short) 3)
                                .value("CAB".getBytes()).build();

                UnrecognizedAttributes unrecognizedAttributes4 =
                        new DefaultUnrecognizedAttributes
                                .UnrecognizedAttributesBuilder()
                                .partial(false).transitive(true).type((short) 4)
                                .value("111".getBytes()).build();

                AsNum asNum1 = new AsNum(11);
                As4BytesCapability as4BytesCapability1 =
                        new DefaultAs4BytesCapability
                                .As4BytesCapabilityBuilder()
                                .asNumber(asNum1).build();
                Cparameters cparameters1 = new DefaultCparameters
                        .CparametersBuilder()
                        .as4BytesCapability(as4BytesCapability1)
                        .build();
                OptionalCapabilities optionalCapabilities1 =
                        new DefaultOptionalCapabilities
                                .OptionalCapabilitiesBuilder()
                                .cParameters(cparameters1).build();

                AsNum asNum2 = new AsNum(22);
                As4BytesCapability as4BytesCapability2 =
                        new DefaultAs4BytesCapability
                                .As4BytesCapabilityBuilder()
                                .asNumber(asNum2).build();
                Cparameters cparameters2 = new DefaultCparameters
                        .CparametersBuilder()
                        .as4BytesCapability(as4BytesCapability2)
                        .build();
                OptionalCapabilities optionalCapabilities2 =
                        new DefaultOptionalCapabilities
                                .OptionalCapabilitiesBuilder()
                                .cParameters(cparameters2).build();

                AsNum asNum3 = new AsNum(33);
                As4BytesCapability as4BytesCapability3 =
                        new DefaultAs4BytesCapability
                                .As4BytesCapabilityBuilder()
                                .asNumber(asNum3).build();
                Cparameters cparameters3 =
                        new DefaultCparameters.CparametersBuilder()
                                .as4BytesCapability(as4BytesCapability3)
                                .build();
                OptionalCapabilities optionalCapabilities3 =
                        new DefaultOptionalCapabilities
                                .OptionalCapabilitiesBuilder()
                                .cParameters(cparameters3).build();

                BgpParameters bgpParameters1 =
                        new DefaultBgpParameters.BgpParametersBuilder()
                                .addToOptionalCapabilities(optionalCapabilities1)
                                .addToOptionalCapabilities(optionalCapabilities2)
                                .addToOptionalCapabilities(optionalCapabilities3)
                                .build();

                AsNum asNum4 = new AsNum(11);
                As4BytesCapability as4BytesCapability4 =
                        new DefaultAs4BytesCapability
                                .As4BytesCapabilityBuilder()
                                .asNumber(asNum4).build();
                Cparameters cparameters4 =
                        new DefaultCparameters.CparametersBuilder()
                                .as4BytesCapability(as4BytesCapability4)
                                .build();
                OptionalCapabilities optionalCapabilities4 =
                        new DefaultOptionalCapabilities
                                .OptionalCapabilitiesBuilder()
                                .cParameters(cparameters4).build();

                AsNum asNum5 = new AsNum(22);
                As4BytesCapability as4BytesCapability5 =
                        new DefaultAs4BytesCapability
                                .As4BytesCapabilityBuilder()
                                .asNumber(asNum5).build();
                Cparameters cparameters5 =
                        new DefaultCparameters.CparametersBuilder()
                                .as4BytesCapability(as4BytesCapability5)
                                .build();
                OptionalCapabilities optionalCapabilities5 =
                        new DefaultOptionalCapabilities
                                .OptionalCapabilitiesBuilder()
                                .cParameters(cparameters5).build();

                AsNum asNum6 = new AsNum(33);
                As4BytesCapability as4BytesCapability6 =
                        new DefaultAs4BytesCapability
                                .As4BytesCapabilityBuilder()
                                .asNumber(asNum6).build();
                Cparameters cparameters6 =
                        new DefaultCparameters.CparametersBuilder()
                                .as4BytesCapability(as4BytesCapability6)
                                .build();
                OptionalCapabilities optionalCapabilities6 =
                        new DefaultOptionalCapabilities
                                .OptionalCapabilitiesBuilder()
                                .cParameters(cparameters6).build();

                BgpParameters bgpParameters2 =
                        new DefaultBgpParameters.BgpParametersBuilder()
                                .addToOptionalCapabilities(optionalCapabilities4)
                                .addToOptionalCapabilities(optionalCapabilities5)
                                .addToOptionalCapabilities(optionalCapabilities6)
                                .build();

                Attributes attributes =
                        new DefaultAttributes.AttributesBuilder()
                                .origin(origin)
                                .multiExitDisc(multiExitDisc)
                                .localPref(localPref)
                                .aigp(aigp)
                                .addToUnrecognizedAttributes(unrecognizedAttributes1)
                                .addToUnrecognizedAttributes(unrecognizedAttributes2)
                                .addToUnrecognizedAttributes(unrecognizedAttributes3)
                                .addToUnrecognizedAttributes(unrecognizedAttributes4)
                                .addToBgpParameters(bgpParameters1)
                                .addToBgpParameters(bgpParameters2).build();
            } else {
                assertTrue(false);
            }
        }*/
    }

//    /**
//     * Unit test case in which verifying object for xml string with config as root name and
//     * operation type.
//     */
//    @Test
//    public void proceessCodecDecodeFunctionForOperTypeTest() {
//        String path = "src/test/resources/ychTestResourceFiles/configrootnameOperationType.xml";
//        testYangSchemaNodeProvider.processSchemaRegistry(null);
//        DefaultYangSchemaRegistry schemaRegistry =
//                testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();
//
//        YangCodecRegistry.initializeDefaultCodec();
//        DefaultYangCodecHandler defaultYangCodecHandler =
//                new DefaultYangCodecHandler(schemaRegistry);
//
//        StringBuilder sb = new StringBuilder();
//        String sCurrentLine;
//
//        try (BufferedReader br = new BufferedReader(new FileReader(path))) {
//
//            while ((sCurrentLine = br.readLine()) != null) {
//                sb.append(sCurrentLine);
//            }
//
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//
//        // Verify the received object list
//        List<Object> objectList =
//                defaultYangCodecHandler.decode(sb.toString(),
//                                               XML, EDIT_CONFIG_REQUEST);
//        Iterator<Object> iterator = objectList.iterator();
//        while (iterator.hasNext()) {
//            Object object = iterator.next();
//            if (object.getClass().getSimpleName()
//                    .equals(LOGISTIC_MOD)) {
//                LogisticsManagerOpParam logistics =
//                        (LogisticsManagerOpParam) object;
//                DefaultPurchasingSupervisor purchasingSupervisor =
//                        (DefaultPurchasingSupervisor) logistics
//                                .purchasingSupervisor();
//
//                assertEquals(AM_OBJ + "purchase-super: operation type", DELETE,
//                             purchasingSupervisor.yangPurchasingSupervisorOpType());
//                assertEquals(AM_OBJ + "customs-super: leaf value", "abc",
//                             logistics.customsSupervisor());
//                assertEquals(AM_OBJ + "purchase-spec: leaf value", "bcd",
//                             logistics.purchasingSupervisor()
//                                     .purchasingSpecialist());
//                assertEquals(AM_OBJ + "purchase-support: leaf value",
//                             "cde", logistics.purchasingSupervisor()
//                                     .support());
//
//            } else if (object.getClass().getSimpleName()
//                    .equals(MERCHA_MOD)) {
//                MerchandisersupervisorOpParam merchandisersupervisorOpParam =
//                        (MerchandisersupervisorOpParam) object;
//                assertEquals(AM_OBJ + "merchandiser-super: leaf value",
//                             "abc", merchandisersupervisorOpParam.supervisor());
//            } else {
//                assertEquals(AM_OBJ, LOGISTIC_MOD, object
//                        .getClass().getSimpleName());
//                assertEquals(AM_OBJ, MERCHA_MOD, object
//                        .getClass().getSimpleName());
//            }
//        }
//    }

    /**
     * Validate the leaf value for purchasing specialist.
     *
     * @param objectList object list
     */
    private void processPurchasingSpecObj(List<Object> objectList) {
        Iterator<Object> iterator = objectList.iterator();
        while (iterator.hasNext()) {
            Object object = iterator.next();
            if (object.getClass().getSimpleName()
                    .equals("LogisticsManagerOpParam")) {
                LogisticsManagerOpParam logisticsManagerOpParam =
                        (LogisticsManagerOpParam) object;
                assertEquals(AM_OBJ + "purchasing-spec: leaf value", "bcd",
                             logisticsManagerOpParam.purchasingSupervisor()
                                     .purchasingSpecialist());
            } else {
                assertEquals(AM_OBJ, "LogisticsManagerOpParam", object
                        .getClass().getSimpleName());
            }
        }
    }

    /**
     * Validate the leaf value for merchandiser supervisor.
     *
     * @param objectList object list
     */
    private void processMerchandiserObj(List<Object> objectList) {
        Iterator<Object> iterator = objectList.iterator();
        while (iterator.hasNext()) {
            Object object = iterator.next();
            if (object.getClass().getSimpleName()
                    .equals(MERCHA_MOD)) {
                MerchandisersupervisorOpParam merchandisersupervisorOpParam =
                        (MerchandisersupervisorOpParam) object;
                assertEquals(AM_OBJ + "merchandiser-super: leaf value", "abc",
                             merchandisersupervisorOpParam.supervisor());
            } else {
                assertEquals(AM_OBJ, MERCHA_MOD, object
                        .getClass().getSimpleName());
            }
        }
    }

    /**
     * Unit test case in which verifying object for xml string with get and
     * filter as root name.
     */
    @Test
    public void proceessCodecDecodeFunctionForGet() {
        String path = "src/test/resources/ychTestResourceFiles/getrootname.xml";
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry =
                testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler defaultYangCodecHandler =
                new DefaultYangCodecHandler(schemaRegistry);

        StringBuilder sb = new StringBuilder();
        String sCurrentLine;

        try (BufferedReader br = new BufferedReader(new FileReader(path))) {

            while ((sCurrentLine = br.readLine()) != null) {
                sb.append(sCurrentLine);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        // Verify the received object list
        List<Object> objectList =
                defaultYangCodecHandler.decode(sb.toString(),
                                               XML, QUERY_REQUEST);
        processPurchasingSpecObj(objectList);
    }

    /**
     * Unit test case in which verifying object for xml string with get-config
     * and filter as root name.
     */
    @Test
    public void proceessCodecDecodeFunctionForGetConfig() {
        String path = "src/test/resources/ychTestResourceFiles/getconfigrootname.xml";
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry =
                testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler defaultYangCodecHandler =
                new DefaultYangCodecHandler(schemaRegistry);

        StringBuilder sb = new StringBuilder();
        String sCurrentLine;

        try (BufferedReader br = new BufferedReader(new FileReader(path))) {

            while ((sCurrentLine = br.readLine()) != null) {
                sb.append(sCurrentLine);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        // Verify the received object list
        List<Object> objectList = defaultYangCodecHandler.decode(
                sb.toString(),
                XML, QUERY_CONFIG_REQUEST);
        processMerchandiserObj(objectList);
    }

    /**
     * Unit test case in which verifying object for xml string with data as
     * root name.
     */
    @Test
    public void proceessCodecDecodeFunctionForGetData() {
        String path = "src/test/resources/ychTestResourceFiles/getReply.xml";
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry =
                testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler defaultYangCodecHandler =
                new DefaultYangCodecHandler(schemaRegistry);

        StringBuilder sb = new StringBuilder();
        String sCurrentLine;

        try (BufferedReader br = new BufferedReader(new FileReader(path))) {

            while ((sCurrentLine = br.readLine()) != null) {
                sb.append(sCurrentLine);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        // Verify the received object list
        List<Object> objectList = defaultYangCodecHandler.decode(
                sb.toString(),
                XML, QUERY_CONFIG_REQUEST);
        processPurchasingSpecObj(objectList);
    }

    /**
     * Unit test case in which verifying object for xml string with rpc-reply
     * and data as root name .
     */
    @Test
    public void proceessCodecDecodeFunctionForGetConfigData() {
        String path = "src/test/resources/ychTestResourceFiles/getconfigReply.xml";
        testYangSchemaNodeProvider.processSchemaRegistry(null);
        DefaultYangSchemaRegistry schemaRegistry =
                testYangSchemaNodeProvider.getDefaultYangSchemaRegistry();

        YangCodecRegistry.initializeDefaultCodec();
        DefaultYangCodecHandler defaultYangCodecHandler =
                new DefaultYangCodecHandler(schemaRegistry);

        StringBuilder sb = new StringBuilder();
        String sCurrentLine;

        try (BufferedReader br = new BufferedReader(new FileReader(path))) {

            while ((sCurrentLine = br.readLine()) != null) {
                sb.append(sCurrentLine);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

        // Verify the received object list
        List<Object> objectList = defaultYangCodecHandler.decode(sb.toString(),
                                                                 XML, null);
        processMerchandiserObj(objectList);
    }
}


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
null

#### Original name
Sphaerosoma echinulatum Seaver, 1905

### Remarks
null

redpajama_set_name: RedPajamaGithub


text:
package cmds

import (
	"encoding/json"
	"fmt"
	"os"
	"text/tabwriter"

	"github.com/logrusorgru/aurora"
	"github.com/spf13/cobra"
	"github.com/velocity-ci/velocity/backend/pkg/velocity/config"
	"github.com/velocity-ci/velocity/backend/pkg/velocity/output"
)

func init() {
	listCmd.AddCommand(listBlueprintsCmd)
}

var listBlueprintsCmd = &cobra.Command{
	Use:     "blueprints",
	Aliases: []string{"b"},
	Short:   "lists blueprints",
	Long:    `lists blueprints`,
	RunE: func(cmd *cobra.Command, args []string) error {
		root, err := config.GetRootConfig()
		if err != nil {
			return err
		}

		blueprints, err := config.GetBlueprintsFromRoot(root)
		if err != nil {
			return err
		}

		switch {
		case machineReadable:
			return listBlueprintsMachine(blueprints)
		default:
			return listBlueprintsText(blueprints)
		}
	},
}

func listBlueprintsText(blueprints []*config.Blueprint) error {
	tabWriter := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)

	printHeader("Blueprints")
	if len(blueprints) > 0 {
		for _, blueprint := range blueprints {
			fmt.Fprintf(tabWriter, " %s %s\t%s\n",
				output.ColorFmt(aurora.CyanFg, "->", " "),
				blueprint.Name,
				aurora.Colorize(blueprint.Description, aurora.ItalicFm|aurora.Gray(20, "").Color()),
			)
		}
		tabWriter.Flush()
	} else {
		fmt.Fprintln(os.Stdout, "  none found")
	}
	return nil
}

func listBlueprintsMachine(blueprints []*config.Blueprint) error {
	jsonBytes, err := json.MarshalIndent(blueprints, "", "  ")
	if err != nil {
		return err
	}
	fmt.Fprintf(os.Stdout, "%s\n", jsonBytes)
	return nil
}


text:
<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 7/4/2017
 * Time: 8:11 AM
 */

class MY_Form_validation extends CI_Form_validation{

    public function error_array(){
        return $this->_error_array;
    }
}


text:
<?php

namespace Magento\Sitemap\Model\ResourceModel\Catalog;

use Magento\CatalogUrlRewrite\Model\ProductUrlRewriteGenerator;
use Magento\Store\Model\Store;

/**
 * Sitemap resource product collection model
 *
 * @author      Magento Core Team <core@magentocommerce.com>
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 */
class Product extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
    const NOT_SELECTED_IMAGE = 'no_selection';

    /**
     * Collection Zend Db select
     *
     * @var \Magento\Framework\DB\Select
     */
    protected $_select;

    /**
     * Attribute cache
     *
     * @var array
     */
    protected $_attributesCache = [];

    /**
     * @var \Magento\Catalog\Model\Product\Gallery\ReadHandler
     */
    protected $mediaGalleryReadHandler;

    /**
     * Sitemap data
     *
     * @var \Magento\Sitemap\Helper\Data
     */
    protected $_sitemapData = null;

    /**
     * @var \Magento\Catalog\Model\ResourceModel\Product
     */
    protected $_productResource;

    /**
     * @var \Magento\Store\Model\StoreManagerInterface
     */
    protected $_storeManager;

    /**
     * @var \Magento\Catalog\Model\Product\Visibility
     */
    protected $_productVisibility;

    /**
     * @var \Magento\Catalog\Model\Product\Attribute\Source\Status
     */
    protected $_productStatus;

    /**
     * @var \Magento\Catalog\Model\ResourceModel\Product\Gallery
     */
    protected $mediaGalleryResourceModel;

    /**
     * @var \Magento\Catalog\Model\Product\Media\Config
     */
    protected $_mediaConfig;

    /**
     * @param \Magento\Framework\Model\ResourceModel\Db\Context $context
     * @param \Magento\Sitemap\Helper\Data $sitemapData
     * @param \Magento\Catalog\Model\ResourceModel\Product $productResource
     * @param \Magento\Store\Model\StoreManagerInterface $storeManager
     * @param \Magento\Catalog\Model\Product\Visibility $productVisibility
     * @param \Magento\Catalog\Model\Product\Attribute\Source\Status $productStatus
     * @param \Magento\Catalog\Model\ResourceModel\Product\Gallery $mediaGalleryResourceModel
     * @param \Magento\Catalog\Model\Product\Gallery\ReadHandler $mediaGalleryReadHandler
     * @param \Magento\Catalog\Model\Product\Media\Config $mediaConfig
     * @param string $connectionName
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
     */
    public function __construct(
        \Magento\Framework\Model\ResourceModel\Db\Context $context,
        \Magento\Sitemap\Helper\Data $sitemapData,
        \Magento\Catalog\Model\ResourceModel\Product $productResource,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Catalog\Model\Product\Visibility $productVisibility,
        \Magento\Catalog\Model\Product\Attribute\Source\Status $productStatus,
        \Magento\Catalog\Model\ResourceModel\Product\Gallery $mediaGalleryResourceModel,
        \Magento\Catalog\Model\Product\Gallery\ReadHandler $mediaGalleryReadHandler,
        \Magento\Catalog\Model\Product\Media\Config $mediaConfig,
        $connectionName = null
    ) {
        $this->_productResource = $productResource;
        $this->_storeManager = $storeManager;
        $this->_productVisibility = $productVisibility;
        $this->_productStatus = $productStatus;
        $this->mediaGalleryResourceModel = $mediaGalleryResourceModel;
        $this->mediaGalleryReadHandler = $mediaGalleryReadHandler;
        $this->_mediaConfig = $mediaConfig;
        $this->_sitemapData = $sitemapData;
        parent::__construct($context, $connectionName);
    }

    /**
     * @return void
     */
    protected function _construct()
    {
        $this->_init('catalog_product_entity', 'entity_id');
    }

    /**
     * Add attribute to filter
     *
     * @param int $storeId
     * @param string $attributeCode
     * @param mixed $value
     * @param string $type
     * @return \Magento\Framework\DB\Select|bool
     */
    protected function _addFilter($storeId, $attributeCode, $value, $type = '=')
    {
        if (!$this->_select instanceof \Magento\Framework\DB\Select) {
            return false;
        }

        switch ($type) {
            case '=':
                $conditionRule = '=?';
                break;
            case 'in':
                $conditionRule = ' IN(?)';
                break;
            default:
                return false;
                break;
        }

        $attribute = $this->_getAttribute($attributeCode);
        if ($attribute['backend_type'] == 'static') {
            $this->_select->where('e.' . $attributeCode . $conditionRule, $value);
        } else {
            $this->_joinAttribute($storeId, $attributeCode);
            if ($attribute['is_global']) {
                $this->_select->where('t1_' . $attributeCode . '.value' . $conditionRule, $value);
            } else {
                $ifCase = $this->getConnection()->getCheckSql(
                    't2_' . $attributeCode . '.value_id > 0',
                    't2_' . $attributeCode . '.value',
                    't1_' . $attributeCode . '.value'
                );
                $this->_select->where('(' . $ifCase . ')' . $conditionRule, $value);
            }
        }

        return $this->_select;
    }

    /**
     * Join attribute by code
     *
     * @param int $storeId
     * @param string $attributeCode
     * @return void
     */
    protected function _joinAttribute($storeId, $attributeCode)
    {
        $connection = $this->getConnection();
        $attribute = $this->_getAttribute($attributeCode);
        $linkField = $this->_productResource->getLinkField();
        $attrTableAlias = 't1_' . $attributeCode;
        $this->_select->joinLeft(
            [$attrTableAlias => $attribute['table']],
            "e.{$linkField} = {$attrTableAlias}.{$linkField}"
            . ' AND ' . $connection->quoteInto($attrTableAlias . '.store_id = ?', Store::DEFAULT_STORE_ID)
            . ' AND ' . $connection->quoteInto($attrTableAlias . '.attribute_id = ?', $attribute['attribute_id']),
            []
        );

        if (!$attribute['is_global']) {
            $attrTableAlias2 = 't2_' . $attributeCode;
            $this->_select->joinLeft(
                ['t2_' . $attributeCode => $attribute['table']],
                "{$attrTableAlias}.{$linkField} = {$attrTableAlias2}.{$linkField}"
                . ' AND ' . $attrTableAlias . '.attribute_id = ' . $attrTableAlias2 . '.attribute_id'
                . ' AND ' . $connection->quoteInto($attrTableAlias2 . '.store_id = ?', $storeId),
                []
            );
        }
    }

    /**
     * Get attribute data by attribute code
     *
     * @param string $attributeCode
     * @return array
     */
    protected function _getAttribute($attributeCode)
    {
        if (!isset($this->_attributesCache[$attributeCode])) {
            $attribute = $this->_productResource->getAttribute($attributeCode);

            $this->_attributesCache[$attributeCode] = [
                'entity_type_id' => $attribute->getEntityTypeId(),
                'attribute_id' => $attribute->getId(),
                'table' => $attribute->getBackend()->getTable(),
                'is_global' => $attribute->getIsGlobal() ==
                \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
                'backend_type' => $attribute->getBackendType(),
            ];
        }
        return $this->_attributesCache[$attributeCode];
    }

    /**
     * Get category collection array
     *
     * @param null|string|bool|int|Store $storeId
     * @return array|bool
     */
    public function getCollection($storeId)
    {
        $products = [];

        /* @var $store Store */
        $store = $this->_storeManager->getStore($storeId);
        if (!$store) {
            return false;
        }

        $connection = $this->getConnection();

        $this->_select = $connection->select()->from(
            ['e' => $this->getMainTable()],
            [$this->getIdFieldName(), $this->_productResource->getLinkField(), 'updated_at']
        )->joinInner(
            ['w' => $this->getTable('catalog_product_website')],
            'e.entity_id = w.product_id',
            []
        )->joinLeft(
            ['url_rewrite' => $this->getTable('url_rewrite')],
            'e.entity_id = url_rewrite.entity_id AND url_rewrite.is_autogenerated = 1 AND url_rewrite.metadata IS NULL'
            . $connection->quoteInto(' AND url_rewrite.store_id = ?', $store->getId())
            . $connection->quoteInto(' AND url_rewrite.entity_type = ?', ProductUrlRewriteGenerator::ENTITY_TYPE),
            ['url' => 'request_path']
        )->where(
            'w.website_id = ?',
            $store->getWebsiteId()
        );

        $this->_addFilter($store->getId(), 'visibility', $this->_productVisibility->getVisibleInSiteIds(), 'in');
        $this->_addFilter($store->getId(), 'status', $this->_productStatus->getVisibleStatusIds(), 'in');

        // Join product images required attributes
        $imageIncludePolicy = $this->_sitemapData->getProductImageIncludePolicy($store->getId());
        if (\Magento\Sitemap\Model\Source\Product\Image\IncludeImage::INCLUDE_NONE != $imageIncludePolicy) {
            $this->_joinAttribute($store->getId(), 'name');
            $this->_select->columns(
                ['name' => $this->getConnection()->getIfNullSql('t2_name.value', 't1_name.value')]
            );

            if (\Magento\Sitemap\Model\Source\Product\Image\IncludeImage::INCLUDE_ALL == $imageIncludePolicy) {
                $this->_joinAttribute($store->getId(), 'thumbnail');
                $this->_select->columns(
                    [
                        'thumbnail' => $this->getConnection()->getIfNullSql(
                            't2_thumbnail.value',
                            't1_thumbnail.value'
                        ),
                    ]
                );
            } elseif (\Magento\Sitemap\Model\Source\Product\Image\IncludeImage::INCLUDE_BASE == $imageIncludePolicy) {
                $this->_joinAttribute($store->getId(), 'image');
                $this->_select->columns(
                    ['image' => $this->getConnection()->getIfNullSql('t2_image.value', 't1_image.value')]
                );
            }
        }

        $query = $connection->query($this->_select);
        while ($row = $query->fetch()) {
            $product = $this->_prepareProduct($row, $store->getId());
            $products[$product->getId()] = $product;
        }

        return $products;
    }

    /**
     * Prepare product
     *
     * @param array $productRow
     * @param int $storeId
     * @return \Magento\Framework\DataObject
     */
    protected function _prepareProduct(array $productRow, $storeId)
    {
        $product = new \Magento\Framework\DataObject();

        $product['id'] = $productRow[$this->getIdFieldName()];
        if (empty($productRow['url'])) {
            $productRow['url'] = 'catalog/product/view/id/' . $product->getId();
        }
        $product->addData($productRow);
        $this->_loadProductImages($product, $storeId);

        return $product;
    }

    /**
     * Load product images
     *
     * @param \Magento\Framework\DataObject $product
     * @param int $storeId
     * @return void
     */
    protected function _loadProductImages($product, $storeId)
    {
        /** @var $helper \Magento\Sitemap\Helper\Data */
        $helper = $this->_sitemapData;
        $imageIncludePolicy = $helper->getProductImageIncludePolicy($storeId);

        // Get product images
        $imagesCollection = [];
        if (\Magento\Sitemap\Model\Source\Product\Image\IncludeImage::INCLUDE_ALL == $imageIncludePolicy) {
            $imagesCollection = $this->_getAllProductImages($product, $storeId);
        } elseif (\Magento\Sitemap\Model\Source\Product\Image\IncludeImage::INCLUDE_BASE == $imageIncludePolicy &&
            $product->getImage() &&
            $product->getImage() != self::NOT_SELECTED_IMAGE
        ) {
            $imagesCollection = [
                new \Magento\Framework\DataObject(
                    ['url' => $this->_getMediaConfig()->getBaseMediaUrlAddition() . $product->getImage()]
                ),
            ];
        }

        if ($imagesCollection) {
            // Determine thumbnail path
            $thumbnail = $product->getThumbnail();
            if ($thumbnail && $product->getThumbnail() != self::NOT_SELECTED_IMAGE) {
                $thumbnail = $this->_getMediaConfig()->getBaseMediaUrlAddition() . $thumbnail;
            } else {
                $thumbnail = $imagesCollection[0]->getUrl();
            }

            $product->setImages(
                new \Magento\Framework\DataObject(
                    ['collection' => $imagesCollection, 'title' => $product->getName(), 'thumbnail' => $thumbnail]
                )
            );
        }
    }

    /**
     * Get all product images
     *
     * @param \Magento\Framework\DataObject $product
     * @param int $storeId
     * @return array
     */
    protected function _getAllProductImages($product, $storeId)
    {
        $product->setStoreId($storeId);
        $gallery = $this->mediaGalleryResourceModel->loadProductGalleryByAttributeId(
            $product,
            $this->mediaGalleryReadHandler->getAttribute()->getId()
        );

        $imagesCollection = [];
        if ($gallery) {
            $productMediaPath = $this->_getMediaConfig()->getBaseMediaUrlAddition();
            foreach ($gallery as $image) {
                $imagesCollection[] = new \Magento\Framework\DataObject(
                    [
                        'url' => $productMediaPath . $image['file'],
                        'caption' => $image['label'] ? $image['label'] : $image['label_default'],
                    ]
                );
            }
        }

        return $imagesCollection;
    }

    /**
     * Get media config
     *
     * @return \Magento\Catalog\Model\Product\Media\Config
     */
    protected function _getMediaConfig()
    {
        return $this->_mediaConfig;
    }
}


text:
"""
    Kubernetes

    No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)

    OpenAPI spec version: v1.8.2

    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""

from __future__ import absolute_import

import os
import sys
import unittest

import kubernetes.client
from kubernetes.client.rest import ApiException
from kubernetes.client.models.v1_pod_affinity_term import V1PodAffinityTerm

class TestV1PodAffinityTerm(unittest.TestCase):
    """ V1PodAffinityTerm unit test stubs """

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def testV1PodAffinityTerm(self):
        """
        Test V1PodAffinityTerm
        """
        # FIXME: construct object with mandatory attributes with example values
        #model = kubernetes.client.models.v1_pod_affinity_term.V1PodAffinityTerm()
        pass

if __name__ == '__main__':
    unittest.main()


text:
package net.fortuna.ical4j.model;

import java.io.Serializable;
import java.text.ParseException;
import java.util.Date;

/**
 * Defines a period of time. A period may be specified as either a start date
 * and end date, or a start date and duration. NOTE: End dates and durations are
 * implicitly derived when not explicitly specified. This means that you cannot
 * rely on the returned values from the getters to deduce whether a period has
 * an explicit end date or duration.
 *
 * @author Ben Fortuna
 */
public class Period implements Serializable, Comparable {

    private static final long serialVersionUID = 7321090422911676490L;

    private DateTime start;

    private DateTime end;

    private Dur duration;

    /**
     * Constructor.
     *
     * @param aValue
     *            a string representation of a period
     * @throws ParseException
     *             where the specified string is not a valid representation
     */
    public Period(final String aValue) throws ParseException {
        start = new DateTime(aValue.substring(0, aValue.indexOf('/')));

        // period may end in either a date-time or a duration..
        try {
            end = new DateTime(aValue.substring(aValue.indexOf('/') + 1));
        } catch (ParseException pe) {
            // duration = DurationFormat.getInstance().parse(aValue);
            duration = new Dur(aValue);
        }
    }

    /**
     * Constructs a new period with the specied start and end date.
     *
     * @param start
     *            the start date of the period
     * @param end
     *            the end date of the period
     */
    public Period(final DateTime start, final DateTime end) {
        this.start = start;
        this.end = end;
    }

    /**
     * Constructs a new period with the specified start date and duration.
     *
     * @param start
     *            the start date of the period
     * @param duration
     *            the duration of the period
     */
    public Period(final DateTime start, final Dur duration) {
        this.start = start;
        this.duration = duration;
    }

    /**
     * Returns the duration of this period. If an explicit duration is not
     * specified, the duration is derived from the end date.
     *
     * @return the duration of this period in milliseconds.
     */
    public final Dur getDuration() {
        if (end != null) {
            return new Dur(start, end);
        }
        return duration;
    }

    /**
     * Returns the end date of this period. If an explicit end date is not
     * specified, the end date is derived from the duration.
     *
     * @return the end date of this period.
     */
    public final DateTime getEnd() {
        if (end == null) {
            DateTime derived = new DateTime(duration.getTime(start).getTime());
            derived.setUtc(start.isUtc());
            return derived;
        }
        return end;
    }

    /**
     * @return Returns the start.
     */
    public final DateTime getStart() {
        return start;
    }

    /**
     * Determines if the specified date occurs within this period (inclusive of
     * period start and end).
     * @param date
     * @return true if the specified date occurs within the current period
     *
     */
    public final boolean includes(final Date date) {
        return includes(date, true);
    }

    /**
     * Decides whether a date falls within this period.
     * @param date the date to be tested
     * @param inclusive specifies whether period start and end are included
     * in the calculation
     * @return true if the date is in the perod, false otherwise
     */
    public final boolean includes(final Date date, final boolean inclusive) {
        if (inclusive) {
            return (!getStart().after(date) && !getEnd().before(date));
        }
        return (getStart().before(date) && getEnd().after(date));
    }

    /**
     * Decides whether this period is completed before the given period starts.
     *
     * @param period
     *            a period that may or may not start after this period ends
     * @return true if the specified period starts after this periods ends,
     *         otherwise false
     */
    public final boolean before(final Period period) {
        return (getEnd().before(period.getStart()));
    }

    /**
     * Decides whether this period starts after the given period ends.
     *
     * @param period
     *            a period that may or may not end before this period starts
     * @return true if the specified period end before this periods starts,
     *         otherwise false
     */
    public final boolean after(final Period period) {
        return (getStart().after(period.getEnd()));
    }

    /**
     * Decides whether this period intersects with another one.
     *
     * @param period
     *            a possible intersecting period
     * @return true if the specified period intersects this one, false
     *         otherwise.
     */
    public final boolean intersects(final Period period) {
        // Test for our start date in period
        // (Exclude if it is the end date of test range)
        if (period.includes(getStart()) && !period.getEnd().equals(getStart())) {
            return true;
        }
        // Test for test range's start date in our range
        // (Exclude if it is the end date of our range)
        else if (includes(period.getStart())
                && !getEnd().equals(period.getStart())) {
            return true;
        }
        return false;
    }

    /**
     * Decides whether these periods are serial without a gap.
     *
     * @return true if one period immediately follows the other, false otherwise
     */
    public final boolean adjacent(final Period period) {
        if (getStart().equals(period.getEnd())) {
            return true;
        } else if (getEnd().equals(period.getStart())) {
            return true;
        }
        return false;
    }

    /**
     * Decides whether the given period is completely contained within this one.
     *
     * @param period
     *            the period that may be contained by this one
     * @return true if this period covers all the dates of the specified period,
     *         otherwise false
     */
    public final boolean contains(final Period period) {
        // Test for period's start and end dates in our range
        return (includes(period.getStart()) && includes(period.getEnd()));
    }

    /**
     * Creates a period that encompasses both this period and another one. If
     * the other period is null, return a copy of this period. NOTE: Resulting
     * periods are specified by explicitly setting a start date and end date
     * (i.e. durations are implied).
     *
     * @param period
     *            the period to add to this one
     * @return a period
     */
    public final Period add(final Period period) {
        DateTime newPeriodStart = null;
        DateTime newPeriodEnd = null;

        if (period == null) {
            newPeriodStart = getStart();
            newPeriodEnd = getEnd();
        } else {
            if (getStart().before(period.getStart())) {
                newPeriodStart = getStart();
            } else {
                newPeriodStart = period.getStart();
            }
            if (getEnd().after(period.getEnd())) {
                newPeriodEnd = getEnd();
            } else {
                newPeriodEnd = period.getEnd();
            }
        }

        return new Period(newPeriodStart, newPeriodEnd);
    }

    /**
     * @see java.lang.Object#toString()
     */
    public final String toString() {
        StringBuffer b = new StringBuffer();
        b.append(start);
        b.append('/');
        if (end != null) {
            b.append(end);
        } else {
            // b.append(DurationFormat.getInstance().format(duration));
            b.append(duration);
        }
        return b.toString();
    }

    /*
     * (non-Javadoc)
     *
     * @see java.lang.Comparable#compareTo(java.lang.Object)
     */
    public final int compareTo(final Object arg0) {
        return compareTo((Period) arg0);
    }

    /**
     * Compares the specified period with this period.
     *
     * @param arg0
     * @return
     */
    public final int compareTo(final Period arg0) {
        // Throws documented exception if type is wrong or parameter is null
        if (arg0 == null) {
            throw new ClassCastException("Cannot compare this object to null");
        }
        int startCompare = getStart().compareTo(arg0.getStart());
        if (startCompare != 0) {
            return startCompare;
        }
        // start dates are equal, compare end dates..
        else if (end != null) {
            int endCompare = end.compareTo(arg0.getEnd());
            if (endCompare != 0) {
                return endCompare;
            }
        }
        // ..or durations
        return getDuration().compareTo(arg0.getDuration());
    }

    /**
     * Overrides the equality test, compares fields of instances for equality.
     *
     * @param o
     *            object being compared for equality
     * @return true if the objects are equal, false otherwise
     */
    public final boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Period)) {
            return false;
        }

        final Period period = (Period) o;

        if (!getStart().equals(period.getStart())) {
            return false;
        } else if (!getEnd().equals(period.getEnd())) {
            return false;
        }
        return true;
    }

    /**
     * Override hashCode() with code that checks fields in this object.
     *
     * @return hascode for this object
     */
    public final int hashCode() {
        int result;
        result = getStart().hashCode();
        result = 29 * result + getEnd().hashCode();
        return result;
    }
}


text:
module Google
  module Cloud
    module GkeHub
      module MultiClusterIngress
        module V1
          # **Multi-cluster Ingress**: The configuration for the MultiClusterIngress
          # feature.
          # @!attribute [rw] config_membership
          #   @return [::String]
          #     Fully-qualified Membership name which hosts the MultiClusterIngress CRD.
          #     Example: `projects/foo-proj/locations/global/memberships/bar`
          class FeatureSpec
            include ::Google::Protobuf::MessageExts
            extend ::Google::Protobuf::MessageExts::ClassMethods
          end
        end
      end
    end
  end
end


text:
package org.efaps.ci;

import org.efaps.util.cache.CacheReloadException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Each class that extends this abstract class represents a configuration
 * item for a type from eFaps. It is used to have easy access during the
 * coding of esjp etc. to the configuration items without having the problem
 * of using strings to access them. The classes are created automatically
 * with a maven target.
 *
 * @author The eFaps Team
 *
 */
//CHECKSTYLE:OFF
public abstract class CIType
    extends CIObject
{

    /**
     * Logging instance used in this class.
     */
    private static final Logger LOG = LoggerFactory.getLogger(CIObject.class);

    /**
     * ID attribute. Each type must have it.
     */
    public final CIAttribute ID = new CIAttribute(this, "ID");

    /**
     * OID attribute.Each type must have it.
     */
    public final CIAttribute OID = new CIAttribute(this, "OID");

    /**
     * Type attribute.Each type must have it.
     */
    public final CIAttribute Type = new CIAttribute(this, "Type");
   //CHECKSTYLE:ON
    /**
     * Constructor setting the uuid.
     * @param _uuid UUID of this type
     */
    protected CIType(final String _uuid)
    {
        super(_uuid);
    }

    /**
     * Get the type this Configuration item represents.
     *
     * @return Type
     */
    public org.efaps.admin.datamodel.Type getType()
    {
        org.efaps.admin.datamodel.Type ret = null;
        try {
            ret =  org.efaps.admin.datamodel.Type.get(this.uuid);
        } catch (final CacheReloadException e) {
            CIType.LOG.error("Error on retrieving Type for CIType with uuid: {}", this.uuid);
        }
        return ret;
    }

    /**
     * Tests, if this type is kind of the type in the parameter (question is, is
     * this type a child of the parameter type).
     *
     * @param _type type to test for parent
     * @return true if this type is a child, otherwise false
     */
    public boolean isKindOf(final org.efaps.admin.datamodel.Type _type)
    {
        return getType().isKindOf(_type);
    }

    /**
     * Tests, if this type the type in the parameter .
     *
     * @param _type type to test
     * @return true if this type otherwise false
     */
    public boolean isType(final org.efaps.admin.datamodel.Type _type)
    {
        return getType().equals(_type);
    }
}