Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,13 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
# Including "ubuntu2204" in the version is a temporary fix to the direct download URL while we transition
# between 4 and 6
mongodb-version: [4.0.18, ubuntu2204-6.0.6]
java-version: [1.8]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Setup Java JDK
uses: actions/[email protected]
# The Java version to make available on the path. Takes a whole or semver Java version, or 1.x syntax (e.g. 1.8 => Java 8.x). Early access versions can be specified in the form of e.g. 14-ea, 14.0.0-ea, or 14.0.0-ea.28
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java-version }}
- name: Install and Start MongoDB
run: |
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-${{ matrix.mongodb-version }}.tgz
tar xfz mongodb-linux-x86_64-${{ matrix.mongodb-version }}.tgz
export PATH=`pwd`/mongodb-linux-x86_64-${{ matrix.mongodb-version }}/bin:$PATH
mkdir -p data/db
mongod --dbpath=data/db &
mongod --version
java-version: '21'
distribution: 'temurin'
- name: Run Maven tests
run: mvn test
9 changes: 7 additions & 2 deletions accession-commons-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>

<build>
Expand All @@ -29,8 +33,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>21</source>
<target>21</target>
<release>21</release>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.bind.DatatypeConverter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HexFormat;
import java.util.function.Function;

/**
Expand All @@ -38,7 +38,7 @@ public String apply(String summary) {
}

private static String generateSha1FromBytes(byte[] nameBytes) {
return DatatypeConverter.printHexBinary(toSHA1(nameBytes));
return HexFormat.of().withUpperCase().formatHex(toSHA1(nameBytes));
}

private static byte[] toSHA1(byte[] bytes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
import uk.ac.ebi.ampt2d.commons.accession.rest.dto.ErrorMessage;
import uk.ac.ebi.ampt2d.commons.accession.rest.validation.CollectionValidator;

import javax.servlet.http.HttpServletRequest;
import javax.validation.ValidationException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.ValidationException;
import java.net.URI;
import java.util.stream.Collectors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import uk.ac.ebi.ampt2d.commons.accession.rest.dto.AccessionVersionsResponseDTO;
import uk.ac.ebi.ampt2d.commons.accession.rest.dto.GetOrCreateAccessionResponseDTO;

import javax.validation.Valid;
import jakarta.validation.Valid;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import org.springframework.validation.Validator;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

import javax.validation.ConstraintViolation;
import javax.validation.ValidationException;
import jakarta.validation.ConstraintViolation;
import jakarta.validation.ValidationException;
import java.util.Collection;
import java.util.Set;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
*/
package uk.ac.ebi.ampt2d.commons.accession.core.exceptions;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import uk.ac.ebi.ampt2d.commons.accession.core.models.AccessionWrapper;

import java.util.Arrays;
import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class MissingUnsavedAccessionsExceptionTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package uk.ac.ebi.ampt2d.commons.accession.generators;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import uk.ac.ebi.ampt2d.commons.accession.core.models.AccessionWrapper;
import uk.ac.ebi.ampt2d.commons.accession.core.models.SaveResponse;
import uk.ac.ebi.ampt2d.commons.accession.hashing.SHA1HashingFunction;
Expand All @@ -30,7 +30,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class SingleAccessionGeneratorTest {
private static String APPLICATION_INSTANCE_ID = "TEST_APPPLICATION_INSTANCE_ID";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
*/
package uk.ac.ebi.ampt2d.commons.accession.hashing;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.function.Function;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

public class SHA1HashingFunctionTest {

@Test
Expand All @@ -32,8 +34,8 @@ public void testGenerateAccession() {
String object1Accession = hashingFunction.apply(object1);
String object2Accession = hashingFunction.apply(object2);
String object3Accession = hashingFunction.apply(object2);
Assert.assertNotEquals(object1Accession, object2Accession);
Assert.assertEquals(object2Accession, object3Accession);
Assert.assertEquals(40, object1Accession.length());
assertNotEquals(object1Accession, object2Accession);
assertEquals(object2Accession, object3Accession);
assertEquals(40, object1Accession.length());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
*/
package uk.ac.ebi.ampt2d.commons.accession.utils;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import uk.ac.ebi.ampt2d.commons.accession.utils.exceptions.ExponentialBackOffMaxRetriesRuntimeException;

import java.util.function.Supplier;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class ExponentialBackOffTest {

Expand All @@ -44,31 +45,39 @@ public String get() {
}
}

@Test(expected = ExponentialBackOffMaxRetriesRuntimeException.class)
@Test
public void testRunnableDefaultTotalAttempts() {
ExtendedRunnable runnable = new ExtendedRunnable();
ExponentialBackOff.execute((Runnable) runnable);
assertThrows(ExponentialBackOffMaxRetriesRuntimeException.class, () -> {
ExponentialBackOff.execute((Runnable) runnable);
});
assertEquals(ExponentialBackOff.DEFAULT_TOTAL_ATTEMPTS, runnable.numRun);
}

@Test(expected = ExponentialBackOffMaxRetriesRuntimeException.class)
@Test
public void testFunctionDefaultTotalAttempts() {
ExtendedRunnable runnable = new ExtendedRunnable();
ExponentialBackOff.execute((Supplier) runnable);
assertThrows(ExponentialBackOffMaxRetriesRuntimeException.class, () -> {
ExponentialBackOff.execute((Supplier) runnable);
});
assertEquals(ExponentialBackOff.DEFAULT_TOTAL_ATTEMPTS, runnable.numRun);
}

@Test(expected = ExponentialBackOffMaxRetriesRuntimeException.class)
@Test
public void testRunnableTotalAttempts() {
ExtendedRunnable runnable = new ExtendedRunnable();
ExponentialBackOff.execute((Runnable) runnable, 3, 1000);
assertThrows(ExponentialBackOffMaxRetriesRuntimeException.class, () -> {
ExponentialBackOff.execute((Runnable) runnable, 3, 1000);
});
assertEquals(3, runnable.numRun);
}

@Test(expected = ExponentialBackOffMaxRetriesRuntimeException.class)
@Test
public void testFunctionTotalAttempts() {
ExtendedRunnable runnable = new ExtendedRunnable();
ExponentialBackOff.execute((Supplier) runnable, 3, 1000);
assertThrows(ExponentialBackOffMaxRetriesRuntimeException.class, () -> {
ExponentialBackOff.execute((Supplier) runnable, 3, 1000);
});
assertEquals(3, runnable.numRun);
}

Expand Down
23 changes: 15 additions & 8 deletions accession-commons-jpa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,26 @@
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java8</artifactId>
<version>2.4.0</version>
<artifactId>cucumber-java</artifactId>
<version>7.18.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>2.4.0</version>
<artifactId>cucumber-spring</artifactId>
<version>7.18.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>2.4.0</version>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>7.18.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Expand All @@ -62,8 +68,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>21</source>
<target>21</target>
<release>21</release>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import uk.ac.ebi.ampt2d.commons.accession.persistence.models.IAccessionedObject;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import uk.ac.ebi.ampt2d.commons.accession.persistence.models.IAccessionedObject;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import jakarta.persistence.Column;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import uk.ac.ebi.ampt2d.commons.accession.core.models.EventType;

import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import java.time.LocalDateTime;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import uk.ac.ebi.ampt2d.commons.accession.persistence.repositories.IAccessionedObjectCustomRepository;
import uk.ac.ebi.ampt2d.commons.accession.persistence.jpa.entities.AccessionedEntity;

import javax.persistence.EntityManager;
import jakarta.persistence.EntityManager;
import java.io.Serializable;
import java.util.List;
import java.util.Stack;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package uk.ac.ebi.ampt2d.commons.accession.persistence.jpa.service;

import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import uk.ac.ebi.ampt2d.commons.accession.core.models.EventType;
import uk.ac.ebi.ampt2d.commons.accession.core.models.IEvent;
import uk.ac.ebi.ampt2d.commons.accession.persistence.jpa.entities.InactiveAccessionEntity;
Expand Down Expand Up @@ -102,7 +101,7 @@ public List<IEvent<MODEL, ACCESSION>> getEvents(ACCESSION accession) {

@Override
public List<? extends IEvent<MODEL, ACCESSION>> getAllEventsInvolvedIn(ACCESSION accession) {
throw new NotImplementedException();
throw new UnsupportedOperationException("Not implemented");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
*/
package uk.ac.ebi.ampt2d.commons.accession;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
import org.junit.platform.suite.api.ConfigurationParameter;
import org.junit.platform.suite.api.IncludeEngines;
import org.junit.platform.suite.api.SelectClasspathResource;
import org.junit.platform.suite.api.Suite;

@RunWith(Cucumber.class)
@CucumberOptions(
features = {
"src/test/resources/features/accession.feature",
"src/test/resources/features/modification.feature",
"src/test/resources/features/merge.feature",
"src/test/resources/features/retrieval.feature"},
plugin = {
"pretty",
"html:target/cucumber"},
tags = {"not @ignore"})
import static io.cucumber.junit.platform.engine.Constants.FILTER_TAGS_PROPERTY_NAME;
import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME;
import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME;

@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("features")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "uk.ac.ebi.ampt2d.commons.accession")
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty, html:target/cucumber-reports.html")
@ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "not @ignore")
public class AccessioningAcceptanceTests {

}
Loading