-
Notifications
You must be signed in to change notification settings - Fork 32
(feat): Feature Management isFeatureEnabled Listener #271
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
Conversation
Pull Request Test Coverage Report for Build 901
💛 - Coveralls |
Pull Request Test Coverage Report for Build 974
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please point me to where confirmation is happening that notification listener is being called with correct parameters
@@ -24,7 +24,6 @@ | |||
import javax.annotation.Nonnull; | |||
import java.util.Map; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like an unnecessary change.
return key; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. remove extraneous line
* onDecision called when an activate was triggered | ||
* | ||
* @param type - The notification type. | ||
* @param userId - The userId passed into activate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the docstrings here as mentioned in the other PR.
|
||
verify(mockEventHandler, times(2)).dispatchEvent(any(LogEvent.class)); | ||
|
||
assertTrue(optimizely.notificationCenter.removeNotificationListener(notificationId)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the check for notification listener being called with correct params happening?
*/ | ||
@Override | ||
public final void notify(Object... args) { | ||
assert (args[0] instanceof String); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aliabbasrizvi here we added multiple assert checks which will throw exception if invalid arguments are passed and it will make sure that correct arguments are passed. so I think we dont need to add this in unit tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have type specific checks i.e. for type: experiment we should check decisionInfo
has correct experiment and variation key. Similarly for type: feature we should check decisionInfo
has correct data.
Can you point me to where such assertions are happening? If not, then we have incomplete tests.
...-api/src/main/java/com/optimizely/ab/notification/DecisionNotificationListenerInterface.java
Outdated
Show resolved
Hide resolved
…Listnr # Conflicts: # core-api/src/main/java/com/optimizely/ab/Optimizely.java # core-api/src/main/java/com/optimizely/ab/notification/DecisionNotificationListener.java # core-api/src/main/java/com/optimizely/ab/notification/NotificationCenter.java # core-api/src/test/java/com/optimizely/ab/OptimizelyTest.java # core-api/src/test/java/com/optimizely/ab/notification/NotificationCenterTest.java
testDecisionInfoMap.put(FEATURE_KEY, validFeatureKey); | ||
testDecisionInfoMap.put(FEATURE_ENABLED, true); | ||
testDecisionInfoMap.put(SOURCE, FeatureDecision.DecisionSource.ROLLOUT); | ||
testDecisionInfoMap.put(SOURCE_INFO, new HashMap<>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. fix indentation
.withFeatureEnabled(featureEnabled) | ||
.withSource(decisionSource) | ||
.withExperimentKey(sourceExperimentKey) | ||
.withVariationKey(sourceVariationKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be remove these 2 build options and replace with withSourceInfo
option which takes SourceInfo
object.
You can then define 2 implementations SourceInfo
. 1 for rollout and 1 for feature test and then use a get method on them to get the source info that you build in the builder here. That may be a better way to structure this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting to make methods of get source info in optimizely or in DecisionNotification.java?
By the way I think current implementation is much simpler and fully utilizing builder pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am suggesting something like:
public interface SourceInfo {
HashMap<String, Object> get()
}
public class FeatureTestSourceInfo implements SourceInfo {
}
public class RolloutSourceInfo implements SourceInfo {
}
This may allow us to hopefully add more SourceInfo
options in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed offline. This will happen in a follow up.
Synced with Mike offline. Going to go ahead with this.
Summary
##Ticket:
OASIS-4228