diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml index 8b4f92ea..a7797652 100644 --- a/.github/workflows/lint-pr.yml +++ b/.github/workflows/lint-pr.yml @@ -18,6 +18,6 @@ jobs: name: Validate PR title runs-on: ubuntu-latest steps: - - uses: amannn/action-semantic-pull-request@0b14f54ac155d88e12522156e52cb6e397745cfd + - uses: amannn/action-semantic-pull-request@b6bca70dcd3e56e896605356ce09b76f7e1e0d39 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index cacf90dd..32800dc1 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -20,9 +20,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + - uses: actions/checkout@27135e314dd1818f797af1db9dae03a9f045786b - name: Set up JDK 8 - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + uses: actions/setup-java@888b4006f39f9718dc69efb685c48e14340507b6 with: java-version: '8' distribution: 'temurin' @@ -32,7 +32,7 @@ jobs: server-password: ${{ secrets.OSSRH_PASSWORD }} - name: Cache local Maven repository - uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 + uses: actions/cache@940f3d7cf195ba83374c77632d1e2cbb2f24ae68 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} @@ -49,7 +49,7 @@ jobs: run: mvn --batch-mode --update-snapshots verify - name: Upload coverage to Codecov - uses: codecov/codecov-action@742000aae0f04cc2a6bf74c9934c84b579cc1c18 + uses: codecov/codecov-action@9b87723d6ac0be351efc7242ba5ec28fa641c77c with: flags: unittests # optional name: coverage # optional diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index 62219ac5..1c32c53d 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -16,22 +16,22 @@ jobs: steps: - name: Check out the code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + uses: actions/checkout@27135e314dd1818f797af1db9dae03a9f045786b - name: Set up JDK 8 - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + uses: actions/setup-java@888b4006f39f9718dc69efb685c48e14340507b6 with: java-version: '8' distribution: 'temurin' cache: maven - name: Initialize CodeQL - uses: github/codeql-action/init@7ba5ed7eed12f15064a031cc1fa3341f93764020 + uses: github/codeql-action/init@204eadab9ded3e22323701abf6bac3aaa9147683 with: languages: java - name: Cache local Maven repository - uses: actions/cache@6998d139ddd3e68c71e9e398d8e40b71a2f39812 + uses: actions/cache@940f3d7cf195ba83374c77632d1e2cbb2f24ae68 with: path: ~/.m2/repository key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} @@ -42,7 +42,7 @@ jobs: run: mvn --batch-mode --update-snapshots verify -P integration-test - name: Upload coverage to Codecov - uses: codecov/codecov-action@742000aae0f04cc2a6bf74c9934c84b579cc1c18 + uses: codecov/codecov-action@9b87723d6ac0be351efc7242ba5ec28fa641c77c with: token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos flags: unittests # optional @@ -51,4 +51,4 @@ jobs: verbose: true # optional (default = false) - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@7ba5ed7eed12f15064a031cc1fa3341f93764020 + uses: github/codeql-action/analyze@204eadab9ded3e22323701abf6bac3aaa9147683 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03d186c8..8e032f8d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: # Release-please creates a PR that tracks all changes steps: - - uses: google-github-actions/release-please-action@514bc6cdae71484c998108f2136a8f5e4c62b9b9 + - uses: google-github-actions/release-please-action@e0b9d1885d92e9a93d5ce8656de60e3b806e542c id: release with: command: manifest @@ -29,10 +29,10 @@ jobs: # These steps are only run if this was a merged release-please PR - name: checkout if: ${{ steps.release.outputs.releases_created }} - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + uses: actions/checkout@27135e314dd1818f797af1db9dae03a9f045786b - name: Set up JDK 8 if: ${{ steps.release.outputs.releases_created }} - uses: actions/setup-java@ea15b3b99cdc9ac45af1882d085e3f9297a75a8b + uses: actions/setup-java@888b4006f39f9718dc69efb685c48e14340507b6 with: java-version: '8' distribution: 'temurin' diff --git a/.github/workflows/static-code-scanning.yaml b/.github/workflows/static-code-scanning.yaml index 70edc8e5..7475cf65 100644 --- a/.github/workflows/static-code-scanning.yaml +++ b/.github/workflows/static-code-scanning.yaml @@ -29,16 +29,16 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c + uses: actions/checkout@27135e314dd1818f797af1db9dae03a9f045786b # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@7ba5ed7eed12f15064a031cc1fa3341f93764020 + uses: github/codeql-action/init@204eadab9ded3e22323701abf6bac3aaa9147683 with: languages: java - name: Autobuild - uses: github/codeql-action/autobuild@7ba5ed7eed12f15064a031cc1fa3341f93764020 + uses: github/codeql-action/autobuild@204eadab9ded3e22323701abf6bac3aaa9147683 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@7ba5ed7eed12f15064a031cc1fa3341f93764020 + uses: github/codeql-action/analyze@204eadab9ded3e22323701abf6bac3aaa9147683 diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 391149ac..1d65d957 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1 +1 @@ -{".":"1.2.0"} \ No newline at end of file +{".":"1.3.0"} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 51318976..3f4d7a77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,55 @@ # Changelog +## [1.3.0](https://github.com/open-feature/java-sdk/compare/v1.2.0...v1.3.0) (2023-03-12) + + +### ๐Ÿ’ฅ Breaking Changes + +* remove the deprecated setTargetingKey method in EvaluationContext. ([#290](https://github.com/open-feature/java-sdk/issues/290)) ([d78c99c](https://github.com/open-feature/java-sdk/commit/d78c99ce16be906452bf7961cd43972b72855dd3)) + + +### ๐Ÿ› Bug Fixes + +* Do not throw null reference exception accessing a missing item. ([#300](https://github.com/open-feature/java-sdk/issues/300)) ([464820d](https://github.com/open-feature/java-sdk/commit/464820d5da0d70ae3682d0819da766460ca0e6ce)) +* handling of double and integer ([#316](https://github.com/open-feature/java-sdk/issues/316)) ([0a27a77](https://github.com/open-feature/java-sdk/commit/0a27a77fc1b46355eb382cb17177e2fbe2e69631)) + + +### ๐Ÿงน Chore + +* add changelog sections ([#320](https://github.com/open-feature/java-sdk/issues/320)) ([cb18a09](https://github.com/open-feature/java-sdk/commit/cb18a099c5f28fe05a5e9dfc62543f1f78c47603)) +* **deps:** update actions/cache digest to 69d9d44 ([#303](https://github.com/open-feature/java-sdk/issues/303)) ([45d3c0f](https://github.com/open-feature/java-sdk/commit/45d3c0fcc1ed48bbda9caa81174a0f026808d38e)) +* **deps:** update actions/cache digest to 81b7281 ([#298](https://github.com/open-feature/java-sdk/issues/298)) ([4098bc8](https://github.com/open-feature/java-sdk/commit/4098bc86e8cb1c70c96bff443a0180d09d050866)) +* **deps:** update actions/cache digest to 940f3d7 ([#321](https://github.com/open-feature/java-sdk/issues/321)) ([ec8f129](https://github.com/open-feature/java-sdk/commit/ec8f129ffcf79b7e9d145a02c683ff7a7f951b01)) +* **deps:** update actions/cache digest to e0d6227 ([#311](https://github.com/open-feature/java-sdk/issues/311)) ([44443e4](https://github.com/open-feature/java-sdk/commit/44443e4e5424c09e75ade3f868b8e261cf355513)) +* **deps:** update actions/checkout digest to 27135e3 ([#323](https://github.com/open-feature/java-sdk/issues/323)) ([c4d7b71](https://github.com/open-feature/java-sdk/commit/c4d7b71f09b664f53830341ab11372db40201e07)) +* **deps:** update actions/setup-java digest to 0de5c66 ([#322](https://github.com/open-feature/java-sdk/issues/322)) ([71c5fc2](https://github.com/open-feature/java-sdk/commit/71c5fc2c0fa9e5e0ee9dfac0aa7ebcd19590d664)) +* **deps:** update actions/setup-java digest to 888b400 ([#326](https://github.com/open-feature/java-sdk/issues/326)) ([33ee57a](https://github.com/open-feature/java-sdk/commit/33ee57a862e021675c615f5b16d87418f49b0a8b)) +* **deps:** update amannn/action-semantic-pull-request digest to b6bca70 ([#292](https://github.com/open-feature/java-sdk/issues/292)) ([237a0bc](https://github.com/open-feature/java-sdk/commit/237a0bcbba91164ccb227ad934df86b14a4852fc)) +* **deps:** update codecov/codecov-action digest to 13d8b07 ([#325](https://github.com/open-feature/java-sdk/issues/325)) ([0f34a95](https://github.com/open-feature/java-sdk/commit/0f34a95174857c9f568204eea7405749c89a67ba)) +* **deps:** update codecov/codecov-action digest to 4b062cb ([#313](https://github.com/open-feature/java-sdk/issues/313)) ([579f8ab](https://github.com/open-feature/java-sdk/commit/579f8ab7504e108056642b71b070aba81ecc0327)) +* **deps:** update codecov/codecov-action digest to 83bb3d0 ([#295](https://github.com/open-feature/java-sdk/issues/295)) ([1b72aeb](https://github.com/open-feature/java-sdk/commit/1b72aeb0e09a84814df41aa2e5df9c873f21838e)) +* **deps:** update codecov/codecov-action digest to 9b87723 ([#327](https://github.com/open-feature/java-sdk/issues/327)) ([cbd4618](https://github.com/open-feature/java-sdk/commit/cbd4618871b408794c5dfc26cc5b53df3e8edd6f)) +* **deps:** update codecov/codecov-action digest to ce0bcc6 ([#304](https://github.com/open-feature/java-sdk/issues/304)) ([259a749](https://github.com/open-feature/java-sdk/commit/259a749a5f0c7069b3ed1c7e654324346d78356a)) +* **deps:** update dependency com.github.spotbugs:spotbugs-maven-plugin to v4.7.3.1 ([#306](https://github.com/open-feature/java-sdk/issues/306)) ([69a1a8f](https://github.com/open-feature/java-sdk/commit/69a1a8fad3e6a672b6f55ed72dd6a030a9856343)) +* **deps:** update dependency com.github.spotbugs:spotbugs-maven-plugin to v4.7.3.2 ([#308](https://github.com/open-feature/java-sdk/issues/308)) ([a8caae6](https://github.com/open-feature/java-sdk/commit/a8caae6e29d419d6f8a368dfd40c001be2c7b7eb)) +* **deps:** update dependency org.apache.maven.plugins:maven-compiler-plugin to v3.11.0 ([#310](https://github.com/open-feature/java-sdk/issues/310)) ([1d731f6](https://github.com/open-feature/java-sdk/commit/1d731f6fa317eb8efef74e76dfd9e57269da6e2b)) +* **deps:** update dependency org.apache.maven.plugins:maven-javadoc-plugin to v3.5.0 ([#299](https://github.com/open-feature/java-sdk/issues/299)) ([4296aa4](https://github.com/open-feature/java-sdk/commit/4296aa48bdc0177187071afb4ae08ac56eab0519)) +* **deps:** update dependency org.cyclonedx:cyclonedx-maven-plugin to v2.7.5 ([#301](https://github.com/open-feature/java-sdk/issues/301)) ([7459eaa](https://github.com/open-feature/java-sdk/commit/7459eaa028c270bc0b522263b4b3215d1feafe2d)) +* **deps:** update github/codeql-action digest to 204eada ([#328](https://github.com/open-feature/java-sdk/issues/328)) ([c92c271](https://github.com/open-feature/java-sdk/commit/c92c271f0900fa3d8f07876d075ef053642f80c1)) +* **deps:** update github/codeql-action digest to 237a258 ([#305](https://github.com/open-feature/java-sdk/issues/305)) ([883a4cd](https://github.com/open-feature/java-sdk/commit/883a4cd5151e776f947aab25372bfb69ec1b94f4)) +* **deps:** update github/codeql-action digest to 3dde1f3 ([#302](https://github.com/open-feature/java-sdk/issues/302)) ([59429ed](https://github.com/open-feature/java-sdk/commit/59429ed55d90954228d2a2c0a8df33000dc54393)) +* **deps:** update github/codeql-action digest to 6ef6e50 ([#314](https://github.com/open-feature/java-sdk/issues/314)) ([8ee4d89](https://github.com/open-feature/java-sdk/commit/8ee4d89c0b0d5397d870fa20d868d3139feddb0e)) +* **deps:** update github/codeql-action digest to 89c5165 ([#293](https://github.com/open-feature/java-sdk/issues/293)) ([c9f5899](https://github.com/open-feature/java-sdk/commit/c9f5899128718c02e0ae4ee71d823bbbae6a23b7)) +* **deps:** update github/codeql-action digest to 903be79 ([#309](https://github.com/open-feature/java-sdk/issues/309)) ([a3a9d0e](https://github.com/open-feature/java-sdk/commit/a3a9d0eafdb28d83ad0b0640f949c5dd5e6e685f)) +* **deps:** update github/codeql-action digest to a589d40 ([#312](https://github.com/open-feature/java-sdk/issues/312)) ([7b79bc8](https://github.com/open-feature/java-sdk/commit/7b79bc818aeef27244299dbab6fb66ee143e5f64)) +* **deps:** update github/codeql-action digest to e00cd12 ([#296](https://github.com/open-feature/java-sdk/issues/296)) ([7a19ac8](https://github.com/open-feature/java-sdk/commit/7a19ac84ce76ade7cd6d03a1fc7c9b3340e232a6)) +* **deps:** update github/codeql-action digest to e12a2ec ([#324](https://github.com/open-feature/java-sdk/issues/324)) ([7753bfe](https://github.com/open-feature/java-sdk/commit/7753bfec07985a28195d6dc41feca39e925e03ca)) +* **deps:** update github/codeql-action digest to e4b846c ([#318](https://github.com/open-feature/java-sdk/issues/318)) ([db11450](https://github.com/open-feature/java-sdk/commit/db114507da17c637aedac3b5c48ecbf0f758a9d5)) +* **deps:** update github/codeql-action digest to f13b180 ([#319](https://github.com/open-feature/java-sdk/issues/319)) ([20a9da6](https://github.com/open-feature/java-sdk/commit/20a9da619486f02d775f132f20a2ccfa834f4fba)) +* **deps:** update google-github-actions/release-please-action digest to 57bb5dc ([#315](https://github.com/open-feature/java-sdk/issues/315)) ([80fe25a](https://github.com/open-feature/java-sdk/commit/80fe25ae285a484c82567baf5293bdb13c7a771e)) +* **deps:** update google-github-actions/release-please-action digest to d3c71f9 ([#297](https://github.com/open-feature/java-sdk/issues/297)) ([514a99e](https://github.com/open-feature/java-sdk/commit/514a99e5ad34afed15b6b0997cd55668abfaff6e)) +* **deps:** update google-github-actions/release-please-action digest to e0b9d18 ([#317](https://github.com/open-feature/java-sdk/issues/317)) ([09824e7](https://github.com/open-feature/java-sdk/commit/09824e7c529d36b84086ee4287e97ba1bd60ba6e)) + ## [1.2.0](https://github.com/open-feature/java-sdk/compare/v1.1.0...v1.2.0) (2023-02-10) diff --git a/README.md b/README.md index 5ac1e6ea..3ce5738b 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ For complete documentation, visit: https://docs.openfeature.dev/docs/category/co dev.openfeature sdk - 1.2.0 + 1.3.0 ``` @@ -92,7 +92,7 @@ If you would like snapshot builds, this is the relevant repository information: ```groovy dependencies { - implementation 'dev.openfeature:sdk:1.2.0' + implementation 'dev.openfeature:sdk:1.3.0' } ``` diff --git a/pom.xml b/pom.xml index 930d2b84..0311e798 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ dev.openfeature sdk - 1.2.0 + 1.3.0 UTF-8 @@ -189,7 +189,7 @@ org.cyclonedx cyclonedx-maven-plugin - 2.7.4 + 2.7.5 library 1.3 @@ -243,7 +243,7 @@ maven-compiler-plugin - 3.10.1 + 3.11.0 @@ -367,7 +367,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.4.1 + 3.5.0 true all,-missing @@ -418,7 +418,7 @@ com.github.spotbugs spotbugs-maven-plugin - 4.7.3.0 + 4.7.3.2 spotbugs-exclusions.xml diff --git a/release-please-config.json b/release-please-config.json index 6ebfa182..66c7193d 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -12,7 +12,61 @@ "extra-files": [ "pom.xml", "README.md" + ], + "changelog-sections": [ + { + "type": "fix", + "section": "๐Ÿ› Bug Fixes" + }, + { + "type": "feat", + "section": "โœจ New Features" + }, + { + "type": "chore", + "section": "๐Ÿงน Chore" + }, + { + "type": "docs", + "section": "๐Ÿ“š Documentation" + }, + { + "type": "perf", + "section": "๐Ÿš€ Performance" + }, + { + "type": "build", + "hidden": true, + "section": "๐Ÿ› ๏ธ Build" + }, + { + "type": "deps", + "section": "๐Ÿ“ฆ Dependencies" + }, + { + "type": "ci", + "hidden": true, + "section": "๐Ÿšฆ CI" + }, + { + "type": "refactor", + "section": "๐Ÿ”„ Refactoring" + }, + { + "type": "revert", + "section": "๐Ÿ”™ Reverts" + }, + { + "type": "style", + "hidden": true, + "section": "๐ŸŽจ Styling" + }, + { + "type": "test", + "hidden": true, + "section": "๐Ÿงช Tests" + } ] } } -} \ No newline at end of file +} diff --git a/src/main/java/dev/openfeature/sdk/EvaluationContext.java b/src/main/java/dev/openfeature/sdk/EvaluationContext.java index 10a7ea17..02fc2401 100644 --- a/src/main/java/dev/openfeature/sdk/EvaluationContext.java +++ b/src/main/java/dev/openfeature/sdk/EvaluationContext.java @@ -7,12 +7,6 @@ @SuppressWarnings("PMD.BeanMembersShouldSerialize") public interface EvaluationContext extends Structure { String getTargetingKey(); - - /** - * Mutating targeting key is not supported in all implementations and will be removed. - */ - @Deprecated - void setTargetingKey(String targetingKey); /** * Merges this EvaluationContext object with the second overriding the this in diff --git a/src/main/java/dev/openfeature/sdk/ImmutableContext.java b/src/main/java/dev/openfeature/sdk/ImmutableContext.java index 3fb25c28..486e789e 100644 --- a/src/main/java/dev/openfeature/sdk/ImmutableContext.java +++ b/src/main/java/dev/openfeature/sdk/ImmutableContext.java @@ -58,15 +58,6 @@ public ImmutableContext(String targetingKey, Map attributes) { this.targetingKey = targetingKey; } - /** - * Mutating targeting key is not supported in ImmutableContext and will be removed. - */ - @Override - @Deprecated - public void setTargetingKey(String targetingKey) { - throw new UnsupportedOperationException("changing of targeting key is not allowed"); - } - /** * Merges this EvaluationContext object with the passed EvaluationContext, overriding in case of conflict. * diff --git a/src/main/java/dev/openfeature/sdk/ImmutableStructure.java b/src/main/java/dev/openfeature/sdk/ImmutableStructure.java index 2dc2cdaf..731a55b1 100644 --- a/src/main/java/dev/openfeature/sdk/ImmutableStructure.java +++ b/src/main/java/dev/openfeature/sdk/ImmutableStructure.java @@ -50,7 +50,7 @@ public Set keySet() { @Override public Value getValue(String key) { Value value = this.attributes.get(key); - return value.clone(); + return value != null ? value.clone() : null; } /** diff --git a/src/main/java/dev/openfeature/sdk/Structure.java b/src/main/java/dev/openfeature/sdk/Structure.java index 9d66c2be..f8b55212 100644 --- a/src/main/java/dev/openfeature/sdk/Structure.java +++ b/src/main/java/dev/openfeature/sdk/Structure.java @@ -56,12 +56,13 @@ default Object convertValue(Value value) { return value.asBoolean(); } - if (value.isNumber()) { - Double valueAsDouble = value.asDouble(); - if (valueAsDouble == Math.floor(valueAsDouble) && !Double.isInfinite(valueAsDouble)) { - return value.asInteger(); + if (value.isNumber() && !value.isNull()) { + Number numberValue = (Number) value.asObject(); + if (numberValue instanceof Double) { + return numberValue.doubleValue(); + } else if (numberValue instanceof Integer) { + return numberValue.intValue(); } - return valueAsDouble; } if (value.isString()) { diff --git a/src/main/java/dev/openfeature/sdk/Value.java b/src/main/java/dev/openfeature/sdk/Value.java index b1ad1c15..f4ad909d 100644 --- a/src/main/java/dev/openfeature/sdk/Value.java +++ b/src/main/java/dev/openfeature/sdk/Value.java @@ -35,8 +35,7 @@ public Value() { * (boolean, string, int, double, list, structure, instant) */ public Value(Object value) throws InstantiationException { - // integer is a special case, convert those. - this.innerObject = value instanceof Integer ? ((Integer)value).doubleValue() : value; + this.innerObject = value; if (!this.isNull() && !this.isBoolean() && !this.isString() @@ -61,7 +60,7 @@ public Value(String value) { } public Value(Integer value) { - this.innerObject = value.doubleValue(); + this.innerObject = value; } public Value(Double value) { @@ -113,7 +112,7 @@ public boolean isString() { * @return boolean */ public boolean isNumber() { - return this.innerObject instanceof Double; + return this.innerObject instanceof Number; } /** @@ -187,8 +186,8 @@ public String asString() { * @return Integer */ public Integer asInteger() { - if (this.isNumber()) { - return (int)Math.round((Double)this.innerObject); + if (this.isNumber() && !this.isNull()) { + return ((Number)this.innerObject).intValue(); } return null; } @@ -199,8 +198,8 @@ public Integer asInteger() { * @return Double */ public Double asDouble() { - if (this.isNumber()) { - return (Double)this.innerObject; + if (this.isNumber() && !isNull()) { + return ((Number)this.innerObject).doubleValue(); } return null; } diff --git a/src/test/java/dev/openfeature/sdk/EvalContextTest.java b/src/test/java/dev/openfeature/sdk/EvalContextTest.java index d2fbb3ac..29fd0898 100644 --- a/src/test/java/dev/openfeature/sdk/EvalContextTest.java +++ b/src/test/java/dev/openfeature/sdk/EvalContextTest.java @@ -164,8 +164,8 @@ public class EvalContextTest { @Test void merge_targeting_key() { String key1 = "key1"; - EvaluationContext ctx1 = new MutableContext(key1); - EvaluationContext ctx2 = new MutableContext(); + MutableContext ctx1 = new MutableContext(key1); + MutableContext ctx2 = new MutableContext(); EvaluationContext ctxMerged = ctx1.merge(ctx2); assertEquals(key1, ctxMerged.getTargetingKey()); diff --git a/src/test/java/dev/openfeature/sdk/ImmutableContextTest.java b/src/test/java/dev/openfeature/sdk/ImmutableContextTest.java index 437e4922..df5784b6 100644 --- a/src/test/java/dev/openfeature/sdk/ImmutableContextTest.java +++ b/src/test/java/dev/openfeature/sdk/ImmutableContextTest.java @@ -12,13 +12,6 @@ class ImmutableContextTest { - @Test - @DisplayName("Mutating targeting key is not allowed on Immutable Context") - void shouldThrowUnsupportedExceptionWhenMutatingTargetingKey() { - EvaluationContext ctx = new ImmutableContext("targeting key", new HashMap<>()); - assertThrows(UnsupportedOperationException.class, () -> ctx.setTargetingKey("")); - } - @DisplayName("attributes mutation should not affect the immutable context") @Test void shouldCreateCopyOfAttributesForImmutableContext() { diff --git a/src/test/java/dev/openfeature/sdk/ImmutableStructureTest.java b/src/test/java/dev/openfeature/sdk/ImmutableStructureTest.java index ff5f7afe..49cd236a 100644 --- a/src/test/java/dev/openfeature/sdk/ImmutableStructureTest.java +++ b/src/test/java/dev/openfeature/sdk/ImmutableStructureTest.java @@ -10,11 +10,7 @@ import java.util.Map; import java.util.Set; -import static org.junit.jupiter.api.Assertions.assertArrayEquals; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotSame; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.*; class ImmutableStructureTest { @Test void noArgShouldContainEmptyAttributes() { @@ -108,4 +104,11 @@ void ModifyingTheValuesReturnByTheKeySetMethodShouldNotModifyTheUnderlyingImmuta keys.remove("key1"); assertEquals(2, structure.keySet().size()); } + + @Test + void GettingAMissingValueShouldReturnNull() { + ImmutableStructure structure = new ImmutableStructure(); + Object value = structure.getValue("missing"); + assertNull(value); + } } diff --git a/src/test/java/dev/openfeature/sdk/ValueTest.java b/src/test/java/dev/openfeature/sdk/ValueTest.java index cf25e7b3..aa6ac62f 100644 --- a/src/test/java/dev/openfeature/sdk/ValueTest.java +++ b/src/test/java/dev/openfeature/sdk/ValueTest.java @@ -66,11 +66,11 @@ class Something {} } @Test public void numericArgShouldReturnDoubleOrInt() { - double innerDoubleValue = .75; + double innerDoubleValue = 1.75; Value doubleValue = new Value(innerDoubleValue); assertTrue(doubleValue.isNumber()); - assertEquals(1, doubleValue.asInteger()); // should be rounded - assertEquals(.75, doubleValue.asDouble()); + assertEquals(1, doubleValue.asInteger()); // the double value represented by this object converted to type int + assertEquals(1.75, doubleValue.asDouble()); int innerIntValue = 100; Value intValue = new Value(innerIntValue); diff --git a/version.txt b/version.txt index 26aaba0e..f0bb29e7 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.2.0 +1.3.0