• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ljacqu / wordeval / 14552398690

19 Apr 2025 07:59PM UTC coverage: 52.924% (+2.3%) from 50.591%
14552398690

push

github

ljacqu
Write sanitizer tests that don't require the dictionary file

268 of 576 branches covered (46.53%)

1 of 2 new or added lines in 1 file covered. (50.0%)

36 existing lines in 9 files now uncovered.

724 of 1368 relevant lines covered (52.92%)

3.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/main/java/ch/jalu/wordeval/appdata/ObjectStore.java
1
package ch.jalu.wordeval.appdata;
2

3
import java.util.HashMap;
4
import java.util.Map;
5
import java.util.Set;
6

7
/**
8
 * Stores objects by a key. Throws an exception if an object tries to be stored with
9
 * the same key twice, or if an object is retrieved for a key that does not have an
10
 * associated object.
11
 */
12
abstract class ObjectStore<K, V> {
2✔
13

14
  protected final Map<K, V> entries = new HashMap<>();
6✔
15

16
  /**
17
   * Adds all given objects to the store.
18
   *
19
   * @param objects the objects to add
20
   */
21
  @SafeVarargs
22
  public final void addAll(V... objects) {
23
    for (V object : objects) {
16✔
24
      add(object);
3✔
25
    }
26
  }
1✔
27

28
  /**
29
   * Adds the given object to the store.
30
   *
31
   * @param object the object to store
32
   */
33
  private void add(V object) {
34
    K key = getKey(object);
4✔
35
    if (entries.containsKey(key)) {
5!
36
      throw new IllegalStateException("An object for key '" + key + "' has already been stored");
×
37
    }
38
    entries.put(key, object);
6✔
39
  }
1✔
40

41
  /**
42
   * Returns the object for the given key or throws an exception if there is no such entry.
43
   *
44
   * @param key the key whose object should be retrieved
45
   * @return the object
46
   */
47
  public V get(K key) {
48
    V value = entries.get(key);
5✔
49
    if (value == null) {
2!
50
      throw new IllegalStateException(
×
UNCOV
51
          "No entry has been stored for key '" + key + "' (" + getClass().getSimpleName() + ")");
×
52
    }
53
    return value;
2✔
54
  }
55

56
  /**
57
   * Returns all keys that are in the store.
58
   *
59
   * @return the key set
60
   */
61
  public Set<K> keySet() {
UNCOV
62
    return entries.keySet();
×
63
  }
64

65
  /**
66
   * Returns the key based on the object.
67
   *
68
   * @param object the object to process
69
   * @return the key
70
   */
71
  protected abstract K getKey(V object);
72

73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc