catalogue-util-library/src/test/java/org/gcube/datacatalogue/utillibrary/test/TestDataCatalogueCMS.java

107 lines
3.4 KiB
Java

package org.gcube.datacatalogue.utillibrary.test;
import java.util.List;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueFactory;
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueImpl;
import org.gcube.datacatalogue.utillibrary.server.cms.CatalogueContentModeratorSystem;
import org.gcube.datacatalogue.utillibrary.server.cms.ItemStatus;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
import org.junit.Test;
import org.slf4j.LoggerFactory;
/**
* The Class TestDataCatalogueLib.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy) Jun 1, 2020
*/
public class TestDataCatalogueCMS {
private static final org.slf4j.Logger LOG = LoggerFactory.getLogger(TestDataCatalogueCMS.class);
private DataCatalogueFactory factory;
private String scope = "/gcube/devsec/devVRE";
private String testUser = "francesco.mangiacrapa";
private String authorizationToken = "8e74a17c-92f1-405a-b591-3a6090066248-98187548";
/**
* Before.
*
* @throws Exception the exception
*/
// @Before
public void before() throws Exception {
factory = DataCatalogueFactory.getFactory();
}
/**
* Factory test.
*
* @throws Exception the exception
*/
// @Test
public void contentModeratorTest() throws Exception {
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(authorizationToken);
DataCatalogueFactory factory = DataCatalogueFactory.getFactory();
DataCatalogueImpl dImpl = factory.getUtilsPerScope(scope);
CatalogueContentModeratorSystem cCMS = dImpl.getCatalogueContentModerator();
LOG.debug(CatalogueContentModeratorSystem.class.getName() + " instancied correclty");
}
/**
* Gets the scope per url.
*
* @return the scope per url
* @throws Exception
*/
//@Test
public void getListItemsForStatus() throws Exception {
try {
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(authorizationToken);
DataCatalogueFactory factory = DataCatalogueFactory.getFactory();
DataCatalogueImpl dImpl = factory.getUtilsPerScope(scope);
CatalogueContentModeratorSystem cCMS = dImpl.getCatalogueContentModerator();
LOG.debug(CatalogueContentModeratorSystem.class.getName() + " instancied correclty");
List<CkanDataset> listDatasets = cCMS.getListItemsForStatus(ItemStatus.PENDING, 20, 0);
for (CkanDataset ckanDataset : listDatasets) {
LOG.debug("CkanDataset read: " + ckanDataset);
}
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Gets the scope per url.
*
* @return the scope per url
* @throws Exception
*/
//@Test
public void getSizeOfListItemsForStatus() throws Exception {
try {
ItemStatus theStatus = ItemStatus.PENDING;
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(authorizationToken);
DataCatalogueFactory factory = DataCatalogueFactory.getFactory();
DataCatalogueImpl dImpl = factory.getUtilsPerScope(scope);
CatalogueContentModeratorSystem cCMS = dImpl.getCatalogueContentModerator();
LOG.debug(CatalogueContentModeratorSystem.class.getName() + " instancied correclty");
long size = cCMS.countListItemsForStatus(theStatus);
LOG.debug("Size of list of items for status "+theStatus + " is: "+ size);
} catch (Exception e) {
e.printStackTrace();
}
}
}