From 7630ecbd84d8a33cb74da3b9b9e1e19e649a1126 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 8 Dec 2022 14:27:11 +0100 Subject: [PATCH] Improved test --- CHANGELOG.md | 2 ++ .../resourceregistry/queries/JsonQueryTest.java | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b72bbd..71f1a45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [v4.1.1-SNAPSHOT] - Fixed bug on JSONQuery for Facets which does not have any properties to match [#24237] +- Fixed bug on JSONQuery for IsRelatedTo relations indicating both source and target resources [#24264] - Fixed bug on returned boolean values as string [#24240] +- Enabled array properties [#24225] ## [v4.1.0] diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/queries/JsonQueryTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/queries/JsonQueryTest.java index 1499476..608fae3 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/queries/JsonQueryTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/queries/JsonQueryTest.java @@ -3,6 +3,7 @@ package org.gcube.informationsystem.resourceregistry.queries; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; +import java.io.FilenameFilter; import java.net.URL; import org.gcube.com.fasterxml.jackson.databind.JsonNode; @@ -34,8 +35,16 @@ public class JsonQueryTest extends ContextTest { File queriesDirectory = getQueriesDirectory(); - for(int i=1; i<7; i++) { - File jsonQueryFile = new File(queriesDirectory, "query" + i + ".json"); + FilenameFilter filenameFilter = new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.endsWith(".json"); + } + }; + + for(File jsonQueryFile : queriesDirectory.listFiles(filenameFilter)) { + logger.info("Going to read JSON query frtm file {}", jsonQueryFile.getAbsolutePath()); + ObjectMapper objectMapper = new ObjectMapper(); JsonNode jsonNode = objectMapper.readTree(jsonQueryFile); logger.info("Going to test the following JSON query {}", jsonNode.toString()); @@ -47,7 +56,7 @@ public class JsonQueryTest extends ContextTest { logger.info("Created Query from JSON: {}", createdStringBuffer.toString()); StringBuffer expectedStringBuffer = new StringBuffer(); - File expectedQueryFile = new File(queriesDirectory, "query" + i + ".query"); + File expectedQueryFile = new File(queriesDirectory, jsonQueryFile.getName().replace("json", "query")); try(BufferedReader br = new BufferedReader(new FileReader(expectedQueryFile))) { for(String line; (line = br.readLine()) != null; ) { expectedStringBuffer.append(line);