public void testSetPhoneStateInexistentPhone() { // Arrange PhoneAndStateDto dto = new PhoneAndStateDto(NUMBER_INEXISTENT, STATE_SILENCE); SetPhoneStateService service = new SetPhoneStateService(dto); // Act try { service.execute(); fail("Phone does not exist therefore state should not be changed. Should throw an exception"); } catch (PhoneException e) { } catch (AnacomException e) { } }
public void testSetPhoneStateBUSY() { // Arrange PhoneAndStateDto dto = new PhoneAndStateDto(NUMBER, STATE_BUSY); SetPhoneStateService service = new SetPhoneStateService(dto); // Act try { service.execute(); } catch (PhoneException e) { fail("State did not change. Should be changed without throwing an exception."); } catch (AnacomException e) { fail("State did not change. Should be changed without throwing an exception."); } // Assert assertEquals( "The phone state should be " + STATE_BUSY.name() + ".", STATE_BUSY, getPhoneState(NUMBER)); }