StateListColourDrawableBuilder { public StateListColourDrawableBuilder addStateColour(int[] states, int colour) { for(int state: states) { if(!ResourceUtils.isValidState(state)) { throw new IllegalArgumentException("Invalid state passed to StateListColourDrawableBuilder: " + state); } } stateColoursList.add(new StateColour(states, colour)); return this; } StateListColourDrawableBuilder(int defaultColour); StateListColourDrawableBuilder addStateColour(int[] states, int colour); Drawable getDrawable();  }
@Test public void adding_invalid_state_should_fail() { try { StateListColourDrawableBuilder builder = new StateListColourDrawableBuilder(Color.BLACK); builder.addStateColour(new int[]{1}, Color.RED); fail("Adding invalid state should fail in StateListColourDrawableBuilder"); } catch (IllegalArgumentException e) {} }