2022-02-02 18:34:32 +01:00
|
|
|
package org.gcube.application.geoportal.clients;
|
|
|
|
|
2022-02-04 17:45:47 +01:00
|
|
|
import com.fasterxml.jackson.databind.ser.std.StdKeySerializers;
|
|
|
|
import org.gcube.application.geoportal.client.DefaultProfiledDocumentsClient;
|
2022-02-02 18:34:32 +01:00
|
|
|
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
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-02-02 18:34:32 +01:00
|
|
|
import org.gcube.application.geoportal.common.rest.ProfiledDocumentsI;
|
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-02-04 17:45:47 +01:00
|
|
|
public class ProfiledDocumentsTest<M extends ProfiledDocument,C extends ProfiledDocumentsI<M>> extends BasicVreTests{
|
|
|
|
|
|
|
|
protected String getProfileID(){return "profiledConcessioni";}
|
|
|
|
|
|
|
|
protected C getClient(){
|
|
|
|
return (C) profiledModel(getProfileID(),ProfiledDocument.class,DefaultProfiledDocumentsClient.class).build();
|
|
|
|
}
|
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-02-04 17:45:47 +01:00
|
|
|
ProfiledDocumentsI<M> client = (ProfiledDocumentsI<M>) getClient();
|
|
|
|
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-02-04 17:45:47 +01:00
|
|
|
ProfiledDocumentsI<M> client = (ProfiledDocumentsI<M>) getClient();
|
|
|
|
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-02-04 17:45:47 +01:00
|
|
|
ProfiledDocumentsI<M> client = (ProfiledDocumentsI<M>) getClient();
|
|
|
|
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
|
|
|
}
|