Search in sources :

Example 1 with ResourceDataBean

use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceDataBean in project entando-core by entando.

the class ResourceManagerIntegrationTest method testAddNullResource.

public void testAddNullResource() throws Throwable {
    List<String> allowedGroups = this.getAllGroupCodes();
    String resDescrToAdd = "Null Entando resource";
    String resourceType = "Attach";
    List<String> resourcesId = _resourceManager.searchResourcesId(resourceType, null, null, allowedGroups);
    int initsize = resourcesId.size();
    ResourceDataBean bean = this.getNullMockResource(resourceType, resDescrToAdd);
    try {
        this._resourceManager.addResource(bean);
        fail();
    } catch (Throwable t) {
    // nothing to do
    } finally {
        this.verifyTestAddNullResource(resDescrToAdd, resourceType, initsize);
    }
}
Also used : MockResourceDataBean(com.agiletec.plugins.jacms.aps.system.services.resource.mock.MockResourceDataBean) ResourceDataBean(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceDataBean)

Example 2 with ResourceDataBean

use of com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceDataBean in project entando-core by entando.

the class ResourceManagerIntegrationTest method testAddRemoveImageResource.

private void testAddRemoveImageResource(String mainGroup) throws Throwable {
    List<String> allowedGroups = this.getAllGroupCodes();
    ResourceInterface res = null;
    String resDescrToAdd = "Entando Logo";
    String resourceType = "Image";
    String categoryCodeToAdd = "resCat1";
    ResourceDataBean bean = this.getMockResource(resourceType, mainGroup, resDescrToAdd, categoryCodeToAdd);
    try {
        List<String> resourcesId = _resourceManager.searchResourcesId(resourceType, null, categoryCodeToAdd, allowedGroups);
        assertEquals(1, resourcesId.size());
        this._resourceManager.addResource(bean);
        resourcesId = _resourceManager.searchResourcesId(resourceType, resDescrToAdd, null, allowedGroups);
        assertEquals(resourcesId.size(), 1);
        resourcesId = _resourceManager.searchResourcesId(resourceType, resDescrToAdd, categoryCodeToAdd, allowedGroups);
        assertEquals(resourcesId.size(), 1);
        res = this._resourceManager.loadResource(resourcesId.get(0));
        assertTrue(res instanceof ImageResource);
        assertEquals(res.getCategories().size(), 1);
        assertEquals(res.getDescription(), resDescrToAdd);
        ResourceInstance instance0 = ((ImageResource) res).getInstance(0, null);
        assertEquals("entando_logo.jpg", res.getMasterFileName());
        assertEquals("image/jpeg", instance0.getMimeType());
        resourcesId = _resourceManager.searchResourcesId(resourceType, null, categoryCodeToAdd, allowedGroups);
        assertEquals(resourcesId.size(), 2);
    } catch (Throwable t) {
        throw t;
    } finally {
        if (res != null) {
            this._resourceManager.deleteResource(res);
            List<String> resources = _resourceManager.searchResourcesId(resourceType, resDescrToAdd, null, allowedGroups);
            assertEquals(resources.size(), 0);
            resources = _resourceManager.searchResourcesId(resourceType, null, categoryCodeToAdd, allowedGroups);
            assertEquals(resources.size(), 1);
        }
    }
}
Also used : ImageResource(com.agiletec.plugins.jacms.aps.system.services.resource.model.ImageResource) MockResourceDataBean(com.agiletec.plugins.jacms.aps.system.services.resource.mock.MockResourceDataBean) ResourceDataBean(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceDataBean) ResourceInstance(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInstance) ResourceInterface(com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)

Aggregations

MockResourceDataBean (com.agiletec.plugins.jacms.aps.system.services.resource.mock.MockResourceDataBean)2 ResourceDataBean (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceDataBean)2 ImageResource (com.agiletec.plugins.jacms.aps.system.services.resource.model.ImageResource)1 ResourceInstance (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInstance)1 ResourceInterface (com.agiletec.plugins.jacms.aps.system.services.resource.model.ResourceInterface)1