Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added GetAllFeatureVariables API and NotificationListener support #217

Merged
merged 35 commits into from
May 21, 2020

Conversation

mnoman09
Copy link
Contributor

@mnoman09 mnoman09 commented May 13, 2020

Summary

  • Added getAllFeatureVariables Api which Get the values of all variables in the feature
  • Decision Notification of type all-feature-variable is getting sent in getAllFeatureVariables API.
  • Sending map of optimizely json in decision notification of type all-feature-variable

Test Plan

  • FSC should pass with FEATURE_JSON tag.
  • Updated unit tests accordingly.

mnoman09 and others added 30 commits April 29, 2020 21:48
# Conflicts:
#	OptimizelySDK.Tests/OptimizelyJsonTest.cs
Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove irrelevant test cases. Also Use proper Optimizely constructor, don't use reflection until it's really necessary.

@@ -1789,6 +1789,9 @@ public void TestUnsupportedVariableType()
var featureVariableStringRandomType = Optimizely.GetFeatureVariableString("", "any_key", TestUserId);
Assert.IsNull(featureVariableStringRandomType);

var featureVariableStringJsonType = Optimizely.GetFeatureVariableString("unsupported_variabletype", "string_json_key", TestUserId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the point to add test here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was an old test which was testing that getFeatureVariableString will return string value even when given json as subtype but this is no longer the case here. So now if the sub type is JSON and we will call getFeatureVariableString to get that variable, it will return null because type will not be matched.


var optly = Helper.CreatePrivateOptimizely();

optly.SetFieldOrProperty("ProjectConfigManager", ConfigManager);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why we are using reflection to instantiate optimizely instance. please explain

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is to set decisionservice object to decisionserviceMock object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it.

var result = (OptimizelyJson)optly.Invoke("GetAllFeatureVariables", null, TestUserId, userAttributes);
Assert.Null(result);

LoggerMock.Verify(log => log.Log(LogLevel.WARN, "The featureKey parameter must be nonnull."), Times.Once);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nonnull or not-null @pawels-optimizely need suggestion.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannot be null


var featureFlag = Config.GetFeatureFlagFromKey(featureKey);

var decision = new FeatureDecision(experiment, null, FeatureDecision.DECISION_SOURCE_ROLLOUT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why variation is null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To verify info log that ""User "" + TestUserId + "" was not bucketed into any variation for feature flag "" + featureKey + "". The default values are being returned.""


DecisionServiceMock.Setup(ds => ds.GetVariationForFeature(featureFlag, TestUserId, Config, userAttributes)).Returns(decision);

var optly = Helper.CreatePrivateOptimizely();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revise it.

}

[Test]
public void TestGetAllFeatureVariablesValid()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean valid?

Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -1788,7 +1788,7 @@ public void TestUnsupportedVariableType()
{
var featureVariableStringRandomType = Optimizely.GetFeatureVariableString("", "any_key", TestUserId);
Assert.IsNull(featureVariableStringRandomType);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove spacing.


var optly = Helper.CreatePrivateOptimizely();

optly.SetFieldOrProperty("ProjectConfigManager", ConfigManager);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it.

Copy link

@pawels-optimizely pawels-optimizely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants