Skip to content

Commit

Permalink
improve contribution guide and remove deprecation
Browse files Browse the repository at this point in the history
Signed-off-by: Kavindu Dodanduwa <[email protected]>
  • Loading branch information
Kavindu-Dodan committed Mar 22, 2024
1 parent 4bedb5a commit 441ced2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 28 deletions.
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ be a jerk.

We're not keen on vendor-specific stuff in this library, but if there are changes that need to happen in the spec to enable vendor-specific stuff in user code or other extension points, check out [the spec](https://github.com/open-feature/spec).

Any contributions you make are expected to be tested with unit tests. You can validate these work with `gradle test`, or the automation itself will run them for you when you make a PR.
Any contributions you make are expected to be tested with unit tests. You can validate these work with `mvn test`.
Further, it is recommended to verify code styling and static code analysis with `mvn verify -P !deploy`.
Regardless, the automation itself will run them for you when you open a PR.

Your code is supposed to work with Java 8+.

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<version>5.11.0</version>
<scope>test</scope>
</dependency>

Expand Down
10 changes: 3 additions & 7 deletions src/main/java/dev/openfeature/sdk/OpenFeatureClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,13 @@ public class OpenFeatureClient implements Client {
private EvaluationContext evaluationContext;

/**
* Deprecated public constructor. Use OpenFeature.API.getClient() instead.
*
* Create an OpenFeature client. For internal use only.
*
* @param openFeatureAPI Backing global singleton
* @param name Name of the client (used by observability tools).
* @param version Version of the client (used by observability tools).
* @deprecated Do not use this constructor. It's for internal use only.
* Clients created using it will not run event handlers.
* Use the OpenFeatureAPI's getClient factory method instead.
*/
@Deprecated() // TODO: eventually we will make this non-public
public OpenFeatureClient(OpenFeatureAPI openFeatureAPI, String name, String version) {
OpenFeatureClient(OpenFeatureAPI openFeatureAPI, String name, String version) {
this.openfeatureApi = openFeatureAPI;
this.name = name;
this.version = version;
Expand Down
35 changes: 17 additions & 18 deletions src/test/java/dev/openfeature/sdk/HookSpecTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
package dev.openfeature.sdk;

import dev.openfeature.sdk.fixtures.HookFixtures;
import dev.openfeature.sdk.testutils.FeatureProviderTestUtils;
import lombok.SneakyThrows;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -13,23 +29,6 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import dev.openfeature.sdk.testutils.FeatureProviderTestUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.InOrder;

import dev.openfeature.sdk.fixtures.HookFixtures;
import lombok.SneakyThrows;

class HookSpecTest implements HookFixtures {
@AfterEach
void emptyApiHooks() {
Expand Down Expand Up @@ -500,7 +499,7 @@ public void finallyAfter(HookContext<Boolean> ctx, Map<String, Object> hints) {
.hook(hook)
.build());

ArgumentCaptor<MutableContext> captor = ArgumentCaptor.forClass(MutableContext.class);
ArgumentCaptor<ImmutableContext> captor = ArgumentCaptor.forClass(ImmutableContext.class);
verify(provider).getBooleanEvaluation(any(), any(), captor.capture());
EvaluationContext ec = captor.getValue();
assertEquals("works", ec.getValue("test").asString());
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/dev/openfeature/sdk/fixtures/HookFixtures.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package dev.openfeature.sdk.fixtures;

import dev.openfeature.sdk.*;
import dev.openfeature.sdk.BooleanHook;
import dev.openfeature.sdk.DoubleHook;
import dev.openfeature.sdk.Hook;
import dev.openfeature.sdk.IntegerHook;
import dev.openfeature.sdk.StringHook;

import static org.mockito.Mockito.spy;

Expand Down

0 comments on commit 441ced2

Please sign in to comment.