Log log = mockLog();
Location l = mockLocation();
replay();
MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, log, r, null);
assertTrue(model.getEmbeddedComponentIds().isEmpty());
MutableEmbeddedComponentModel fred = model.addEmbeddedComponent(
"fred",
"Fred",
COMPONENT_CLASS_NAME,
l);
assertEquals(fred.getId(), "fred");
assertEquals(fred.getComponentType(), "Fred");
assertSame(fred.getLocation(), l);
MutableEmbeddedComponentModel barney = model.addEmbeddedComponent(
"barney",
"Barney",
COMPONENT_CLASS_NAME,
null);
assertEquals(model.getEmbeddedComponentIds(), Arrays.asList("barney", "fred"));
assertSame(model.getEmbeddedComponentModel("fred"), fred);
assertSame(model.getEmbeddedComponentModel("barney"), barney);
// Access by id is case insensitive
assertSame(model.getEmbeddedComponentModel("FRED"), fred);
assertSame(model.getEmbeddedComponentModel("BARNEY"), barney);
assertEquals(
fred.toString(),
"EmbeddedComponentModel[id=fred type=Fred class=org.example.components.Fred]");