### Question:
ComponentBase { public Component newComponent(String name, String description) { Validate.validState(componentType != null, "componentType must be set"); if (componentType == ComponentType.FORUM) { return new Jcommune(name, description, copyAll(defaultProperties)); } else if (componentType == ComponentType.ADMIN_PANEL) { return new Poulpe(name, description, copyAll(defaultProperties)); } else { return new Component(name, description, componentType, copyAll(defaultProperties)); } } protected  ComponentBase();  ComponentBase(@Nonnull ComponentType componentType); Component newComponent(String name, String description); ComponentType getComponentType(); Collection<Property> getDefaultProperties();  }### Answer:
@Test public void newComponent_nameAndDescription() { ComponentBase baseComponent = TestFixtures.baseComponent(); String name = random(), description = random(); Component component = baseComponent.newComponent(name, description); assertEquals(component.getName(), name); assertEquals(component.getDescription(), description); }
@Test(expectedExceptions = IllegalStateException.class) public void newComponent_componentTypeNotSet() { ComponentBase baseComponent = new ComponentBase(); baseComponent.newComponent(random(), random()); }
@Test public void newComponent_defaultPropertyCopied() { ComponentBase baseComponent = TestFixtures.baseComponent(); Property property = givenDefaultProperty(baseComponent); Component component = baseComponent.newComponent(random(), random()); assertContainsProperty(component, property); }
@Test public void newComponent_propertiesAreNotTheSameEntities() { ComponentBase baseComponent = TestFixtures.baseComponent(); Property property = givenDefaultProperty(baseComponent); Component component = baseComponent.newComponent(random(), random()); assertPropertiesAreDifferentEntities(property, component); }