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 PerAppVPNTestSuite {

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

        PerAppVPN perAppVPN = new PerAppVPN();
        perAppVPN.setVPNUUID("");

        perAppVPN.validateRequest();

    }

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

        PerAppVPN perAppVPN = new PerAppVPN();
        perAppVPN.setVPNUUID("1235325235");
        perAppVPN.setOnDemandMatchAppEnabled(null);

        perAppVPN.validateRequest();

    }

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

        PerAppVPN perAppVPN = new PerAppVPN();
        perAppVPN.setVPNUUID("1235325235");
        perAppVPN.setOnDemandMatchAppEnabled(true);
        List<String> safariDomains = new ArrayList<String>();
        safariDomains.add("apple.com");
        safariDomains.add("google.com");
        perAppVPN.setSafariDomains(safariDomains);
        perAppVPN.validateRequest();

        VPNOperations vpnOperations = new VPNOperations();
        PayloadOperationWrapper payload = vpnOperations.createPerAppVPNPayload(perAppVPN);

        Assert.assertNotNull(payload);

    }

}
