Skip to content

Commit

Permalink
Add clear method in Facts API
Browse files Browse the repository at this point in the history
Resolves #250
  • Loading branch information
fmbenhassine committed Apr 5, 2020
1 parent 5d5b533 commit 0a631ff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions easy-rules-core/src/main/java/org/jeasy/rules/api/Facts.java
Expand Up @@ -93,6 +93,13 @@ public Iterator<Map.Entry<String, Object>> iterator() {
return facts.entrySet().iterator();
}

/**
* Clear facts.
*/
public void clear() {
facts.clear();
}

@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder("[");
Expand Down
Expand Up @@ -81,6 +81,14 @@ public void asMap() {
assertThat(o instanceof HashMap).isTrue();
}

@Test
public void testClear() {
Facts facts = new Facts();
facts.put("foo", "bar");
facts.clear();
assertThat(facts.asMap()).isEmpty();
}

@Test(expected = NullPointerException.class)
public void whenPutNullFact_thenShouldThrowNullPointerException() throws Exception {
facts.put(null, "foo");
Expand Down

0 comments on commit 0a631ff

Please sign in to comment.