Added test to find if there are items with serchable=false

This commit is contained in:
Luca Frosini 2020-02-18 09:23:33 +01:00
parent f96ca0de94
commit 6963f3714c
1 changed files with 29 additions and 1 deletions

View File

@ -1,6 +1,7 @@
package org.gcube.gcat.client;
import java.io.IOException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -159,7 +160,7 @@ public class ItemTest extends ContextTest {
String itemsString = item.list(10, 0, "dorne");
logger.debug("Got list {}", itemsString);
Map<String, String> queryParams = new HashMap<>();
Map<String,String> queryParams = new HashMap<>();
queryParams.put(GCatConstants.Q_KEY, "organization:dorne OR organization:ckand4scienceharvest");
itemsString = item.list(queryParams);
logger.debug("Got list {}", itemsString);
@ -198,6 +199,33 @@ public class ItemTest extends ContextTest {
Assert.assertTrue(name.compareTo(gotName) == 0);
}
protected static final String SEARCHABLE_KEY = "searchable";
public static final String GCAT_URL_STRING = "https://gcat.d4science.org/gcat";
// @Test
public void findNotSearchable() throws Exception {
ContextTest.setContextByName("/d4science.research-infrastructures.eu/SoBigData/ResourceCatalogue");
ObjectMapper mapper = new ObjectMapper();
JavaType listType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, String.class);
Item item = new Item(new URL(GCAT_URL_STRING));
String itemsString = item.list(300, 0);
logger.debug("Got items are {}", itemsString);
List<String> items = mapper.readValue(itemsString, listType);
while(items.size() > 0) {
for(String itemName : items) {
logger.debug("Analysing item {}", itemName);
String itemString = item.read(itemName);
// logger.trace(itemString);
JsonNode itemNode = mapper.readTree(itemString);
if(itemNode.has(SEARCHABLE_KEY)){
logger.warn("{} has {}={}\n{}", itemName, SEARCHABLE_KEY, itemNode.get(SEARCHABLE_KEY).asBoolean(), itemsString);
}
Thread.sleep(50);
}
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
}
}
// @Test
public void purgeAll() throws Exception {
ObjectMapper mapper = new ObjectMapper();