MongoTogglzRepository extends AbstractMongoRepository<String, FeatureState> implements StateRepository { @Override public FeatureState getFeatureState(final Feature feature) { final Optional<FeatureState> featureState = findOne(feature.name()); return featureState.orElse(null); } MongoTogglzRepository(final MongoDatabase mongoDatabase,
                                 final FeatureClassProvider featureClassProvider,
                                 final UserProvider userProvider,
                                 final MongoProperties mongoProperties); @Override FeatureState getFeatureState(final Feature feature); @Override void setFeatureState(final FeatureState featureState);  }
@Test public void shouldLoadFeatureState() { final FeatureState featureState = new FeatureState(TestFeatures.TEST_FEATURE_1); featureState.setEnabled(true); featureState.setStrategyId("someStrategy"); featureState.setParameter("someKey1", "someValue1"); featureState.setParameter("someKey2", "someValue2"); testee.create(featureState); final FeatureState loadedFeatureState = testee.getFeatureState(TestFeatures.TEST_FEATURE_1); assertThat(loadedFeatureState.getFeature(), is(TestFeatures.TEST_FEATURE_1)); assertThat(loadedFeatureState.getStrategyId(), is("someStrategy")); assertThat(loadedFeatureState.isEnabled(), is(true)); assertThat(loadedFeatureState.getParameter("someKey1"), is("someValue1")); assertThat(loadedFeatureState.getParameter("someKey2"), is("someValue2")); }