Search in sources :

Example 1 with MockResourcesDAO

use of com.agiletec.aps.services.mock.MockResourcesDAO in project entando-core by entando.

the class TestResourceDAO method testAddDeleteResource.

public void testAddDeleteResource() throws Throwable {
    DataSource dataSource = (DataSource) this.getApplicationContext().getBean("portDataSource");
    MockResourcesDAO mockResourcesDao = new MockResourcesDAO();
    mockResourcesDao.setDataSource(dataSource);
    ResourceInterface resource = new ImageResource();
    resource.setId("temp");
    resource.setDescr("temp");
    resource.setMainGroup(Group.FREE_GROUP_NAME);
    resource.setType("Image");
    resource.setFolder("/temp");
    // resource.setBaseURL("temp");
    ResourceRecordVO resourceRecordVO = null;
    try {
        mockResourcesDao.deleteResource("temp");
    } catch (Throwable t) {
        throw t;
    }
    _resourceDao.addResource(resource);
    resourceRecordVO = _resourceDao.loadResourceVo(resource.getId());
    assertEquals(resourceRecordVO.getDescr().equals("temp"), true);
    _resourceDao.deleteResource(resource.getId());
    resourceRecordVO = _resourceDao.loadResourceVo(resource.getId());
    assertNull(resourceRecordVO);
}
Also used : ImageResource(com.agiletec.plugins.jacms.aps.system.services.resource.model.ImageResource) ResourceRecordVO(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceRecordVO) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface) MockResourcesDAO(com.agiletec.aps.services.mock.MockResourcesDAO) DataSource(javax.sql.DataSource)

Aggregations

MockResourcesDAO (com.agiletec.aps.services.mock.MockResourcesDAO)1 ImageResource (com.agiletec.plugins.jacms.aps.system.services.resource.model.ImageResource)1 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)1 ResourceRecordVO (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceRecordVO)1 DataSource (javax.sql.DataSource)1