-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adds missing namespace in catalog query scope (#248)
- Loading branch information
Showing
3 changed files
with
101 additions
and
26 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
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
69 changes: 69 additions & 0 deletions
69
...api/src/test/java/org/eclipse/edc/catalog/api/query/FederatedCatalogApiExtensionTest.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,69 @@ | ||
/* | ||
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation | ||
* | ||
*/ | ||
|
||
package org.eclipse.edc.catalog.api.query; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.eclipse.edc.jsonld.spi.JsonLd; | ||
import org.eclipse.edc.jsonld.util.JacksonJsonLd; | ||
import org.eclipse.edc.junit.extensions.DependencyInjectionExtension; | ||
import org.eclipse.edc.spi.system.ServiceExtensionContext; | ||
import org.eclipse.edc.spi.types.TypeManager; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
import static org.eclipse.edc.catalog.api.query.FederatedCatalogApiExtension.CATALOG_QUERY_SCOPE; | ||
import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.VOCAB; | ||
import static org.eclipse.edc.jsonld.spi.Namespaces.DCAT_PREFIX; | ||
import static org.eclipse.edc.jsonld.spi.Namespaces.DCAT_SCHEMA; | ||
import static org.eclipse.edc.jsonld.spi.Namespaces.DCT_PREFIX; | ||
import static org.eclipse.edc.jsonld.spi.Namespaces.DCT_SCHEMA; | ||
import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_PREFIX; | ||
import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_SCHEMA; | ||
import static org.eclipse.edc.policy.model.OdrlNamespace.ODRL_PREFIX; | ||
import static org.eclipse.edc.policy.model.OdrlNamespace.ODRL_SCHEMA; | ||
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE; | ||
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_PREFIX; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
@ExtendWith(DependencyInjectionExtension.class) | ||
public class FederatedCatalogApiExtensionTest { | ||
|
||
private final JsonLd jsonLd = mock(); | ||
private final TypeManager typeManager = mock(); | ||
private final ObjectMapper mapper = JacksonJsonLd.createObjectMapper(); | ||
|
||
@BeforeEach | ||
void setUp(ServiceExtensionContext context) { | ||
context.registerService(JsonLd.class, jsonLd); | ||
context.registerService(TypeManager.class, typeManager); | ||
when(typeManager.getMapper()).thenReturn(mapper); | ||
} | ||
|
||
@Test | ||
void initialize_shouldRegisterNamespaces(FederatedCatalogApiExtension extension, ServiceExtensionContext context) { | ||
extension.initialize(context); | ||
|
||
verify(jsonLd).registerNamespace(DCAT_PREFIX, DCAT_SCHEMA, CATALOG_QUERY_SCOPE); | ||
verify(jsonLd).registerNamespace(DCT_PREFIX, DCT_SCHEMA, CATALOG_QUERY_SCOPE); | ||
verify(jsonLd).registerNamespace(ODRL_PREFIX, ODRL_SCHEMA, CATALOG_QUERY_SCOPE); | ||
verify(jsonLd).registerNamespace(VOCAB, EDC_NAMESPACE, CATALOG_QUERY_SCOPE); | ||
verify(jsonLd).registerNamespace(EDC_PREFIX, EDC_NAMESPACE, CATALOG_QUERY_SCOPE); | ||
verify(jsonLd).registerNamespace(DSPACE_PREFIX, DSPACE_SCHEMA, CATALOG_QUERY_SCOPE); | ||
} | ||
|
||
} |