diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2019-12-28 14:09:00 +0100 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2019-12-28 14:09:00 +0100 |
commit | 899e0768dad8418d1d1f2ee9294519d8ad8791a7 (patch) | |
tree | ad62e7741f73b163bb2bdd886c731b251bdcd785 | |
parent | 5f7e37d7b26832b3b512f9dda310cb9bc92c93fb (diff) |
Test attribute removal
-rw-r--r-- | src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java index 31b701d..869dc1c 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/agent/modules/StanikTest.java @@ -95,6 +95,24 @@ public class StanikTest { assertEquals(new ValueString("baz"), actualAttributes.getOrNull("bar")); } + @Test + public void updateWithRemovedAttributes() throws Exception { + AttributesMap attributes = new AttributesMap(); + attributes.add("foo", new ValueInt(1337l)); + attributes.add("bar", new ValueString("baz")); + UpdateAttributesMessage message = new UpdateAttributesMessage("test_msg", 0, "/", attributes); + stanik.handleTyped(message); + + AttributesMap newAttributes = new AttributesMap(); + newAttributes.add("foo", new ValueInt(1338l)); + UpdateAttributesMessage newMessage = new UpdateAttributesMessage("test_msg2", 0, "/", newAttributes); + stanik.handleTyped(newMessage); + + AttributesMap actualAttributes = stanik.getHierarchy().getAttributes(); + assertEquals(1, countAttributes(actualAttributes)); + assertEquals(new ValueInt(1338l), actualAttributes.getOrNull("foo")); + } + public int countAttributes(AttributesMap attributes) { int count = 0; for (Entry<Attribute, Value> attribute : attributes) { |