Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
Signed-off-by: liran2000 <[email protected]>
  • Loading branch information
liran2000 committed Aug 14, 2023
1 parent 1e508ca commit 071fa03
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 21 deletions.
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ If you're adding tests to cover something in the spec, use the `@Specification`

The continuous integration runs a set of [gherkin e2e tests](https://github.com/open-feature/test-harness/blob/main/features/evaluation.feature) using `InMemoryProvider`.

to run alone:
```
mvn test -P e2e-test
```

## Releasing

See [releasing](./docs/release.md).
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/dev/openfeature/sdk/MutableStructure.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
import java.util.Set;
import java.util.stream.Collectors;

import static dev.openfeature.sdk.Value.objectToValue;

/**
* {@link MutableStructure} represents a potentially nested object type which is used to represent
* structured data.
Expand Down Expand Up @@ -110,17 +108,4 @@ public Map<String, Object> asObjectMap() {
e -> convertValue(getValue(e.getKey()))
));
}

/**
* Transform an object map to a {@link Structure} type.
*
* @param map map of objects
* @return a Structure object in the SDK format
*/
public static Structure mapToStructure(Map<String, Object> map) {
return new MutableStructure(
map.entrySet().stream()
.filter(e -> e.getValue() != null)
.collect(Collectors.toMap(Map.Entry::getKey, e -> objectToValue(e.getValue()))));
}
}
14 changes: 14 additions & 0 deletions src/main/java/dev/openfeature/sdk/Structure.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import static dev.openfeature.sdk.Value.objectToValue;

/**
* {@link Structure} represents a potentially nested object type which is used to represent
* structured data.
Expand Down Expand Up @@ -123,4 +125,16 @@ default <T extends Structure> Map<String, Value> merge(Function<Map<String, Valu
}
return merged;
}

/**
* Transform an object map to a {@link Structure} type.
*
* @param map map of objects
* @return a Structure object in the SDK format
*/
static Structure mapToStructure(Map<String, Object> map) {
return new MutableStructure(map.entrySet().stream()
.filter(e -> e.getValue() != null)
.collect(Collectors.toMap(Map.Entry::getKey, e -> objectToValue(e.getValue()))));
}
}
2 changes: 1 addition & 1 deletion src/main/java/dev/openfeature/sdk/Value.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import lombok.SneakyThrows;
import lombok.ToString;

import static dev.openfeature.sdk.MutableStructure.mapToStructure;
import static dev.openfeature.sdk.Structure.mapToStructure;

/**
* Values serve as a generic return type for structure data from providers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.Map;

/**
* Flag representation.
* Flag representation for the in-memory provider.
*/
@ToString
@Builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public InMemoryProvider(Map<String, Flag<?>> flags) {
public void initialize(EvaluationContext evaluationContext) throws Exception {
super.initialize(evaluationContext);
state = ProviderState.READY;
log.info("finished initializing provider, state: {}", state);
log.debug("finished initializing provider, state: {}", state);
ProviderEventDetails details = ProviderEventDetails.builder()
.message("provider is ready")
.build();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/dev/openfeature/sdk/StructureTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.List;
import java.util.Map;

import static dev.openfeature.sdk.MutableStructure.mapToStructure;
import static dev.openfeature.sdk.Structure.mapToStructure;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import static dev.openfeature.sdk.MutableStructure.mapToStructure;
import static dev.openfeature.sdk.Structure.mapToStructure;
import static dev.openfeature.sdk.testutils.TestFlagsUtils.buildFlags;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.HashMap;
import java.util.Map;

import static dev.openfeature.sdk.MutableStructure.mapToStructure;
import static dev.openfeature.sdk.Structure.mapToStructure;

/**
* Test flags utils.
Expand Down

0 comments on commit 071fa03

Please sign in to comment.