Skip to content
Permalink
Browse files

[#1212] introduce testng (#1215)

fixes #1212
  • Loading branch information...
Rascat authored and galpha committed Jun 12, 2019
1 parent a48fcbc commit 2cb03a3c8c9da2c79336962707cedb3b536d55e3
Showing with 506 additions and 1,021 deletions.
  1. +13 −0 gradoop-common/gradoop-common-testng.xml
  2. +15 −0 gradoop-common/pom.xml
  3. +3 −2 gradoop-common/src/main/java/org/gradoop/common/model/impl/properties/PropertyValue.java
  4. +43 −4 gradoop-common/src/test/java/org/gradoop/common/model/impl/id/GradoopIdTest.java
  5. +10 −8 gradoop-common/src/test/java/org/gradoop/common/model/impl/id/GradoopIdsTest.java
  6. +2 −3 gradoop-common/src/test/java/org/gradoop/common/model/impl/metadata/MetaDataTest.java
  7. +8 −6 gradoop-common/src/test/java/org/gradoop/common/model/impl/pojo/EdgeTest.java
  8. +5 −4 gradoop-common/src/test/java/org/gradoop/common/model/impl/pojo/ElementTest.java
  9. +4 −2 gradoop-common/src/test/java/org/gradoop/common/model/impl/pojo/GraphElementTest.java
  10. +8 −7 gradoop-common/src/test/java/org/gradoop/common/model/impl/pojo/GraphHeadTest.java
  11. +3 −3 gradoop-common/src/test/java/org/gradoop/common/model/impl/pojo/VertexTest.java
  12. +7 −6 gradoop-common/src/test/java/org/gradoop/common/model/impl/properties/PropertiesTest.java
  13. +9 −8 gradoop-common/src/test/java/org/gradoop/common/model/impl/properties/PropertyTest.java
  14. +9 −8 gradoop-common/src/test/java/org/gradoop/common/model/impl/properties/PropertyValueListTest.java
  15. +99 −891 gradoop-common/src/test/java/org/gradoop/common/model/impl/properties/PropertyValueTest.java
  16. +244 −0 gradoop-common/src/test/java/org/gradoop/common/model/impl/properties/PropertyValueTestProvider.java
  17. +10 −64 gradoop-common/src/test/java/org/gradoop/common/model/impl/properties/PropertyValueUtilsTest.java
  18. +4 −3 gradoop-common/src/test/java/org/gradoop/common/util/AsciiGraphLoaderTest.java
  19. +2 −2 gradoop-common/src/test/java/org/gradoop/common/util/NetworkHelperTest.java
  20. +8 −0 pom.xml
@@ -0,0 +1,13 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >

<suite name="Gradoop Common Suite" verbose="1" >
<test name="Gradoop Common Tests">
<packages>
<package name="org.gradoop.common.model.impl.properties"/>
<package name="org.gradoop.common.util"/>
<package name="org.gradoop.common.model.impl.pojo"/>
<package name="org.gradoop.common.model.impl.metadata"/>
<package name="org.gradoop.common.model.impl.id"/>
</packages>
</test>
</suite>
@@ -105,6 +105,15 @@
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>gradoop-common-testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>

@@ -158,6 +167,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
@@ -324,8 +324,9 @@ public boolean isNumber() {
if (strategy.is(value)) {
return (T) value;
}
throw new UnsupportedOperationException("Value '" + value + "' of type " +
value.getClass().getSimpleName() + ", cannot be accessed as " + clazz.getSimpleName());
String type = value == null ? "null" : value.getClass().getSimpleName();
throw new UnsupportedOperationException("Value '" + value + "' of type " + type +
", cannot be accessed as " + clazz.getSimpleName());
}

/**
@@ -15,13 +15,14 @@
*/
package org.gradoop.common.model.impl.id;

import org.junit.Test;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.nio.ByteBuffer;
import java.util.concurrent.ThreadLocalRandom;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
import static org.testng.Assert.assertNotEquals;
import static org.testng.AssertJUnit.*;

public class GradoopIdTest {

@@ -48,7 +49,7 @@ public void testCompareTo() {
GradoopId id1 = GradoopId.get();
GradoopId id2 = GradoopId.get();

assertThat(id1.compareTo(id1), is(0));
assertEquals(id1.compareTo(id1), 0);
assertTrue(id1.compareTo(id2) != 0);
}

@@ -122,4 +123,42 @@ public void testMin() {
assertTrue("Second ID is smaller then the minimum.", second.compareTo(min) >= 0);
assertTrue(first == min || second == min);
}

/**
* Test if {@link GradoopId#isValid(String)} returns false for invalid input strings
*
* @param input an invalid input string
*/
@Test(dataProvider = "invalid strings")
public void testIsValidWithInvalidInput(String input) {
assertFalse("Invalid input string was evaluated as valid: " + input,
GradoopId.isValid(input));
}

@DataProvider(name = "invalid strings")
private Object[][] invalidStringsDataProvider() {
return new Object[][] {
{"abc3451d98ebd3452fff32a"}, // too short
{"1234567891011121131415161"}, // too long
{"12345678910111211314151G"}}; // 'G' is not a valid char in a hex string
}

/**
* Test if {@link GradoopId#isValid(String)} returns true for valid input strings.
*
* @param input a valid input string
*/
@Test(dataProvider = "valid strings")
public void testIsValidWithValidInput(String input) {
assertTrue("Valid input string was evaluated as invalid: " + input,
GradoopId.isValid(input));
}

@DataProvider(name = "valid strings")
private Object[][] validStringDataProvider() {
return new Object[][] {
{"912345678910111213141516"},
{"1AB363914FD1325CC43790AB"},
{"bcdef12345678910bac76d4e"}};
}
}
@@ -20,7 +20,7 @@
import org.apache.flink.core.memory.DataInputViewStreamWrapper;
import org.apache.flink.core.memory.DataOutputView;
import org.apache.flink.core.memory.DataOutputViewStreamWrapper;
import org.junit.Test;
import org.testng.annotations.Test;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -29,7 +29,9 @@
import java.util.NoSuchElementException;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.testng.AssertJUnit.*;
import static org.testng.Assert.assertNotEquals;

public class GradoopIdsTest {

@@ -40,18 +42,18 @@ public void testAdd() {

GradoopIdSet ids = new GradoopIdSet();

assertThat(ids.size(), is(0));
assertEquals(0, ids.size());

ids.add(id1);
assertThat(ids.size(), is(1));
assertEquals(1, ids.size());
assertTrue(ids.contains(id1));
// must not change
ids.add(id1);
assertThat(ids.size(), is(1));
assertEquals(1, ids.size());
assertTrue(ids.contains(id1));
// must change
ids.add(id2);
assertThat(ids.size(), is(2));
assertEquals(2, ids.size());
assertTrue(ids.contains(id1));
assertTrue(ids.contains(id2));
}
@@ -219,7 +221,7 @@ public void testIterator() {
assertFalse(idsIterator.hasNext());
}

@Test(expected = NoSuchElementException.class)
@Test(expectedExceptions = NoSuchElementException.class)
public void testIteratorException() {
GradoopIdSet ids = new GradoopIdSet();

@@ -297,7 +299,7 @@ public void testEquals() {
assertEquals("hashCode succeeds for same ids but different sizes", aab.hashCode(), ab.hashCode());

GradoopIdSet empty = new GradoopIdSet();
assertTrue("equals failed for one empty list", !abc.equals(empty));
assertNotEquals(empty, abc, "equals failed for one empty list");
assertTrue("hashCode failed for one empty list", abc.hashCode() != empty.hashCode());

GradoopIdSet empty2 = new GradoopIdSet();
@@ -17,7 +17,7 @@

import org.gradoop.common.model.impl.id.GradoopId;
import org.gradoop.common.model.impl.properties.PropertyValue;
import org.junit.Test;
import org.testng.annotations.Test;
import org.mockito.internal.util.collections.Sets;

import java.math.BigDecimal;
@@ -32,8 +32,7 @@
import java.util.Map;
import java.util.Set;

import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.testng.AssertJUnit.*;

public class MetaDataTest {

@@ -21,10 +21,12 @@
import org.gradoop.common.model.impl.properties.Properties;
import org.gradoop.common.util.GradoopConstants;
import org.hamcrest.core.Is;
import org.junit.Test;
import org.testng.annotations.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;

public class EdgeTest {

@@ -82,28 +84,28 @@ public void createWithMissingLabelTest() {
assertThat(e.getLabel(), is(GradoopConstants.DEFAULT_EDGE_LABEL));
}

@Test(expected = NullPointerException.class)
@Test(expectedExceptions = NullPointerException.class)
public void createWithNullIDTest() {
GradoopId sourceId = GradoopId.get();
GradoopId targetId = GradoopId.get();
new EdgeFactory().initEdge(null, sourceId, targetId);
}

@Test(expected = NullPointerException.class)
@Test(expectedExceptions = NullPointerException.class)
public void createWithNullSourceIdTest() {
GradoopId edgeId = GradoopId.get();
GradoopId targetId = GradoopId.get();
new EdgeFactory().initEdge(edgeId, null, targetId);
}

@Test(expected = NullPointerException.class)
@Test(expectedExceptions = NullPointerException.class)
public void createWithNullTargetIdTest() {
GradoopId edgeId = GradoopId.get();
GradoopId sourceId = GradoopId.get();
new EdgeFactory().initEdge(edgeId, sourceId, null);
}

@Test(expected = NullPointerException.class)
@Test(expectedExceptions = NullPointerException.class)
public void createWithNullLabelTest() {
GradoopId edgeId = GradoopId.get();
GradoopId sourceId = GradoopId.get();
@@ -17,9 +17,10 @@

import org.gradoop.common.model.impl.id.GradoopId;
import org.gradoop.common.model.impl.properties.Properties;
import org.junit.Test;
import org.testng.annotations.Test;

import static org.gradoop.common.GradoopTestUtils.*;
import static org.junit.Assert.*;
import static org.testng.AssertJUnit.*;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.withSettings;
@@ -46,7 +47,7 @@ public void testSetProperty() {
assertEquals(elementMock.getProperties(), properties);
}

@Test(expected = NullPointerException.class)
@Test(expectedExceptions = NullPointerException.class)
public void testSetPropertyNull() {
Element elementMock = mock(Element.class, CALLS_REAL_METHODS);
elementMock.setProperty(null);
@@ -79,7 +80,7 @@ public void testRemovePropertyNoProperties() {
assertNull(elementMock.removeProperty(KEY_1));
}

@Test(expected = NullPointerException.class)
@Test(expectedExceptions = NullPointerException.class)
public void testGetPropertyValueNull() {
Properties properties = Properties.create();
properties.set(KEY_0, STRING_VAL_6);
@@ -18,11 +18,13 @@
import org.gradoop.common.model.impl.id.GradoopId;
import org.gradoop.common.model.impl.id.GradoopIdSet;
import org.gradoop.common.model.impl.properties.Properties;
import org.junit.Test;
import static org.junit.Assert.*;
import org.testng.annotations.Test;

import static org.mockito.Mockito.CALLS_REAL_METHODS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.withSettings;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;

public class GraphElementTest {

@@ -20,10 +20,12 @@
import org.gradoop.common.model.impl.properties.Properties;
import org.gradoop.common.util.GradoopConstants;
import org.hamcrest.core.Is;
import org.junit.Test;
import org.testng.annotations.Test;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.testng.AssertJUnit.*;
import static org.testng.Assert.assertNotEquals;

public class GraphHeadTest {
@Test
@@ -59,12 +61,12 @@ public void createWithMissingLabelTest() {
assertThat(g.getLabel(), is(GradoopConstants.DEFAULT_GRAPH_LABEL));
}

@Test(expected = NullPointerException.class)
@Test(expectedExceptions = NullPointerException.class)
public void createWithNullIDTest() {
new GraphHeadFactory().initGraphHead(null);
}

@Test(expected = NullPointerException.class)
@Test(expectedExceptions = NullPointerException.class)
public void createWithNullLabelTest() {
GradoopId graphID = GradoopId.get();
new GraphHeadFactory().initGraphHead(graphID, null);
@@ -81,7 +83,7 @@ public void equalsTest() {

assertEquals("Graph heads were not equal", graphHead1, graphHead1);
assertEquals("Graph heads were not equal", graphHead1, graphHead2);
assertNotEquals("Graph heads were equal", graphHead1, graphHead3);
assertNotEquals(graphHead1, graphHead3, "Graph heads were equal");
}

@Test
@@ -93,8 +95,7 @@ public void testHashCode() {
EPGMGraphHead graphHead2 = new GraphHeadFactory().initGraphHead(graphID1);
EPGMGraphHead graphHead3 = new GraphHeadFactory().initGraphHead(graphID2);

assertTrue("Graph heads have different hash",
graphHead1.hashCode() == graphHead2.hashCode());
assertEquals("Graph heads have different hash", graphHead2.hashCode(), graphHead1.hashCode());
assertFalse("Graph heads have same hash",
graphHead1.hashCode() == graphHead3.hashCode());
}
@@ -21,7 +21,7 @@
import org.gradoop.common.model.impl.properties.Properties;
import org.gradoop.common.util.GradoopConstants;
import org.hamcrest.core.Is;
import org.junit.Test;
import org.testng.annotations.Test;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
@@ -72,12 +72,12 @@ public void createWithMissingLabelTest() {
assertThat(v.getLabel(), is(GradoopConstants.DEFAULT_VERTEX_LABEL));
}

@Test(expected = NullPointerException.class)
@Test(expectedExceptions = NullPointerException.class)
public void createWithNullIDTest() {
new VertexFactory().initVertex(null);
}

@Test(expected = NullPointerException.class)
@Test(expectedExceptions = NullPointerException.class)
public void createWithNullLabelTest() {
GradoopId vertexID = GradoopId.get();
new VertexFactory().initVertex(vertexID, null);

0 comments on commit 2cb03a3

Please sign in to comment.
You can’t perform that action at this time.