### Question:
AttributeMunger { public static <T> void setAttributeIfChanged(EntityAndAttribute<T> entityAndAttribute, T val) { setAttributeIfChanged(entityAndAttribute.getEntity(), entityAndAttribute.getAttribute(), val); } AttributeMunger(Entity adjunctEntity); void transformSensorStringReplacingWithPublicAddressAndPort(
            final EntityAndAttribute<String> targetToUpdate,
            final Optional<EntityAndAttribute<Integer>> optionalTargetPort,
            final Iterable<? extends AttributeSensor<String>> targetsToMatch,
            final EntityAndAttribute<String> replacementSource); static String replaceIfNotNull(String string, String searchFor, String replaceWith); static void setAttributeIfChanged(EntityAndAttribute<T> entityAndAttribute, T val); static void setAttributeIfChanged(Entity entity, AttributeSensor<T> attribute, T val);  }### Answer:
@Test(groups="Integration") public void testSetAttributeIfChanged() throws Exception { AttributeMunger.setAttributeIfChanged(new EntityAndAttribute<String>(app, TestApplication.MY_ATTRIBUTE), "val1"); assertEquals(app.getAttribute(TestApplication.MY_ATTRIBUTE), "val1"); assertEquals(events, ImmutableList.of("val1"), "actual="+events); AttributeMunger.setAttributeIfChanged(new EntityAndAttribute<String>(app, TestApplication.MY_ATTRIBUTE), "val1"); assertEqualsContinually(events, ImmutableList.of("val1")); assertEquals(app.getAttribute(TestApplication.MY_ATTRIBUTE), "val1"); AttributeMunger.setAttributeIfChanged(new EntityAndAttribute<String>(app, TestApplication.MY_ATTRIBUTE), "val2"); assertEquals(app.getAttribute(TestApplication.MY_ATTRIBUTE), "val2"); assertEqualsEventually(events, ImmutableList.of("val1", "val2")); }