use of com.thoughtworks.go.server.domain.support.toggle.FeatureToggle in project gocd by gocd.
the class FeatureToggleRepositoryTest method shouldReadFeatureTogglesFromUsersTogglesFile.
@Test
public void shouldReadFeatureTogglesFromUsersTogglesFile() throws Exception {
FeatureToggle featureToggle1 = new FeatureToggle("key1", "desc1", true);
FeatureToggle featureToggle2 = new FeatureToggle("key2", "desc2", false);
setupUserToggles(featureToggle1, featureToggle2);
FeatureToggleRepository repository = new FeatureToggleRepository(environment);
assertThat(repository.userToggles(), is(new FeatureToggles(featureToggle1, featureToggle2)));
}
use of com.thoughtworks.go.server.domain.support.toggle.FeatureToggle in project gocd by gocd.
the class FeatureToggleServiceTest method shouldInvalidateCacheWhenAFeatureTogglesValueIsChanged.
@Test
public void shouldInvalidateCacheWhenAFeatureTogglesValueIsChanged() throws Exception {
when(repository.availableToggles()).thenReturn(new FeatureToggles(new FeatureToggle("key1", "desc1", true)));
when(repository.userToggles()).thenReturn(new FeatureToggles());
FeatureToggleService service = new FeatureToggleService(repository, new StubGoCache(new TestTransactionSynchronizationManager()));
service.allToggles();
verify(repository, times(1)).availableToggles();
service.changeValueOfToggle("key1", false);
verify(repository, times(1)).availableToggles();
service.allToggles();
verify(repository, times(2)).availableToggles();
}
use of com.thoughtworks.go.server.domain.support.toggle.FeatureToggle in project gocd by gocd.
the class FeatureToggleServiceTest method shouldListAllFeatureToggles.
@Test
public void shouldListAllFeatureToggles() throws Exception {
FeatureToggles existingToggles = new FeatureToggles(new FeatureToggle("key1", "description1", true), new FeatureToggle("key2", "description2", false));
when(repository.availableToggles()).thenReturn(existingToggles);
when(repository.userToggles()).thenReturn(new FeatureToggles());
FeatureToggleService service = new FeatureToggleService(repository, goCache);
assertThat(service.allToggles(), is(existingToggles));
}
use of com.thoughtworks.go.server.domain.support.toggle.FeatureToggle in project gocd by gocd.
the class FeatureToggleServiceTest method shouldAllowChangingValueOfAValidFeatureToggle.
@Test
public void shouldAllowChangingValueOfAValidFeatureToggle() throws Exception {
FeatureToggle availableToggle1 = new FeatureToggle("key1", "desc1", true);
when(repository.availableToggles()).thenReturn(new FeatureToggles(availableToggle1));
when(repository.userToggles()).thenReturn(new FeatureToggles());
FeatureToggleService service = new FeatureToggleService(repository, goCache);
service.changeValueOfToggle("key1", false);
verify(repository).changeValueOfToggle("key1", false);
}
use of com.thoughtworks.go.server.domain.support.toggle.FeatureToggle in project gocd by gocd.
the class FeatureToggleServiceTest method shouldKnowWhetherAToggleIsOnOrOff.
@Test
public void shouldKnowWhetherAToggleIsOnOrOff() throws Exception {
FeatureToggles existingToggles = new FeatureToggles(new FeatureToggle("key1", "description1", true), new FeatureToggle("key2", "description2", false));
when(repository.availableToggles()).thenReturn(existingToggles);
when(repository.userToggles()).thenReturn(new FeatureToggles());
FeatureToggleService service = new FeatureToggleService(repository, goCache);
assertThat(service.isToggleOn("key1"), is(true));
assertThat(service.isToggleOn("key2"), is(false));
}
Aggregations