Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feat/MET-5806_supp…
Browse files Browse the repository at this point in the history
…ort_embeddable_resources_profile

# Conflicts:
#	metis-media-service/src/main/java/eu/europeana/metis/mediaprocessing/RdfDeserializerImpl.java
#	metis-media-service/src/main/java/eu/europeana/metis/mediaprocessing/extraction/AudioVideoProcessor.java
  • Loading branch information
stzanakis committed Aug 15, 2024
2 parents 2f3cabc + 6457c23 commit 5dc7ace
Show file tree
Hide file tree
Showing 142 changed files with 2,585 additions and 1,564 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: push
jobs:

ci:
uses: europeana/metis-actions/.github/workflows/ci.yml@jdk21
uses: europeana/metis-actions/.github/workflows/ci.yml@main
with:
sonar_organization: europeana
sonar_project_key: europeana_metis-framework
Expand All @@ -14,14 +14,14 @@ jobs:

deploy-artifacts:
needs: ci
uses: europeana/metis-actions/.github/workflows/deploy-artifacts.yml@jdk21
uses: europeana/metis-actions/.github/workflows/deploy-artifacts.yml@main
secrets:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

docker-build_metis-authentication:
needs: ci
uses: europeana/metis-actions/.github/workflows/docker-build-push.yml@jdk21
uses: europeana/metis-actions/.github/workflows/docker-build-push.yml@main
with:
docker-organization: europeana
docker-image-name: metis-authentication
Expand All @@ -31,7 +31,7 @@ jobs:
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
docker-build_metis-core:
needs: ci
uses: europeana/metis-actions/.github/workflows/docker-build-push.yml@jdk21
uses: europeana/metis-actions/.github/workflows/docker-build-push.yml@main
with:
docker-organization: europeana
docker-image-name: metis-core
Expand All @@ -41,7 +41,7 @@ jobs:
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
docker-build_metis-dereference:
needs: ci
uses: europeana/metis-actions/.github/workflows/docker-build-push.yml@jdk21
uses: europeana/metis-actions/.github/workflows/docker-build-push.yml@main
with:
docker-organization: europeana
docker-image-name: metis-dereference
Expand All @@ -51,7 +51,7 @@ jobs:
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
docker-build_metis-repository:
needs: ci
uses: europeana/metis-actions/.github/workflows/docker-build-push.yml@jdk21
uses: europeana/metis-actions/.github/workflows/docker-build-push.yml@main
with:
docker-organization: europeana
docker-image-name: metis-repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:

jobs:
ci-release:
uses: europeana/metis-actions/.github/workflows/release.yml@jdk21
uses: europeana/metis-actions/.github/workflows/release.yml@main
with:
release-version: ${{ github.event.inputs.release-version }}
commit-hash-branch: ${{ github.event.inputs.commit-hash-branch }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

/**
* The Role of an account.
*
* @author Simon Tzanakis ([email protected])
* @since 2017-10-31
*/
public enum AccountRole {
METIS_ADMIN, EUROPEANA_DATA_OFFICER, PROVIDER_VIEWER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
/**
* The Metis user containing all parameters.
* <p>This class is used as a JPA class to the postgresql database</p>
*
* @author Simon Tzanakis ([email protected])
* @since 2017-10-27
*/
@Entity
@Table(name = "metis_users")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public static <T, R> List<R> getListOfAggregationRetryable(Aggregation<T> aggreg
* @param <T> the type of class that the {@link Query} represents
* @return the morphia cursor
*/
@SuppressWarnings("resource")
private static <T> BiFunction<Query<T>, FindOptions, MorphiaCursor<T>> getMorphiaCursorFromQuery() {
return (querySupplied, findOptionsSupplied) -> Optional.ofNullable(findOptionsSupplied)
.map(querySupplied::iterator).orElseGet(querySupplied::iterator);
Expand All @@ -114,7 +113,6 @@ private static <T> BiFunction<Query<T>, FindOptions, MorphiaCursor<T>> getMorphi
* @param <R> the type of class that the result of the {@link Aggregation} represents
* @return the morphia cursor
*/
@SuppressWarnings("resource")
private static <T, R> BiFunction<Aggregation<T>, AggregationOptions, MorphiaCursor<R>> getMorphiaCursorFromAggregation(
Class<R> resultObjectClass) {
return (aggregationSupplied, aggregationOptionsSupplied) -> Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.mongodb.MongoClientSettings;
import com.mongodb.ReadPreference;
Expand All @@ -24,7 +24,7 @@
*/
class MongoClientProviderTest {

private final static String DATABASE_NAME = "dbTest";
private static final String DATABASE_NAME = "dbTest";

private static EmbeddedLocalhostMongo embeddedLocalhostMongo;

Expand All @@ -39,7 +39,7 @@ static void tearDown() {
embeddedLocalhostMongo.stop();
}

private static MongoProperties getMongoProperties() {
private static MongoProperties<IllegalArgumentException> getMongoProperties() {
final String mongoHost = embeddedLocalhostMongo.getMongoHost();
final int mongoPort = embeddedLocalhostMongo.getMongoPort();
final MongoProperties<IllegalArgumentException> mongoProperties = new MongoProperties<>(
Expand Down Expand Up @@ -79,7 +79,7 @@ void createAsSupplier() {

final Supplier<MongoClient> mongoClientSupplier = MongoClientProvider.createAsSupplier(String.format("mongodb://%s:%s", mongoHost, mongoPort));

assertTrue(mongoClientSupplier.get() instanceof MongoClient);
assertInstanceOf(MongoClient.class, mongoClientSupplier.get());
}

@Test
Expand All @@ -95,7 +95,7 @@ void createMongoClient() {
final MongoClient mongoClient = new MongoClientProvider<IllegalArgumentException>(getMongoProperties()).createMongoClient();

assertNotNull(mongoClient);
assertTrue(mongoClient instanceof MongoClient);
assertInstanceOf(MongoClient.class, mongoClient);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ void addMongoHost() throws Exception {
}

private static void assertMongoPropertiesOnlyWithAuthentication(MongoProperties mongoProperties) throws Exception {
assertEquals("localhost:8521", mongoProperties.getMongoHosts().get(0).toString());
assertEquals("localhost:8521", mongoProperties.getMongoHosts().getFirst().toString());
assertNotNull(mongoProperties.getMongoCredentials());
assertEquals("authenticationdb", mongoProperties.getMongoCredentials().getSource());
assertEquals("userName", mongoProperties.getMongoCredentials().getUserName());
assertEquals("password", new String(mongoProperties.getMongoCredentials().getPassword()));
}

private static void assertMongoPropertiesWithoutAuthentication(MongoProperties mongoProperties) throws Exception {
assertEquals("localhost:8521", mongoProperties.getMongoHosts().get(0).toString());
assertEquals("localhost:8521", mongoProperties.getMongoHosts().getFirst().toString());
assertNull(mongoProperties.getMongoCredentials());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
*/
class RecordDaoTest {

private final static String DATABASE_NAME = "dbTest";
private static final String DATABASE_NAME = "dbTest";

private static RecordDao recordDao;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import dev.morphia.Datastore;
import eu.europeana.metis.mongo.dao.RecordRedirectDao;
import eu.europeana.metis.mongo.embedded.EmbeddedLocalhostMongo;
import eu.europeana.metis.mongo.model.RecordRedirect;
import java.time.Instant;
Expand All @@ -26,7 +25,7 @@
*/
class RecordRedirectDaoTest {

private final static String DATABASE_NAME = "dbTest";
private static final String DATABASE_NAME = "dbTest";

private static RecordRedirectDao recordRedirectDao;

Expand Down Expand Up @@ -91,7 +90,7 @@ void getRecordRedirectsByNewId() {
List<RecordRedirect> recordRedirectList = recordRedirectDao.getRecordRedirectsByNewId("61eec080f582833f364dad08");

assertEquals(1, recordRedirectList.size());
assertEquals(recordRedirect.getNewId(), recordRedirectList.get(0).getNewId());
assertEquals(recordRedirect.getNewId(), recordRedirectList.getFirst().getNewId());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@
import dev.morphia.query.Query;
import eu.europeana.metis.mongo.embedded.EmbeddedLocalhostMongo;
import eu.europeana.metis.mongo.model.HasMongoObjectId;
import eu.europeana.metis.mongo.utils.MorphiaUtils;
import eu.europeana.metis.mongo.utils.ObjectIdSerializer;
import java.util.List;
import java.util.Objects;
import org.bson.types.ObjectId;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
Expand All @@ -37,7 +33,7 @@
*/
class MorphiaUtilsTest {

private final static String DATABASE_NAME = "dbTest";
private static final String DATABASE_NAME = "dbTest";

private static Datastore datastore;

Expand Down Expand Up @@ -92,7 +88,7 @@ void getListOfAggregationRetryable() {
final List<DummyEntity> dummyEntityList = MorphiaUtils.getListOfAggregationRetryable(aggregation, DummyEntity.class);

assertEquals(1, dummyEntityList.size());
assertEquals(5, Integer.valueOf(dummyEntityList.get(0).name));
assertEquals(5, Integer.valueOf(dummyEntityList.getFirst().name));
}

@Test
Expand All @@ -107,7 +103,7 @@ void testGetListOfAggregationRetryable() {
aggregationOptions);

assertEquals(1, dummyEntityList.size());
assertEquals(5, Integer.valueOf(dummyEntityList.get(0).name));
assertEquals(5, Integer.valueOf(dummyEntityList.getFirst().name));
}

private static void addEntitiesToDatastore() {
Expand Down Expand Up @@ -180,12 +176,10 @@ public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof DummyEntity)) {
if (!(o instanceof DummyEntity that)) {
return false;
}

final DummyEntity that = (DummyEntity) o;

if (!Objects.equals(id, that.id)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
import eu.europeana.metis.mongo.utils.ObjectIdSerializer;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
Expand Down Expand Up @@ -55,8 +54,7 @@ void serializeNull_expectSuccess() throws IOException {
}

private static JsonGenerator getJsonGenerator(Writer writer) throws IOException {
final JsonGenerator jsonGenerator = JsonFactory.builder().build().createGenerator(writer);
return jsonGenerator;
return JsonFactory.builder().build().createGenerator(writer);
}

private static SerializerProvider getSerializerProvider() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* A utilities class used to encapsulate methods that throw exceptions {@link RuntimeException} or
* {@link Exception} and should follow retries logic based on specific caused exceptions.
*
* @author Simon Tzanakis ([email protected])
* @since 2018-07-24
*/
public final class ExternalRequestUtil {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import java.io.IOException;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.LBHttpSolrClient;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

/**
* Unit test for {@link CompoundSolrClient}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void addSolrHost() throws Exception {
List<URI> actualSolrHosts = solrProperties.getSolrHosts();

assertEquals(1, actualSolrHosts.size());
assertEquals(new URI("http://localhost:8983/solr"), actualSolrHosts.get(0));
assertEquals(new URI("http://localhost:8983/solr"), actualSolrHosts.getFirst());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package eu.europeana.metis.core.common;
package eu.europeana.metis.utils;

import java.util.Arrays;
import java.util.Comparator;
Expand Down Expand Up @@ -120,6 +120,28 @@ public static Country getCountryFromIsoCode(String isoCode) {
return null;
}

/**
* Method that returns the enum with the corresponding given string value
* @param countryName The string value to match the enum values with
* @return The enum country values that matches the given string value
*/
public static Country fromCountryNameToIsoCode(String countryName){
Country result = null;
for(Country country : values()){
if(country.getName().equals(countryName)){
result = country;
break;
}
}

if(result == null){
throw new IllegalArgumentException("Country name "+countryName+" not found");
}

return result;

}

/**
* Provides the countries sorted by the {@link #getName()} field
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public final class RestEndpoints {
// DEPUBLISHED RECORDS
public static final String DEPUBLISH_RECORDIDS_DATASETID = "/depublish/record_ids/{datasetId}";
public static final String DEPUBLISH_EXECUTE_DATASETID = "/depublish/execute/{datasetId}";
public static final String DEPUBLISH_REASONS = "/depublish/reasons";

//AUTHENTICATION
public static final String AUTHENTICATION_REGISTER = "/authentication/register";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
public class CompressedFileHandlerGzTest {

public static final String FILE_EXTENSION = ".tar.gz";
private final static String DESTINATION_DIR = String.format("src%1$stest%1$sresources%1$s__files%1$s", File.separator);
private final static int XML_FILES_COUNT = 13;
private final static String FILE_NAME = "gzFile";
private final static String FILE_NAME2 = "gzFileWithCompressedGZFiles";
private final static String FILE_NAME3 = "gzFilesWithMixedCompressedFiles";
private final static String FILE_NAME4 = "gzFileWithSubdirContainingSpaceInName";
private final static String XML_TYPE = "xml";
private final static String DESTINATION_NAME_FOR_ZIP_WITH_SPACES = "zip_file";
private static final String DESTINATION_DIR = String.format("src%1$stest%1$sresources%1$s__files%1$s", File.separator);
private static final int XML_FILES_COUNT = 13;
private static final String FILE_NAME = "gzFile";
private static final String FILE_NAME2 = "gzFileWithCompressedGZFiles";
private static final String FILE_NAME3 = "gzFilesWithMixedCompressedFiles";
private static final String FILE_NAME4 = "gzFileWithSubdirContainingSpaceInName";
private static final String XML_TYPE = "xml";
private static final String DESTINATION_NAME_FOR_ZIP_WITH_SPACES = "zip_file";

@AfterAll
public static void cleanUp() throws IOException {
Expand Down Expand Up @@ -56,14 +56,6 @@ void shouldUnpackTheTarGzFilesRecursivelyWithCompressedXMLFiles() throws IOExcep
assertEquals(XML_FILES_COUNT, files.size());
}

@Test
void shouldUnpackTheTGZFilesRecursivelyWithCompressedXMLFiles() throws IOException {
CompressedFileHandler.extractFile(Path.of(DESTINATION_DIR + FILE_NAME2 + FILE_EXTENSION), Path.of(DESTINATION_DIR));
Collection<File> files = getXMLFiles(DESTINATION_DIR + FILE_NAME2);
assertNotNull(files);
assertEquals(XML_FILES_COUNT, files.size());
}

@Test
void shouldUnpackTheTarGzFilesRecursivelyWithMixedNestedCompressedFiles() throws IOException {
CompressedFileHandler.extractFile(Path.of(DESTINATION_DIR + FILE_NAME3 + FILE_EXTENSION), Path.of(DESTINATION_DIR));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void testPerformThrowingFunctionReturn() {

Integer actualValue = performThrowingFunction(number, x -> {
integerList.add(x * 2);
return integerList.get(0);
return integerList.getFirst();
}
);
assertEquals(24, actualValue);
Expand Down
Loading

0 comments on commit 5dc7ace

Please sign in to comment.