forked from D-Net/dnet-hadoop
using proper assertions
This commit is contained in:
parent
b762c28cb6
commit
71ef7d9e66
|
@ -6,6 +6,7 @@ import java.net.URISyntaxException;
|
|||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -42,6 +43,7 @@ public class GCatAPIClientTest {
|
|||
String objidentifier = "nstest::test";
|
||||
String json = IOUtils
|
||||
.toString(getClass().getResourceAsStream("/eu/dnetlib/dhp/oa/graph/dump/gcat/gcat_pub.json"));
|
||||
System.out.println("Creating item...");
|
||||
Assert.that(client.publish(json) == HttpStatus.SC_CREATED, "Item not created");
|
||||
System.out.println("item created, now listing...");
|
||||
Assert.that(client.list(0, 10).size() == 1, "List has more elements than expected");
|
||||
|
@ -56,28 +58,22 @@ public class GCatAPIClientTest {
|
|||
@Test
|
||||
public void testPurgeUnexisting() throws IOException, URISyntaxException {
|
||||
String id = "1234";
|
||||
Assert.that(!client.purge(id), "It should return false! The item does not exist");
|
||||
Assertions.assertFalse(client.purge(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPurgeAllEmptyCat() throws IOException, URISyntaxException {
|
||||
Assert
|
||||
.that(
|
||||
0 == client.purgeAll(),
|
||||
"Expected 0 elements in the catalogue...we dropped anything that was there...sorry");
|
||||
Assertions.assertEquals(0, client.purgeAll());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPublishAndPurgeAll() throws IOException, URISyntaxException {
|
||||
String json = IOUtils
|
||||
.toString(getClass().getResourceAsStream("/eu/dnetlib/dhp/oa/graph/dump/gcat/gcat_pub.json"));
|
||||
Assert.that(client.publish(json) == HttpStatus.SC_CREATED, "Item not created");
|
||||
Assertions.assertEquals(HttpStatus.SC_CREATED, client.publish(json));
|
||||
System.out.println("item created, now listing...");
|
||||
Assert.that(client.list(0, 10).size() == 1, "List has more elements than expected");
|
||||
Assertions.assertEquals(1, client.list(0, 10).size());
|
||||
// and then drop all
|
||||
Assert
|
||||
.that(
|
||||
1 == client.purgeAll(),
|
||||
"Expected 1 elements in the catalogue...we dropped anything that was there...sorry");
|
||||
Assertions.assertEquals(1, client.purgeAll());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue