Refactored Test Classes
This commit is contained in:
parent
5d1d46e0c5
commit
add1754dcc
|
@ -2,7 +2,7 @@ package org.gcube.application.geoportal;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.gcube.application.cms.tests.TokenSetter;
|
import org.gcube.application.cms.tests.TokenSetter;
|
||||||
import org.gcube.application.cms.tests.model.TestModel;
|
|
||||||
import org.gcube.application.geoportal.common.rest.TempFile;
|
import org.gcube.application.geoportal.common.rest.TempFile;
|
||||||
import org.gcube.application.geoportal.common.utils.Files;
|
import org.gcube.application.geoportal.common.utils.Files;
|
||||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||||
|
|
|
@ -7,7 +7,8 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
import org.gcube.application.cms.tests.model.TestModel;
|
|
||||||
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||||
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
|
import org.gcube.application.geoportal.client.legacy.ConcessioniManagerI;
|
||||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.*;
|
import org.gcube.application.geoportal.common.model.legacy.*;
|
||||||
|
@ -28,28 +29,28 @@ public class StatefulClientTests extends BasicVreTests{
|
||||||
StorageUtils storage=new StorageUtils();
|
StorageUtils storage=new StorageUtils();
|
||||||
|
|
||||||
|
|
||||||
Concessione toRegister= TestModel.prepareEmptyConcessione();
|
Concessione toRegister= TestConcessioniModel.prepareEmptyConcessione();
|
||||||
toRegister.setNome("Mock module");
|
toRegister.setNome("Mock module");
|
||||||
manager.createNew(toRegister);
|
manager.createNew(toRegister);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Concessione source=TestModel.prepareConcessione();
|
Concessione source=TestConcessioniModel.prepareConcessione();
|
||||||
|
|
||||||
|
|
||||||
UploadedImage toRegisterImg= source.getImmaginiRappresentative().get(0);
|
UploadedImage toRegisterImg= source.getImmaginiRappresentative().get(0);
|
||||||
|
|
||||||
// TEMP Files are hosted in INFRASTRUCTURE's VOLATILE AREA
|
// TEMP Files are hosted in INFRASTRUCTURE's VOLATILE AREA
|
||||||
TempFile toUpload=storage.putOntoStorage(
|
TempFile toUpload=storage.putOntoStorage(
|
||||||
new File(TestModel.getBaseFolder(),"immagine1.png"), "immagine.png");
|
new File(TestConcessioniModel.getBaseFolder(),"immagine1.png"), "immagine.png");
|
||||||
|
|
||||||
manager.addImmagineRappresentativa(toRegisterImg, toUpload);
|
manager.addImmagineRappresentativa(toRegisterImg, toUpload);
|
||||||
|
|
||||||
|
|
||||||
//Alternative Method
|
//Alternative Method
|
||||||
InputStreamDescriptor isDesc=
|
InputStreamDescriptor isDesc=
|
||||||
new InputStreamDescriptor(new FileInputStream(new File(TestModel.getBaseFolder(),
|
new InputStreamDescriptor(new FileInputStream(new File(TestConcessioniModel.getBaseFolder(),
|
||||||
"immagine1.png")), "San Mauro_drone totale.JPG");
|
"immagine1.png")), "San Mauro_drone totale.JPG");
|
||||||
manager.addImmagineRappresentativa(toRegisterImg, isDesc);
|
manager.addImmagineRappresentativa(toRegisterImg, isDesc);
|
||||||
|
|
||||||
|
@ -58,15 +59,15 @@ public class StatefulClientTests extends BasicVreTests{
|
||||||
|
|
||||||
//Relazione
|
//Relazione
|
||||||
manager.setRelazioneScavo(source.getRelazioneScavo(),
|
manager.setRelazioneScavo(source.getRelazioneScavo(),
|
||||||
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "relazione_it.pdf"),
|
storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"), "relazione_it.pdf"),
|
||||||
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "relazione_en.pdf"));
|
storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"), "relazione_en.pdf"));
|
||||||
assertEquals(AccessPolicy.EMBARGOED,manager.getCurrent().getRelazioneScavo().getPolicy());
|
assertEquals(AccessPolicy.EMBARGOED,manager.getCurrent().getRelazioneScavo().getPolicy());
|
||||||
|
|
||||||
//Abstract
|
//Abstract
|
||||||
manager.setAbstractRelazioneScavo(
|
manager.setAbstractRelazioneScavo(
|
||||||
source.getAbstractRelazione(),
|
source.getAbstractRelazione(),
|
||||||
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "abstract_relazione_it.pdf"),
|
storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"), "abstract_relazione_it.pdf"),
|
||||||
storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"), "abstract_relazione_en.pdf"));
|
storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"), "abstract_relazione_en.pdf"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,12 +75,12 @@ public class StatefulClientTests extends BasicVreTests{
|
||||||
|
|
||||||
manager.setPosizionamento(source.getPosizionamentoScavo(),
|
manager.setPosizionamento(source.getPosizionamentoScavo(),
|
||||||
storage.putOntoStorage(
|
storage.putOntoStorage(
|
||||||
new File(TestModel.getBaseFolder(),"pos.shp"),"pos.shp"));
|
new File(TestConcessioniModel.getBaseFolder(),"pos.shp"),"pos.shp"));
|
||||||
|
|
||||||
// Piante
|
// Piante
|
||||||
manager.addPiantaFineScavo(source.getPianteFineScavo().get(0),
|
manager.addPiantaFineScavo(source.getPianteFineScavo().get(0),
|
||||||
storage.putOntoStorage(
|
storage.putOntoStorage(
|
||||||
new File(TestModel.getBaseFolder(),"pianta.shp"),"pianta.shp"));
|
new File(TestConcessioniModel.getBaseFolder(),"pianta.shp"),"pianta.shp"));
|
||||||
// new File("/Users/fabioisti/Documents/invio_08_05/Montalto di Castro (VT)_Vulci_Indagini non invasive_Doc. paragr._Va/CONSEGNA_WGS84")
|
// new File("/Users/fabioisti/Documents/invio_08_05/Montalto di Castro (VT)_Vulci_Indagini non invasive_Doc. paragr._Va/CONSEGNA_WGS84")
|
||||||
// .listFiles((file,name)->{return name.startsWith("Mag_anomalies_WGS84");})));
|
// .listFiles((file,name)->{return name.startsWith("Mag_anomalies_WGS84");})));
|
||||||
|
|
||||||
|
@ -118,7 +119,7 @@ public class StatefulClientTests extends BasicVreTests{
|
||||||
ConcessioniManagerI manager=statefulMongoConcessioni().build();
|
ConcessioniManagerI manager=statefulMongoConcessioni().build();
|
||||||
StorageUtils storage=new StorageUtils();
|
StorageUtils storage=new StorageUtils();
|
||||||
|
|
||||||
manager.createNew(TestModel.prepareEmptyConcessione());
|
manager.createNew(TestConcessioniModel.prepareEmptyConcessione());
|
||||||
|
|
||||||
manager.delete();
|
manager.delete();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,9 @@ import java.util.Iterator;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.cms.tests.model.TestFilters;
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniFilters;
|
||||||
import org.gcube.application.cms.tests.model.TestModel;
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||||
import org.gcube.application.cms.tests.model.TestQueries;
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniQueries;
|
||||||
import org.gcube.application.geoportal.client.utils.Queries;
|
import org.gcube.application.geoportal.client.utils.Queries;
|
||||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.*;
|
import org.gcube.application.geoportal.common.model.legacy.*;
|
||||||
|
@ -40,7 +40,7 @@ public class StatelessClientTests extends BasicVreTests{
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void searches() throws Exception {
|
public void searches() throws Exception {
|
||||||
TestFilters.filters.forEach((k,v)->{
|
TestConcessioniFilters.filters.forEach((k, v)->{
|
||||||
try {
|
try {
|
||||||
System.out.println("Count for " + k + "\t" + count(client.search(v)));
|
System.out.println("Count for " + k + "\t" + count(client.search(v)));
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
@ -62,7 +62,7 @@ public class StatelessClientTests extends BasicVreTests{
|
||||||
// No Transformation
|
// No Transformation
|
||||||
System.out.print("First Registered \t");
|
System.out.print("First Registered \t");
|
||||||
Iterator<Concessione> queriedDocuments=client.query(
|
Iterator<Concessione> queriedDocuments=client.query(
|
||||||
Queries.parse(TestQueries.queries.get("firstRegistered.json")));
|
Queries.parse(TestConcessioniQueries.queries.get("firstRegistered.json")));
|
||||||
// Expected one result
|
// Expected one result
|
||||||
assertTrue(count(queriedDocuments)==1);
|
assertTrue(count(queriedDocuments)==1);
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class StatelessClientTests extends BasicVreTests{
|
||||||
System.out.print("Last Registered \t");
|
System.out.print("Last Registered \t");
|
||||||
// Expected one result
|
// Expected one result
|
||||||
queriedDocuments=client.query(
|
queriedDocuments=client.query(
|
||||||
Queries.parse(TestQueries.queries.get("lastRegistered.json")));
|
Queries.parse(TestConcessioniQueries.queries.get("lastRegistered.json")));
|
||||||
assertTrue(count(queriedDocuments)==1);
|
assertTrue(count(queriedDocuments)==1);
|
||||||
|
|
||||||
queriedDocuments.forEachRemaining((Concessione c)->{System.out.println(c.getNome());});
|
queriedDocuments.forEachRemaining((Concessione c)->{System.out.println(c.getNome());});
|
||||||
|
@ -80,11 +80,11 @@ public class StatelessClientTests extends BasicVreTests{
|
||||||
// Transformations
|
// Transformations
|
||||||
System.out.println(
|
System.out.println(
|
||||||
client.queryForJSON(
|
client.queryForJSON(
|
||||||
Queries.parse(TestQueries.queries.get("lastNameRegisteredByFabio.json"))));
|
Queries.parse(TestConcessioniQueries.queries.get("lastNameRegisteredByFabio.json"))));
|
||||||
|
|
||||||
System.out.println(
|
System.out.println(
|
||||||
client.queryForJSON(
|
client.queryForJSON(
|
||||||
Queries.parse(TestQueries.queries.get("publicationWarningMessages.json"))));
|
Queries.parse(TestConcessioniQueries.queries.get("publicationWarningMessages.json"))));
|
||||||
|
|
||||||
// String query=Files.readFileAsString(filterFile.getAbsolutePath(), Charset.defaultCharset());
|
// String query=Files.readFileAsString(filterFile.getAbsolutePath(), Charset.defaultCharset());
|
||||||
// System.out.println("Count for "+filterFile.getName()+"\t"+ count(client.search(query)));
|
// System.out.println("Count for "+filterFile.getName()+"\t"+ count(client.search(query)));
|
||||||
|
@ -101,14 +101,14 @@ public class StatelessClientTests extends BasicVreTests{
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateNew() throws Exception {
|
public void testCreateNew() throws Exception {
|
||||||
Concessione c= client.createNew(TestModel.prepareEmptyConcessione());
|
Concessione c= client.createNew(TestConcessioniModel.prepareEmptyConcessione());
|
||||||
assertNotNull(c);
|
assertNotNull(c);
|
||||||
assertNotNull(c.getMongo_id());
|
assertNotNull(c.getMongo_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReplace() throws Exception {
|
public void testReplace() throws Exception {
|
||||||
Concessione testObject= client.createNew(TestModel.prepareEmptyConcessione());
|
Concessione testObject= client.createNew(TestConcessioniModel.prepareEmptyConcessione());
|
||||||
String title="My new shiny Title";
|
String title="My new shiny Title";
|
||||||
testObject.setNome(title);
|
testObject.setNome(title);
|
||||||
Concessione c1=client.replace(testObject);
|
Concessione c1=client.replace(testObject);
|
||||||
|
@ -117,11 +117,11 @@ public class StatelessClientTests extends BasicVreTests{
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testUploadFileSet() throws Exception {
|
public void testUploadFileSet() throws Exception {
|
||||||
Concessione testObject= client.createNew(TestModel.prepareConcessione());
|
Concessione testObject= client.createNew(TestConcessioniModel.prepareConcessione());
|
||||||
AddSectionToConcessioneRequest request=
|
AddSectionToConcessioneRequest request=
|
||||||
// FileSets.prepareRequest(new StorageUtils(),Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf"));
|
// FileSets.prepareRequest(new StorageUtils(),Paths.RELAZIONE,new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"));
|
||||||
FileSets.build(Paths.ABSTRACT_RELAZIONE).add(
|
FileSets.build(Paths.ABSTRACT_RELAZIONE).add(
|
||||||
new StorageUtils().putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"),"San Mauro_drone totale.JPG"))
|
new StorageUtils().putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"),"San Mauro_drone totale.JPG"))
|
||||||
.getTheRequest();
|
.getTheRequest();
|
||||||
|
|
||||||
testObject= client.registerFileSet(testObject.getMongo_id(), request);
|
testObject= client.registerFileSet(testObject.getMongo_id(), request);
|
||||||
|
@ -134,7 +134,7 @@ public class StatelessClientTests extends BasicVreTests{
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDeleteById() throws Exception {
|
public void testDeleteById() throws Exception {
|
||||||
Concessione c= client.createNew(TestModel.prepareEmptyConcessione());
|
Concessione c= client.createNew(TestConcessioniModel.prepareEmptyConcessione());
|
||||||
client.deleteById(c.getMongo_id());
|
client.deleteById(c.getMongo_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ public class StatelessClientTests extends BasicVreTests{
|
||||||
|
|
||||||
private Concessione prepare() throws Exception {
|
private Concessione prepare() throws Exception {
|
||||||
int numImgs=1;
|
int numImgs=1;
|
||||||
Concessione c= client.createNew(TestModel.prepareConcessione(1,numImgs));
|
Concessione c= client.createNew(TestConcessioniModel.prepareConcessione(1,numImgs));
|
||||||
StorageUtils storage = new StorageUtils();
|
StorageUtils storage = new StorageUtils();
|
||||||
|
|
||||||
c.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
|
c.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
|
||||||
|
@ -191,30 +191,30 @@ public class StatelessClientTests extends BasicVreTests{
|
||||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||||
|
|
||||||
c=client.registerFileSet(mongoId,
|
c=client.registerFileSet(mongoId,
|
||||||
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf")));
|
FileSets.prepareRequest(storage,Paths.RELAZIONE,new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf")));
|
||||||
|
|
||||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||||
|
|
||||||
c=client.registerFileSet(mongoId,
|
c=client.registerFileSet(mongoId,
|
||||||
FileSets.prepareRequest(storage,Paths.ABSTRACT_RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf")));
|
FileSets.prepareRequest(storage,Paths.ABSTRACT_RELAZIONE,new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf")));
|
||||||
|
|
||||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||||
|
|
||||||
for(int i=0;i<numImgs;i++)
|
for(int i=0;i<numImgs;i++)
|
||||||
c=client.registerFileSet(mongoId,
|
c=client.registerFileSet(mongoId,
|
||||||
FileSets.build(Paths.imgByIndex(i)).
|
FileSets.build(Paths.imgByIndex(i)).
|
||||||
add(storage.putOntoStorage(new File(TestModel.getBaseFolder(),"immagine"+(i+1)+".png"),
|
add(storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"immagine"+(i+1)+".png"),
|
||||||
i+"San Mauro_drone totale.JPG")).getTheRequest());
|
i+"San Mauro_drone totale.JPG")).getTheRequest());
|
||||||
|
|
||||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||||
|
|
||||||
c=client.registerFileSet(mongoId,
|
c=client.registerFileSet(mongoId,
|
||||||
FileSets.prepareRequest(storage,Paths.POSIZIONAMENTO,new File(TestModel.getBaseFolder(),"pos.shp")));
|
FileSets.prepareRequest(storage,Paths.POSIZIONAMENTO,new File(TestConcessioniModel.getBaseFolder(),"pos.shp")));
|
||||||
|
|
||||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||||
|
|
||||||
c=client.registerFileSet(mongoId,
|
c=client.registerFileSet(mongoId,
|
||||||
FileSets.prepareRequest(storage,Paths.piantaByIndex(0),new File(TestModel.getBaseFolder(),"pianta.shp")));
|
FileSets.prepareRequest(storage,Paths.piantaByIndex(0),new File(TestConcessioniModel.getBaseFolder(),"pianta.shp")));
|
||||||
|
|
||||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
package org.gcube.application.geoportal.service;
|
package org.gcube.application.geoportal.service;
|
||||||
|
|
||||||
import org.gcube.application.cms.tests.TokenSetter;
|
import org.gcube.application.cms.tests.TokenSetter;
|
||||||
import org.gcube.application.cms.tests.model.TestFilters;
|
|
||||||
import org.gcube.application.cms.tests.model.TestQueries;
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniFilters;
|
||||||
import org.gcube.application.cms.tests.model.TestModel;
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||||
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniQueries;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
|
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.Concessione.Paths;
|
import org.gcube.application.geoportal.common.model.legacy.Concessione.Paths;
|
||||||
|
@ -49,7 +50,7 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
||||||
FileSets.RequestBuilder builder = FileSets.build(path);
|
FileSets.RequestBuilder builder = FileSets.build(path);
|
||||||
|
|
||||||
for(String file:files)
|
for(String file:files)
|
||||||
builder.add(storage.putOntoStorage(new File(TestModel.getBaseFolder(),file),file));
|
builder.add(storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),file),file));
|
||||||
|
|
||||||
return check(target.path(FILES_PATH).path(id).request(MediaType.APPLICATION_JSON).
|
return check(target.path(FILES_PATH).path(id).request(MediaType.APPLICATION_JSON).
|
||||||
post(Entity.entity(Serialization.write(builder.getTheRequest()),
|
post(Entity.entity(Serialization.write(builder.getTheRequest()),
|
||||||
|
@ -95,7 +96,7 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Concessione get(WebTarget target) throws Exception {
|
private static Concessione get(WebTarget target) throws Exception {
|
||||||
return register(target, TestModel.prepareConcessione());
|
return register(target, TestConcessioniModel.prepareConcessione());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Concessione getById(WebTarget target ,String id) throws Exception {
|
private static Concessione getById(WebTarget target ,String id) throws Exception {
|
||||||
|
@ -112,7 +113,7 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
||||||
|
|
||||||
|
|
||||||
private static <T> Iterator<T> queryFile(String filename, WebTarget target, Class<T> clazz) throws Exception {
|
private static <T> Iterator<T> queryFile(String filename, WebTarget target, Class<T> clazz) throws Exception {
|
||||||
String queryString= TestQueries.queries.get(filename);
|
String queryString= TestConcessioniQueries.queries.get(filename);
|
||||||
|
|
||||||
String result = check(target.path(InterfaceConstants.Methods.QUERY_PATH).request(MediaType.APPLICATION_JSON_TYPE).post(
|
String result = check(target.path(InterfaceConstants.Methods.QUERY_PATH).request(MediaType.APPLICATION_JSON_TYPE).post(
|
||||||
Entity.entity(queryString,MediaType.APPLICATION_JSON)),String.class);
|
Entity.entity(queryString,MediaType.APPLICATION_JSON)),String.class);
|
||||||
|
@ -135,7 +136,7 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
||||||
public void search() throws Exception {
|
public void search() throws Exception {
|
||||||
WebTarget target=target(PATH);
|
WebTarget target=target(PATH);
|
||||||
AtomicLong validatedCount= new AtomicLong(0);
|
AtomicLong validatedCount= new AtomicLong(0);
|
||||||
Iterator<Concessione> it=search(TestFilters.filters.get("validated.json"),target);
|
Iterator<Concessione> it=search(TestConcessioniFilters.filters.get("validated.json"),target);
|
||||||
it.forEachRemaining(concessione -> {validatedCount.incrementAndGet();});
|
it.forEachRemaining(concessione -> {validatedCount.incrementAndGet();});
|
||||||
System.out.println("Validated : "+ validatedCount.get());
|
System.out.println("Validated : "+ validatedCount.get());
|
||||||
}
|
}
|
||||||
|
@ -170,7 +171,7 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
||||||
@Test
|
@Test
|
||||||
public void createNew() throws Exception {
|
public void createNew() throws Exception {
|
||||||
WebTarget target=target(PATH);
|
WebTarget target=target(PATH);
|
||||||
Concessione c=register(target,TestModel.prepareConcessione());
|
Concessione c=register(target,TestConcessioniModel.prepareConcessione());
|
||||||
Assert.assertTrue(c.getMongo_id()!=null&&!c.getMongo_id().isEmpty());
|
Assert.assertTrue(c.getMongo_id()!=null&&!c.getMongo_id().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,14 +238,14 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
||||||
@Test
|
@Test
|
||||||
public void uploadFile() throws Exception {
|
public void uploadFile() throws Exception {
|
||||||
WebTarget target=target(PATH);
|
WebTarget target=target(PATH);
|
||||||
Response resp=target.request(MediaType.APPLICATION_JSON).post(Entity.entity(Serialization.write(TestModel.prepareEmptyConcessione()), MediaType.APPLICATION_JSON));
|
Response resp=target.request(MediaType.APPLICATION_JSON).post(Entity.entity(Serialization.write(TestConcessioniModel.prepareEmptyConcessione()), MediaType.APPLICATION_JSON));
|
||||||
Concessione c=check(resp,Concessione.class);
|
Concessione c=check(resp,Concessione.class);
|
||||||
Assert.assertTrue(c.getMongo_id()!=null&&!c.getMongo_id().isEmpty());
|
Assert.assertTrue(c.getMongo_id()!=null&&!c.getMongo_id().isEmpty());
|
||||||
System.out.println("ID IS "+c.getMongo_id());
|
System.out.println("ID IS "+c.getMongo_id());
|
||||||
|
|
||||||
// Insert section
|
// Insert section
|
||||||
c.setRelazioneScavo(TestModel.prepareConcessione().getRelazioneScavo());
|
c.setRelazioneScavo(TestConcessioniModel.prepareConcessione().getRelazioneScavo());
|
||||||
// c.getRelazioneScavo().setMongo_id(TestModel.rnd());
|
// c.getRelazioneScavo().setMongo_id(TestConcessioniModel.rnd());
|
||||||
|
|
||||||
resp=target.request(MediaType.APPLICATION_JSON).put(Entity.entity(Serialization.write(c), MediaType.APPLICATION_JSON));
|
resp=target.request(MediaType.APPLICATION_JSON).put(Entity.entity(Serialization.write(c), MediaType.APPLICATION_JSON));
|
||||||
|
|
||||||
|
@ -312,10 +313,10 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
||||||
|
|
||||||
private Concessione getFullPublished(WebTarget target) throws Exception {
|
private Concessione getFullPublished(WebTarget target) throws Exception {
|
||||||
|
|
||||||
File layerFolder=TestModel.getBaseFolder();
|
File layerFolder=TestConcessioniModel.getBaseFolder();
|
||||||
Map<String, List<File>> layers = Files.getAllShapeSet(layerFolder,true);
|
Map<String, List<File>> layers = Files.getAllShapeSet(layerFolder,true);
|
||||||
|
|
||||||
Concessione c=TestModel.prepareConcessione(layers.size(),1);
|
Concessione c=TestConcessioniModel.prepareConcessione(layers.size(),1);
|
||||||
|
|
||||||
c.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
|
c.getRelazioneScavo().setPolicy(AccessPolicy.EMBARGOED);
|
||||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||||
|
@ -338,7 +339,7 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
||||||
|
|
||||||
String[] keys=layers.keySet().toArray(new String [0]);
|
String[] keys=layers.keySet().toArray(new String [0]);
|
||||||
c=upload(storage,target,c.getMongo_id(),Paths.POSIZIONAMENTO,
|
c=upload(storage,target,c.getMongo_id(),Paths.POSIZIONAMENTO,
|
||||||
// TestModel.getBaseFolder().list((file,name)->{return name.startsWith("pianta.shp");}));
|
// TestConcessioniModel.getBaseFolder().list((file,name)->{return name.startsWith("pianta.shp");}));
|
||||||
layers.get(keys[0]).toArray(new File[0]));
|
layers.get(keys[0]).toArray(new File[0]));
|
||||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||||
|
|
||||||
|
@ -349,7 +350,7 @@ public class ConcessioniOverMongoTest extends BasicServiceTestUnit{
|
||||||
c.getContentByPath(path).setTitolo("Pianta from "+key.replace(layerFolder.getAbsolutePath(),""));
|
c.getContentByPath(path).setTitolo("Pianta from "+key.replace(layerFolder.getAbsolutePath(),""));
|
||||||
c=update(c,target);
|
c=update(c,target);
|
||||||
c=upload(storage, target, c.getMongo_id(), path,
|
c=upload(storage, target, c.getMongo_id(), path,
|
||||||
// TestModel.getBaseFolder().list((file,name)->{return name.startsWith("pianta.shp");}));
|
// TestConcessioniModel.getBaseFolder().list((file,name)->{return name.startsWith("pianta.shp");}));
|
||||||
layers.get(key).toArray(new File[0]));
|
layers.get(key).toArray(new File[0]));
|
||||||
}
|
}
|
||||||
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
assertEquals(AccessPolicy.EMBARGOED,c.getRelazioneScavo().getPolicy());
|
||||||
|
|
|
@ -4,7 +4,8 @@ import ch.qos.logback.core.net.SyslogOutputStream;
|
||||||
import com.mongodb.MongoWaitQueueFullException;
|
import com.mongodb.MongoWaitQueueFullException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.gcube.application.cms.tests.TokenSetter;
|
import org.gcube.application.cms.tests.TokenSetter;
|
||||||
import org.gcube.application.cms.tests.model.TestModel;
|
|
||||||
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||||
import org.gcube.application.geoportal.service.BasicServiceTestUnit;
|
import org.gcube.application.geoportal.service.BasicServiceTestUnit;
|
||||||
import org.gcube.application.geoportal.service.engine.ImplementationProvider;
|
import org.gcube.application.geoportal.service.engine.ImplementationProvider;
|
||||||
|
@ -114,7 +115,7 @@ public class Caches extends BasicServiceTestUnit {
|
||||||
|
|
||||||
final StorageUtils storage=ImplementationProvider.get().getStorageProvider().getObject();
|
final StorageUtils storage=ImplementationProvider.get().getStorageProvider().getObject();
|
||||||
|
|
||||||
String id =storage.putOntoStorage(new File(TestModel.getBaseFolder(),"relazione.pdf"))[0].getId();
|
String id =storage.putOntoStorage(new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"))[0].getId();
|
||||||
|
|
||||||
//for 100 secs
|
//for 100 secs
|
||||||
while(Duration.between(start,LocalDateTime.now()).
|
while(Duration.between(start,LocalDateTime.now()).
|
||||||
|
|
|
@ -3,7 +3,8 @@ package org.gcube.application.geoportal.service.engine.materialization;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.gcube.application.cms.tests.TokenSetter;
|
import org.gcube.application.cms.tests.TokenSetter;
|
||||||
import org.gcube.application.cms.tests.model.TestModel;
|
|
||||||
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.GeoServerContent;
|
import org.gcube.application.geoportal.common.model.legacy.GeoServerContent;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
|
import org.gcube.application.geoportal.common.model.legacy.LayerConcessione;
|
||||||
|
@ -60,7 +61,7 @@ public class SDITests {
|
||||||
//Disabled because dependant on state
|
//Disabled because dependant on state
|
||||||
public void registerLayer() throws IOException, SDIInteractionException {
|
public void registerLayer() throws IOException, SDIInteractionException {
|
||||||
Concessione toTest= Serialization.read(Files.readFileAsString(
|
Concessione toTest= Serialization.read(Files.readFileAsString(
|
||||||
new File(TestModel.getBaseFolder(),"transferTest.json").getAbsolutePath(), Charset.defaultCharset()), Concessione.class);
|
new File(TestConcessioniModel.getBaseFolder(),"transferTest.json").getAbsolutePath(), Charset.defaultCharset()), Concessione.class);
|
||||||
|
|
||||||
|
|
||||||
SDIManager manager = new SDIManager();
|
SDIManager manager = new SDIManager();
|
||||||
|
|
|
@ -2,7 +2,8 @@ package org.gcube.application.cms.usecases;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.gcube.application.cms.tests.TokenSetter;
|
import org.gcube.application.cms.tests.TokenSetter;
|
||||||
import org.gcube.application.cms.tests.model.TestModel;
|
|
||||||
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||||
import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest;
|
import org.gcube.application.geoportal.common.model.rest.AddSectionToConcessioneRequest;
|
||||||
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||||
|
@ -29,7 +30,7 @@ public class StressTest {
|
||||||
AtomicLong executed=new AtomicLong(0);
|
AtomicLong executed=new AtomicLong(0);
|
||||||
|
|
||||||
AddSectionToConcessioneRequest request= FileSets.prepareRequest(
|
AddSectionToConcessioneRequest request= FileSets.prepareRequest(
|
||||||
new StorageUtils(), Concessione.Paths.RELAZIONE,new File(TestModel.getBaseFolder(),"relazione.pdf"));
|
new StorageUtils(), Concessione.Paths.RELAZIONE,new File(TestConcessioniModel.getBaseFolder(),"relazione.pdf"));
|
||||||
|
|
||||||
int numRequests=100000;
|
int numRequests=100000;
|
||||||
for(int i=0;i<numRequests;i++){
|
for(int i=0;i<numRequests;i++){
|
||||||
|
@ -38,7 +39,7 @@ public class StressTest {
|
||||||
public void run() {
|
public void run() {
|
||||||
try{
|
try{
|
||||||
MongoConcessioni client=mongoConcessioni().build();
|
MongoConcessioni client=mongoConcessioni().build();
|
||||||
Concessione c =TestModel.prepareConcessione(1,1);
|
Concessione c =TestConcessioniModel.prepareConcessione(1,1);
|
||||||
c.setNome("Stress test");
|
c.setNome("Stress test");
|
||||||
c.setDefaults();
|
c.setDefaults();
|
||||||
c=client.createNew(c);
|
c=client.createNew(c);
|
||||||
|
|
|
@ -2,7 +2,8 @@ package org.gcube.application.cms.usecases.mocks;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.gcube.application.cms.tests.model.TestModel;
|
|
||||||
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||||
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport;
|
import org.gcube.application.geoportal.common.model.legacy.report.ValidationReport;
|
||||||
|
@ -117,17 +118,17 @@ public class ConcessionPublisherThread implements Runnable{
|
||||||
private static Concessione createMock(String baseName, String packageName, Map<String,List<File>> piante, List<File> pos,
|
private static Concessione createMock(String baseName, String packageName, Map<String,List<File>> piante, List<File> pos,
|
||||||
MongoConcessioni client, StorageUtils storage) throws Exception {
|
MongoConcessioni client, StorageUtils storage) throws Exception {
|
||||||
|
|
||||||
Concessione c= TestModel.prepareConcessione(piante.size(), 1);
|
Concessione c= TestConcessioniModel.prepareConcessione(piante.size(), 1);
|
||||||
c.setNome("Mock for "+baseName+" ("+packageName+")");
|
c.setNome("Mock for "+baseName+" ("+packageName+")");
|
||||||
c= client.createNew(c);
|
c= client.createNew(c);
|
||||||
String mongoId=c.getMongo_id();
|
String mongoId=c.getMongo_id();
|
||||||
|
|
||||||
// TEST DATA, DO NOT CARE
|
// TEST DATA, DO NOT CARE
|
||||||
client.registerFileSet(mongoId, FileSets.prepareRequest(storage,
|
client.registerFileSet(mongoId, FileSets.prepareRequest(storage,
|
||||||
Concessione.Paths.RELAZIONE,new File (TestModel.getBaseFolder(),"relazione.pdf")));
|
Concessione.Paths.RELAZIONE,new File (TestConcessioniModel.getBaseFolder(),"relazione.pdf")));
|
||||||
|
|
||||||
client.registerFileSet(mongoId, FileSets.prepareRequest(storage,
|
client.registerFileSet(mongoId, FileSets.prepareRequest(storage,
|
||||||
Concessione.Paths.imgByIndex(0),Files.getSiblings(TestModel.getBaseFolder(),"immagine").get(0)));
|
Concessione.Paths.imgByIndex(0),Files.getSiblings(TestConcessioniModel.getBaseFolder(),"immagine").get(0)));
|
||||||
|
|
||||||
// POSIZIONAMENTO
|
// POSIZIONAMENTO
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ package org.gcube.application.cms.usecases.mocks;
|
||||||
|
|
||||||
import com.opencsv.CSVReader;
|
import com.opencsv.CSVReader;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.gcube.application.cms.tests.model.TestModel;
|
|
||||||
import org.gcube.application.cms.tests.TokenSetter;
|
import org.gcube.application.cms.tests.TokenSetter;
|
||||||
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||||
import org.gcube.application.geoportal.common.utils.FileSets;
|
import org.gcube.application.geoportal.common.utils.FileSets;
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public class MockFromFolder {
|
||||||
String context = "/pred4s/preprod/preVRE";
|
String context = "/pred4s/preprod/preVRE";
|
||||||
|
|
||||||
|
|
||||||
File descriptorsBaseFolder=new File(TestModel.getBaseFolder(),"packages");
|
File descriptorsBaseFolder=new File(TestConcessioniModel.getBaseFolder(),"packages");
|
||||||
|
|
||||||
// config csv -> base folder
|
// config csv -> base folder
|
||||||
Map<String,String> configurations=new HashMap<>();
|
Map<String,String> configurations=new HashMap<>();
|
||||||
|
|
Loading…
Reference in New Issue