From 71ef7d9e66a45c28ed520c77e83f7645d1e28378 Mon Sep 17 00:00:00 2001 From: Alessia Bardi Date: Tue, 23 Jun 2020 11:30:41 +0200 Subject: [PATCH] using proper assertions --- .../dhp/oa/graph/gcat/GCatAPIClientTest.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/gcat/GCatAPIClientTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/gcat/GCatAPIClientTest.java index 966e604989..7b83db5601 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/gcat/GCatAPIClientTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/gcat/GCatAPIClientTest.java @@ -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()); } }