Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 13 additions & 29 deletions exercises/practice/hamming/src/test/java/HammingTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertThrows;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import org.junit.Ignore;
import org.junit.Test;
Expand Down Expand Up @@ -38,49 +38,33 @@ public void testDistanceInLongDifferentStrands() {
@Ignore("Remove to run test")
@Test
public void testValidatesFirstStrandNotLonger() {
IllegalArgumentException expected =
assertThrows(
IllegalArgumentException.class,
() -> new Hamming("AATG", "AAA"));

assertThat(expected)
.hasMessage("leftStrand and rightStrand must be of equal length.");
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> new Hamming("AATG", "AAA"))
.withMessage("leftStrand and rightStrand must be of equal length.");
}

@Ignore("Remove to run test")
@Test
public void testValidatesSecondStrandNotLonger() {
IllegalArgumentException expected =
assertThrows(
IllegalArgumentException.class,
() -> new Hamming("ATA", "AGTG"));

assertThat(expected)
.hasMessage("leftStrand and rightStrand must be of equal length.");
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> new Hamming("ATA", "AGTG"))
.withMessage("leftStrand and rightStrand must be of equal length.");
}

@Ignore("Remove to run test")
@Test
public void testDisallowLeftEmptyStrand() {
IllegalArgumentException expected =
assertThrows(
IllegalArgumentException.class,
() -> new Hamming("", "G"));

assertThat(expected)
.hasMessage("left strand must not be empty.");
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> new Hamming("", "G"))
.withMessage("left strand must not be empty.");
}

@Ignore("Remove to run test")
@Test
public void testDisallowRightEmptyStrand() {
IllegalArgumentException expected =
assertThrows(
IllegalArgumentException.class,
() -> new Hamming("G", ""));

assertThat(expected)
.hasMessage("right strand must not be empty.");
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> new Hamming("G", ""))
.withMessage("right strand must not be empty.");
}

}