Map<String, Object> attributes = Maps.newHashMap();
attributes.put("a1", "a1");
attributes.put("a2", "a2");
attributes.put("value", "aura");
Component component = Aura.getInstanceService().getInstance(compName, ComponentDef.class, attributes);
assertEquals("a1 should have been updated by provider", "a1Provider", component.getAttributes().getValue("a1"));
assertEquals("b1 should have been set by provider", "b1Provider", component.getAttributes().getValue("b1"));
assertNull("a2 should have been updated by provider to null", component.getAttributes().getValue("a2"));
assertNull("b2 should not have been set", component.getAttributes().getValue("b2"));
attributes.clear();
attributes.put("a3", "a3");
attributes.put("value", "aura");
component = Aura.getInstanceService().getInstance(compName, ComponentDef.class, attributes);
assertEquals("b2 should have been set by provider", "b2Provider", component.getAttributes().getValue("b2"));
attributes.clear();
try {
component = Aura.getInstanceService().getInstance(compName, ComponentDef.class, attributes);
fail("'value' is required on the underlying concrete component. This should have thrown an exception as provider also didn't set it.");
} catch (AuraValidationException e) {
assertEquals(MissingRequiredAttributeException.getMessage(component.getDescriptor(), "value"),
e.getMessage());
}
}