From 899e0768dad8418d1d1f2ee9294519d8ad8791a7 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sat, 28 Dec 2019 14:09:00 +0100 Subject: Test attribute removal --- .../edu/mimuw/cloudatlas/agent/modules/StanikTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 : attributes) { -- cgit v1.2.3