Search in sources :

Example 6 with FeatureToggle

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)));
}
Also used : FeatureToggles(com.thoughtworks.go.server.domain.support.toggle.FeatureToggles) FeatureToggle(com.thoughtworks.go.server.domain.support.toggle.FeatureToggle) Test(org.junit.Test)

Example 7 with FeatureToggle

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();
}
Also used : FeatureToggles(com.thoughtworks.go.server.domain.support.toggle.FeatureToggles) FeatureToggle(com.thoughtworks.go.server.domain.support.toggle.FeatureToggle) StubGoCache(com.thoughtworks.go.server.service.StubGoCache) TestTransactionSynchronizationManager(com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager) Test(org.junit.Test)

Example 8 with FeatureToggle

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));
}
Also used : FeatureToggles(com.thoughtworks.go.server.domain.support.toggle.FeatureToggles) FeatureToggle(com.thoughtworks.go.server.domain.support.toggle.FeatureToggle) Test(org.junit.Test)

Example 9 with FeatureToggle

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);
}
Also used : FeatureToggles(com.thoughtworks.go.server.domain.support.toggle.FeatureToggles) FeatureToggle(com.thoughtworks.go.server.domain.support.toggle.FeatureToggle) Test(org.junit.Test)

Example 10 with FeatureToggle

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));
}
Also used : FeatureToggles(com.thoughtworks.go.server.domain.support.toggle.FeatureToggles) FeatureToggle(com.thoughtworks.go.server.domain.support.toggle.FeatureToggle) Test(org.junit.Test)

Aggregations

FeatureToggle (com.thoughtworks.go.server.domain.support.toggle.FeatureToggle)14 Test (org.junit.Test)14 FeatureToggles (com.thoughtworks.go.server.domain.support.toggle.FeatureToggles)13 File (java.io.File)3 StubGoCache (com.thoughtworks.go.server.service.StubGoCache)2 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)2