78 lines
2.7 KiB
Java
78 lines
2.7 KiB
Java
|
package org.gcube.portlets.user.geoportaldataviewer;
|
||
|
|
||
|
import org.gcube.application.geoportal.common.model.document.Project;
|
||
|
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||
|
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
||
|
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||
|
import org.gcube.application.geoportalcommon.geoportal.ProjectsCaller;
|
||
|
import org.gcube.application.geoportalcommon.geoportal.UseCaseDescriptorCaller;
|
||
|
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||
|
import org.gcube.application.geoportalcommon.shared.geoportal.view.ProjectView;
|
||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||
|
import org.gcube.portlets.user.geoportaldataviewer.server.GeoportalDataViewerServiceImpl;
|
||
|
import org.junit.Before;
|
||
|
import org.junit.Test;
|
||
|
|
||
|
/**
|
||
|
* The Class GeoportalViewer_Tests.
|
||
|
*
|
||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||
|
*
|
||
|
* Sep 9, 2022
|
||
|
*/
|
||
|
public class GeoportalViewer_Tests {
|
||
|
|
||
|
private UseCaseDescriptorCaller clientUCD;
|
||
|
|
||
|
private ProjectsCaller clientProjects;
|
||
|
|
||
|
// private static String CONTEXT = "/pred4s/preprod/preVRE";
|
||
|
// private static String TOKEN = ""; //preVRE
|
||
|
|
||
|
private static String CONTEXT = "/gcube/devsec/devVRE";
|
||
|
private static String TOKEN = "c41a00c0-7897-48d2-a67a-05190d6ce5e6-98187548"; // devVRE
|
||
|
|
||
|
private static String PROFILE_ID = "profiledConcessioni";
|
||
|
private static String PROJECT_ID = "6311d408900dde90e44d9265";
|
||
|
|
||
|
private static String USERNAME = "francesco.mangiacrapa";
|
||
|
|
||
|
/**
|
||
|
* Gets the client.
|
||
|
*
|
||
|
* @return the client
|
||
|
*/
|
||
|
@Before
|
||
|
public void getClient() {
|
||
|
// assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||
|
ScopeProvider.instance.set(CONTEXT);
|
||
|
SecurityTokenProvider.instance.set(TOKEN);
|
||
|
clientUCD = GeoportalClientCaller.useCaseDescriptors();
|
||
|
clientProjects = GeoportalClientCaller.projects();
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
public void getPreviewObjectForID() {
|
||
|
|
||
|
try {
|
||
|
ScopeProvider.instance.set(CONTEXT);
|
||
|
SecurityTokenProvider.instance.set(TOKEN);
|
||
|
Project project = clientProjects.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||
|
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||
|
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
|
||
|
|
||
|
ScopeProvider.instance.set(CONTEXT);
|
||
|
SecurityTokenProvider.instance.set(TOKEN);
|
||
|
GeoportalDataViewerServiceImpl gdvsi = new GeoportalDataViewerServiceImpl();
|
||
|
|
||
|
ProjectView projectView = gdvsi.loadProjectView(projectDV, CONTEXT, USERNAME);
|
||
|
System.out.println(projectView);
|
||
|
} catch (Exception e) {
|
||
|
// TODO Auto-generated catch block
|
||
|
e.printStackTrace();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|