2022-02-25 11:44:56 +01:00
|
|
|
package org.gcube.application.cms.sdi.plugins;
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
import org.bson.Document;
|
|
|
|
import org.gcube.application.cms.plugins.IndexerPluginInterface;
|
|
|
|
import org.gcube.application.cms.plugins.faults.PluginExecutionException;
|
|
|
|
import org.gcube.application.cms.plugins.reports.IndexDocumentReport;
|
|
|
|
import org.gcube.application.cms.plugins.reports.Report;
|
|
|
|
import org.gcube.application.cms.plugins.requests.IndexDocumentRequest;
|
|
|
|
import org.gcube.application.cms.serialization.Serialization;
|
|
|
|
import org.gcube.application.cms.tests.BasicPluginTest;
|
|
|
|
import org.gcube.application.cms.tests.TestDocuments;
|
|
|
|
import org.gcube.application.cms.tests.TestProfiles;
|
2022-03-04 14:23:20 +01:00
|
|
|
import org.gcube.application.geoportal.common.model.document.Project;
|
2022-03-14 17:04:09 +01:00
|
|
|
import org.gcube.application.geoportal.common.model.document.accounting.Context;
|
|
|
|
import org.gcube.application.geoportal.common.model.document.accounting.User;
|
2022-02-25 11:44:56 +01:00
|
|
|
import org.gcube.application.geoportal.common.utils.tests.GCubeTest;
|
2022-03-14 17:04:09 +01:00
|
|
|
import org.gcube.spatial.data.geonetwork.utils.UserUtils;
|
2022-02-25 11:44:56 +01:00
|
|
|
import org.junit.Test;
|
|
|
|
|
2022-03-04 11:30:31 +01:00
|
|
|
import static junit.framework.TestCase.assertTrue;
|
2022-02-25 11:44:56 +01:00
|
|
|
import static org.junit.Assume.assumeTrue;
|
|
|
|
|
|
|
|
public class IndexerTest extends BasicPluginTest {
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testIndexRequest() throws PluginExecutionException, JsonProcessingException {
|
|
|
|
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
2022-03-04 14:23:20 +01:00
|
|
|
Project doc= TestDocuments.documentMap.get("profiledConcessioniExample.json");
|
2022-03-14 17:04:09 +01:00
|
|
|
|
|
|
|
IndexDocumentRequest request=new IndexDocumentRequest(TestProfiles.profiles.get(doc.getProfileID()),
|
|
|
|
getTestUser(),getTestContext(),doc);
|
|
|
|
|
2022-02-25 11:44:56 +01:00
|
|
|
Document parameters = new Document();
|
|
|
|
parameters.put("workspace", "testing_workspace");
|
|
|
|
parameters.put("indexName", "unique_index"+System.currentTimeMillis());
|
|
|
|
request.setCallParameters(parameters);
|
|
|
|
|
|
|
|
IndexerPluginInterface plugin = (IndexerPluginInterface) plugins.get(SDIIndexerPlugin.DESCRIPTOR.getId());
|
|
|
|
|
|
|
|
IndexDocumentReport response = plugin.index(request);
|
2022-03-04 11:30:31 +01:00
|
|
|
assertTrue(response!=null);
|
2022-02-25 11:44:56 +01:00
|
|
|
response.validate();
|
2022-03-04 11:30:31 +01:00
|
|
|
System.out.println("Response is "+Serialization.write(response));
|
2022-02-25 11:44:56 +01:00
|
|
|
|
2022-03-04 11:30:31 +01:00
|
|
|
assertTrue(response.getStatus().equals(Report.Status.OK));
|
|
|
|
assertTrue(response.prepareResult().getSpatialReference()!=null);
|
2022-02-25 11:44:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|