@Test(expected = AttributeException.class) public void addThrowsAttributeException() { String attributeName = "name"; MyObject object = new MyObject(); Set<String> keySet = new HashSet<String>(); keySet.add("ada"); doReturn(keySet).when(indexes).keySet(); doReturn(cacheIndex).when(indexes).get(attributeName); doNothing().when(cacheIndex).put(object, object); handler.add(object, object); }
public void add(final K key, final V value) { for (final String attributeName : indexes.keySet()) { final Object indexedKey = getFieldValue(attributeName, value); if (indexedKey == null) { throw new NullPointerException(); } indexes.get(attributeName).put(indexedKey, key); } }
DefaultIndexHandler implements IndexHandler<K, V> { public void add(final K key, final V value) { for (final String attributeName : indexes.keySet()) { final Object indexedKey = getFieldValue(attributeName, value); if (indexedKey == null) { throw new NullPointerException(); } indexes.get(attributeName).put(indexedKey, key); } } }
DefaultIndexHandler implements IndexHandler<K, V> { public void add(final K key, final V value) { for (final String attributeName : indexes.keySet()) { final Object indexedKey = getFieldValue(attributeName, value); if (indexedKey == null) { throw new NullPointerException(); } indexes.get(attributeName).put(indexedKey, key); } } DefaultIndexHandler(); }
DefaultIndexHandler implements IndexHandler<K, V> { public void add(final K key, final V value) { for (final String attributeName : indexes.keySet()) { final Object indexedKey = getFieldValue(attributeName, value); if (indexedKey == null) { throw new NullPointerException(); } indexes.get(attributeName).put(indexedKey, key); } } DefaultIndexHandler(); void addIndex(final String attributeName, final IndexType type); void add(final K key, final V value); void remove(final K key, final V value); void clear(); @SuppressWarnings("unchecked") List<K> execute(final Query query); }
DefaultIndexHandler implements IndexHandler<K, V> { public void add(final K key, final V value) { for (final String attributeName : indexes.keySet()) { final Object indexedKey = getFieldValue(attributeName, value); if (indexedKey == null) { throw new NullPointerException(); } indexes.get(attributeName).put(indexedKey, key); } } DefaultIndexHandler(); void addIndex(final String attributeName, final IndexType type); void add(final K key, final V value); void remove(final K key, final V value); void clear(); @SuppressWarnings("unchecked") List<K> execute(final Query query);  }