@Test(expectedExceptions = LicenseRejectedException.class) public void shouldThrowExceptionOnRejection() { // Given License license = new License("...", "..."); // When license.reject(); // Then this should never be reached }
@Test(expectedExceptions = LicenseRejectedException.class) public void shouldIncludeRejectedLicenseInException() throws Exception { // Given License license = new License("...", "..."); // When try { license.reject(); } catch (LicenseRejectedException ex) { // Then assertEquals(ex.getRejectedLicense(), license); throw ex; } }
@Test public void shouldRecordRejection() { // Given License license = new License("...", "..."); license.accept(); // When try { license.reject(); } catch (LicenseRejectedException ignored) { } // Then: last action should win assertFalse(license.isAccepted()); }