|
|
|
@ -2,6 +2,7 @@ package org.gcube.application.geoportal.clients;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
@ -28,93 +29,6 @@ public class StatelessClientTests extends BasicVreTests{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private MongoConcessioni client=mongoConcessioni().build();
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCreateNew() throws Exception {
|
|
|
|
|
Concessione c= client.createNew(TestModel.prepareEmptyConcessione());
|
|
|
|
|
assertNotNull(c);
|
|
|
|
|
assertNotNull(c.getMongo_id());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testDeleteById() throws Exception {
|
|
|
|
|
Concessione c= client.createNew(TestModel.prepareEmptyConcessione());
|
|
|
|
|
client.deleteById(c.getMongo_id());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testList() throws Exception {
|
|
|
|
|
final AtomicLong counter=new AtomicLong();
|
|
|
|
|
long before=System.currentTimeMillis();
|
|
|
|
|
client.getList().forEachRemaining((Concessione c)-> {counter.addAndGet(1);});
|
|
|
|
|
System.out.println("Loaded "+counter+" in "+(System.currentTimeMillis()-before)+" ms");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testReplace() throws Exception {
|
|
|
|
|
Concessione c= client.createNew(TestModel.prepareEmptyConcessione());
|
|
|
|
|
|
|
|
|
|
String title="My new shiny Title";
|
|
|
|
|
c.setNome(title);
|
|
|
|
|
Concessione c1=client.replace(c);
|
|
|
|
|
assertEquals(title, c1.getNome());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUploadFileSet() throws Exception {
|
|
|
|
|
Concessione c= client.createNew(TestModel.prepareConcessione());
|
|
|
|
|
assertNotNull(c.getRelazioneScavo());
|
|
|
|
|
AddSectionToConcessioneRequest request=
|
|
|
|
|
FileSets.prepareRequest(new StorageUtils(),Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf"));
|
|
|
|
|
|
|
|
|
|
c= client.registerFileSet(c.getMongo_id(), request);
|
|
|
|
|
|
|
|
|
|
assertNotNull(c.getRelazioneScavo().getActualContent());
|
|
|
|
|
assertNotNull(c.getRelazioneScavo().getActualContent().get(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testPublsh() throws Exception {
|
|
|
|
|
publish(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Concessione publish(Boolean verify) throws Exception {
|
|
|
|
|
return publish(verify,client);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Concessione publish(Boolean verify,MongoConcessioni client) throws Exception {
|
|
|
|
|
Concessione c= client.createNew(TestModel.prepareConcessione(1,1));
|
|
|
|
|
StorageUtils storage = new StorageUtils();
|
|
|
|
|
|
|
|
|
|
String mongoId=c.getMongo_id();
|
|
|
|
|
|
|
|
|
|
client.registerFileSet(mongoId,
|
|
|
|
|
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf")));
|
|
|
|
|
|
|
|
|
|
client.registerFileSet(mongoId,
|
|
|
|
|
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf")));
|
|
|
|
|
|
|
|
|
|
client.registerFileSet(mongoId,
|
|
|
|
|
FileSets.prepareRequest(storage,Paths.imgByIndex(0),new File(TestModel.getBaseFolder(),"immagine.png")));
|
|
|
|
|
|
|
|
|
|
client.registerFileSet(mongoId,
|
|
|
|
|
FileSets.prepareRequest(storage,Paths.POSIZIONAMENTO,new File(TestModel.getBaseFolder(),"pos.shp")));
|
|
|
|
|
|
|
|
|
|
client.registerFileSet(mongoId,
|
|
|
|
|
FileSets.prepareRequest(storage,Paths.piantaByIndex(0),new File(TestModel.getBaseFolder(),"pianta.shp")));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c=client.publish(mongoId);
|
|
|
|
|
|
|
|
|
|
if(verify)
|
|
|
|
|
assertTrue(c.getReport().getStatus().equals(ValidationStatus.PASSED));
|
|
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void getConfiguration() throws Exception {
|
|
|
|
@ -168,22 +82,98 @@ public class StatelessClientTests extends BasicVreTests{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCleanFileSet() throws Exception {
|
|
|
|
|
public void testList() throws Exception {
|
|
|
|
|
final AtomicLong counter=new AtomicLong();
|
|
|
|
|
long before=System.currentTimeMillis();
|
|
|
|
|
client.getList().forEachRemaining((Concessione c)-> {counter.addAndGet(1);});
|
|
|
|
|
System.out.println("Loaded "+counter+" in "+(System.currentTimeMillis()-before)+" ms");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCreateNew() throws Exception {
|
|
|
|
|
Concessione c= client.createNew(TestModel.prepareEmptyConcessione());
|
|
|
|
|
assertNotNull(c);
|
|
|
|
|
assertNotNull(c.getMongo_id());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testReplace() throws Exception {
|
|
|
|
|
Concessione testObject= client.createNew(TestModel.prepareEmptyConcessione());
|
|
|
|
|
String title="My new shiny Title";
|
|
|
|
|
testObject.setNome(title);
|
|
|
|
|
Concessione c1=client.replace(testObject);
|
|
|
|
|
assertEquals(title, c1.getNome());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testUploadFileSet() throws Exception {
|
|
|
|
|
Concessione testObject= client.createNew(TestModel.prepareEmptyConcessione());
|
|
|
|
|
AddSectionToConcessioneRequest request=
|
|
|
|
|
// FileSets.prepareRequest(new StorageUtils(),Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf"));
|
|
|
|
|
FileSets.build(Paths.ABSTRACT_RELAZIONE).add(
|
|
|
|
|
new StorageUtils().putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"),"San Mauro_drone totale.JPG"))
|
|
|
|
|
.getTheRequest();
|
|
|
|
|
|
|
|
|
|
testObject= client.registerFileSet(testObject.getMongo_id(), request);
|
|
|
|
|
|
|
|
|
|
Concessione c=publish(false);
|
|
|
|
|
client.unPublish(c.getMongo_id());
|
|
|
|
|
assertNotNull(testObject.getContentByPath(Paths.ABSTRACT_RELAZIONE).getActualContent());
|
|
|
|
|
assertNotNull(testObject.getContentByPath(Paths.ABSTRACT_RELAZIONE).getActualContent().get(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testDeleteById() throws Exception {
|
|
|
|
|
Concessione c= client.createNew(TestModel.prepareEmptyConcessione());
|
|
|
|
|
client.deleteById(c.getMongo_id());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public Concessione testPublsh() throws Exception {
|
|
|
|
|
Concessione c= client.createNew(TestModel.prepareConcessione(1,1));
|
|
|
|
|
StorageUtils storage = new StorageUtils();
|
|
|
|
|
|
|
|
|
|
String mongoId=c.getMongo_id();
|
|
|
|
|
|
|
|
|
|
client.registerFileSet(mongoId,
|
|
|
|
|
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf")));
|
|
|
|
|
|
|
|
|
|
client.registerFileSet(mongoId,
|
|
|
|
|
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf")));
|
|
|
|
|
|
|
|
|
|
client.registerFileSet(mongoId,
|
|
|
|
|
FileSets.prepareRequest(storage,Paths.imgByIndex(0),new File(TestModel.getBaseFolder(),"immagine.png")));
|
|
|
|
|
|
|
|
|
|
client.registerFileSet(mongoId,
|
|
|
|
|
FileSets.prepareRequest(storage,Paths.POSIZIONAMENTO,new File(TestModel.getBaseFolder(),"pos.shp")));
|
|
|
|
|
|
|
|
|
|
client.registerFileSet(mongoId,
|
|
|
|
|
FileSets.prepareRequest(storage,Paths.piantaByIndex(0),new File(TestModel.getBaseFolder(),"pianta.shp")));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c=client.publish(mongoId);
|
|
|
|
|
|
|
|
|
|
assertTrue(c.getReport().getStatus().equals(ValidationStatus.PASSED));
|
|
|
|
|
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testCleanFileSet() throws Exception {
|
|
|
|
|
|
|
|
|
|
Concessione testObject=testPublsh();
|
|
|
|
|
//Precheck to be sure
|
|
|
|
|
assertFalse(c.getPosizionamentoScavo().getActualContent().isEmpty());
|
|
|
|
|
assertFalse(c.getPianteFineScavo().get(0).getActualContent().isEmpty());
|
|
|
|
|
assertFalse(testObject.getPosizionamentoScavo().getActualContent().isEmpty());
|
|
|
|
|
assertFalse(testObject.getPianteFineScavo().get(0).getActualContent().isEmpty());
|
|
|
|
|
|
|
|
|
|
//Clear pos
|
|
|
|
|
c=client.cleanFileSet(c.getMongo_id(),Paths.POSIZIONAMENTO);
|
|
|
|
|
assertTrue(c.getPosizionamentoScavo().getActualContent().isEmpty());
|
|
|
|
|
testObject=client.cleanFileSet(testObject.getMongo_id(),Paths.POSIZIONAMENTO);
|
|
|
|
|
assertTrue(testObject.getPosizionamentoScavo().getActualContent().isEmpty());
|
|
|
|
|
|
|
|
|
|
//Clear pianta [0]
|
|
|
|
|
c=client.cleanFileSet(c.getMongo_id(),Paths.piantaByIndex(0));
|
|
|
|
|
assertTrue(c.getPianteFineScavo().get(0).getActualContent().isEmpty());
|
|
|
|
|
testObject =client.cleanFileSet(testObject.getMongo_id(),Paths.piantaByIndex(0));
|
|
|
|
|
assertTrue(testObject.getPianteFineScavo().get(0).getActualContent().isEmpty());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|