|
15 | 15 | import org.assertj.db.common.AbstractTest; |
16 | 16 | import org.junit.Test; |
17 | 17 |
|
18 | | -import java.util.Arrays; |
19 | | - |
20 | | -import static org.assertj.core.api.Assertions.assertThat; |
21 | | -import static org.junit.Assert.fail; |
| 18 | +import static java.util.Collections.singletonList; |
| 19 | +import static org.assertj.core.api.Assertions.assertThatThrownBy; |
22 | 20 |
|
23 | 21 | /** |
24 | 22 | * Tests on the exceptions of Change |
25 | | - * |
| 23 | + * |
26 | 24 | * @author Régis Pouiller |
27 | | - * |
| 25 | + * |
28 | 26 | */ |
29 | 27 | public class Change_Exception_Test extends AbstractTest { |
30 | 28 |
|
31 | 29 | /** |
32 | 30 | * This method should fail because the data type must be not null. |
33 | 31 | */ |
34 | 32 | @Test |
35 | | - public void should_fail_because_datatype_must_be_not_null() { |
36 | | - try { |
37 | | - getChange(null, "name", ChangeType.CREATION, getRow(Arrays.asList(""), Arrays.asList(""), Arrays.asList(getValue( |
38 | | - null, null))), |
39 | | - getRow(Arrays.asList(""), Arrays.asList(""), Arrays.asList(getValue(null, null)))); |
40 | | - |
41 | | - fail("An exception must be raised"); |
42 | | - } catch (Exception exception) { |
43 | | - assertThat(exception.getCause().getLocalizedMessage()).isEqualTo("The type of the data must be not null"); |
44 | | - } |
| 33 | + public void should_fail_because_datatype_must_be_not_null() throws Exception { |
| 34 | + |
| 35 | + Row start = getRow(singletonList(""), singletonList(""), singletonList(getValue(null, null))); |
| 36 | + Row end = getRow(singletonList(""), singletonList(""), singletonList(getValue(null, null))); |
| 37 | + |
| 38 | + assertThatThrownBy(() -> getChange(null, "name", ChangeType.CREATION, start, end)) |
| 39 | + .isInstanceOf(Exception.class) |
| 40 | + .getCause() |
| 41 | + .hasMessage("The type of the data must be not null"); |
45 | 42 | } |
46 | 43 |
|
47 | 44 | /** |
48 | 45 | * This method should fail because the data name must be not null. |
49 | 46 | */ |
50 | 47 | @Test |
51 | | - public void should_fail_because_dataname_must_be_not_null() { |
52 | | - try { |
53 | | - getChange(DataType.TABLE, null, ChangeType.CREATION, getRow(Arrays.asList(""), Arrays.asList(""), Arrays.asList(getValue( |
54 | | - null, null))), |
55 | | - getRow(Arrays.asList(""), Arrays.asList(""), Arrays.asList(getValue(null, null)))); |
56 | | - |
57 | | - fail("An exception must be raised"); |
58 | | - } catch (Exception exception) { |
59 | | - assertThat(exception.getCause().getLocalizedMessage()).isEqualTo("The name of the data must be not null"); |
60 | | - } |
| 48 | + public void should_fail_because_dataname_must_be_not_null() throws Exception { |
| 49 | + |
| 50 | + Row start = getRow(singletonList(""), singletonList(""), singletonList(getValue(null, null))); |
| 51 | + Row end = getRow(singletonList(""), singletonList(""), singletonList(getValue(null, null))); |
| 52 | + |
| 53 | + assertThatThrownBy(() -> getChange(DataType.TABLE, null, ChangeType.CREATION, start, end)) |
| 54 | + .isInstanceOf(Exception.class) |
| 55 | + .getCause() |
| 56 | + .hasMessage("The name of the data must be not null"); |
61 | 57 | } |
62 | 58 | } |
0 commit comments