public void add(CSQueue queue) {
    String fullName = queue.getQueuePath();
    String shortName = queue.getQueueShortName();

    try {
      modificationLock.writeLock().lock();

      fullNameQueues.put(fullName, queue);
      getMap.put(fullName, queue);

      //we only update short queue name ambiguity for non root queues
      if (!shortName.equals(CapacitySchedulerConfiguration.ROOT)) {
        //getting or creating the ambiguity set for the current queue
        Set<String> fullNamesSet =
            this.shortNameToLongNames.getOrDefault(shortName, new HashSet<>());

        //adding the full name to the queue
        fullNamesSet.add(fullName);
        this.shortNameToLongNames.put(shortName, fullNamesSet);
      }

      //updating the getMap references for the queue
      updateGetMapForShortName(shortName);
    } finally {
      modificationLock.writeLock().unlock();
    }
  }
@Test
  public void testAmbiguousMapping() throws IOException {
    CSQueueStore store = new CSQueueStore();

    //root.main
    CSQueue main = createParentQueue("main", root);
    //root.main.A
    CSQueue mainA = createParentQueue("A", main);
    //root.main.A.C
    CSQueue mainAC = createLeafQueue("C", mainA);
    //root.main.A.D
    CSQueue mainAD = createParentQueue("D", mainA);
    //root.main.A.D.E
    CSQueue mainADE = createLeafQueue("E", mainAD);
    //root.main.A.D.F
    CSQueue mainADF = createLeafQueue("F", mainAD);
    //root.main.B
    CSQueue mainB = createParentQueue("B", main);
    //root.main.B.C
    CSQueue mainBC = createLeafQueue("C", mainB);
    //root.main.B.D
    CSQueue mainBD = createParentQueue("D", mainB);
    //root.main.B.D.E
    CSQueue mainBDE = createLeafQueue("E", mainBD);
    //root.main.B.D.G
    CSQueue mainBDG = createLeafQueue("G", mainBD);

    store.add(main);
    store.add(mainA);
    store.add(mainAC);
    store.add(mainAD);
    store.add(mainADE);
    store.add(mainADF);
    store.add(mainB);
    store.add(mainBC);
    store.add(mainBD);
    store.add(mainBDE);
    store.add(mainBDG);

    assertAccessibleByAllNames(store, main);
    assertAccessibleByAllNames(store, mainA);
    assertAccessibleByAllNames(store, mainB);
    assertAccessibleByAllNames(store, mainADF);
    assertAccessibleByAllNames(store, mainBDG);

    assertAmbiguous(store, mainAC);
    assertAmbiguous(store, mainAD);
    assertAmbiguous(store, mainADE);
    assertAmbiguous(store, mainBC);
    assertAmbiguous(store, mainBD);
    assertAmbiguous(store, mainBDE);
  }