Skip to content

Commit

Permalink
Merge pull request #74 from EBISPOT/2.x-dev
Browse files Browse the repository at this point in the history
2.x dev
  • Loading branch information
jamesamcl authored May 14, 2021
2 parents b05f7df + da45f1b commit c0a87d0
Show file tree
Hide file tree
Showing 38 changed files with 447 additions and 351 deletions.
45 changes: 37 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<org.springframework.version>4.1.2.RELEASE</org.springframework.version>
<org.springframework.security.version>3.2.5.RELEASE</org.springframework.security.version>
<org.slf4j.version>1.7.5</org.slf4j.version>
<junit.jupiter.version>5.7.1</junit.jupiter.version>
<maven.surefire.version>3.0.0-M5</maven.surefire.version>
</properties>

<build>
Expand All @@ -23,8 +25,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -236,12 +238,14 @@
</dependency>

<!-- testing dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>junit</groupId>-->
<!-- <artifactId>junit</artifactId>-->
<!-- <version>4.10</version>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->



<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -396,6 +400,19 @@
<version>1.9.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -455,6 +472,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
Expand Down
6 changes: 6 additions & 0 deletions zooma-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

<properties>
<zooma.version>2.1.11-SNAPSHOT</zooma.version>
<junit.jupiter.version>5.7.1</junit.jupiter.version>
</properties>

<dependencies>
Expand All @@ -30,5 +31,10 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package uk.ac.ebi.fgpt.zooma.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;

/**
Expand All @@ -9,15 +12,19 @@
* @date 28/05/12
*/
public class CollectionUtils {
private static Logger logger = LoggerFactory.getLogger(CollectionUtils.class);

public static <C extends Collection> boolean compareCollectionContents(C c1, C c2) {
if (c1.size() != c2.size()) {
logger.trace("Size of c1=" + c1.size() + " does not match size of c2=" + c2.size());
return false;
}
else {
boolean allMatched = true;
// make sure c2 contains all elements in c1
for (Object o : c1) {
if (!c2.contains(o)) {
logger.trace(c2 + " does not contain o=" + o);
allMatched = false;
break;
}
Expand All @@ -26,6 +33,7 @@ public static <C extends Collection> boolean compareCollectionContents(C c1, C c
// and make sure c1 contains all elements in c2
for (Object o : c2) {
if (!c1.contains(o)) {
logger.trace(c1 + " does not contain o=" + o);
allMatched = false;
break;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package uk.ac.ebi.fgpt.zooma.util;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -12,8 +12,7 @@
import java.util.List;
import java.util.Set;

import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.*;

/**
* Javadocs go here!
Expand All @@ -22,6 +21,8 @@
* @date 18/02/13
*/
public class TestCollectionUtils {
private Logger logger = LoggerFactory.getLogger(getClass());

private Object item1;
private Object item2;

Expand All @@ -31,8 +32,9 @@ public class TestCollectionUtils {
private Object unequalItem1;
private Object unequalItem2;

@Before
@BeforeEach
public void setup() {
logger.trace("Initializing item1");
item1 = new Object() {
@Override public int hashCode() {
return 1;
Expand Down Expand Up @@ -77,7 +79,7 @@ public void setup() {
unequalItem2 = new Object();
}

@After
@AfterEach
public void teardown() {
item1 = null;
item2 = null;
Expand All @@ -90,52 +92,46 @@ public void teardown() {
@Test
public void testSame() {
Collection coll = Arrays.asList(item1, item2);
assertTrue("Comparing identical collections should be return true",
CollectionUtils.compareCollectionContents(coll, coll));
assertTrue(CollectionUtils.compareCollectionContents(coll, coll), "Comparing identical collections should be return true");
}

@Test
public void testAllEqual() {
Collection coll1 = Arrays.asList(item1, item2);
Collection coll2 = Arrays.asList(equalItem1, equalItem2);
assertTrue("Comparing equal collections should be return true",
CollectionUtils.compareCollectionContents(coll1, coll2));
assertTrue(CollectionUtils.compareCollectionContents(coll1, coll2), "Comparing equal collections should be return true");

Collection coll3 = Arrays.asList(item1, item2);
Collection coll4 = Arrays.asList(equalItem1, equalItem2);
assertTrue("Comparing equal but differently ordered collections should be return true",
CollectionUtils.compareCollectionContents(coll3, coll4));
Collection coll4 = Arrays.asList(equalItem2, equalItem1);
assertTrue(CollectionUtils.compareCollectionContents(coll3, coll4), "Comparing equal but differently ordered collections should be return true");

List<Object> coll5 = new ArrayList<>();
coll5.add(item1);
coll5.add(item2);
Set<Object> coll6 = new HashSet<>();
coll6.add(equalItem1);
coll6.add(equalItem2);
assertTrue("Comparing differently typed collections with same elements should be return true",
CollectionUtils.compareCollectionContents(coll5, coll6));
assertTrue(CollectionUtils.compareCollectionContents(coll5, coll6), "Comparing differently typed collections with same elements should be return true");
}

@Test
public void testNotAllEqual() {
Collection coll1 = Arrays.asList(item1, item2);
Collection coll2 = Arrays.asList(equalItem1, unequalItem2);
assertFalse("Comparing unequal collections should be return false",
CollectionUtils.compareCollectionContents(coll1, coll2));
assertFalse(CollectionUtils.compareCollectionContents(coll1, coll2), "Comparing unequal collections should be return false");
}

@Test
public void testAllDifferent() {
Collection coll1 = Arrays.asList(item1, item2);
Collection coll2 = Arrays.asList(unequalItem1, unequalItem2);
assertFalse("Comparing unequal collections should be return false",
CollectionUtils.compareCollectionContents(coll1, coll2));
assertFalse(CollectionUtils.compareCollectionContents(coll1, coll2), "Comparing unequal collections should be return false");
}

@Test
public void testEmpty() {
Collection coll1 = Collections.emptyList();
Collection coll2 = Collections.emptyList();
assertTrue("Empty collections should be equal", CollectionUtils.compareCollectionContents(coll1, coll2));
assertTrue(CollectionUtils.compareCollectionContents(coll1, coll2), "Empty collections should be equal");
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package uk.ac.ebi.fgpt.zooma.util;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import uk.ac.ebi.fgpt.zooma.datasource.OntologyDAO;

import java.net.URI;
import java.util.Collections;

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.fail;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand All @@ -35,7 +33,7 @@ public class TestLabelUtils {

private OntologyDAO ontologyDAO;

@Before
@BeforeEach
public void setup() {
testLabel1 = "label one";
testLabel2 = "label two";
Expand All @@ -55,7 +53,7 @@ public void setup() {
when(ontologyDAO.getSemanticTagSynonyms(entity1)).thenReturn(Collections.singleton(testSynonym));
}

@After
@AfterEach
public void teardown() {
ontologyDAO = null;
LabelUtils utils = new LabelUtils();
Expand Down
Loading

0 comments on commit c0a87d0

Please sign in to comment.