public QueueCapacityVector parse(String capacityString, QueuePath queuePath) {

    if (queuePath.isRoot()) {
      return QueueCapacityVector.of(100f, ResourceUnitCapacityType.PERCENTAGE);
    }

    if (capacityString == null) {
      return new QueueCapacityVector();
    }
    // Trim all spaces from capacity string
    capacityString = capacityString.replaceAll(" ", "");

    for (Parser parser : parsers) {
      Matcher matcher = parser.regex.matcher(capacityString);
      if (matcher.find()) {
        return parser.parser.apply(matcher);
      }
    }

    return new QueueCapacityVector();
  }
@Test
  public void testInvalidCapacityConfigs() {
    QueueCapacityVector capacityVectorWithInvalidSuffix =
        capacityConfigParser.parse(NONEXISTINGSUFFIX, QUEUE_PATH);
    List<QueueCapacityVectorEntry> entriesWithInvalidSuffix =
        Lists.newArrayList(capacityVectorWithInvalidSuffix.iterator());
    Assert.assertEquals(0, entriesWithInvalidSuffix.size());

    QueueCapacityVector invalidDelimiterCapacityVector =
        capacityConfigParser.parse(INVALID_CAPACITY_FORMAT, QUEUE_PATH);
    List<QueueCapacityVectorEntry> invalidDelimiterEntries =
        Lists.newArrayList(invalidDelimiterCapacityVector.iterator());
    Assert.assertEquals(0, invalidDelimiterEntries.size());

    QueueCapacityVector invalidCapacityVector =
        capacityConfigParser.parse(INVALID_CAPACITY_BRACKET, QUEUE_PATH);
    List<QueueCapacityVectorEntry> resources =
        Lists.newArrayList(invalidCapacityVector.iterator());
    Assert.assertEquals(0, resources.size());

    QueueCapacityVector emptyBracketCapacityVector =
        capacityConfigParser.parse(EMPTY_BRACKET, QUEUE_PATH);
    List<QueueCapacityVectorEntry> emptyEntries =
        Lists.newArrayList(emptyBracketCapacityVector.iterator());
    Assert.assertEquals(0, emptyEntries.size());

    QueueCapacityVector emptyCapacity =
        capacityConfigParser.parse("", QUEUE_PATH);
    List<QueueCapacityVectorEntry> emptyResources =
        Lists.newArrayList(emptyCapacity.iterator());
    Assert.assertEquals(emptyResources.size(), 0);

    QueueCapacityVector nonSetCapacity =
        capacityConfigParser.parse(null, QUEUE_PATH);
    List<QueueCapacityVectorEntry> nonSetResources =
        Lists.newArrayList(nonSetCapacity.iterator());
    Assert.assertEquals(nonSetResources.size(), 0);
  }