Repository navigation
Show each IP Intelligence value's weighting in the examples - #148
Merged
Merged
Conversation
# Conflicts: # AGENTS.md
The specification's IP Intelligence required examples page says "Examples MUST demonstrate accessing both the value and its associated weighting". The fresh clone run of the getting started example now fails unless its output holds "(weighting ", so the check shows whether a person running the example with the free data file sees a weighting.
rc now passes -ExpectDownload to run-fresh-clone-example.ps1 as a switch
and tests the script and the workflow's calls of it with Pester. Two
conflicts, resolved by keeping both changes.
- In ci/run-fresh-clone-example.ps1, rc's [switch]$ExpectDownload and its
comment, then this branch's optional -Expect text.
- In .github/workflows/examples-fresh-clone.yml, rc's -ExpectDownload and
-ExpectDownload:$false, each followed by this branch's
-Expect '${{ matrix.expect }}'.
rc's run-fresh-clone-example.Tests.ps1 replaces the workflow's matrix
values before running each call, so it now also replaces matrix.expect
with the empty text the device-detection entries give, and two new cases
check that -Expect passes when the output holds the text and fails when it
does not.
…ighting The getting started example read its values through the typed getters, such as getRegisteredName(), which give a String and no weighting. So with the free data file it printed "RegisteredName: UNICOM" and no weighting at all. Reading a property by name gives a list of weighted values, which the helper prints as "UNICOM (weighting 1.00)", as the specification's "Examples MUST demonstrate accessing both the value and its associated weighting" asks. AGENTS.md now gives a line the free data file prints as its example, and the helper's comment says what it does with a list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every IP Intelligence property is a list of weighted values, and no Java example showed a weighting. Two things hid it.
PropertyHelper, whoseunwrapValuekept each weighted value's value and dropped its weighting (PropertyHelperlines 67 to 84 at rc 49bc431e, line 76).getRegisteredName(), which is declared asAspectPropertyValue<String>(IPIntelligenceDataline 242) and so gives the value alone. With the free data file the example printedRegisteredName: UNICOMand no weighting at all.So a developer running the Getting Started example saw "UNICOM" and never learned that the answer carries a weighting, or how to read it.
What the specification says
ip-intelligence-specification/required-examples.md at d79bbe3b, "Weighted Values", line 107:
The section's example prints each value followed by its weighting.
What changed
PropertyHelper.unwrapValuewrites each weighted value followed by its weighting, read withIWeightedValue.getWeighting()and written to two decimal places in the root locale, for exampleJapan (weighting 1.00), orTokyo (weighting 0.75), Osaka (weighting 0.25)where there are two answers. Values that are not weighted are written as before, and the method's comment says what it does with a list.GettingStartedOnPrem.writeValuereads each property by name withipData.get(property), which gives the list of weighted values, rather than through the typed getter. So with the free data file the example printsRegisteredName: UNICOM (weighting 1.00). Its comment says that the typed getters give the value alone.(weighting.ci/run-fresh-clone-example.ps1takes an optional-Expecttext, the workflow passes(weightingfor the IP Intelligence entries and an empty text for Device Detection, andci/run-fresh-clone-example.Tests.ps1gains a case where the output holds the text and passes, and one where it does not and fails.RegisteredCountry: CN (weighting 1.00), which is a line the free data file prints.examples/ip-intelligenceis not among the packagesci/packages.jsonpublishes, so this change publishes nothing.Changes at this head
The previous head, db2907a, showed the weighting only for values that reach the helper as a list. Its own fresh clone run printed
RegisteredName: UNICOMwith no weighting, because the example read the three properties the free data file has through their typed getters. Three commits follow it.(weighting, so the check shows whether a person running the example with the free data file sees a weighting.rc49bc431 merged in (see Base branch).rc, before the fix): fresh clone run 44451566157, job "ip-intelligence on ubuntu-latest, downloading its data file" failed with "The example's output does not hold '(weighting '.", the example having printedRegisteredName: UNICOM. The other checks on f2e9f4f passed.RegisteredName: UNICOM (weighting 1.00),RegisteredOwner: Unknown (weighting 1.00)andRegisteredCountry: CN (weighting 1.00). CI script tests run 44452048118 ran the script's Pester tests, the two new cases among them, on Ubuntu and Windows and passed.Tests
Two tests, each written before its fix.
PropertyHelperTest.testWeightedValuesShowTheirWeighting(commit 281779b). One value with a raw weighting of 65535 is writtenJapan (weighting 1.00), and two with raw weightings of 49151 and 16384 are writtenTokyo (weighting 0.75), Osaka (weighting 0.25). Red onrcb33daa0 (281779b with the workflow, 56729f0) in run 43618736428, wherePropertyHelperTestran 5 with 1 failure, the new test, "expected:<Japan[ (weighting 1.00)]> but was:<Japan[]>". Green on the change (b9eabc3 with the workflow, aa314da) in run 43618750238, all 5 passed.Released tests
The released tests on
mainthat exercise what this draft touches are the four in the IP Intelligence examples'PropertyHelperTestandGettingStartedOnPremTestin the IP Intelligence console examples. Both files are unaltered here apart from the one test added toPropertyHelperTest.Tests of what it touches
Run 44452870138 built 1166f45, with one temporary workflow commit on top of it (a278c23) and nothing merged, on nine configurations, Ubuntu x64 with Java 8, 11, 17 and 21, Ubuntu arm64 with Java 17, and Windows with Java 8, 11, 17 and 21, and every job passed. In its Ubuntu Java 17 job the IP Intelligence examples ran
PropertyHelperTest5 of 5,GettingStartedOnPremTest1 of 1 andExamplesWithoutSettingsTest11 of 11, with every other test in the examples passing. macOS was left out of this build. Therchead is built with macOS before it merges intomain.Base branch
rc49bc431 is merged into the head with a merge commit, f2e9f4fc, afterrcmade-ExpectDownloada switch ofci/run-fresh-clone-example.ps1and began testing the script and the workflow's calls of it with Pester. Two conflicts, each resolved by keeping both changes.ci/run-fresh-clone-example.ps1,rc's[switch]$ExpectDownloadand its comment, then this draft's optional-Expecttext..github/workflows/examples-fresh-clone.yml,rc's-ExpectDownloadand-ExpectDownload:$false, each followed by this draft's-Expect '${{ matrix.expect }}'.rc'srun-fresh-clone-example.Tests.ps1replaces the workflow's matrix values before it runs each call, so it now also replacesmatrix.expectwith the empty text the Device Detection entries give.An earlier merge of
rc81e3d4a, db2907a5, conflicted in one hunk of AGENTS.md, where #162 rewrote the IP Intelligence part of "Correct output" to say that every line the Lite file cannot answer readsneeds the Enterprise data file. That resolution kept #162's text and put this draft's sentence in front of it.rchas since moved to 3bb6e71, and the draft merges with it with no conflict. #192 also changesexamples-fresh-clone.ymland AGENTS.md, in other lines, and a trial merge of the two heads is clean.Before you upgrade
Nothing to change. The change is in the IP Intelligence examples, AGENTS.md and CI, which publish no package. The examples' output now carries each value's weighting.
What remains
Nothing for this change.