Пример #1
0
  @Test(expectedExceptions = LicenseRejectedException.class)
  public void shouldThrowExceptionOnRejection() {
    // Given
    License license = new License("...", "...");

    // When
    license.reject();

    // Then this should never be reached
  }
Пример #2
0
  @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;
    }
  }
Пример #3
0
  @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());
  }