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

    // When
    license.reject();

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