private List<T> loadAllByAllDocIds() { List<String> ids = db.getAllDocIds(); List<T> all = new ArrayList<T>(ids.size()); for (String id : ids) { if (!id.startsWith("_design")) { all.add(get(id)); } } return all; } /**
private void doLoad(Reader in) throws IOException, JsonParseException, JsonMappingException { Set<String> allIds = new HashSet<String>(db.getAllDocIds()); JsonNode jn = objectMapper.readValue(in, JsonNode.class); for (Iterator<JsonNode> i = jn.elements(); i.hasNext();) { JsonNode n = i.next(); String id = n.get("_id").textValue(); if (!allIds.contains(id)) { LOG.info("adding {} to database", id); createDocument(n, id); } } } /**
public static final void strictAssertEquals(InputStream expectedData, CouchDbConnector couchDb) { try { List<Map<String, Object>> expectedDocuments = DataLoader.getDocuments(expectedData); List<String> allDocIds = couchDb.getAllDocIds(); checkNumberOfDocuments(expectedDocuments, allDocIds); List<Map<String, Object>> remainingExpectedElementsWithoutIds = checkDocumentsWithId(expectedDocuments, couchDb, allDocIds); checkDocumentsWithoutId(couchDb, allDocIds, remainingExpectedElementsWithoutIds); } catch (JsonProcessingException e) { throw new IllegalArgumentException(e); } catch (IOException e) { throw new IllegalArgumentException(e); } }
public static final void strictAssertEquals(InputStream expectedData, CouchDbConnector couchDb) { try { List<Map<String, Object>> expectedDocuments = DataLoader.getDocuments(expectedData); List<String> allDocIds = couchDb.getAllDocIds(); checkNumberOfDocuments(expectedDocuments, allDocIds); List<Map<String, Object>> remainingExpectedElementsWithoutIds = checkDocumentsWithId(expectedDocuments, couchDb, allDocIds); checkDocumentsWithoutId(couchDb, allDocIds, remainingExpectedElementsWithoutIds); } catch (JsonProcessingException e) { throw new IllegalArgumentException(e); } catch (IOException e) { throw new IllegalArgumentException(e); } }