Search in sources :

Example 26 with FunctionLibrary

use of org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary in project carbon-identity-framework by wso2.

the class FunctionLibraryManagementServiceTest method updateFunctionLibraryData.

@DataProvider(name = "updateFunctionLibraryDataProvider")
public Object[][] updateFunctionLibraryData() {
    FunctionLibrary functionLibrary11 = new FunctionLibrary();
    functionLibrary11.setFunctionLibraryName("sample11");
    functionLibrary11.setDescription("sample11");
    functionLibrary11.setFunctionLibraryScript("function samplefunction11(){}");
    FunctionLibrary functionLibrary12 = new FunctionLibrary();
    functionLibrary12.setFunctionLibraryName("sample12");
    functionLibrary12.setDescription("sample12");
    functionLibrary12.setFunctionLibraryScript("function samplefunction12(){}");
    FunctionLibrary functionLibrary13 = new FunctionLibrary();
    functionLibrary13.setFunctionLibraryName("sample13");
    functionLibrary13.setDescription("sample13");
    functionLibrary13.setFunctionLibraryScript("function samplefunction13(){}");
    FunctionLibrary functionLibrary14 = new FunctionLibrary();
    functionLibrary14.setFunctionLibraryName("sample14");
    functionLibrary14.setDescription("sample14");
    functionLibrary14.setFunctionLibraryScript("function samplefunction14(){}");
    return new Object[][] { { functionLibrary11, SAMPLE_TENANT_DOMAIN }, { functionLibrary12, SAMPLE_TENANT_DOMAIN2 }, { functionLibrary13, SAMPLE_TENANT_DOMAIN }, { functionLibrary14, SAMPLE_TENANT_DOMAIN2 } };
}
Also used : FunctionLibrary(org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary) DataProvider(org.testng.annotations.DataProvider)

Example 27 with FunctionLibrary

use of org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary in project carbon-identity-framework by wso2.

the class FunctionLibraryDAOImplTest method listFunctionLibraries.

@Test(dataProvider = "listFunctionLibraryDataProvider")
public void listFunctionLibraries(List<Object> functionLibraries, String tenantDomain) throws FunctionLibraryManagementException {
    try (Connection connection = DAOUtils.getConnection(DB_NAME)) {
        FunctionLibraryDAO functionLibraryDAO = new FunctionLibraryDAOImpl();
        addFunctionLibraries(functionLibraryDAO, functionLibraries, tenantDomain);
        when(IdentityDatabaseUtil.getDBConnection(false)).thenReturn(connection);
        List<FunctionLibrary> functionLibrariesList = functionLibraryDAO.listFunctionLibraries(tenantDomain);
        assertTrue(functionLibrariesList != null && functionLibrariesList.size() != 0, "Failed to retrieve script libraries.");
        // Clean after test
        deleteFunctionLibraries(functionLibraryDAO, functionLibraries, tenantDomain);
    } catch (SQLException e) {
        log.error("SQLException");
    }
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) FunctionLibrary(org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary) FunctionLibraryDAO(org.wso2.carbon.identity.functions.library.mgt.dao.FunctionLibraryDAO) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) PowerMockIdentityBaseTest(org.wso2.carbon.identity.testutil.powermock.PowerMockIdentityBaseTest)

Example 28 with FunctionLibrary

use of org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary in project carbon-identity-framework by wso2.

the class FunctionLibraryDAOImplTest method listFunctionLibrariesData.

@DataProvider(name = "listFunctionLibraryDataProvider")
public Object[][] listFunctionLibrariesData() {
    FunctionLibrary functionLibrary4 = new FunctionLibrary();
    functionLibrary4.setFunctionLibraryName("sample4");
    functionLibrary4.setDescription("sample4");
    functionLibrary4.setFunctionLibraryScript("samplefunction4");
    FunctionLibrary functionLibrary5 = new FunctionLibrary();
    functionLibrary5.setFunctionLibraryName("sample5");
    functionLibrary5.setDescription("sample5");
    functionLibrary5.setFunctionLibraryScript("samplefunction5");
    FunctionLibrary functionLibrary6 = new FunctionLibrary();
    functionLibrary6.setFunctionLibraryName("sample6");
    functionLibrary6.setDescription("sample6");
    functionLibrary6.setFunctionLibraryScript("samplefunction6");
    FunctionLibrary functionLibrary7 = new FunctionLibrary();
    functionLibrary7.setFunctionLibraryName("sample7");
    functionLibrary7.setDescription("sample7");
    functionLibrary7.setFunctionLibraryScript("samplefunction7");
    return new Object[][] { { Arrays.asList(functionLibrary4, functionLibrary5), SAMPLE_TENANT_DOMAIN }, { Arrays.asList(functionLibrary6, functionLibrary7), SAMPLE_TENANT_DOMAIN2 } };
}
Also used : FunctionLibrary(org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary) DataProvider(org.testng.annotations.DataProvider)

Example 29 with FunctionLibrary

use of org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary in project carbon-identity-framework by wso2.

the class FunctionLibraryDAOImplTest method updateFunctionLibrary.

@Test(dataProvider = "updateFunctionLibraryDataProvider")
public void updateFunctionLibrary(Object functionLibrary, String tenantDomain) throws SQLException, FunctionLibraryManagementException {
    try (Connection connection1 = DAOUtils.getConnection(DB_NAME);
        Connection connection2 = DAOUtils.getConnection(DB_NAME)) {
        FunctionLibraryDAO functionLibraryDAO = new FunctionLibraryDAOImpl();
        addFunctionLibraries(functionLibraryDAO, Collections.singletonList(functionLibrary), tenantDomain);
        FunctionLibrary funLib = (FunctionLibrary) functionLibrary;
        String oldName = funLib.getFunctionLibraryName();
        funLib.setFunctionLibraryName("updatedName");
        when(IdentityDatabaseUtil.getDBConnection()).thenReturn(connection1);
        functionLibraryDAO.updateFunctionLibrary(oldName, funLib, tenantDomain);
        when(IdentityDatabaseUtil.getDBConnection(false)).thenReturn(connection2);
        assertNotNull(functionLibraryDAO.getFunctionLibrary(funLib.getFunctionLibraryName(), tenantDomain), "Failed to update script library.");
        // Clean after test
        deleteFunctionLibraries(functionLibraryDAO, Collections.singletonList(functionLibrary), tenantDomain);
    }
}
Also used : Connection(java.sql.Connection) FunctionLibrary(org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary) FunctionLibraryDAO(org.wso2.carbon.identity.functions.library.mgt.dao.FunctionLibraryDAO) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) PowerMockIdentityBaseTest(org.wso2.carbon.identity.testutil.powermock.PowerMockIdentityBaseTest)

Example 30 with FunctionLibrary

use of org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary in project carbon-identity-framework by wso2.

the class FunctionLibraryDAOImplTest method getFunctionLibraryData.

@DataProvider(name = "getFunctionLibraryDataProvider")
public Object[][] getFunctionLibraryData() {
    FunctionLibrary functionLibrary8 = new FunctionLibrary();
    functionLibrary8.setFunctionLibraryName("sample8");
    functionLibrary8.setDescription("sample8");
    functionLibrary8.setFunctionLibraryScript("samplefunction8");
    FunctionLibrary functionLibrary9 = new FunctionLibrary();
    functionLibrary9.setFunctionLibraryName("sample9");
    functionLibrary9.setDescription("sample9");
    functionLibrary9.setFunctionLibraryScript("samplefunction9");
    return new Object[][] { { functionLibrary8, SAMPLE_TENANT_DOMAIN }, { functionLibrary9, SAMPLE_TENANT_DOMAIN2 } };
}
Also used : FunctionLibrary(org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary) DataProvider(org.testng.annotations.DataProvider)

Aggregations

FunctionLibrary (org.wso2.carbon.identity.functions.library.mgt.model.FunctionLibrary)31 Test (org.testng.annotations.Test)19 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 PowerMockIdentityBaseTest (org.wso2.carbon.identity.testutil.powermock.PowerMockIdentityBaseTest)15 DataProvider (org.testng.annotations.DataProvider)13 FunctionLibraryManagementException (org.wso2.carbon.identity.functions.library.mgt.exception.FunctionLibraryManagementException)11 FunctionLibraryDAO (org.wso2.carbon.identity.functions.library.mgt.dao.FunctionLibraryDAO)10 Connection (java.sql.Connection)9 FunctionLibraryDAOImpl (org.wso2.carbon.identity.functions.library.mgt.dao.impl.FunctionLibraryDAOImpl)9 SQLException (java.sql.SQLException)5 AxisFault (org.apache.axis2.AxisFault)5 FunctionLibrary (org.wso2.carbon.identity.functions.library.mgt.model.xsd.FunctionLibrary)5 IOException (java.io.IOException)4 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)4 PreparedStatement (java.sql.PreparedStatement)3 IdentityRuntimeException (org.wso2.carbon.identity.base.IdentityRuntimeException)3 File (java.io.File)2 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1