Updated Tests
This commit is contained in:
parent
44b87e9aff
commit
7a7b39418f
|
@ -1,20 +1,26 @@
|
|||
package org.gcube.application;
|
||||
|
||||
import static org.gcube.application.geoportal.client.plugins.GeoportalAbstractPlugin.projects;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.configuration.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||
import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
|
||||
import org.gcube.application.geoportal.common.model.document.relationships.RelationshipNavigationObject;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataValueObjectModel;
|
||||
import org.gcube.application.geoportalcommon.ProjectDVBuilder;
|
||||
import org.gcube.application.geoportalcommon.geoportal.GeoportalClientCaller;
|
||||
|
@ -23,6 +29,7 @@ import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
|||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.ResultDocumentDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.config.ItemFieldDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.LifecycleInformationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.PhaseDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.ProjectDV;
|
||||
|
@ -47,7 +54,7 @@ public class Project_Tests {
|
|||
private static String CONTEXT = "/gcube/devsec/devVRE";
|
||||
private static String TOKEN = ""; // devVRE
|
||||
private static String PROFILE_ID = "profiledConcessioni";
|
||||
private static String PROJECT_ID = "632c633155e2947b0278c999";
|
||||
private static String PROJECT_ID = "6365485fa8d67f4c82794cc4";
|
||||
|
||||
@Before
|
||||
public void getClient() {
|
||||
|
@ -67,7 +74,7 @@ public class Project_Tests {
|
|||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
//@Test
|
||||
public void getByID() throws Exception {
|
||||
Project project = client.getProjectByID(PROFILE_ID, PROJECT_ID);
|
||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||
|
@ -79,9 +86,11 @@ public class Project_Tests {
|
|||
Object theValue = theMap.get(key);
|
||||
System.out.println("The key: " + key + " has value: " + theValue);
|
||||
}
|
||||
|
||||
System.out.println(projectDV.getSpatialReference());
|
||||
}
|
||||
|
||||
// @Test
|
||||
//@Test
|
||||
public void getListProjectsDV() throws Exception {
|
||||
List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
||||
ProjectDVBuilder projectBuilder = ProjectDVBuilder.newBuilder().fullDocumentMap(true);
|
||||
|
@ -93,7 +102,7 @@ public class Project_Tests {
|
|||
|
||||
}
|
||||
|
||||
// @Test
|
||||
//@Test
|
||||
public void getResultDocumentForID() {
|
||||
try {
|
||||
ProjectsCaller projects = GeoportalClientCaller.projects();
|
||||
|
@ -106,10 +115,11 @@ public class Project_Tests {
|
|||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
@Test
|
||||
public void getListProjectsDVFiltered() throws Exception {
|
||||
// List<Project> listOfProjects = client.getListForProfileID(PROFILE_ID);
|
||||
|
||||
|
||||
SearchingFilter filter = new SearchingFilter();
|
||||
|
||||
// Where Clause
|
||||
|
@ -118,10 +128,20 @@ public class Project_Tests {
|
|||
// searchInto.put("_id", "61f0299baf51592c36795f52");
|
||||
// searchInto.put("_theDocument.nome", "Test progetto con clustering di
|
||||
// fileset");
|
||||
WhereClause whereClause = new WhereClause(LOGICAL_OP.AND, searchInto);
|
||||
// searchInto.put("_theDocument.paroleChiaveLibere", "scavo");
|
||||
// searchInto.put("_theDocument.editore", "scavo");
|
||||
// searchInto.put("_theDocument.paroleChiaveICCD", "scavo");
|
||||
// searchInto.put("_theDocument.responsabile", "scavo");
|
||||
WhereClause whereClause = new WhereClause(LOGICAL_OP.OR, searchInto);
|
||||
conditions.add(whereClause);
|
||||
filter.setConditions(conditions);
|
||||
|
||||
List<ItemFieldDV> orderByFields = new ArrayList<ItemFieldDV>();
|
||||
List<String> jsonFields = Arrays.asList("_theDocument.dataInizioProgetto");
|
||||
ItemFieldDV itemField = new ItemFieldDV("dataInizioProgetto", jsonFields, "$or", false, false, false);
|
||||
orderByFields.add(itemField);
|
||||
filter.setOrderByFields(orderByFields);
|
||||
|
||||
LinkedHashMap<String, Object> projection = new LinkedHashMap<String, Object>();
|
||||
// default
|
||||
projection.put("_theDocument.nome", 1);
|
||||
|
@ -148,9 +168,10 @@ public class Project_Tests {
|
|||
List<ResultDocumentDV> results = ConvertToDataValueObjectModel.toListResultDocument(projects);
|
||||
int i = 0;
|
||||
for (ResultDocumentDV projectDV : results) {
|
||||
System.out.println(++i + ") " + projectDV);
|
||||
System.out.println(++i + ") " + projectDV.getId() + " dataInizioProgetto: "+projectDV.getDocumentAsMap().get("dataInizioProgetto"));
|
||||
}
|
||||
|
||||
|
||||
// TEST TO PROJECT DV
|
||||
/*
|
||||
* ProjectDVBuilder projectBuilder =
|
||||
|
@ -161,6 +182,46 @@ public class Project_Tests {
|
|||
* for (ProjectDV projectDV : listProjects) { System.out.println(++i + ") " +
|
||||
* projectDV); }
|
||||
*/
|
||||
|
||||
/*int limit = 2;
|
||||
LinkedHashMap<String, Object> documentAsMap = new LinkedHashMap<String, Object>(limit);
|
||||
|
||||
try {
|
||||
// Project theProject =
|
||||
// GeoportalClientCaller.projects().getProjectByID(profileID, projectID);
|
||||
|
||||
QueryRequest request = new QueryRequest();
|
||||
request.setFilter(Document.parse("{\"" + Project.ID + "\" : " + "{\"$eq\" : \"" + PROJECT_ID + "\"}}"));
|
||||
request.setProjection(Document.parse("{\"" + Project.ID + "\" : " + "1}"));
|
||||
// should be one
|
||||
projects(PROFILE_ID).build().f
|
||||
projects(PROFILE_ID).build().query(request).forEachRemaining(p -> {
|
||||
try {
|
||||
System.out.println("p is: "+p);
|
||||
Iterator<Entry<String, Object>> entrySetsIt = p.getTheDocument().entrySet().iterator();
|
||||
int i = 0;
|
||||
while (entrySetsIt.hasNext()) {
|
||||
if (i > limit)
|
||||
break;
|
||||
|
||||
Entry<String, Object> entry = entrySetsIt.next();
|
||||
documentAsMap.put(entry.getKey(), entry.getValue());
|
||||
i++;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
|
||||
System.out.println("getEntrySetsDocumentForProjectID returning map: "+documentAsMap);
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
String erroMsg = "Error occurred on loading EntrySets document for profileID " + PROFILE_ID
|
||||
+ " and projectID " + PROJECT_ID;
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
}
|
||||
|
||||
// @Test
|
||||
|
@ -207,7 +268,7 @@ public class Project_Tests {
|
|||
for (Relationship relationship : relations) {
|
||||
System.out.println("\n\ngetRelationshipsChain for "+relationship);
|
||||
Iterator<RelationshipNavigationObject> iterator = client.getRelationshipChain(PROFILE_ID, PROJECT_ID,
|
||||
relationship.getRelationshipName());
|
||||
relationship.getRelationshipName(), true);
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
RelationshipNavigationObject nav = (RelationshipNavigationObject) iterator.next();
|
||||
|
|
|
@ -157,7 +157,7 @@ public class UCD_Tests {
|
|||
* @return the UCD for data list handler ids
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
// @Test
|
||||
//@Test
|
||||
public void getUCDFor_DataList_HandlerIds() throws Exception {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
|
@ -313,6 +313,9 @@ public class UCD_Tests {
|
|||
System.out.println("UCD profileID:" + useCaseDescriptorDV.getProfileID());
|
||||
List<HandlerDeclarationDV> handlers = useCaseDescriptorDV.getHandlers();
|
||||
for (HandlerDeclarationDV handler : handlers) {
|
||||
System.out.println("\n\thandler id:" + handler.getId());
|
||||
System.out.println("\thandler ItemType:" + handler.getItemType());
|
||||
System.out.println("\thandler Type:" + handler.getType());
|
||||
ConfigurationDV<?> config = handler.getConfiguration();
|
||||
System.out.println("\tConfig type:" + config.getConfigurationType());
|
||||
// System.out.println("\tConfig:" + config.getConfiguration());
|
||||
|
|
Loading…
Reference in New Issue