gcube-cms-suite/geoportal-client/src/test/java/org/gcube/application/geoportal/clients/ProfiledDocumentsTest.java

69 lines
2.6 KiB
Java
Raw Normal View History

2022-02-02 18:34:32 +01:00
package org.gcube.application.geoportal.clients;
2022-02-04 17:45:47 +01:00
import org.gcube.application.geoportal.client.DefaultProfiledDocumentsClient;
2022-03-04 14:23:20 +01:00
import org.gcube.application.geoportal.common.model.document.Project;
2022-02-04 17:45:47 +01:00
import org.gcube.application.geoportal.common.model.rest.Configuration;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
2022-03-04 14:23:20 +01:00
import org.gcube.application.geoportal.common.rest.Projects;
2022-02-24 18:09:30 +01:00
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
2022-02-02 18:34:32 +01:00
import org.junit.Test;
2022-02-04 17:45:47 +01:00
import java.rmi.RemoteException;
import java.util.concurrent.atomic.AtomicLong;
2022-02-02 18:34:32 +01:00
2022-02-04 17:45:47 +01:00
import static junit.framework.TestCase.assertTrue;
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.*;
2022-02-24 18:09:30 +01:00
import static org.junit.Assume.assumeTrue;
2022-02-02 18:34:32 +01:00
2022-03-04 14:23:20 +01:00
public class ProfiledDocumentsTest<M extends Project,C extends Projects<M>> extends BasicVreTests{
2022-02-04 17:45:47 +01:00
protected String getProfileID(){return "profiledConcessioni";}
protected C getClient(){
2022-03-04 14:23:20 +01:00
return (C) profiledModel(getProfileID(), Project.class,DefaultProfiledDocumentsClient.class).build();
2022-02-04 17:45:47 +01:00
}
2022-02-02 18:34:32 +01:00
@Test
public void getConfiguration() throws Exception {
2022-02-24 18:09:30 +01:00
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
2022-03-04 14:23:20 +01:00
Projects<M> client = (Projects<M>) getClient();
2022-02-04 17:45:47 +01:00
Configuration config=client.getConfiguration();
System.out.println("Configuration is "+ config);
}
@Test
public void list() throws Exception {
2022-02-24 18:09:30 +01:00
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
2022-03-04 14:23:20 +01:00
Projects<M> client = (Projects<M>) getClient();
2022-02-04 17:45:47 +01:00
AtomicLong counter=new AtomicLong(0);
client.query(new QueryRequest()).forEachRemaining( M -> counter.incrementAndGet());
System.out.println("Found "+counter.get()+" elements");
System.out.println("Getting JSON ");
System.out.println(client.queryForJSON(new QueryRequest()));
}
@Test
public void scanStatusByID() throws Exception {
2022-02-24 18:09:30 +01:00
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
2022-03-04 14:23:20 +01:00
Projects<M> client = (Projects<M>) getClient();
2022-02-04 17:45:47 +01:00
AtomicLong counter=new AtomicLong(0);
client.query(new QueryRequest()).forEachRemaining( m -> {
2022-02-23 17:13:22 +01:00
System.out.print(counter.incrementAndGet()+ ", ID : "+m.getId());
2022-02-04 17:45:47 +01:00
try {
2022-02-23 17:13:22 +01:00
M proj=client.getById(m.getId());
2022-02-04 17:45:47 +01:00
System.out.println("... OK.. STATUS : "+proj.getLifecycleInformation());
} catch (RemoteException e) {
2022-02-23 17:13:22 +01:00
System.err.println(" Error with "+m.getId());
2022-02-04 17:45:47 +01:00
System.err.println(e);
System.out.println("... ERRR !!!!");
}
});
2022-02-02 18:34:32 +01:00
}
2022-02-04 17:45:47 +01:00
2022-02-02 18:34:32 +01:00
}