use of com.thoughtworks.go.util.Clock in project gocd by gocd.
the class TimeStampBasedCounterTest method shouldGetIncrementalTimeStampBasedOnSeed.
@Test
public void shouldGetIncrementalTimeStampBasedOnSeed() {
Clock clock = mock(Clock.class);
when(clock.currentTimeMillis()).thenReturn(1000L);
TimeStampBasedCounter timeStampBasedCounter = new TimeStampBasedCounter(clock);
assertThat(timeStampBasedCounter.getNext(), is(1001L));
assertThat(timeStampBasedCounter.getNext(), is(1002L));
}
use of com.thoughtworks.go.util.Clock in project gocd by gocd.
the class TimeStampBasedCounterTest method shouldAllow.
@Test
public void shouldAllow() throws InterruptedException {
ArrayList<Thread> list = new ArrayList<>();
Clock clock = mock(Clock.class);
when(clock.currentTimeMillis()).thenReturn(0L);
TimeStampBasedCounter provider = new TimeStampBasedCounter(clock);
for (int i = 0; i < 10; i++) {
int finalI = i;
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
provider.getNext();
// System.out.println("provider.getNext() = " + provider.getNext() + " id: " + finalI);
}
}, "Thread" + i);
list.add(thread);
}
for (Thread thread : list) {
thread.start();
}
for (Thread thread : list) {
thread.join();
}
}
use of com.thoughtworks.go.util.Clock in project gocd by gocd.
the class PipelineSelectionsServiceTest method setup.
@Before
public void setup() throws Exception {
new SystemEnvironment().setProperty(SystemEnvironment.ENFORCE_SERVER_IMMUTABILITY, "N");
goConfigDao = mock(GoConfigDao.class);
pipelineRepository = mock(PipelineRepository.class);
pipelinePauseService = mock(PipelinePauseService.class);
systemEnvironment = mock(SystemEnvironment.class);
cruiseConfig = unchangedConfig();
expectLoad(cruiseConfig);
this.clock = mock(Clock.class);
userDao = mock(UserDao.class);
stub(systemEnvironment.optimizeFullConfigSave()).toReturn(false);
ConfigElementImplementationRegistry registry = ConfigElementImplementationRegistryMother.withNoPlugins();
goConfigService = mock(GoConfigService.class);
pipelineSelectionsService = new PipelineSelectionsService(pipelineRepository, goConfigService, clock);
}
Aggregations