### Question:
State { public @NonNull State add(int key, @DrawableRes int drawable) { if (!isValidKey(key)) { throw new IllegalStateException("Invalid key: " + key + " used for: " + getClass().getName() + " when adding drawable: " + drawable); } states.put(key, drawable); return this; } State(); @NonNull State add(int key, @DrawableRes int drawable); abstract void attach(@NonNull StateDraweeView view); abstract void detach(@NonNull StateDraweeView view); @Override String toString();  }### Answer:
@Test public void test_IsValidKeyIsTakenIntoAccount() { State state = newState(); try { state.add(-1, 0); } catch (Exception e) { Assert.assertEquals("Invalid key: -1 used for: " + state.getClass().getName() + " when adding drawable: 0", e.getMessage()); } }
@Test public void test_AddKey() { State state = newState(); state.add(0, R.drawable.ui_ic_view_feedback_default); state.add(1, R.drawable.ui_ic_view_feedback_default); state.add(2, R.drawable.ui_ic_view_feedback_default); Assert.assertEquals(3, state.states.size()); }