Fixed test
This commit is contained in:
parent
166ea432c3
commit
c489f267e6
|
@ -1,48 +1,45 @@
|
|||
package org.gcube.application.geoportal.clients;
|
||||
package org.gcube.application.geoportal.clients.legacy;
|
||||
|
||||
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.sun.corba.se.spi.orbutil.threadpool.Work;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniFilters;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniQueries;
|
||||
import org.gcube.application.geoportal.client.utils.ConcessioniUtils;
|
||||
import org.gcube.application.geoportal.client.utils.Queries;
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
import org.gcube.application.geoportal.clients.BasicVreTests;
|
||||
import org.gcube.application.geoportal.common.model.legacy.*;
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione.Paths;
|
||||
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport.ValidationStatus;
|
||||
import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||
import org.gcube.application.geoportal.common.utils.FileSets;
|
||||
import org.gcube.application.geoportal.common.utils.Files;
|
||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
|
||||
import org.junit.Test;
|
||||
|
||||
public class StatelessClientTests extends BasicVreTests{
|
||||
import java.io.File;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
private MongoConcessioni client=mongoConcessioni().build();
|
||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.mongoConcessioni;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
|
||||
public class StatelessClientTests extends BasicVreTests {
|
||||
|
||||
|
||||
private final MongoConcessioni client=mongoConcessioni().build();
|
||||
|
||||
@Test
|
||||
public void getConfiguration() throws Exception {
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
System.out.println(client.getCurrentConfiguration());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void searches() throws Exception {
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
TestConcessioniFilters.filters.forEach((k, v)->{
|
||||
try {
|
||||
System.out.println("Count for " + k + "\t" + count(client.search(v)));
|
||||
|
@ -57,7 +54,7 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void query() throws Exception {
|
||||
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
System.out.println("FRA "+ count(client.query(
|
||||
Queries.parse(TestConcessioniQueries.queries.get("emptyresult.json")))));
|
||||
|
||||
|
@ -95,6 +92,7 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void testList() throws Exception {
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
final AtomicLong counter=new AtomicLong();
|
||||
long before=System.currentTimeMillis();
|
||||
client.getList().forEachRemaining((Concessione c)-> {counter.addAndGet(1);});
|
||||
|
@ -103,6 +101,7 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void testCreateNew() throws Exception {
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
Concessione c= client.createNew(TestConcessioniModel.prepareEmptyConcessione());
|
||||
assertNotNull(c);
|
||||
assertNotNull(c.getMongo_id());
|
||||
|
@ -112,7 +111,9 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void testClone() throws Exception {
|
||||
Concessione c= prepare();
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
//Concessione c= prepare();
|
||||
Concessione c = client.getById("6165af0102ad3d60e1d26edd");
|
||||
Concessione copied = ConcessioniUtils.clone(client,c.getMongo_id());
|
||||
assertEquals(copied.getNome(),c.getNome());
|
||||
checkCopied(copied.getRelazioneScavo(),c.getRelazioneScavo());
|
||||
|
@ -124,6 +125,13 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
assertEquals(copied.getImmaginiRappresentative().size(),c.getImmaginiRappresentative().size());
|
||||
for(int i=0;i<c.getImmaginiRappresentative().size();i++)
|
||||
checkCopied(copied.getImmaginiRappresentative().get(i),c.getImmaginiRappresentative().get(i));
|
||||
|
||||
|
||||
// checking publish outcome
|
||||
if(c.getReport()!=null && c.getReport().getStatus().equals(ValidationStatus.PASSED)){
|
||||
copied = client.publish(copied.getMongo_id());
|
||||
assertEquals(c.getReport().getStatus(),copied.getReport().getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkCopied(AssociatedContent copied,AssociatedContent original){
|
||||
|
@ -131,11 +139,11 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
assertEquals(copied.getLicenseID(),original.getLicenseID());
|
||||
assertEquals(copied.getTitolo(),original.getTitolo());
|
||||
if(copied instanceof LayerConcessione){
|
||||
assertNull(((LayerConcessione)copied).getLayerName());
|
||||
assertNull(((LayerConcessione)copied).getLayerID());
|
||||
assertNull(((LayerConcessione)copied).getLayerUUID());
|
||||
assertNull(((LayerConcessione)copied).getWorkspace());
|
||||
assertNull(((LayerConcessione)copied).getWmsLink());
|
||||
assertNull(((LayerConcessione)copied).getLayerName());
|
||||
assertNull(((LayerConcessione)copied).getLayerID());
|
||||
assertNull(((LayerConcessione)copied).getLayerUUID());
|
||||
assertNull(((LayerConcessione)copied).getWorkspace());
|
||||
assertNull(((LayerConcessione)copied).getWmsLink());
|
||||
}
|
||||
|
||||
if(original.getActualContent()!=null){
|
||||
|
@ -153,6 +161,7 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void testReplace() throws Exception {
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
Concessione testObject= client.createNew(TestConcessioniModel.prepareEmptyConcessione());
|
||||
String title="My new shiny Title";
|
||||
testObject.setNome(title);
|
||||
|
@ -162,12 +171,14 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void testUploadFileSet() throws Exception {
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
Concessione testObject= client.createNew(TestConcessioniModel.prepareConcessione());
|
||||
AddSectionToConcessioneRequest request=
|
||||
Serialization.convert(
|
||||
// FileSets.prepareRequest(new StorageUtils(),Paths.RELAZIONE,new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"));
|
||||
FileSets.build(Paths.ABSTRACT_RELAZIONE).add(
|
||||
new StorageUtils().putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"),"San Mauro_drone totale.JPG"))
|
||||
.getTheRequest();
|
||||
FileSets.build(Paths.ABSTRACT_RELAZIONE,null,null).add(
|
||||
new StorageUtils().putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"),"San Mauro_drone totale.JPG"))
|
||||
.getTheRequest(),AddSectionToConcessioneRequest.class);
|
||||
|
||||
testObject= client.registerFileSet(testObject.getMongo_id(), request);
|
||||
|
||||
|
@ -179,6 +190,7 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void testDeleteById() throws Exception {
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
Concessione c= client.createNew(TestConcessioniModel.prepareEmptyConcessione());
|
||||
client.deleteById(c.getMongo_id());
|
||||
}
|
||||
|
@ -186,6 +198,7 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void testPublish() throws Exception {
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
Concessione c=prepare();
|
||||
|
||||
assertTrue(c.getReport().getStatus().equals(ValidationStatus.PASSED));
|
||||
|
@ -195,7 +208,7 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
|
||||
@Test
|
||||
public void testCleanFileSet() throws Exception {
|
||||
|
||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||
Concessione testObject=prepare();
|
||||
System.out.println("Object is "+testObject.getPosizionamentoScavo());
|
||||
//Precheck to be sure
|
||||
|
@ -236,30 +249,37 @@ public class StatelessClientTests extends BasicVreTests{
|
|||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
c=client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf")));
|
||||
Serialization.convert(FileSets.prepareRequest(storage,Paths.RELAZIONE,null,null,
|
||||
new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf")), AddSectionToConcessioneRequest.class));
|
||||
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
c=client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.ABSTRACT_RELAZIONE,new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf")));
|
||||
Serialization.convert(
|
||||
FileSets.prepareRequest(storage,Paths.ABSTRACT_RELAZIONE,null, null, new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf")),AddSectionToConcessioneRequest.class));
|
||||
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
for(int i=0;i<numImgs;i++)
|
||||
c=client.registerFileSet(mongoId,
|
||||
FileSets.build(Paths.imgByIndex(i)).
|
||||
add(storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"immagine"+(i+1)+".png"),
|
||||
i+"San Mauro_drone totale.JPG")).getTheRequest());
|
||||
Serialization.convert(
|
||||
FileSets.build(Paths.imgByIndex(i),null,null).
|
||||
add(storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"immagine"+(i+1)+".png"),
|
||||
i+"San Mauro_drone totale.JPG")).getTheRequest(),AddSectionToConcessioneRequest.class));
|
||||
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
c=client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.POSIZIONAMENTO,new File(TestConcessioniModel.getBaseFolder(),"pos.shp")));
|
||||
Serialization.convert(
|
||||
FileSets.prepareRequest(storage,Paths.POSIZIONAMENTO,null,null,new File(TestConcessioniModel.getBaseFolder(),
|
||||
"pos.shp")),AddSectionToConcessioneRequest.class));
|
||||
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
c=client.registerFileSet(mongoId,
|
||||
FileSets.prepareRequest(storage,Paths.piantaByIndex(0),new File(TestConcessioniModel.getBaseFolder(),"pianta.shp")));
|
||||
Serialization.convert(
|
||||
FileSets.prepareRequest(storage,Paths.piantaByIndex(0),null,null,
|
||||
new File(TestConcessioniModel.getBaseFolder(),"pianta.shp")),AddSectionToConcessioneRequest.class));
|
||||
|
||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||
|
||||
|
|
Loading…
Reference in New Issue