From 80e48a7d1fdce08844e467cb87de0f733c2abf5c Mon Sep 17 00:00:00 2001 From: James Rosewell Date: Thu, 17 Sep 2026 01:26:18 +0100 Subject: [PATCH] TEST: Run the cloud tests again, and let a property have no value Two cloud test classes were turned off in May 2025 with no reason given, so ValueCloudTests and MissingPropertyHandlingTests have not run since, six tests in all. Turning them back on showed two real problems. The fixture in MissingPropertyHandlingTests still named the element ip-intelligence, whereas the engine reads ip, so the test threw looking for a key the response did not have. The value type test asked every listed property for its value. A property the key is not entitled to, or one the client script populates, is listed but carries no value and gives a reason instead, and asking such a value for its type throws. It now reads whether there is a value first, checks that the reason was given when there is none, and checks the type when there is one. Checked against the live cloud with a paid key, ip-intelligence.cloud reports 12 tests run, none failing and none skipped, where before the change the six restored tests error. --- .../ipintelligence/cloud/ValueTests.java | 17 +++++++++++++++-- .../cloud/data/ValueCloudTests.java | 2 -- .../MissingPropertyHandlingTests.java | 4 +--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/ValueTests.java b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/ValueTests.java index 3b7ee8b..80be997 100644 --- a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/ValueTests.java +++ b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/ValueTests.java @@ -70,12 +70,25 @@ public static void valueTypes(WrapperCloud wrapper) throws Exception { assertNotNull("Value of " + property.getName() + " is null. ", value); assertTrue(AspectPropertyValue.class.isAssignableFrom(value.getClass())); + AspectPropertyValue propertyValue = + (AspectPropertyValue) value; + // A property the resource key is not entitled to, or one + // the client script populates, is listed but carries no + // value and says why instead. Asking such a value for its + // type throws, so what is checked here is that the reason + // was given, which is what a caller reads. + if (propertyValue.hasValue() == false) { + assertNotNull("Property '" + property.getName() + + "' has no value and no reason was given.", + propertyValue.getNoValueMessage()); + continue; + } assertTrue("Value of '" + property.getName() + - "' was of type " + ((AspectPropertyValue) value).getValue().getClass().getSimpleName() + + "' was of type " + propertyValue.getValue().getClass().getSimpleName() + " but should have been " + expectedType.getSimpleName() + ".", expectedType.isAssignableFrom( - ((AspectPropertyValue) value).getValue().getClass())); + propertyValue.getValue().getClass())); } } } diff --git a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/data/ValueCloudTests.java b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/data/ValueCloudTests.java index 83cb2b8..fc703b8 100644 --- a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/data/ValueCloudTests.java +++ b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/data/ValueCloudTests.java @@ -27,10 +27,8 @@ import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; -@Ignore public class ValueCloudTests extends TestsBase { @Before diff --git a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/flowelements/MissingPropertyHandlingTests.java b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/flowelements/MissingPropertyHandlingTests.java index 2e860d0..e212f52 100644 --- a/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/flowelements/MissingPropertyHandlingTests.java +++ b/ip-intelligence.cloud/src/test/java/fiftyone/ipintelligence/cloud/flowelements/MissingPropertyHandlingTests.java @@ -33,7 +33,6 @@ import fiftyone.pipeline.engines.services.MissingPropertyReason; import fiftyone.pipeline.engines.services.MissingPropertyResult; import fiftyone.pipeline.engines.services.MissingPropertyService; -import org.junit.Ignore; import org.junit.Test; import org.slf4j.ILoggerFactory; import org.slf4j.LoggerFactory; @@ -46,7 +45,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -@Ignore public class MissingPropertyHandlingTests { protected static final ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory(); @@ -136,7 +134,7 @@ public void PropertyNotInResource() throws Exception { private static String nullValueJson = "{\n" + - " 'ip-intelligence': {\n" + + " 'ip': {\n" + " 'registeredname': 'Example Network',\n" + " 'registeredcountry': 'US',\n" + " 'latitude': null,\n" +