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,8 +75,9 @@ public class TestDataCatalogueCMS {
// @Test // @Test
public void listItemsForCMStatus() throws Exception { public void listItemsForCMStatus() throws Exception {
try {
ItemStatus theStatus = ItemStatus.PENDING; ItemStatus theStatus = ItemStatus.PENDING;
ScopeProvider.instance.set(scope);
SecurityTokenProvider.instance.set(authorizationToken); SecurityTokenProvider.instance.set(authorizationToken);
DataCatalogueImpl dImpl = factory.getUtilsPerScope(scope); DataCatalogueImpl dImpl = factory.getUtilsPerScope(scope);
CatalogueContentModeratorSystem cCMS = dImpl.getCatalogueContentModerator(); CatalogueContentModeratorSystem cCMS = dImpl.getCatalogueContentModerator();
@ -75,11 +93,17 @@ public class TestDataCatalogueCMS {
Map<String, String> filters = new HashMap<String, String>(); Map<String, String> filters = new HashMap<String, String>();
filters.put("author_email", theQuery); filters.put("author_email", theQuery);
List<CkanDataset> listItems = cCMS.getListItemsForStatus(theStatus, 10, 0, filters, GCatCaller.DEFAULT_SORT_VALUE); 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; int i = 0;
for (CkanDataset ckanDataset : listItems) { for (CkanDataset ckanDataset : listItems) {
System.out.println(++i + ") item returned: " + ckanDataset); 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 {
@ -102,7 +126,7 @@ public class TestDataCatalogueCMS {
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");