### Question:
TransactionalComponentService extends AbstractTransactionalEntityService<Component, ComponentDao> implements ComponentService { @Override public void addComponent(Component component) throws EntityUniqueConstraintException { Component existInDbComponent = getByType(component.getComponentType()); if (existInDbComponent != null && component.getId() != existInDbComponent.getId()) { throw new EntityUniqueConstraintException(); } dao.saveOrUpdate(component); } TransactionalComponentService(ComponentDao dao); @Override List<Component> getAll(); @Override void deleteComponent(Component component); @Deprecated @Override void saveComponent(Component component); @Override void reindexComponent(Jcommune jcommune); @Override Set<ComponentType> getAvailableTypes(); @Override ComponentBase baseComponentFor(ComponentType componentType); @Override Component getByType(ComponentType type); JCommuneNotifier getjCommuneNotifier(); void setjCommuneNotifier(JCommuneNotifier jCommuneNotifier); @Override void addComponent(Component component); @Override void updateComponent(Component component);  }### Answer:
@Test public void testAddComponent() throws Exception { when(componentService.getByType(component.getComponentType())).thenReturn(component); componentService.addComponent(component); verify(componentDao).saveOrUpdate(component); }