Skip to content

Commit

Permalink
Get rid of JUnit rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
khmarbaise committed Apr 30, 2019
1 parent 86c8081 commit c4f5953
Showing 1 changed file with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@

package com.offbytwo.jenkins.helper;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import com.offbytwo.jenkins.helper.Range;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;

/**
* <ul>
Expand All @@ -23,7 +20,7 @@
* The same as {0,N}.</li>
* <li>{N}: Just retrieve the N-th element. The same as {N,N+1}.</li>
* </ul>
*
*
* @author Karl Heinz Marbaise
*/
public class RangeTest {
Expand Down Expand Up @@ -56,27 +53,24 @@ public void onlyGiven() {
assertThat(r.getRangeString()).isEqualTo(getEscaped("3,4"));
}

@Rule
public ExpectedException exception = ExpectedException.none();

@Test
public void toIsGivenLargerThanFromShouldResultInIllegalArgumentException() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("to must be greater than from");
Range.build().from(5).to(1);
assertThatIllegalArgumentException()
.isThrownBy(() -> Range.build().from(5).to(1))
.withMessage("to must be greater than from");
}

@Test
public void fromGivenNegativeValueShouldResultInIllegalArgumentException() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("from value must be greater or equal null.");
Range.build().from(-1);
assertThatIllegalArgumentException()
.isThrownBy(() -> Range.build().from(-1))
.withMessage("from value must be greater or equal null.");
}

@Test
public void fromGivenPositiveToNegativeValueShouldResultInIllegalArgumentException() {
exception.expect(IllegalArgumentException.class);
exception.expectMessage("to must be greater or equal null.");
Range.build().from(5).to(-1);
assertThatIllegalArgumentException()
.isThrownBy(() -> Range.build().from(5).to(-1))
.withMessage("to must be greater or equal null.");
}
}

0 comments on commit c4f5953

Please sign in to comment.