use of com.thoughtworks.go.server.service.StubGoCache in project gocd by gocd.
the class UserSqlMapDaoTest method setUp.
@Before
public void setUp() {
initMocks(this);
goCache = new StubGoCache(new TestTransactionSynchronizationManager());
dao = new UserSqlMapDao(sessionFactory, transactionTemplate, goCache, transactionSynchronizationManager);
}
use of com.thoughtworks.go.server.service.StubGoCache 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.service.StubGoCache in project gocd by gocd.
the class FeatureToggleServiceTest method shouldCacheFeatureToggleStatus.
@Test
public void shouldCacheFeatureToggleStatus() 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();
service.allToggles();
service.isToggleOn("key1");
service.isToggleOn("someOtherKey");
verify(repository, times(1)).availableToggles();
}
use of com.thoughtworks.go.server.service.StubGoCache in project gocd by gocd.
the class StageSqlMapDaoTest method setUp.
@Before
public void setUp() {
goCache = new StubGoCache(new TestTransactionSynchronizationManager());
sqlMapClientTemplate = mock(SqlMapClientTemplate.class);
stageSqlMapDao = new StageSqlMapDao(mock(JobInstanceSqlMapDao.class), new Cache(true, false, false), mock(TransactionTemplate.class), mock(SqlMapClient.class), goCache, mock(TransactionSynchronizationManager.class), mock(SystemEnvironment.class), null);
stageSqlMapDao.setSqlMapClientTemplate(sqlMapClientTemplate);
cloner = mock(Cloner.class);
ReflectionUtil.setField(stageSqlMapDao, "cloner", cloner);
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
return invocationOnMock.getArguments()[0];
}
}).when(cloner).deepClone(anyObject());
}
Aggregations