task_23692 #4

Merged
francesco.mangiacrapa merged 4 commits from task_23692 into master 2022-08-01 15:03:14 +02:00
1 changed files with 50 additions and 26 deletions
Showing only changes of commit e0eff32f80 - Show all commits

View File

@ -13,8 +13,7 @@ import org.gcube.datacatalogue.utillibrary.server.DataCatalogueImpl;
import org.gcube.datacatalogue.utillibrary.server.cms.CatalogueContentModeratorSystem;
import org.gcube.datacatalogue.utillibrary.shared.ItemStatus;
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
import org.junit.Before;
import org.junit.Test;
import org.gcube.gcat.client.Item;
import org.slf4j.LoggerFactory;
/**
@ -27,20 +26,38 @@ 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 = "";
private String scope = "/gcube/devsec/devVRE";
//private String scope = "/gcube/devsec";
private String authorizationToken = ""; //devVRE
/**
* Before.
*
* @throws Exception the exception
*/
@Before
//@Before
public void before() throws Exception {
factory = DataCatalogueFactory.getFactory();
}
//@Test
public void testGCatAvailability() {
try {
LOG.info("testGCatAvailability running");
int offset = 0;
int limit = 10;
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(authorizationToken);
LOG.debug("Trying with scope: "+scope);
String items = new Item().list(limit, offset);
LOG.debug("List items: " + items);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Factory test.
*
@ -58,27 +75,34 @@ public class TestDataCatalogueCMS {
// @Test
public void listItemsForCMStatus() throws Exception {
ItemStatus theStatus = ItemStatus.PENDING;
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(authorizationToken);
DataCatalogueImpl dImpl = factory.getUtilsPerScope(scope);
CatalogueContentModeratorSystem cCMS = dImpl.getCatalogueContentModerator();
LOG.debug(CatalogueContentModeratorSystem.class.getName() + " instancied correclty");
try {
ItemStatus theStatus = ItemStatus.PENDING;
List<String> emailsAddresses = new ArrayList<String>();
// emailsAddresses.add("luca.frosini@isti.cnr.it");
emailsAddresses.add("francesco.mangiacrapa@isti.cnr.it");
// emailsAddresses.add("pagano@cnr.it");
SecurityTokenProvider.instance.set(authorizationToken);
DataCatalogueImpl dImpl = factory.getUtilsPerScope(scope);
CatalogueContentModeratorSystem cCMS = dImpl.getCatalogueContentModerator();
LOG.debug(CatalogueContentModeratorSystem.class.getName() + " instancied correclty");
String theQuery = mockQueryForEmails(emailsAddresses, "OR");
List<String> emailsAddresses = new ArrayList<String>();
// emailsAddresses.add("luca.frosini@isti.cnr.it");
emailsAddresses.add("francesco.mangiacrapa@isti.cnr.it");
// emailsAddresses.add("pagano@cnr.it");
Map<String, String> filters = new HashMap<String, String>();
filters.put("author_email", theQuery);
String theQuery = mockQueryForEmails(emailsAddresses, "OR");
List<CkanDataset> listItems = cCMS.getListItemsForStatus(theStatus, 10, 0, filters, GCatCaller.DEFAULT_SORT_VALUE);
int i = 0;
for (CkanDataset ckanDataset : listItems) {
System.out.println(++i + ") item returned: " + ckanDataset);
Map<String, String> filters = new HashMap<String, String>();
filters.put("author_email", theQuery);
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(authorizationToken);
List<CkanDataset> listItems = cCMS.getListItemsForStatus(theStatus, 10, 0, true, filters,
GCatCaller.DEFAULT_SORT_VALUE);
int i = 0;
for (CkanDataset ckanDataset : listItems) {
System.out.println(++i + ") item returned: " + ckanDataset);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@ -89,7 +113,7 @@ public class TestDataCatalogueCMS {
* @return the scope per url
* @throws Exception
*/
@Test
// @Test
public void countListItemsForStatus() throws Exception {
try {
@ -101,9 +125,9 @@ public class TestDataCatalogueCMS {
LOG.debug(CatalogueContentModeratorSystem.class.getName() + " instancied correclty");
List<String> emailsAddresses = new ArrayList<String>();
//emailsAddresses.add("luca.frosini@isti.cnr.it");
//emailsAddresses.add("francesco.mangiacrapa@isti.cnr.it");
//emailsAddresses.add("pagano@cnr.it");
// emailsAddresses.add("luca.frosini@isti.cnr.it");
emailsAddresses.add("francesco.mangiacrapa@isti.cnr.it");
// emailsAddresses.add("pagano@cnr.it");
String theQuery = mockQueryForEmails(emailsAddresses, "OR");