-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: migrate query to Freemarker (#831)
- Loading branch information
1 parent
053a023
commit d04513a
Showing
3 changed files
with
69 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/main/resources/request/operations/famOpeSer/getSeries.ftlh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
SELECT ?id ?labelLg1 ?labelLg2 | ||
FROM <${OPERATIONS_GRAPH}> | ||
WHERE { | ||
?family dcterms:hasPart ?uri . | ||
?uri skos:prefLabel ?labelLg1 . | ||
FILTER (lang(?labelLg1) = '${LG1}') . | ||
?uri skos:prefLabel ?labelLg2 . | ||
FILTER (lang(?labelLg2) = '${LG2}') . | ||
BIND(STRAFTER(STR(?uri),'/operations/serie/') AS ?id) . | ||
FILTER(STRENDS(STR(?family),'/operations/famille/${ID}')) . | ||
} | ||
ORDER BY ?id |
50 changes: 50 additions & 0 deletions
50
...rmes/testcontainers/queries/sparql_queries/operations/families/OpFamiliesQueriesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package fr.insee.rmes.testcontainers.queries.sparql_queries.operations.families; | ||
|
||
import fr.insee.rmes.bauhaus_services.rdf_utils.RepositoryGestion; | ||
import fr.insee.rmes.bauhaus_services.rdf_utils.RepositoryInitiator; | ||
import fr.insee.rmes.bauhaus_services.rdf_utils.RepositoryUtils; | ||
import fr.insee.rmes.config.ConfigStub; | ||
import fr.insee.rmes.persistance.sparql_queries.operations.families.OpFamiliesQueries; | ||
import fr.insee.rmes.persistance.sparql_queries.operations.operations.OperationsQueries; | ||
import fr.insee.rmes.persistance.sparql_queries.operations.series.OpSeriesQueries; | ||
import fr.insee.rmes.testcontainers.queries.WithGraphDBContainer; | ||
import org.json.JSONArray; | ||
import org.json.JSONObject; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
public class OpFamiliesQueriesTest extends WithGraphDBContainer { | ||
RepositoryGestion repositoryGestion = new RepositoryGestion(getRdfGestionConnectionDetails(), new RepositoryUtils(null, RepositoryInitiator.Type.DISABLED)); | ||
|
||
@BeforeAll | ||
static void initData(){ | ||
container.withTrigFiles("all-operations-and-indicators.trig"); | ||
} | ||
|
||
@Test | ||
void should_return_all_families() throws Exception { | ||
OpSeriesQueries.setConfig(new ConfigStub()); | ||
JSONArray result = repositoryGestion.getResponseAsArray(OpFamiliesQueries.familiesQuery()); | ||
assertEquals(56, result.length()); | ||
|
||
for (var i = 0; i < result.length(); i++){ | ||
assertNotNull(result.getJSONObject(i).getString("id")); | ||
assertNotNull(result.getJSONObject(i).getString("label")); | ||
} | ||
} | ||
|
||
@Test | ||
void should_return_series() throws Exception { | ||
OpSeriesQueries.setConfig(new ConfigStub()); | ||
JSONArray result = repositoryGestion.getResponseAsArray(OpFamiliesQueries.getSeries("s79")); | ||
assertEquals(3, result.length()); | ||
|
||
assertEquals("s1178", result.getJSONObject(0).getString("id")); | ||
assertEquals("s1266", result.getJSONObject(1).getString("id")); | ||
assertEquals("s1279", result.getJSONObject(2).getString("id")); | ||
} | ||
} |