Search in sources :

Example 1 with ApplicationDAO

use of org.wso2.carbon.apimgt.core.dao.ApplicationDAO in project carbon-apimgt by wso2.

the class ApplicationDAOImplIT method testFingerprintAfterUpdatingApplication.

@Test
public void testFingerprintAfterUpdatingApplication() throws Exception {
    ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO();
    // add new app
    Application currentApp = TestUtil.addTestApplication();
    String fingerprintBeforeUpdate = ETagUtils.generateETag(applicationDAO.getLastUpdatedTimeOfApplication(currentApp.getId()));
    Assert.assertNotNull(fingerprintBeforeUpdate);
    Thread.sleep(1);
    Application newApp = SampleTestObjectCreator.createAlternativeApplication();
    newApp.setId(currentApp.getId());
    newApp.setCreatedTime(currentApp.getCreatedTime());
    // update app
    applicationDAO.updateApplication(currentApp.getId(), newApp);
    String fingerprintAfterUpdate = ETagUtils.generateETag(applicationDAO.getLastUpdatedTimeOfApplication(currentApp.getId()));
    Assert.assertNotNull(fingerprintAfterUpdate);
    // compare
    Assert.assertNotEquals(fingerprintBeforeUpdate, fingerprintAfterUpdate);
}
Also used : ApplicationDAO(org.wso2.carbon.apimgt.core.dao.ApplicationDAO) Application(org.wso2.carbon.apimgt.core.models.Application) Test(org.testng.annotations.Test)

Example 2 with ApplicationDAO

use of org.wso2.carbon.apimgt.core.dao.ApplicationDAO in project carbon-apimgt by wso2.

the class ApplicationDAOImplIT method testAddAndGetApplication.

@Test
public void testAddAndGetApplication() throws Exception {
    // add new app
    Application app = TestUtil.addTestApplication();
    ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO();
    // get added app
    Application appFromDB = applicationDAO.getApplication(app.getId());
    Assert.assertNotNull(appFromDB);
    // compare
    Assert.assertEquals(appFromDB, app, TestUtil.printDiff(appFromDB, app));
    validateAppTimestamps(appFromDB, app);
}
Also used : ApplicationDAO(org.wso2.carbon.apimgt.core.dao.ApplicationDAO) Application(org.wso2.carbon.apimgt.core.models.Application) Test(org.testng.annotations.Test)

Example 3 with ApplicationDAO

use of org.wso2.carbon.apimgt.core.dao.ApplicationDAO in project carbon-apimgt by wso2.

the class ApplicationDAOImplIT method testGetAllApplications.

@Test
public void testGetAllApplications() throws Exception {
    // add 4 apps
    String username = "admin";
    Application app1 = TestUtil.addCustomApplication("App1", username);
    Application app2 = TestUtil.addCustomApplication("App2", username);
    Application app3 = TestUtil.addCustomApplication("App3", username);
    Application app4 = TestUtil.addCustomApplication("App4", username);
    ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO();
    // get added apps
    List<Application> appsFromDB = applicationDAO.getApplications(username);
    Assert.assertNotNull(appsFromDB);
    Assert.assertEquals(appsFromDB.size(), 4);
    for (Application application : appsFromDB) {
        Assert.assertNotNull(application);
        if (application.getName().equals(app1.getName())) {
            Assert.assertEquals(application, app1, TestUtil.printDiff(application, app1));
            validateAppTimestamps(application, app1);
        } else if (application.getName().equals(app2.getName())) {
            Assert.assertEquals(application, app2, TestUtil.printDiff(application, app2));
            validateAppTimestamps(application, app2);
        } else if (application.getName().equals(app3.getName())) {
            Assert.assertEquals(application, app3, TestUtil.printDiff(application, app3));
            validateAppTimestamps(application, app3);
        } else if (application.getName().equals(app4.getName())) {
            Assert.assertEquals(application, app4, TestUtil.printDiff(application, app4));
            validateAppTimestamps(application, app4);
        } else {
            Assert.fail("Invalid Application returned.");
        }
    }
}
Also used : ApplicationDAO(org.wso2.carbon.apimgt.core.dao.ApplicationDAO) Application(org.wso2.carbon.apimgt.core.models.Application) Test(org.testng.annotations.Test)

Example 4 with ApplicationDAO

use of org.wso2.carbon.apimgt.core.dao.ApplicationDAO in project carbon-apimgt by wso2.

the class ApplicationDAOImplIT method testAddApplicationWithPermissions.

@Test
public void testAddApplicationWithPermissions() throws Exception {
    // add new app with permissions
    Application app = TestUtil.addTestApplicationWithPermissions();
    ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO();
    // get added app
    Application appFromDB = applicationDAO.getApplication(app.getId());
    Assert.assertNotNull(appFromDB);
    // compare
    Assert.assertEquals(appFromDB, app, TestUtil.printDiff(appFromDB, app));
    validateAppTimestamps(appFromDB, app);
}
Also used : ApplicationDAO(org.wso2.carbon.apimgt.core.dao.ApplicationDAO) Application(org.wso2.carbon.apimgt.core.models.Application) Test(org.testng.annotations.Test)

Example 5 with ApplicationDAO

use of org.wso2.carbon.apimgt.core.dao.ApplicationDAO in project carbon-apimgt by wso2.

the class ApplicationDAOImplIT method testUpdateApplication.

@Test
public void testUpdateApplication() throws Exception {
    // add new app
    Application currentApp = TestUtil.addTestApplication();
    ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO();
    Application newApp = SampleTestObjectCreator.createAlternativeApplication();
    newApp.setId(currentApp.getId());
    newApp.setCreatedTime(currentApp.getCreatedTime());
    // update app
    applicationDAO.updateApplication(currentApp.getId(), newApp);
    // get app
    Application appFromDB = applicationDAO.getApplication(newApp.getId());
    Assert.assertNotNull(appFromDB);
    // compare
    Assert.assertEquals(appFromDB, newApp, TestUtil.printDiff(appFromDB, newApp));
    validateAppTimestamps(appFromDB, newApp);
}
Also used : ApplicationDAO(org.wso2.carbon.apimgt.core.dao.ApplicationDAO) Application(org.wso2.carbon.apimgt.core.models.Application) Test(org.testng.annotations.Test)

Aggregations

ApplicationDAO (org.wso2.carbon.apimgt.core.dao.ApplicationDAO)62 Test (org.testng.annotations.Test)56 Application (org.wso2.carbon.apimgt.core.models.Application)50 BeforeTest (org.testng.annotations.BeforeTest)32 APIStore (org.wso2.carbon.apimgt.core.api.APIStore)32 WorkflowDAO (org.wso2.carbon.apimgt.core.dao.WorkflowDAO)21 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)18 APISubscriptionDAO (org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO)18 PolicyDAO (org.wso2.carbon.apimgt.core.dao.PolicyDAO)15 ApplicationPolicy (org.wso2.carbon.apimgt.core.models.policy.ApplicationPolicy)15 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)13 SubscriptionPolicy (org.wso2.carbon.apimgt.core.models.policy.SubscriptionPolicy)13 API (org.wso2.carbon.apimgt.core.models.API)12 Policy (org.wso2.carbon.apimgt.core.models.policy.Policy)10 SQLException (java.sql.SQLException)8 APIBuilder (org.wso2.carbon.apimgt.core.models.API.APIBuilder)7 ApiDAO (org.wso2.carbon.apimgt.core.dao.ApiDAO)6 WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)5 CompositeAPI (org.wso2.carbon.apimgt.core.models.CompositeAPI)5 Subscription (org.wso2.carbon.apimgt.core.models.Subscription)4