Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add a check for / suffix for basyx external url in registry integration #333

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
82a79d2
fix: –add a check for / suffix for basyx external url in registry int…
ShehriyarShariq-Fraunhofer Jul 9, 2024
4a7a8aa
fix: submodal integration test
ShehriyarShariq-Fraunhofer Jul 9, 2024
62d44d1
Empty commit for the CI to run
MateusMolina Jul 9, 2024
13868a9
fix: registry integration create url logic
ShehriyarShariq-Fraunhofer Jul 9, 2024
94923af
Merge branch 'fix-slash-check-registry-integration' of https://github…
ShehriyarShariq-Fraunhofer Jul 9, 2024
bb3e3e9
Empty commit for the CI to run
MateusMolina Jul 9, 2024
437ac16
fix: latest merge
ShehriyarShariq-Fraunhofer Jul 16, 2024
9bdb684
Empty commit for the CI to run
MateusMolina Jul 16, 2024
c410c6a
fix: feature-registry-integration createURL remove static reference i…
ShehriyarShariq-Fraunhofer Jul 16, 2024
245bae2
Merge branch 'fix-slash-check-registry-integration' of https://github…
ShehriyarShariq-Fraunhofer Jul 16, 2024
dae87d7
Triggering the CI
MateusMolina Jul 23, 2024
ba08cbd
fix: createUrl method issue with path without leading slash resolved
ShehriyarShariq-Fraunhofer Jul 23, 2024
99a47de
Merge branch 'fix-slash-check-registry-integration' of https://github…
ShehriyarShariq-Fraunhofer Jul 23, 2024
9d86f9e
fix: use main static createUrl method in DescriptorFactory test cases
ShehriyarShariq-Fraunhofer Jul 23, 2024
c75b166
refactor: remove create*Url method from Dummy*DescriptorFactory
ShehriyarShariq-Fraunhofer Jul 25, 2024
9272437
fix: Test*DescriptorFactory refactor tests
ShehriyarShariq-Fraunhofer Jul 25, 2024
ad5b8a1
Merge branch 'main' into fix-slash-check-registry-integration
ShehriyarShariq-Fraunhofer Jul 26, 2024
27e19d4
refactor: make createRepositoryUrl common + refactor implementation
ShehriyarShariq-Fraunhofer Jul 31, 2024
da4b87b
fix: RepositoryUrlHelper - add tests with context path in url
ShehriyarShariq-Fraunhofer Aug 1, 2024
3306f65
refactor: reformat RepositoryUrlHelper + Test
ShehriyarShariq-Fraunhofer Aug 1, 2024
2be64c0
fix: resolve merge conflicts with latest updates from main
ShehriyarShariq-Fraunhofer Aug 26, 2024
7b303c4
Empty commit to trigger the CI
MateusMolina Aug 27, 2024
b4afd85
Merge branch 'main' into fix-slash-check-registry-integration
ShehriyarShariq-Fraunhofer Sep 2, 2024
bcdef6e
fix: refactor utility url functions
ShehriyarShariq-Fraunhofer Sep 2, 2024
d30b228
Triggering the CI
MateusMolina Sep 3, 2024
37bc55e
fix: aas repository feature auth url function fix
ShehriyarShariq-Fraunhofer Sep 3, 2024
a29ab5a
Merge branch 'fix-slash-check-registry-integration' of https://github…
ShehriyarShariq-Fraunhofer Sep 3, 2024
66b6354
Triggering the CI
MateusMolina Sep 3, 2024
581e641
fix: revert pom + update createRepositoryUrl functionality
ShehriyarShariq-Fraunhofer Sep 16, 2024
dedc173
Triggering the CI
MateusMolina Sep 17, 2024
3ccbec3
fix: add license headers
ShehriyarShariq-Fraunhofer Sep 24, 2024
9c118a4
fix: update test for external url
ShehriyarShariq-Fraunhofer Sep 30, 2024
27bdb45
stash
ShehriyarShariq-Fraunhofer Oct 1, 2024
ec7e126
Merge branch 'main' into fix-slash-check-registry-integration
ShehriyarShariq-Fraunhofer Oct 14, 2024
c7f3d55
feat: AasRepositoryRegistryLinkDescriptorGenerationTest
ShehriyarShariq-Fraunhofer Oct 15, 2024
5bd2f77
stash
ShehriyarShariq-Fraunhofer Oct 27, 2024
09f00d0
Merge branch 'main' into fix-slash-check-registry-integration
ShehriyarShariq-Fraunhofer Oct 27, 2024
493f177
stash
ShehriyarShariq-Fraunhofer Oct 27, 2024
d0ba025
stash
ShehriyarShariq-Fraunhofer Oct 28, 2024
2b5163f
stash
ShehriyarShariq-Fraunhofer Oct 29, 2024
0de2d33
fix: working registry url slash test
ShehriyarShariq-Fraunhofer Oct 29, 2024
b1babf6
feat: working test
ShehriyarShariq-Fraunhofer Oct 29, 2024
ec123aa
fix: merge from main
ShehriyarShariq-Fraunhofer Oct 29, 2024
ae3c928
feat: add Submodel Repo Registry Test
ShehriyarShariq-Fraunhofer Oct 29, 2024
d15ef4d
fix: merge with main
ShehriyarShariq-Fraunhofer Oct 29, 2024
f03d036
Merge branch 'fix-slash-check-registry-integration' of https://github…
ShehriyarShariq-Fraunhofer Oct 29, 2024
a9f4ad2
fix: revert pom.xml
ShehriyarShariq-Fraunhofer Oct 29, 2024
ed11d33
style: code clean-up
MateusMolina Nov 4, 2024
4913629
test: refactor *RepositoryRegistryLink tests to be parameterized
MateusMolina Nov 4, 2024
1119feb
style: minor fixes
MateusMolina Nov 4, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.Endpoint;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.ProtocolInformation;
import org.eclipse.digitaltwin.basyx.aasregistry.main.client.mapper.AttributeMapper;
import org.eclipse.digitaltwin.basyx.core.RepositoryUrlHelper;
import org.eclipse.digitaltwin.basyx.http.Base64UrlEncodedIdentifier;

/**
Expand Down Expand Up @@ -196,18 +197,8 @@ private String getProtocol(String endpoint) {
private List<String> createAasRepositoryUrls(List<String> aasRepositoryBaseURLs) {
List<String> toReturn = new ArrayList<>(aasRepositoryBaseURLs.size());
for (String eachUrl : aasRepositoryBaseURLs) {
toReturn.add(createAasRepositoryUrl(eachUrl));
toReturn.add(RepositoryUrlHelper.createRepositoryUrl(eachUrl, AAS_REPOSITORY_PATH));
}
return toReturn;
}

private String createAasRepositoryUrl(String aasRepositoryBaseURL) {

try {
return new URL(new URL(aasRepositoryBaseURL), AAS_REPOSITORY_PATH).toString();
} catch (MalformedURLException e) {
throw new RuntimeException("The AAS Repository Base url is malformed.\n" + e.getMessage());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetKind;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.Endpoint;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.ProtocolInformation;
import org.eclipse.digitaltwin.basyx.core.RepositoryUrlHelper;
import org.eclipse.digitaltwin.basyx.http.Base64UrlEncodedIdentifier;

/**
Expand Down Expand Up @@ -91,7 +92,7 @@ private static ProtocolInformation createProtocolInformation(String href) {
}

private static String createHref(String aasId, String aasRepoBaseUrl) {
return String.format("%s/%s", createAasRepositoryUrl(aasRepoBaseUrl), Base64UrlEncodedIdentifier.encodeIdentifier(aasId));
return String.format("%s/%s", RepositoryUrlHelper.createRepositoryUrl(aasRepoBaseUrl, AAS_REPOSITORY_PATH), Base64UrlEncodedIdentifier.encodeIdentifier(aasId));
}

private static String getProtocol(String endpoint) {
Expand All @@ -101,14 +102,4 @@ private static String getProtocol(String endpoint) {
throw new RuntimeException();
}
}

private static String createAasRepositoryUrl(String aasRepositoryBaseURL) {

try {
return new URL(new URL(aasRepositoryBaseURL), AAS_REPOSITORY_PATH).toString();
} catch (MalformedURLException e) {
throw new RuntimeException("The AAS Repository Base url is malformed. " + e.getMessage());
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
/*******************************************************************************
* Copyright (C) 2024 the Eclipse BaSyx Authors
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* SPDX-License-Identifier: MIT
******************************************************************************/

package org.eclipse.digitaltwin.basyx.aasrepository.feature.registry.integration;

import static org.junit.Assert.assertEquals;

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

import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell;
import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShell;
import org.eclipse.digitaltwin.basyx.aasregistry.client.api.RegistryAndDiscoveryInterfaceApi;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetAdministrationShellDescriptor;
import org.eclipse.digitaltwin.basyx.aasregistry.main.client.factory.AasDescriptorFactory;
import org.eclipse.digitaltwin.basyx.aasregistry.main.client.mapper.AttributeMapper;
import org.eclipse.digitaltwin.basyx.aasrepository.AasRepository;
import org.eclipse.digitaltwin.basyx.aasrepository.backend.SimpleAasRepositoryFactory;
import org.eclipse.digitaltwin.basyx.aasrepository.backend.inmemory.AasInMemoryBackendProvider;
import org.eclipse.digitaltwin.basyx.aasservice.backend.InMemoryAasServiceFactory;
import org.eclipse.digitaltwin.basyx.core.filerepository.InMemoryFileRepository;
import org.eclipse.digitaltwin.basyx.http.Base64UrlEncodedIdentifier;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.mockito.Mockito;

/**
* Test suite for {@link RegistryIntegrationAasRepository} feature
*/
@RunWith(Parameterized.class)
public class AasRepositoryRegistryLinkDescriptorGenerationTest {
private static final String DUMMY_IDSHORT = "ExampleMotor";
private static final String DUMMY_AAS_ID = "customIdentifier";

private static final String BASE_URL = "http://localhost:8081";

private RegistryIntegrationAasRepository registryIntegrationAasRepository;
private AasRepository mockedAasRepository;
private AasRepositoryRegistryLink mockedRegistryLink;
private AttributeMapper mockedAttributeMapper;
private RegistryAndDiscoveryInterfaceApi mockedRegistryApi;

@Before
public void setUp() {
mockedAasRepository = getAasRepository();
mockedRegistryLink = Mockito.mock(AasRepositoryRegistryLink.class);
mockedAttributeMapper = Mockito.mock(AttributeMapper.class);
mockedRegistryApi = Mockito.mock(RegistryAndDiscoveryInterfaceApi.class);

Mockito.when(mockedRegistryLink.getRegistryApi()).thenReturn(mockedRegistryApi);

registryIntegrationAasRepository = new RegistryIntegrationAasRepository(mockedAasRepository, mockedRegistryLink, mockedAttributeMapper);
}

@Parameterized.Parameter(0)
public String externalUrl;

@Parameterized.Parameter(1)
public String expectedUrl;

@Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][] { { BASE_URL + "/context", BASE_URL + "/context/shells/" + Base64UrlEncodedIdentifier.encodeIdentifier(DUMMY_AAS_ID) },
{ BASE_URL, BASE_URL + "/shells/" + Base64UrlEncodedIdentifier.encodeIdentifier(DUMMY_AAS_ID) }, { BASE_URL + "/", BASE_URL + "/shells/" + Base64UrlEncodedIdentifier.encodeIdentifier(DUMMY_AAS_ID) },
{ BASE_URL + "/context/", BASE_URL + "/context/shells/" + Base64UrlEncodedIdentifier.encodeIdentifier(DUMMY_AAS_ID) } });
}

@Test
public void testExternalUrl() {
Mockito.when(mockedRegistryLink.getAasRepositoryBaseURLs()).thenReturn(List.of(externalUrl));

AssetAdministrationShellDescriptor descriptor = createAndRetrieveDescriptor(createDummyAas());
String actualUrl = descriptor.getEndpoints().get(0).getProtocolInformation().getHref();

assertEquals(expectedUrl, actualUrl);
}

private AssetAdministrationShellDescriptor createAndRetrieveDescriptor(AssetAdministrationShell shell) {
registryIntegrationAasRepository.createAas(shell);

AasDescriptorFactory descriptorFactory = new AasDescriptorFactory(shell, mockedRegistryLink.getAasRepositoryBaseURLs(), mockedAttributeMapper);
return descriptorFactory.create();
}

private AssetAdministrationShell createDummyAas() {
return new DefaultAssetAdministrationShell.Builder()
.id(DUMMY_AAS_ID)
.idShort(DUMMY_IDSHORT)
.build();
}

protected AasRepository getAasRepository() {
return new SimpleAasRepositoryFactory(new AasInMemoryBackendProvider(), new InMemoryAasServiceFactory(new InMemoryFileRepository())).create();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetAdministrationShellDescriptor;
import org.eclipse.digitaltwin.basyx.aasregistry.client.model.GetAssetAdministrationShellDescriptorsResult;
import org.eclipse.digitaltwin.basyx.aasregistry.main.client.mapper.DummyAasDescriptorFactory;
import org.eclipse.digitaltwin.basyx.core.RepositoryUrlHelper;
import org.eclipse.digitaltwin.basyx.http.Base64UrlEncodedIdentifier;
import org.eclipse.digitaltwin.basyx.http.serialization.BaSyxHttpTestUtils;
import org.junit.After;
Expand Down Expand Up @@ -129,25 +130,17 @@ private String getAas1JSONString() throws FileNotFoundException, IOException {
}

private CloseableHttpResponse createAasOnRepo(String aasJsonContent) throws IOException {
return BaSyxHttpTestUtils.executePostOnURL(createAasRepositoryUrl(getFirstAasRepoBaseUrl()), aasJsonContent);
String url = RepositoryUrlHelper.createRepositoryUrl(getFirstAasRepoBaseUrl(), AAS_REPOSITORY_PATH);
return BaSyxHttpTestUtils.executePostOnURL(RepositoryUrlHelper.createRepositoryUrl(getFirstAasRepoBaseUrl(), AAS_REPOSITORY_PATH), aasJsonContent);
}

private String getSpecificAasAccessURL(String aasId) {
return createAasRepositoryUrl(getFirstAasRepoBaseUrl()) + "/"
return RepositoryUrlHelper.createRepositoryUrl(getFirstAasRepoBaseUrl(), AAS_REPOSITORY_PATH) + "/"
+ Base64UrlEncodedIdentifier.encodeIdentifier(aasId);
}

private String getFirstAasRepoBaseUrl() {
return getAasRepoBaseUrls()[0];
}

private static String createAasRepositoryUrl(String aasRepositoryBaseURL) {

try {
return new URL(new URL(aasRepositoryBaseURL), AAS_REPOSITORY_PATH).toString();
} catch (MalformedURLException e) {
throw new RuntimeException("The AAS Repository Base url is malformed. " + e.getMessage());
}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*******************************************************************************
* Copyright (C) 2024 the Eclipse BaSyx Authors
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* SPDX-License-Identifier: MIT
******************************************************************************/

package org.eclipse.digitaltwin.basyx.core;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add license header


import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;

public final class RepositoryUrlHelper {

private RepositoryUrlHelper() {
}

public static String createRepositoryUrl(String baseUrl, String additionalPath) {
try {
URI baseUri = new URI(baseUrl);

String[] basePathSegments = baseUri.getPath().replaceAll("^/|/$", "").split("/");
String[] additionalPathSegments = additionalPath != null ? additionalPath.replaceAll("^/|/$", "").split("/") : new String[0];

StringBuilder fullPath = new StringBuilder();
for (String segment : basePathSegments) {
if (!segment.isEmpty()) {
fullPath.append("/").append(segment);
}
}
for (String segment : additionalPathSegments) {
if (!segment.isEmpty()) {
fullPath.append("/").append(segment);
}
}

URI finalUri = new URI(baseUri.getScheme(), null, baseUri.getHost(), baseUri.getPort(), fullPath.toString(), null, null);

return finalUri.toURL().toString();
} catch (URISyntaxException | MalformedURLException e) {
throw new RuntimeException("The Base URL or additional path is malformed.\n" + e.getMessage(), e);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*******************************************************************************
* Copyright (C) 2024 the Eclipse BaSyx Authors
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* SPDX-License-Identifier: MIT
******************************************************************************/

package org.eclipse.digitaltwin.basyx.core;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add license header


import static org.junit.Assert.assertEquals;

import org.junit.Test;

public class TestRepositoryUrlHelper {

private static final String BASE_URL = "http://localhost:8081";
private static final String BASE_URL_WITH_CONTEXT = "http://localhost:8081/context";
private static final String ADDITIONAL_PATH = "shells";

private static final String EXPECTED_URL = BASE_URL + "/" + ADDITIONAL_PATH;
private static final String EXPECTED_URL_WITH_CONTEXT = BASE_URL_WITH_CONTEXT + "/" + ADDITIONAL_PATH;

@Test
public void testUrlWithTrailingSlashAndPathNameWithNoLeadingSlash() {
assertEquals(EXPECTED_URL, RepositoryUrlHelper.createRepositoryUrl(BASE_URL + "/", ADDITIONAL_PATH));
}

@Test
public void testUrlWithoutTrailingSlashAndPathNameWithNoLeadingSlash() {
assertEquals(EXPECTED_URL, RepositoryUrlHelper.createRepositoryUrl(BASE_URL, ADDITIONAL_PATH));
}

@Test
public void testUrlWithTrailingSlashAndPathNameWithLeadingSlash() {
assertEquals(EXPECTED_URL, RepositoryUrlHelper.createRepositoryUrl(BASE_URL + "/", "/" + ADDITIONAL_PATH));
}

@Test
public void testUrlWithoutTrailingSlashAndPathNameWithLeadingSlash() {
assertEquals(EXPECTED_URL, RepositoryUrlHelper.createRepositoryUrl(BASE_URL, "/" + ADDITIONAL_PATH));
}

@Test
public void testUrlWithContextAndTrailingSlashAndPathNameWithLeadingSlash() {
assertEquals(EXPECTED_URL_WITH_CONTEXT,
RepositoryUrlHelper.createRepositoryUrl(BASE_URL_WITH_CONTEXT + "/", "/" + ADDITIONAL_PATH));
}

@Test
public void testUrlWithContextAndNoTrailingSlashAndPathNameWithLeadingSlash() {
assertEquals(EXPECTED_URL_WITH_CONTEXT,
RepositoryUrlHelper.createRepositoryUrl(BASE_URL_WITH_CONTEXT, "/" + ADDITIONAL_PATH));
}

@Test
public void testUrlWithContextAndTrailingSlashAndPathNameWithNoLeadingSlash() {
assertEquals(EXPECTED_URL_WITH_CONTEXT,
RepositoryUrlHelper.createRepositoryUrl(BASE_URL_WITH_CONTEXT + "/", ADDITIONAL_PATH));
}

@Test
public void testUrlWithContextAndNoTrailingSlashAndPathNameWithNoLeadingSlash() {
assertEquals(EXPECTED_URL_WITH_CONTEXT,
RepositoryUrlHelper.createRepositoryUrl(BASE_URL_WITH_CONTEXT, ADDITIONAL_PATH));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.eclipse.digitaltwin.aas4j.v3.model.LangStringTextType;
import org.eclipse.digitaltwin.aas4j.v3.model.Reference;
import org.eclipse.digitaltwin.aas4j.v3.model.Submodel;
import org.eclipse.digitaltwin.basyx.core.RepositoryUrlHelper;
import org.eclipse.digitaltwin.basyx.http.Base64UrlEncodedIdentifier;
import org.eclipse.digitaltwin.basyx.submodelregistry.client.mapper.AttributeMapper;
import org.eclipse.digitaltwin.basyx.submodelregistry.client.model.Endpoint;
Expand Down Expand Up @@ -187,18 +188,8 @@ private String getProtocol(String endpoint) {
private List<String> createSubmodelRepositoryUrls(List<String> submodelRepositoryBaseURLs) {
List<String> toReturn = new ArrayList<>(submodelRepositoryBaseURLs.size());
for (String eachUrl : submodelRepositoryBaseURLs) {
toReturn.add(createSubmodelRepositoryUrl(eachUrl));
toReturn.add(RepositoryUrlHelper.createRepositoryUrl(eachUrl, SUBMODEL_REPOSITORY_PATH));
}
return toReturn;
}

private String createSubmodelRepositoryUrl(String submodelRepositoryBaseURL) {

try {
return new URL(new URL(submodelRepositoryBaseURL), SUBMODEL_REPOSITORY_PATH).toString();
} catch (MalformedURLException e) {
throw new RuntimeException("The Submodel Repository Base url is malformed.\n" + e.getMessage());
}
}

}
Loading