Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f9eb229
Test: configuration files give a list as a comma-separated string and…
jwrosewell Nov 15, 2026
2566fe8
Fix: split a configured property list at each comma and set an enumer…
jwrosewell Nov 15, 2026
99ffe2e
Test: an Element Data key is compared without regard to case (PR-3)
jwrosewell Nov 15, 2026
10d2de7
Fix: find Element Data by its key without regard to case (PR-3)
jwrosewell Nov 15, 2026
e1f17c3
Fix: time the cached Pipeline overhead after the one call the cache m…
jwrosewell Nov 15, 2026
7002189
Test: a data file and a temporary folder may be given as relative pat…
jwrosewell Nov 15, 2026
0dd259f
Test: a configuration file with the names the .NET sample uses builds…
jwrosewell Nov 15, 2026
3d978c3
Fix: read SetAutoDisposeElements, the name other languages use, for s…
jwrosewell Nov 15, 2026
6c3c550
Test: every Hash engine Property has a description and data tiers (PR…
jwrosewell Nov 15, 2026
294688b
Test: the string stored for a Property can be read as well as the par…
jwrosewell Nov 15, 2026
61a505c
Fix: offer the stored string of an on-premise Property through Provid…
jwrosewell Nov 15, 2026
02a4d28
Test: each missing Property message has the text of the specification…
jwrosewell Nov 15, 2026
df84ae1
Fix: give each missing Property message the specification's text (PR-17)
jwrosewell Nov 15, 2026
f9b48b7
Test: the reason a Property is missing is decided in the specificatio…
jwrosewell Nov 15, 2026
1c59f13
Fix: decide the reason a Property is missing in the specification's o…
jwrosewell Nov 16, 2026
6ad767f
Test: element data keys hold only alphanumeric characters, full stop …
jwrosewell Nov 16, 2026
b157ff8
Test: element data keys are lower-case (PR-2)
jwrosewell Nov 16, 2026
3195f5d
Fix: leave an enumeration with its own parse method to that method wh…
jwrosewell Nov 16, 2026
901de63
Merge rc into the section 10 conformance work
jwrosewell Nov 16, 2026
464d294
Take rc's cloud aspect engine base, whose own way of reporting a fail…
jwrosewell Nov 16, 2026
4c60460
Merge rc into the Property metadata work
jwrosewell Nov 16, 2026
3472227
Take the property metadata test off the deprecated FileUtils
jwrosewell Nov 16, 2026
a52f006
Keep rc's missing property service tests, which an earlier merge of r…
jwrosewell Nov 16, 2026
56c21f5
Build the IP Intelligence API example on this repository's JSON Build…
jwrosewell Nov 16, 2026
5cae01c
Merge rc into the Property metadata work
jwrosewell Nov 16, 2026
9af6ee0
Keep rc's TypedKeyMapBuilder, which #167 brought
jwrosewell Nov 16, 2026
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
@@ -0,0 +1,69 @@
/* *********************************************************************
* 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.devicedetection.cloud.flowelements;

import org.junit.Test;
import org.slf4j.Logger;

import java.util.Locale;

import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;

/**
* The string key of each Device Detection cloud engine's data contains only
* alphanumeric characters, full stop or hyphen.
* <p>
* Specification: pipeline-specification/features/access-to-results.md line 7
* at 51Degrees/specifications 706de1f0, "Strings SHOULD only contain
* alphanumeric characters, full stop or hyphen."
*/
public class ElementDataKeyFormatTests {

private static String[] keys() {
return new String[] {
new DeviceDetectionCloudEngine(mock(Logger.class), null)
.getElementDataKey(),
new HardwareProfileCloudEngine(mock(Logger.class), null)
.getElementDataKey()
};
}

@Test
public void keys_OnlyAlphanumericFullStopOrHyphen() {
for (String key : keys()) {
assertTrue(key, key.matches("[A-Za-z0-9.-]+"));
}
}

/**
* Specification: access-to-results.md line 10, "Lower-case SHOULD be
* used."
*/
@Test
public void keys_LowerCase() {
for (String key : keys()) {
assertTrue(key, key.equals(key.toLowerCase(Locale.ROOT)));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/* *********************************************************************
* 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.devicedetection.hash.engine.onpremise.flowelements;

import fiftyone.pipeline.engines.Constants;
import fiftyone.pipeline.engines.fiftyone.data.FiftyOneAspectPropertyMetaData;
import org.junit.Test;
import org.slf4j.LoggerFactory;

import java.io.File;

import static fiftyone.devicedetection.shared.testhelpers.TestFileUtils.LITE_HASH_DATA_FILE_PATH;
import static fiftyone.pipeline.util.FileFinder.getFilePath;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeTrue;

/**
* Every Property of the Hash engine has the metadata an Aspect Engine must
* add to that of a Flow Element: a description, and the data tiers where the
* Property is present.
* <p>
* Specification: pipeline-specification/features/properties.md line 101 at
* 51Degrees/specifications 706de1f0, "Aspect Engines are REQUIRED to
* populate some additional metadata values beyond those described for Flow
* Elements.", with lines 108 and 109 naming Description and Data tiers where
* present.
*/
public class PropertyMetaDataTests {

@Test
public void everyProperty_HasDescriptionAndDataTiers() throws Exception {
File dataFile = null;
try {
dataFile = getFilePath(LITE_HASH_DATA_FILE_PATH);
} catch (IllegalArgumentException e) {
assumeTrue(e.getMessage(), false);
}

try (DeviceDetectionHashEngine engine =
new DeviceDetectionHashEngineBuilder(
LoggerFactory.getILoggerFactory(), null)
.setPerformanceProfile(
Constants.PerformanceProfiles.LowMemory)
.setAutoUpdate(false)
.build(dataFile.toString(), false)) {
String tier = engine.getDataSourceTier();
assertFalse(engine.getProperties().isEmpty());
for (FiftyOneAspectPropertyMetaData property :
engine.getProperties()) {
String name = property.getName();
assertNotNull(name + " has a description",
property.getDescription());
assertFalse(name + " has a description",
property.getDescription().trim().isEmpty());
assertNotNull(name + " has data tiers",
property.getDataTiersWherePresent());
assertFalse(name + " has data tiers",
property.getDataTiersWherePresent().isEmpty());
if (property.isAvailable()) {
assertTrue(
name + " is in the data file, so its tiers name " +
"the data file's tier '" + tier + "'",
containsIgnoringCase(
property.getDataTiersWherePresent(), tier));
}
}
}
}

private static boolean containsIgnoringCase(
Iterable<String> values,
String value) {
for (String candidate : values) {
if (candidate.equalsIgnoreCase(value)) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import fiftyone.pipeline.engines.data.AspectData;
import fiftyone.pipeline.engines.data.AspectPropertyMetaData;
import fiftyone.pipeline.engines.data.AspectPropertyValue;
import fiftyone.pipeline.engines.data.ProvidesValuesAsString;
import fiftyone.pipeline.engines.flowelements.AspectEngine;
import fiftyone.pipeline.engines.services.MissingPropertyService;
import org.slf4j.Logger;
Expand All @@ -42,7 +43,8 @@
/**
* Base class used for all 51Degrees on-premise device detection results classes.
*/
public abstract class DeviceDataBaseOnPremise extends DeviceDataBase {
public abstract class DeviceDataBaseOnPremise extends DeviceDataBase
implements ProvidesValuesAsString {

protected final Map<Class<?>, Class<?>> primitiveTypes;
private final Object dataLock = new Object();
Expand Down Expand Up @@ -93,6 +95,25 @@ public abstract AspectPropertyValue<List<String>> getValues(
protected abstract AspectPropertyValue<String> getValueAsString(
String propertyName);

/**
* {@inheritDoc}
* <p>
* The Property is first read through its typed accessor, so a Property
* that is not in the results throws, and a lazy loaded result is waited
* for, exactly as for that accessor.
*/
@SuppressWarnings("unchecked")
@Override
public AspectPropertyValue<String> getStoredValueAsString(
String propertyName) {
getAs(propertyName,
AspectPropertyValue.class,
getPropertyType(propertyName));
synchronized (getLock) {
return getValueAsString(propertyName);
}
}

/**
* Get the value for the specified property as an {@link Integer}. If the
* property cannot be represented as an {@link Integer}, then the result
Expand Down
Loading
Loading