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