From 0b029bed0058c312669cf0c6c76cde76e9a10ab6 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Sun, 15 Nov 2026 08:54:50 +0000 Subject: [PATCH 1/2] Test that a property list given as one string is split at every comma --- ...AspectEngineBuilderBasePropertiesTest.java | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 pipeline/pipeline.engines/src/test/java/fiftyone/pipeline/engines/flowelements/AspectEngineBuilderBasePropertiesTest.java diff --git a/pipeline/pipeline.engines/src/test/java/fiftyone/pipeline/engines/flowelements/AspectEngineBuilderBasePropertiesTest.java b/pipeline/pipeline.engines/src/test/java/fiftyone/pipeline/engines/flowelements/AspectEngineBuilderBasePropertiesTest.java new file mode 100644 index 000000000..6bdef8e56 --- /dev/null +++ b/pipeline/pipeline.engines/src/test/java/fiftyone/pipeline/engines/flowelements/AspectEngineBuilderBasePropertiesTest.java @@ -0,0 +1,89 @@ +/* ********************************************************************* + * This Original Work is copyright of 51 Degrees Mobile Experts Limited. + * Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House, + * Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU. + * + * This Original Work is licensed under the European Union Public Licence + * (EUPL) v.1.2 and is subject to its terms as set out below. + * + * If a copy of the EUPL was not distributed with this file, You can obtain + * one at https://opensource.org/licenses/EUPL-1.2. + * + * The 'Compatible Licences' set out in the Appendix to the EUPL (as may be + * amended by the European Commission) shall be deemed incompatible for + * the purposes of the Work and the provisions of the compatibility + * clause in Article 5 of the EUPL shall not apply. + * + * If using the Work as, or as part of, a network application, by + * including the attribution notice(s) required under Article 5 of the EUPL + * in the end user terms of the application under an appropriate heading, + * such notice(s) shall fulfill the requirements of that article. + * ********************************************************************* */ + +package fiftyone.pipeline.engines.flowelements; + +import fiftyone.pipeline.engines.testhelpers.flowelements.EmptyEngineBuilder; +import org.junit.Test; +import org.slf4j.LoggerFactory; + +import java.util.Arrays; +import java.util.Collections; + +import static org.junit.Assert.assertEquals; + +/** + * A list of properties given as one string, as a configuration file gives + * it, is a comma-separated list. + */ +public class AspectEngineBuilderBasePropertiesTest { + + private static EmptyEngineBuilder builder() { + return new EmptyEngineBuilder(LoggerFactory.getILoggerFactory()); + } + + @Test + public void setProperties_CommasWithoutSpaces_EachProperty() { + EmptyEngineBuilder builder = builder() + .setProperties("IsMobile,BrowserName,PlatformName"); + assertEquals( + Arrays.asList("IsMobile", "BrowserName", "PlatformName"), + builder.getProperties()); + } + + @Test + public void setProperties_SpacesAroundNames_Trimmed() { + EmptyEngineBuilder builder = builder() + .setProperties(" IsMobile, BrowserName ,PlatformName , DeviceType"); + assertEquals( + Arrays.asList("IsMobile", "BrowserName", "PlatformName", + "DeviceType"), + builder.getProperties()); + } + + @Test + public void setProperties_EmptyEntries_LeftOut() { + EmptyEngineBuilder builder = builder() + .setProperties("IsMobile,,BrowserName,"); + assertEquals( + Arrays.asList("IsMobile", "BrowserName"), + builder.getProperties()); + } + + @Test + public void setProperties_OneName_OneProperty() { + EmptyEngineBuilder builder = builder().setProperties("IsMobile"); + assertEquals( + Collections.singletonList("IsMobile"), + builder.getProperties()); + } + + @Test + public void setProperties_Repeated_AddedOnce() { + EmptyEngineBuilder builder = builder() + .setProperties("IsMobile,IsMobile") + .setProperties("BrowserName, IsMobile"); + assertEquals( + Arrays.asList("IsMobile", "BrowserName"), + builder.getProperties()); + } +} From d4677e54d1bc48b6c5bfbf1cac197f8b26679420 Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Sun, 15 Nov 2026 08:54:51 +0000 Subject: [PATCH 2/2] Split a property list given as one string at every comma, trimming each name --- .../engines/flowelements/AspectEngineBuilderBase.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pipeline/pipeline.engines/src/main/java/fiftyone/pipeline/engines/flowelements/AspectEngineBuilderBase.java b/pipeline/pipeline.engines/src/main/java/fiftyone/pipeline/engines/flowelements/AspectEngineBuilderBase.java index aaba5f317..cd13fe07f 100644 --- a/pipeline/pipeline.engines/src/main/java/fiftyone/pipeline/engines/flowelements/AspectEngineBuilderBase.java +++ b/pipeline/pipeline.engines/src/main/java/fiftyone/pipeline/engines/flowelements/AspectEngineBuilderBase.java @@ -136,14 +136,19 @@ public TBuilder setProperties(List properties) { * Configure the properties that the engine will populate in the response. *

* By default, all properties will be populated. - * @param properties The properties that we want the engine to populate + * @param properties The properties that we want the engine to populate, + * separated by commas as a configuration file gives a + * list, with any spaces round each name ignored * @return this builder */ @DefaultValue("All properties") @SuppressWarnings("unchecked") public TBuilder setProperties(String properties) { - for (String property : properties.split("\\s,\\s")) { - tryAddProperty(property); + for (String property : properties.split(",")) { + String name = property.trim(); + if (name.isEmpty() == false) { + tryAddProperty(name); + } } return (TBuilder) this; }