### Question:
DefaultPartitionAttributesBuilder implements PartitionAttributesBuilder { @Override public <T> PartitionAttributesBuilder add(Key<T> key, T value) { if (keyValueArray.length == nextIndex) { keyValueArray = copyOf(keyValueArray, (keyValueArray.length << 1) + 2); } int currentIndex = nextIndex; while (currentIndex > 0) { final int parentKeyIndex = ((currentIndex - 2) >>> 1) & PARENT_MASK; final Key parentKey = (Key) keyValueArray[parentKeyIndex]; final int cmp = parentKey.compareTo(key); if (cmp > 0) { break; } else if (cmp == 0) { throw new DuplicateAttributeException(key, "duplicate key [" + key + "] with values: [" + value + ", " + keyValueArray[parentKeyIndex + 1] + "]"); } keyValueArray[currentIndex] = parentKey; keyValueArray[currentIndex + 1] = keyValueArray[parentKeyIndex + 1]; currentIndex = parentKeyIndex; } keyValueArray[currentIndex] = key; keyValueArray[currentIndex + 1] = value; nextIndex += 2; return this; } DefaultPartitionAttributesBuilder(int initialSize); @Override PartitionAttributesBuilder add(Key<T> key, T value); @Override PartitionAttributes build();  }### Answer:
@Test public void duplicateKeyDifferentValueThrowsAtAdd() { DefaultPartitionAttributesBuilder builder = new DefaultPartitionAttributesBuilder(8); builder.add(DC_KEY, DEFAULT_DC); builder.add(OTHER_KEY, 2); builder.add(MAIN_KEY, true); builder.add(SHARD_KEY, DEFAULT_SHARD); try { builder.add(OTHER_KEY, 3); fail(); } catch (DuplicateAttributeException e) { assertSame(OTHER_KEY, e.getKey()); } }