@Test(expected = UnsupportedOperationException.class) public void testOnlyAllowedCommands() { final CutSelectionSessionCommand cut = new CutSelectionSessionCommand(commandExecutedEvent, sessionManager); SessionSingletonCommandsFactory.createOrPut(cut, sessionManager); }
public static void createOrPut(AbstractSelectionAwareSessionCommand<EditorSession> command, SessionManager sessionManager) { if (sessionManager == null) { throw new IllegalStateException("Session Manager is Null"); } if (command instanceof CopySelectionSessionCommand) { if (copySessionInstances.containsKey(sessionManager.getCurrentSession())) { throw new IllegalStateException("Only one instance of CopySelectionSessionCommand per Client Session can exist"); } copySessionInstances.put(sessionManager.getCurrentSession(), (CopySelectionSessionCommand) command); } else if (command instanceof DeleteSelectionSessionCommand) { if (deleteSessionInstances.containsKey(sessionManager.getCurrentSession())) { throw new IllegalStateException("Only one instance of DeleteSelectionSessionCommand per Client Session can exist"); } deleteSessionInstances.put(sessionManager.getCurrentSession(), (DeleteSelectionSessionCommand) command); } else { throw new UnsupportedOperationException("Session Command Not Compatible Yet : " + command.getClass()); } }
SessionSingletonCommandsFactory { public static void createOrPut(AbstractSelectionAwareSessionCommand<EditorSession> command, SessionManager sessionManager) { if (sessionManager == null) { throw new IllegalStateException("Session Manager is Null"); } if (command instanceof CopySelectionSessionCommand) { if (copySessionInstances.containsKey(sessionManager.getCurrentSession())) { throw new IllegalStateException("Only one instance of CopySelectionSessionCommand per Client Session can exist"); } copySessionInstances.put(sessionManager.getCurrentSession(), (CopySelectionSessionCommand) command); } else if (command instanceof DeleteSelectionSessionCommand) { if (deleteSessionInstances.containsKey(sessionManager.getCurrentSession())) { throw new IllegalStateException("Only one instance of DeleteSelectionSessionCommand per Client Session can exist"); } deleteSessionInstances.put(sessionManager.getCurrentSession(), (DeleteSelectionSessionCommand) command); } else { throw new UnsupportedOperationException("Session Command Not Compatible Yet : " + command.getClass()); } } }
SessionSingletonCommandsFactory { public static void createOrPut(AbstractSelectionAwareSessionCommand<EditorSession> command, SessionManager sessionManager) { if (sessionManager == null) { throw new IllegalStateException("Session Manager is Null"); } if (command instanceof CopySelectionSessionCommand) { if (copySessionInstances.containsKey(sessionManager.getCurrentSession())) { throw new IllegalStateException("Only one instance of CopySelectionSessionCommand per Client Session can exist"); } copySessionInstances.put(sessionManager.getCurrentSession(), (CopySelectionSessionCommand) command); } else if (command instanceof DeleteSelectionSessionCommand) { if (deleteSessionInstances.containsKey(sessionManager.getCurrentSession())) { throw new IllegalStateException("Only one instance of DeleteSelectionSessionCommand per Client Session can exist"); } deleteSessionInstances.put(sessionManager.getCurrentSession(), (DeleteSelectionSessionCommand) command); } else { throw new UnsupportedOperationException("Session Command Not Compatible Yet : " + command.getClass()); } }  }
SessionSingletonCommandsFactory { public static void createOrPut(AbstractSelectionAwareSessionCommand<EditorSession> command, SessionManager sessionManager) { if (sessionManager == null) { throw new IllegalStateException("Session Manager is Null"); } if (command instanceof CopySelectionSessionCommand) { if (copySessionInstances.containsKey(sessionManager.getCurrentSession())) { throw new IllegalStateException("Only one instance of CopySelectionSessionCommand per Client Session can exist"); } copySessionInstances.put(sessionManager.getCurrentSession(), (CopySelectionSessionCommand) command); } else if (command instanceof DeleteSelectionSessionCommand) { if (deleteSessionInstances.containsKey(sessionManager.getCurrentSession())) { throw new IllegalStateException("Only one instance of DeleteSelectionSessionCommand per Client Session can exist"); } deleteSessionInstances.put(sessionManager.getCurrentSession(), (DeleteSelectionSessionCommand) command); } else { throw new UnsupportedOperationException("Session Command Not Compatible Yet : " + command.getClass()); } }  static void createOrPut(AbstractSelectionAwareSessionCommand<EditorSession> command, SessionManager sessionManager); static CopySelectionSessionCommand getInstanceCopy(
            final Event<?> commandExecutedEvent,
            SessionManager sessionManager); static DeleteSelectionSessionCommand getInstanceDelete(
            final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
            final ManagedInstance<CanvasCommandFactory<AbstractCanvasHandler>> canvasCommandFactoryInstance,
            final Event<CanvasClearSelectionEvent> clearSelectionEvent,
            final DefinitionUtils definitionUtils,
            final SessionManager sessionManager); }
SessionSingletonCommandsFactory { public static void createOrPut(AbstractSelectionAwareSessionCommand<EditorSession> command, SessionManager sessionManager) { if (sessionManager == null) { throw new IllegalStateException("Session Manager is Null"); } if (command instanceof CopySelectionSessionCommand) { if (copySessionInstances.containsKey(sessionManager.getCurrentSession())) { throw new IllegalStateException("Only one instance of CopySelectionSessionCommand per Client Session can exist"); } copySessionInstances.put(sessionManager.getCurrentSession(), (CopySelectionSessionCommand) command); } else if (command instanceof DeleteSelectionSessionCommand) { if (deleteSessionInstances.containsKey(sessionManager.getCurrentSession())) { throw new IllegalStateException("Only one instance of DeleteSelectionSessionCommand per Client Session can exist"); } deleteSessionInstances.put(sessionManager.getCurrentSession(), (DeleteSelectionSessionCommand) command); } else { throw new UnsupportedOperationException("Session Command Not Compatible Yet : " + command.getClass()); } }  static void createOrPut(AbstractSelectionAwareSessionCommand<EditorSession> command, SessionManager sessionManager); static CopySelectionSessionCommand getInstanceCopy(
            final Event<?> commandExecutedEvent,
            SessionManager sessionManager); static DeleteSelectionSessionCommand getInstanceDelete(
            final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
            final ManagedInstance<CanvasCommandFactory<AbstractCanvasHandler>> canvasCommandFactoryInstance,
            final Event<CanvasClearSelectionEvent> clearSelectionEvent,
            final DefinitionUtils definitionUtils,
            final SessionManager sessionManager);  }