From 2a7c677355d090845f44d463239609d0e7decf44 Mon Sep 17 00:00:00 2001 From: Jannis Jung Date: Mon, 18 Sep 2023 12:07:55 +0200 Subject: [PATCH] Improves null value handling Co-authored-by: Marie Witt Signed-off-by: Jannis Jung --- .../AasEnvironmentPreconfigurationLoader.java | 12 +++--- .../http/TestAasEnvironmentHTTP.java | 25 ++++++++++++ .../basyx.aasenvironment.component/pom.xml | 39 +++++++++++++++++-- 3 files changed, 67 insertions(+), 9 deletions(-) diff --git a/basyx.aasenvironment/basyx.aasenvironment-core/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/preconfiguration/AasEnvironmentPreconfigurationLoader.java b/basyx.aasenvironment/basyx.aasenvironment-core/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/preconfiguration/AasEnvironmentPreconfigurationLoader.java index 50af46ec2..9c23955b2 100644 --- a/basyx.aasenvironment/basyx.aasenvironment-core/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/preconfiguration/AasEnvironmentPreconfigurationLoader.java +++ b/basyx.aasenvironment/basyx.aasenvironment-core/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/preconfiguration/AasEnvironmentPreconfigurationLoader.java @@ -79,7 +79,7 @@ public AasEnvironmentPreconfigurationLoader(ResourceLoader resourceLoader, Strin @Autowired public AasEnvironmentPreconfigurationLoader(ResourceLoader resourceLoader, @Value("${basyx.environmentPaths:#{null}}") List pathsToLoad, @Value("${basyx.environmentDict:#{null}}") String directoryToLoad) { - this(resourceLoader, Stream.concat(extractFilesToLoadFromEnvironmentDirectory(directoryToLoad).stream(), pathsToLoad.stream()) + this(resourceLoader, Stream.concat(extractFilesToLoadFromEnvironmentDirectory(directoryToLoad).stream(), pathsToLoad != null ? pathsToLoad.stream() : new ArrayList().stream()) .collect(Collectors.toList())); this.directoryToLoad = directoryToLoad; } @@ -106,12 +106,12 @@ private void loadEnvironmentFromFile(AasRepository aasRepository, SubmodelReposi } } - private static List extractFilesToLoadFromEnvironmentDirectory(String folderToLoad) throws IllegalArgumentException { - if (folderToLoad == null) { - new ArrayList(); + private static List extractFilesToLoadFromEnvironmentDirectory(String directoryToLoad) throws IllegalArgumentException { + if (directoryToLoad == null) { + return new ArrayList(); } - folderToLoad = convertFromClassPathFormat(folderToLoad); - File rootDirectory = new File(folderToLoad); + directoryToLoad = convertFromClassPathFormat(directoryToLoad); + File rootDirectory = new File(directoryToLoad); RecursiveDirectoryScanner directoryScanner = new RecursiveDirectoryScanner(); List potentialEnvironments = directoryScanner.listFiles(rootDirectory); diff --git a/basyx.aasenvironment/basyx.aasenvironment-http/src/test/java/org/eclipse/basyx/digitaltwin/aasenvironment/http/TestAasEnvironmentHTTP.java b/basyx.aasenvironment/basyx.aasenvironment-http/src/test/java/org/eclipse/basyx/digitaltwin/aasenvironment/http/TestAasEnvironmentHTTP.java index 77da41d5d..0d45b494b 100644 --- a/basyx.aasenvironment/basyx.aasenvironment-http/src/test/java/org/eclipse/basyx/digitaltwin/aasenvironment/http/TestAasEnvironmentHTTP.java +++ b/basyx.aasenvironment/basyx.aasenvironment-http/src/test/java/org/eclipse/basyx/digitaltwin/aasenvironment/http/TestAasEnvironmentHTTP.java @@ -1,3 +1,28 @@ +/******************************************************************************* + * Copyright (C) 2023 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.basyx.digitaltwin.aasenvironment.http; import static org.junit.Assert.assertEquals; diff --git a/basyx.aasenvironment/basyx.aasenvironment.component/pom.xml b/basyx.aasenvironment/basyx.aasenvironment.component/pom.xml index da0d58da2..a59b0643d 100644 --- a/basyx.aasenvironment/basyx.aasenvironment.component/pom.xml +++ b/basyx.aasenvironment/basyx.aasenvironment.component/pom.xml @@ -1,4 +1,6 @@ - + 4.0.0 @@ -75,6 +77,36 @@ httpclient5 test + + org.eclipse.digitaltwin.basyx + basyx.submodelrepository-core + test + tests + + + org.eclipse.digitaltwin.basyx + basyx.aasrepository-core + + + org.eclipse.digitaltwin.basyx + basyx.aasrepository-core + tests + test + + + org.eclipse.digitaltwin.basyx + + basyx.conceptdescriptionrepository-core + + + + org.eclipse.digitaltwin.basyx + + basyx.conceptdescriptionrepository-core + + test + tests + @@ -87,7 +119,7 @@ - + @@ -107,7 +139,8 @@ - ${docker.host.port}:${docker.container.port} + + ${docker.host.port}:${docker.container.port} ${docker.container.waitForEndpoint}