From 74f43159c45cb537dd0b93307acea8a4823eb0eb Mon Sep 17 00:00:00 2001 From: Branislav Stojkovic Date: Thu, 13 Mar 2025 15:21:46 +0100 Subject: [PATCH] unit tests --- diylc/.DS_Store | Bin 6148 -> 6148 bytes diylc/diylc-core/pom.xml | 6 ++++++ .../diylc/presenter/ComponentProcessor.java | 5 +++++ .../java/org/diylc/presenter/Presenter.java | 14 ++++++++++---- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/diylc/.DS_Store b/diylc/.DS_Store index 1327d980f0c864e85b9791f343fa5022ff2da9b1..9caebd44cd91efdf3bcc221f1c13e59b3bc286db 100644 GIT binary patch delta 21 ccmZoMXffEZjD^G4%v?vo(9CS}I+ieD07xwcA^-pY delta 21 ccmZoMXffEZjD^F*$W%wc(7java-http-proxy 1.0 + + org.mockito + mockito-core + 5.3.1 + test + diff --git a/diylc/diylc-core/src/main/java/org/diylc/presenter/ComponentProcessor.java b/diylc/diylc-core/src/main/java/org/diylc/presenter/ComponentProcessor.java index 2bab6e2b..3b839c92 100644 --- a/diylc/diylc-core/src/main/java/org/diylc/presenter/ComponentProcessor.java +++ b/diylc/diylc-core/src/main/java/org/diylc/presenter/ComponentProcessor.java @@ -311,4 +311,9 @@ public class ComponentProcessor { return true; return false; } + + // Add this method for testing purposes + protected void setComponentTypeForTest(Class> componentClass, ComponentType componentType) { + componentTypeMap.put(componentClass.getName(), componentType); + } } diff --git a/diylc/diylc-core/src/main/java/org/diylc/presenter/Presenter.java b/diylc/diylc-core/src/main/java/org/diylc/presenter/Presenter.java index a8b9c3b3..6ac63270 100644 --- a/diylc/diylc-core/src/main/java/org/diylc/presenter/Presenter.java +++ b/diylc/diylc-core/src/main/java/org/diylc/presenter/Presenter.java @@ -192,23 +192,25 @@ public class Presenter implements IPlugInPort, IConfigListener { } public Presenter(IView view, IConfigurationManager configManager, boolean importVariantsAndBlocks) { + this(view, configManager, importVariantsAndBlocks, new MessageDispatcher(true)); + } + + // New constructor for testing + protected Presenter(IView view, IConfigurationManager configManager, boolean importVariantsAndBlocks, MessageDispatcher messageDispatcher) { super(); this.view = view; this.configManager = configManager; + this.messageDispatcher = messageDispatcher; plugIns = new ArrayList(); - messageDispatcher = new MessageDispatcher(true); selectedComponents = new HashSet>(); lockedComponents = new HashSet>(); 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 getMessageDispatcher() { + return messageDispatcher; + } }