List of usage examples for java.util Map.Entry isEmpty
boolean isEmpty();
From source file:org.apache.solr.handler.TestSolrConfigHandlerConcurrent.java
@Test public void test() throws Exception { Map editable_prop_map = (Map) Utils.fromJSONResource("EditableSolrConfigAttributes.json"); Map caches = (Map) editable_prop_map.get("query"); setupHarnesses();//w ww.j a v a 2 s .co m List<Thread> threads = new ArrayList<>(caches.size()); final List<List> collectErrors = new ArrayList<>(); for (Object o : caches.entrySet()) { final Map.Entry e = (Map.Entry) o; Thread t = new Thread() { @Override public void run() { try { ArrayList errs = new ArrayList(); collectErrors.add(errs); invokeBulkCall((String) e.getKey(), errs, (Map) e.getValue()); } catch (Exception e) { e.printStackTrace(); } } }; threads.add(t); t.start(); } for (Thread thread : threads) thread.join(); boolean success = true; for (List e : collectErrors) { if (!e.isEmpty()) { success = false; log.error(e.toString()); } } assertTrue(collectErrors.toString(), success); }
From source file:com.msopentech.odatajclient.testservice.utils.AbstractUtilities.java
protected String getDefaultEntryKey(final String entitySetName, final InputStream entity, final Accept accept) throws IOException { try {//from w w w.j a v a 2 s . c om String res; if ("Message".equals(entitySetName)) { try { final List<String> propertyNames = new ArrayList<String>(); propertyNames.add("MessageId"); propertyNames.add("FromUsername"); final StringBuilder keyBuilder = new StringBuilder(); for (Map.Entry<String, InputStream> value : getPropertyValues(entity, propertyNames, accept) .entrySet()) { if (keyBuilder.length() > 0) { keyBuilder.append(","); } keyBuilder.append(value.getKey()).append("=").append(IOUtils.toString(value.getValue())); } res = keyBuilder.toString(); } catch (Exception e) { int messageId = sequence.get(entitySetName) + 1; if (sequence.containsKey(entitySetName)) { res = "MessageId=" + String.valueOf(messageId) + ",FromUsername=1"; } else { throw new Exception( String.format("Unable to retrieve entity key value for %s", entitySetName)); } sequence.put(entitySetName, Integer.valueOf(messageId)); } } else if ("Order".equals(entitySetName)) { try { final Map<String, InputStream> value = getPropertyValues(entity, Collections.<String>singletonList("OrderId"), accept); res = value.isEmpty() ? null : IOUtils.toString(value.values().iterator().next()); } catch (Exception e) { if (sequence.containsKey(entitySetName)) { res = String.valueOf(sequence.get(entitySetName) + 1); } else { throw new Exception( String.format("Unable to retrieve entity key value for %s", entitySetName)); } } sequence.put(entitySetName, Integer.valueOf(res)); } else if ("Customer".equals(entitySetName)) { try { final Map<String, InputStream> value = getPropertyValues(entity, Collections.<String>singletonList("CustomerId"), accept); res = value.isEmpty() ? null : IOUtils.toString(value.values().iterator().next()); } catch (Exception e) { if (sequence.containsKey(entitySetName)) { res = String.valueOf(sequence.get(entitySetName) + 1); } else { throw new Exception( String.format("Unable to retrieve entity key value for %s", entitySetName)); } } sequence.put(entitySetName, Integer.valueOf(res)); } else if ("ComputerDetail".equals(entitySetName)) { try { final Map<String, InputStream> value = getPropertyValues(entity, Collections.<String>singletonList("ComputerDetailId"), accept); res = value.isEmpty() ? null : IOUtils.toString(value.values().iterator().next()); } catch (Exception e) { if (sequence.containsKey(entitySetName)) { res = String.valueOf(sequence.get(entitySetName) + 1); } else { throw new Exception( String.format("Unable to retrieve entity key value for %s", entitySetName)); } } sequence.put(entitySetName, Integer.valueOf(res)); } else if ("AllGeoTypesSet".equals(entitySetName)) { try { final Map<String, InputStream> value = getPropertyValues(entity, Collections.<String>singletonList("Id"), accept); res = value.isEmpty() ? null : IOUtils.toString(value.values().iterator().next()); } catch (Exception e) { if (sequence.containsKey(entitySetName)) { res = String.valueOf(sequence.get(entitySetName) + 1); } else { throw new Exception( String.format("Unable to retrieve entity key value for %s", entitySetName)); } } sequence.put(entitySetName, Integer.valueOf(res)); } else if ("CustomerInfo".equals(entitySetName)) { try { final Map<String, InputStream> value = getPropertyValues(entity, Collections.<String>singletonList("CustomerInfoId"), accept); res = value.isEmpty() ? null : IOUtils.toString(value.values().iterator().next()); } catch (Exception e) { if (sequence.containsKey(entitySetName)) { res = String.valueOf(sequence.get(entitySetName) + 1); } else { throw new Exception( String.format("Unable to retrieve entity key value for %s", entitySetName)); } } sequence.put(entitySetName, Integer.valueOf(res)); } else { throw new Exception(String.format("EntitySet '%s' not found", entitySetName)); } return res; } catch (Exception e) { throw new NotFoundException(e); } finally { IOUtils.closeQuietly(entity); } }