### Question:
AsyncXCommandExecutor { public void handleConcurrencyExceeded(CallableWrapper<?> command) { String type = command.getElement().getType(); Set<CallableWrapper<?>> commandsForType = pendingCommandsPerType.get(type); if (commandsForType == null) { commandsForType = new ConcurrentHashSet<>(); Set<CallableWrapper<?>> oldCommandForType; oldCommandForType = pendingCommandsPerType.putIfAbsent(type, commandsForType); if (oldCommandForType != null) { commandsForType = oldCommandForType; } } commandsForType.add(command); } @SuppressWarnings({"unchecked", "rawtypes"}) @SuppressFBWarnings( value = "SIC_INNER_SHOULD_BE_STATIC_ANON", justification = "Unnecessary to refactor innen classes defined here")  AsyncXCommandExecutor(int threads,
            int delayedCallableThreads,
            boolean needConcurrencyCheck,
            CallableQueueService callableAccess,
            long maxActiveCommands,
            long maxWait,
            int priorities,
            int awaitTerminationTimeoutSeconds); @VisibleForTesting  AsyncXCommandExecutor(boolean needConcurrencyCheck,
            CallableQueueService callableAccess,
            long maxActiveCommands,
            ThreadPoolExecutor executor,
            ScheduledThreadPoolExecutor scheduledExecutor,
            PriorityBlockingQueue<CallableWrapper<?>> priorityBlockingQueue,
            BlockingQueue<AccessibleRunnableScheduledFuture<ScheduledXCallable>> delayQueue,
            ConcurrentHashMap<String, Set<CallableWrapper<?>>> pendingCommandsPerType,
            AtomicInteger activeCommands,
            long maxWait,
            long priorities,
            int awaitTerminationTimeoutSeconds); synchronized boolean queue(CallableWrapper<?> wrapper, boolean ignoreQueueSize); void handleConcurrencyExceeded(CallableWrapper<?> command); void checkMaxConcurrency(String type); void commandFinished(); ThreadPoolExecutor getExecutorService(); void shutdown(); boolean isShutDown(); boolean isTerminated(); List<String> getQueueDump(); int getSize(); static final int MIN_PRIORITY; static final long ANTI_STARVATION_INTERVAL; }### Answer:
@Test public void testPendingCommandsWithSameType() { XCallable<?> callable = mock(XCallable.class); when(callable.getType()).thenReturn(DEFAULT_TYPE); Mockito.<XCallable<?>>when(callableWrapper.getElement()).thenReturn(callable); XCallable<?> secondCallable = mock(XCallable.class); when(secondCallable.getType()).thenReturn(DEFAULT_TYPE); CallableWrapper<?> secondWrapper = mock(CallableWrapper.class); Mockito.<XCallable<?>>when(secondWrapper.getElement()).thenReturn(secondCallable); asyncExecutor.handleConcurrencyExceeded(callableWrapper); asyncExecutor.handleConcurrencyExceeded(secondWrapper); assertEquals("Number of pending commands", 1, pendingCommandsPerType.size()); Set<CallableWrapper<?>> pendingCommandsList = pendingCommandsPerType.get(DEFAULT_TYPE); assertNotNull("List of pending commands doesn't exist", pendingCommandsList); assertEquals("List of pending commands", 2, pendingCommandsList.size()); }