I have the following enum
public enum State {
UNCHECKED, SUBMITTED, VALIDATED, REJECTED, ENTITLED;
}
and in another class I have a method that receives a State as an argument, like this
public void validate (State state) throws InvalidStateException {
if (state != State.VALIDATED || state != State.REJECTED)
throw new InvalidStateException();
}
this method should throw the exception InvalidStateException only when the argument State isn't either State.VALIDATED or State.REJECTED but is in fact throwing it always. I just can't see where the mistake can be or how could I write the code in another way that would work.
I know that this isn't working because the following JUnit Test says the mentioned exception is being thrown and it shouldn't:
@Test
public void testValidate () throws InvalidStateException {
object.validate(State.VALIDATED);
}