Esempio n. 1
0
  @Test(expectedExceptions = LicenseRejectedException.class)
  public void shouldThrowExceptionOnRejection() {
    // Given
    License license = new License("...", "...");

    // When
    license.reject();

    // Then this should never be reached
  }
Esempio n. 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;
    }
  }
Esempio n. 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());
  }