package org.wso2.carbon.device.mgt.ios.payload.beans;

import org.testng.Assert;
import org.testng.annotations.Test;
import org.wso2.carbon.device.mgt.ios.payload.dto.PayloadOperationWrapper;
import org.wso2.carbon.device.mgt.ios.payload.exception.PListException;
import org.wso2.carbon.device.mgt.ios.payload.exception.ProfileConfigurationException;
import org.wso2.carbon.device.mgt.ios.payload.operation.VPNOperations;

import java.util.ArrayList;
import java.util.List;

public class AppToPerAppVPNMappingTestSuite {

    @Test(expectedExceptions = ProfileConfigurationException.class)
    public void testAppLayerVPNMappings() throws ProfileConfigurationException {

        AppToPerAppVPNMapping appToPerAppVPNMapping = new AppToPerAppVPNMapping();
        appToPerAppVPNMapping.setAppLayerVPNMappings(null);
        appToPerAppVPNMapping.validateRequest();

    }

    @Test
    public void testAppToPerAppVPNMappingPayload() throws ProfileConfigurationException, PListException {

        AppToPerAppVPNMapping appToPerAppVPNMapping = new AppToPerAppVPNMapping();

        AppLayerVPNMapping appLayerVPNMapping1 = new AppLayerVPNMapping();
        appLayerVPNMapping1.setIdentifier("identifier1");
        appLayerVPNMapping1.setVPNUUID("vpnuuid1");

        AppLayerVPNMapping appLayerVPNMapping2 = new AppLayerVPNMapping();
        appLayerVPNMapping2.setIdentifier("identifier1");
        appLayerVPNMapping2.setVPNUUID("vpnuuid1");

        List<AppLayerVPNMapping> listAppLayerVPNMapping = new ArrayList<AppLayerVPNMapping>();
        listAppLayerVPNMapping.add(appLayerVPNMapping1);
        listAppLayerVPNMapping.add(appLayerVPNMapping2);
        appToPerAppVPNMapping.setAppLayerVPNMappings(listAppLayerVPNMapping);

        appToPerAppVPNMapping.validateRequest();

        VPNOperations vpnOperations = new VPNOperations();
        PayloadOperationWrapper payload = vpnOperations.createAppToPerAppVPNMappingPayload(appToPerAppVPNMapping);

        Assert.assertNotNull(payload);

    }

}
