2021-10-01 17:42:23 +02:00
|
|
|
package org.gcube.application.geoportal.service.engine.materialization;
|
|
|
|
|
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.gcube.application.cms.tests.TokenSetter;
|
2021-12-01 12:02:48 +01:00
|
|
|
|
|
|
|
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
2021-10-01 17:42:23 +02:00
|
|
|
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.LayerConcessione;
|
|
|
|
import org.gcube.application.geoportal.common.utils.Files;
|
2022-02-24 18:09:30 +01:00
|
|
|
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
|
2021-10-01 17:42:23 +02:00
|
|
|
import org.gcube.application.geoportal.service.engine.postgis.PostgisIndex;
|
2022-02-04 17:45:47 +01:00
|
|
|
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
|
2021-10-01 17:42:23 +02:00
|
|
|
import org.gcube.application.geoportal.service.model.internal.faults.SDIInteractionException;
|
2022-02-01 15:24:39 +01:00
|
|
|
import org.gcube.application.cms.serialization.Serialization;
|
2021-10-01 17:42:23 +02:00
|
|
|
import org.junit.Assert;
|
|
|
|
import org.junit.Before;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
2022-02-24 18:09:30 +01:00
|
|
|
import static org.junit.Assume.assumeTrue;
|
|
|
|
|
2021-10-01 17:42:23 +02:00
|
|
|
@Slf4j
|
2022-02-24 18:09:30 +01:00
|
|
|
public class SDITests extends GCubeTest {
|
|
|
|
|
2021-10-01 17:42:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void registerCentroidsLayer() throws SDIInteractionException, SQLException, ConfigurationException {
|
2022-02-24 18:09:30 +01:00
|
|
|
assumeTrue(isTestInfrastructureEnabled());
|
2021-10-01 17:42:23 +02:00
|
|
|
PostgisIndex index=new PostgisIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testRegexp(){
|
|
|
|
Matcher hostMatcher=SDIManager.HOSTNAME_PATTERN.matcher("jdbc:postgresql://postgresql-srv-dev.d4science.org:5432/geoserver_dev_db");
|
|
|
|
Assert.assertTrue(hostMatcher.find());
|
|
|
|
System.out.println("HOST :\t"+hostMatcher.group());
|
|
|
|
|
|
|
|
Matcher portMatcher=SDIManager.PORT_PATTERN.matcher("jdbc:postgresql://postgresql-srv-dev.d4science.org:5432/geoserver_dev_db");
|
|
|
|
Assert.assertTrue(portMatcher.find());
|
|
|
|
System.out.println("PORT :\t"+portMatcher.group());
|
|
|
|
|
|
|
|
Matcher dbMatcher=SDIManager.DB_NAME_PATTERN.matcher("jdbc:postgresql://postgresql-srv-dev.d4science.org:5432/geoserver_dev_db");
|
|
|
|
Assert.assertTrue(dbMatcher.find());
|
|
|
|
System.out.println("DB :\t"+dbMatcher.group());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// @Test
|
|
|
|
//Disabled because dependant on state
|
|
|
|
public void registerLayer() throws IOException, SDIInteractionException {
|
|
|
|
Concessione toTest= Serialization.read(Files.readFileAsString(
|
2021-12-01 12:02:48 +01:00
|
|
|
new File(TestConcessioniModel.getBaseFolder(),"transferTest.json").getAbsolutePath(), Charset.defaultCharset()), Concessione.class);
|
2021-10-01 17:42:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
SDIManager manager = new SDIManager();
|
|
|
|
List<LayerConcessione> toPush=new ArrayList<>();
|
|
|
|
toPush.add(toTest.getPosizionamentoScavo());
|
|
|
|
toPush.addAll(toTest.getPianteFineScavo());
|
|
|
|
|
|
|
|
for (LayerConcessione l :toPush){
|
|
|
|
GeoServerContent content=manager.pushShapeLayerFileSet(l,toTest.getFolderId(),toTest.getMongo_id()+"_"+System.currentTimeMillis());
|
|
|
|
System.out.println("Published "+content);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|