unit tests

This commit is contained in:
Branislav Stojkovic
2025-03-13 15:21:46 +01:00
parent a0b27de187
commit 74f43159c4
4 changed files with 21 additions and 4 deletions
@@ -311,4 +311,9 @@ public class ComponentProcessor {
return true;
return false;
}
// Add this method for testing purposes
protected void setComponentTypeForTest(Class<? extends IDIYComponent<?>> componentClass, ComponentType componentType) {
componentTypeMap.put(componentClass.getName(), componentType);
}
}
@@ -192,23 +192,25 @@ public class Presenter implements IPlugInPort, IConfigListener {
}
public Presenter(IView view, IConfigurationManager<?> configManager, boolean importVariantsAndBlocks) {
this(view, configManager, importVariantsAndBlocks, new MessageDispatcher<EventType>(true));
}
// New constructor for testing
protected Presenter(IView view, IConfigurationManager<?> configManager, boolean importVariantsAndBlocks, MessageDispatcher<EventType> messageDispatcher) {
super();
this.view = view;
this.configManager = configManager;
this.messageDispatcher = messageDispatcher;
plugIns = new ArrayList<IPlugIn>();
messageDispatcher = new MessageDispatcher<EventType>(true);
selectedComponents = new HashSet<IDIYComponent<?>>();
lockedComponents = new HashSet<IDIYComponent<?>>();
currentProject = new Project();
// cloner = new Cloner();
drawingManager = new DrawingManager(messageDispatcher, configManager);
projectFileManager = new ProjectFileManager(messageDispatcher);
instantiationManager = new InstantiationManager();
variantManager = new VariantManager(configManager, projectFileManager.getXStream());
buildingBlockManager = new BuildingBlockManager(configManager, projectFileManager.getXStream(), instantiationManager);
// lockedLayers = EnumSet.noneOf(ComponentLayer.class);
// visibleLayers = EnumSet.allOf(ComponentLayer.class);
if (importVariantsAndBlocks) {
variantManager.upgradeVariants(getComponentTypes());
variantManager.importDefaultVariants();
@@ -2857,4 +2859,8 @@ public class Presenter implements IPlugInPort, IConfigListener {
messageDispatcher.dispatchMessage(EventType.REPAINT);
}
}
protected MessageDispatcher<EventType> getMessageDispatcher() {
return messageDispatcher;
}
}