package org.wso2.carbon.device.mgt.ios.core.service;

import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.device.mgt.ios.core.exception.IOSEnrollmentException;
import org.wso2.carbon.device.mgt.ios.core.util.AppConfigurations;

public class IOSEnrollmentServiceTestSuite {

    private IOSEnrollmentService enrollmentService;
    private static final String CONFIGURATION_FILE_PATH = "src/test/resources";
    private static final String CHALLENGE_TOKEN = "6590628006462240464";
    private static final String TENANT_NAME = "carbon.super";

    @BeforeClass
    public void initializeService() throws Exception {
        enrollmentService = IOSEnrollmentService.getInstance();
        System.setProperty(AppConfigurations.CONF_LOCATION, CONFIGURATION_FILE_PATH);
    }

    public IOSEnrollmentService getEnrollmentService() {
        return enrollmentService;
    }

    @Test
    public void testGenerateMobileConfigurations() {
        try {
            String mobileConfigurations = enrollmentService.generateMobileConfigurations(CHALLENGE_TOKEN, TENANT_NAME);
            if(mobileConfigurations == null) {
                Assert.fail("Mobile configuration payload is empty");
            } else {
                Assert.assertNotNull(mobileConfigurations);
            }
        } catch (IOSEnrollmentException e) {
            Assert.fail("Error occurred while generating mobile configurations ", e);
        }
    }
}
