### Question:
UniqueId implements UniqueIdInterface { public byte[] getId(final String name) throws NoSuchUniqueName, HBaseException { byte[] id = getIdFromCache(name); if (id != null) { cacheHits++; } else { cacheMisses++; id = getIdFromHBase(name); if (id == null) { throw new NoSuchUniqueName(kind(), name); } if (id.length != idWidth) { throw new IllegalStateException("Found id.length = " + id.length + " which is != " + idWidth + " required for '" + kind() + '\''); } addIdToCache(name, id); addNameToCache(id, name); } return id; } UniqueId(final HBaseClient client, final byte[] table, final String kind,
                    final int width); int cacheHits(); int cacheMisses(); int cacheSize(); String kind(); short width(); void dropCaches(); String getName(final byte[] id); byte[] getId(final String name); byte[] getOrCreateId(String name); List<String> suggest(final String search); void rename(final String oldname, final String newname); String toString();  }### Answer:
@Test(expected=IllegalStateException.class) public void getIdMisconfiguredWidth() { uid = new UniqueId(client, table, kind, 3); final byte[] id = { 'a', 0x42 }; final byte[] byte_name = { 'f', 'o', 'o' }; ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(1); kvs.add(new KeyValue(byte_name, ID, kind_array, id)); when(client.get(anyGet())) .thenReturn(Deferred.fromResult(kvs)); uid.getId("foo"); }
@Test(expected=NoSuchUniqueName.class) public void getIdForNonexistentName() { uid = new UniqueId(client, table, kind, 3); when(client.get(anyGet())) .thenReturn(Deferred.<ArrayList<KeyValue>>fromResult(null)); uid.getId("foo"); }