forked from dtinit/data-transfer-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ItemImportResultTest.java
46 lines (38 loc) · 1.25 KB
/
ItemImportResultTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package org.datatransferproject.spi.transfer.idempotentexecutor;
import static org.datatransferproject.spi.transfer.idempotentexecutor.ItemImportResult.Status.SUCCESS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
public class ItemImportResultTest {
@Test
public void testNullBytesIsOk() {
ItemImportResult<String> result = ItemImportResult.success("blabla", null);
assertEquals(SUCCESS, result.getStatus());
assertFalse(result.hasBytes());
}
@Test
public void testNullBytesThrowOnGet() {
Assertions.assertThrows(IllegalStateException.class, () -> {
ItemImportResult.success("blabla", null).getBytes();
});
}
@Test
public void testSuccessWithNoData() {
Assertions.assertThrows(NullPointerException.class, () -> {
ItemImportResult.success(null, 0L);
});
}
@Test
public void testFailWithIncorrectBytes() {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
ItemImportResult.success("blabla", -1L);
});
}
@Test
public void testErrorWithNoException() {
Assertions.assertThrows(NullPointerException.class, () -> {
ItemImportResult.error(null, 10L);
});
}
}