Added test

This commit is contained in:
Luca Frosini 2019-09-25 17:43:10 +02:00
parent 9142a4eae0
commit b6d08bf8ac
1 changed files with 19 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.junit.Assert;
import org.junit.Test;
@ -172,4 +173,22 @@ public class ItemTest extends ContextTest {
String gotName = jsonNode.get(NAME_KEY).asText();
Assert.assertTrue(name.compareTo(gotName) == 0);
}
// @Test
public void purgeAll() throws Exception {
ObjectMapper mapper = new ObjectMapper();
JavaType listType = mapper.getTypeFactory().constructCollectionType(ArrayList.class, String.class);
Item item = new Item();
String itemsString = item.list(200, 0);
List<String> items = mapper.readValue(itemsString, listType);
while(items.size()>0) {
for(String itemName : items) {
item.purge(itemName);
Thread.sleep(50);
}
itemsString = item.list(200, 0);
items = mapper.readValue(itemsString, listType);
Thread.sleep(TimeUnit.SECONDS.toMillis(5));
}
}
}