@Test public void putAll() { User batMan = newUser("batMan"); User spiderMan = newUser("spiderMan"); User superMan = newUser("superMan"); Map<String, User> userMap = getUsersAsMap(batMan, spiderMan, superMan); assertThat(users.keySet().containsAll(userMap.keySet())).isFalse(); assertThat(users.values().containsAll(userMap.values())).isFalse(); usersTemplate.putAll(userMap); assertThat(users.keySet().containsAll(userMap.keySet())).isTrue(); assertThat(users.values().containsAll(userMap.values())).isTrue(); }
/** * Given a List of QueryObjects known to be inconsistent as determined by validation, log where * the suspect objects are found by checking for it in 1) the expected List 2) the CQ history of * events 3) the select results 4) the localRegion * * @param inconsistencies A List of suspect QueryObjects to check in each location. * @param expected The expected List of objects for a query. * @param history The CQHistory for the query * @returns */ private String getLocationString(List inconsistencies, List expected, CQHistory history) { StringBuffer aStr = new StringBuffer(); for (int i = 0; i < inconsistencies.size(); i++) { QueryObject suspect = (QueryObject) (inconsistencies.get(i)); // check the local region boolean found = false; Iterator it = aRegion.keySet().iterator(); while (it.hasNext()) { Object key = it.next(); Region.Entry entry = aRegion.getEntry(key); QueryObject qo = (QueryObject) (entry.getValue()); if ((qo != null) && (qo.equals(suspect))) { found = true; aStr.append( qo.toStringAbbreviated() + " was found in " + aRegion.getFullPath() + " at key " + key + "\n"); } } if (!found) { aStr.append( suspect.toStringAbbreviated() + " was NOT found in " + aRegion.getFullPath() + "\n"); } // seach for all occurrences in expected list found = false; it = expected.iterator(); while (it.hasNext()) { QueryObject qo = (QueryObject) (it.next()); if (qo.equals(suspect)) { found = true; aStr.append(qo.toStringAbbreviated() + " was found in expected results\n"); } } if (!found) { aStr.append(suspect.toStringAbbreviated() + " was NOT found in expected results\n"); } // seach for all occurrences in selectResults SelectResults selResults = history.getSelectResults(); found = false; it = selResults.iterator(); while (it.hasNext()) { QueryObject qo = (QueryObject) (it.next()); if (qo.equals(suspect)) { found = true; aStr.append(qo.toStringAbbreviated() + " was found in SelectResults\n"); } } if (!found) { aStr.append(suspect.toStringAbbreviated() + " was NOT found in SelectResults\n"); } // seach for all occurrences in history found = false; List eventList = history.getEvents(); for (int j = 0; j < eventList.size(); j++) { CqEvent event = (CqEvent) (eventList.get(j)); QueryObject qo = (QueryObject) (event.getNewValue()); if ((qo != null) && (qo.equals(suspect))) { found = true; aStr.append( qo.toStringAbbreviated() + " was found in event history as new value " + event + "\n"); } } if (!found) { aStr.append(suspect.toStringAbbreviated() + " was NOT found in CqEvent history\n"); } } return aStr.toString(); }