93 lines
2.8 KiB
Java
93 lines
2.8 KiB
Java
package org.gcube.application;
|
|
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
|
import org.gcube.application.geoportalcommon.MongoServiceCommon;
|
|
import org.gcube.application.geoportalcommon.config.GNADataConfigProfileReader;
|
|
import org.gcube.application.geoportalcommon.shared.GeoNaDataViewerProfile;
|
|
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
|
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
|
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
|
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
|
|
public class TestGNACommon {
|
|
|
|
private static String TOKEN = "";
|
|
private static String CONTEXT = "/gcube/devsec/devVRE";
|
|
private static String USERNAME = "francesco.mangiacrapa";
|
|
|
|
@Before
|
|
public void init() {
|
|
ScopeProvider.instance.set(CONTEXT);
|
|
SecurityTokenProvider.instance.set(TOKEN);
|
|
}
|
|
|
|
//@Test
|
|
public GeoNaDataViewerProfile getGeoNaDataViewProfile() throws Exception {
|
|
System.out.println("getGeoNaDataViewProfile called");
|
|
|
|
ScopeProvider.instance.set(CONTEXT);
|
|
GeoportalCommon gc = new GeoportalCommon();
|
|
GeoNaDataViewerProfile profile = gc.getGeoNaDataViewProfile(null);
|
|
System.out.println("Returning profile: " + profile);
|
|
return profile;
|
|
}
|
|
|
|
//@Test
|
|
public GeoNaItemRef getLinks() throws Exception {
|
|
System.out.println("getGeoNaDataViewProfile called");
|
|
|
|
ScopeProvider.instance.set(CONTEXT);
|
|
GeoportalCommon gc = new GeoportalCommon();
|
|
GeoNaItemRef item = new GeoNaItemRef("", "concessione");
|
|
GeoNaItemRef links = gc.getPublicLinksFor(item, true);
|
|
return links;
|
|
}
|
|
|
|
@Test
|
|
public void queryConcessioniTest() throws Exception {
|
|
try {
|
|
|
|
ScopeProvider.instance.set(CONTEXT);
|
|
MongoServiceCommon msc = new MongoServiceCommon();
|
|
SearchingFilter filter = new SearchingFilter();
|
|
|
|
Map<String, Object> searchInto = new HashMap<String, Object>();
|
|
//searchInto.put("nome", "mock");
|
|
searchInto.put("authors", "annalisa");
|
|
filter.setSearchInto(searchInto);
|
|
ResultSetPaginatedData result = msc.queryOnMongo(30, 0, 30, filter, "concessione");
|
|
|
|
int i = 0;
|
|
for (ConcessioneDV concessione : result.getData()) {
|
|
System.out.println(++i +") "+concessione);
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
// TODO: handle exception
|
|
}
|
|
|
|
}
|
|
|
|
//@Test
|
|
public void readUserRights() throws Exception {
|
|
|
|
GNADataConfigProfileReader r = new GNADataConfigProfileReader();
|
|
try {
|
|
ScopeProvider.instance.set(CONTEXT);
|
|
r.readProfileFromInfrastrucure();
|
|
} catch (Exception e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
}
|