Skip to content

Commit

Permalink
zero value and events tests fixing formatting deleting unused classes
Browse files Browse the repository at this point in the history
Signed-off-by: DBlanchard88 <DBlanchard88@github.com>
  • Loading branch information
DBlanchard88 authored and DBlanchard88 committed Oct 1, 2023
1 parent 37d587a commit 7e160ad
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 43 deletions.
24 changes: 12 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,24 @@
</dependency>

<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.14.0</version>
<scope>test</scope>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>7.14.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>7.14.0</version>
<scope>test</scope>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<version>7.14.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.0</version>
<scope>test</scope>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<!-- end test -->
</dependencies>
Expand Down
8 changes: 4 additions & 4 deletions providers/flagd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,10 @@
<goal>exec</goal>
</goals>
<configuration>
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
<!-- run: cp test-harness/features/evaluation.feature src/test/resources/features/ -->
<executable>cp</executable>
<arguments>
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
<!-- run: cp test-harness/features/evaluation.feature src/test/resources/features/ -->
<executable>cp</executable>
<arguments>
<argument>test-harness/gherkin/flagd.feature</argument>
<argument>src/test/resources/features/</argument>
</arguments>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package dev.openfeature.contrib.providers.flagd.e2e.steps;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.atMost;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -129,13 +127,13 @@ public void a_string_flag_with_key_is_evaluated_with_default_value(String flagKe
this.stringFlagKey = flagKey;
this.stringFlagDefaultValue = defaultValue;
}

@Then("the resolved string value should be {string}")
public void the_resolved_string_value_should_be(String expected) {
String value = client.getStringValue(this.stringFlagKey, this.stringFlagDefaultValue);
assertEquals(expected, value);
}

// integer value
@When("an integer flag with key {string} is evaluated with default value {int}")
public void an_integer_flag_with_key_is_evaluated_with_default_value(String flagKey, Integer defaultValue) {
Expand Down Expand Up @@ -385,46 +383,48 @@ public void a_context_containing_a_key_with_value(String key, String value) {

@Then("the returned value should be {string}")
public void the_returned_value_should_be(String expected) {
String value = client.getStringValue(this.stringFlagKey, this.stringFlagDefaultValue, this.customEvaluatorContext);
String value = client.getStringValue(this.stringFlagKey, this.stringFlagDefaultValue,
this.customEvaluatorContext);
assertEquals(expected, value);
}

/*
* Events
*/

// Flag change event
// Flag change event
@When("a PROVIDER_CONFIGURATION_CHANGED handler is added")
public void a_provider_configuration_changed_handler_is_added() {
this.changeHandler = (EventDetails details) -> {
this.changeHandler = (EventDetails details) -> {
this.isChangeHandlerRun = true;
};
client.onProviderConfigurationChanged(this.changeHandler);

}

@When("a flag with key {string} is modified")
public void a_flag_with_key_is_modified(String flagKey) {
//This happens automatically
// This happens automatically
}

@Then("the PROVIDER_CONFIGURATION_CHANGED handler must run")
public void the_provider_configuration_changed_handler_must_run() {
Awaitility.await()
.atMost(Duration.ofSeconds(2))
.until(() -> {
return this.isChangeHandlerRun;
});
.atMost(Duration.ofSeconds(2))
.until(() -> {
return this.isChangeHandlerRun;
});
}

@Then("the event details must indicate {string} was altered")
public void the_event_details_must_indicate_was_altered(String flagKey) {
//TODO: In-process-provider doesnt support flag change list.
// TODO: In-process-provider doesnt support flag change list.
}

// Provider ready event
@When("a PROVIDER_READY handler is added")
public void a_provider_ready_handler_is_added() {
this.readyHandler = (EventDetails details) -> {
this.readyHandler = (EventDetails details) -> {
this.isReadyHandlerRun = true;
};
client.onProviderReady(this.readyHandler);
Expand All @@ -433,47 +433,53 @@ public void a_provider_ready_handler_is_added() {
@Then("the PROVIDER_READY handler must run")
public void the_provider_ready_handler_must_run() {
Awaitility.await()
.atMost(Duration.ofSeconds(2))
.until(() -> {
return this.isReadyHandlerRun;
});
.atMost(Duration.ofSeconds(2))
.until(() -> {
return this.isReadyHandlerRun;
});
}

/*
* Zero Value
*/
* Zero Value
*/

// boolean value
@When("a zero-value boolean flag with key {string} is evaluated with default value {string}")
public void a_zero_value_boolean_flag_with_key_is_evaluated_with_default_value(String flagKey, String defaultValue) {
public void a_zero_value_boolean_flag_with_key_is_evaluated_with_default_value(String flagKey,
String defaultValue) {
this.booleanFlagKey = flagKey;
this.booleanFlagDefaultValue = Boolean.valueOf(defaultValue);
}

@Then("the resolved boolean zero-value should be {string}")
public void the_resolved_boolean_zero_value_should_be(String expected) {
boolean value = client.getBooleanValue(this.booleanFlagKey, this.booleanFlagDefaultValue);
assertEquals(Boolean.valueOf(expected),value);
assertEquals(Boolean.valueOf(expected), value);
}

// float/double value
@When("a zero-value float flag with key {string} is evaluated with default value {double}")
public void a_zero_value_float_flag_with_key_is_evaluated_with_default_value(String flagKey, Double defaultValue) {
// TODO: There is a bug here with 0 value floats
// TODO: There is a bug here with 0 value floats
// this.doubleFlagKey = flagKey;
// this.doubleFlagDefaultValue = defaultValue;
// this.doubleFlagDefaultValue = defaultValue;
}

@Then("the resolved float zero-value should be {double}")
public void the_resolved_float_zero_value_should_be(Double expected) {
// FlagEvaluationDetails<Double> details = client.getDoubleDetails("float-zero-flag", this.doubleFlagDefaultValue);
// assertEquals(expected, details.getValue());
// FlagEvaluationDetails<Double> details =
// client.getDoubleDetails("float-zero-flag", this.doubleFlagDefaultValue);
// assertEquals(expected, details.getValue());
}

// integer value
@When("a zero-value integer flag with key {string} is evaluated with default value {int}")
public void a_zero_value_integer_flag_with_key_is_evaluated_with_default_value(String flagKey, Integer defaultValue) {
public void a_zero_value_integer_flag_with_key_is_evaluated_with_default_value(String flagKey,
Integer defaultValue) {
this.intFlagKey = flagKey;
this.intFlagDefaultValue = defaultValue;
}

@Then("the resolved integer zero-value should be {int}")
public void the_resolved_integer_zero_value_should_be(Integer expected) {
int value = client.getIntegerValue(this.intFlagKey, this.intFlagDefaultValue);
Expand All @@ -486,6 +492,7 @@ public void a_zero_value_string_flag_with_key_is_evaluated_with_default_value(St
this.stringFlagKey = flagKey;
this.stringFlagDefaultValue = defaultValue;
}

@Then("the resolved string zero-value should be {string}")
public void the_resolved_string_zero_value_should_be(String expected) {
String value = client.getStringValue(this.stringFlagKey, this.stringFlagDefaultValue);
Expand Down

0 comments on commit 7e160ad

Please sign in to comment.