### Question:
Toggled implements NotificationSignal { @Override public int value() { if (mFlag != Notification.DEFAULT_VIBRATE && mFlag != Notification.DEFAULT_SOUND && mFlag != Notification.DEFAULT_LIGHTS) { throw new IllegalArgumentException("Notification signal flag is not valid: " + mFlag); } return mEnable ? addFlag(mOriginal.value(), mFlag) : removeFlag(mOriginal.value(), mFlag); } Toggled(int flag, boolean enable, NotificationSignal original); @Override int value();  }### Answer:
@Test public void testValidFlags_dontThrowException() { new Toggled(Notification.DEFAULT_SOUND, true, new NoSignal()).value(); new Toggled(Notification.DEFAULT_VIBRATE, true, new NoSignal()).value(); new Toggled(Notification.DEFAULT_LIGHTS, true, new NoSignal()).value(); }
@Test(expected = IllegalArgumentException.class) public void testInValidFlag_throwsException() { new Toggled(15, true, new NoSignal()).value(); }
@Test public void testAddingFlag() { assertThat(new Toggled(Notification.DEFAULT_SOUND, true, new NoSignal()).value(), is(new NoSignal().value() | Notification.DEFAULT_SOUND)); assertThat(new Toggled(Notification.DEFAULT_SOUND, false, new NoSignal()).value(), is(new NoSignal().value())); }