use of com.thoughtworks.go.server.service.GoConfigService in project gocd by gocd.
the class BuildCauseProducerServiceTest method shouldScheduleAfterAllMaterialsAreUpdated.
@Test
public void shouldScheduleAfterAllMaterialsAreUpdated() throws Exception {
HgMaterial hgMaterial = new HgMaterial("url", null);
HgMaterialConfig hgMaterialConfig = new HgMaterialConfig("url", null);
SvnMaterial svnMaterial = new SvnMaterial("url", null, null, false);
SvnMaterialConfig svnMaterialConfig = new SvnMaterialConfig("url", null, null, false);
pipelineConfig.addMaterialConfig(hgMaterialConfig);
pipelineConfig.addMaterialConfig(svnMaterialConfig);
GoConfigService service = mock(GoConfigService.class);
when(service.pipelineConfigNamed(pipelineConfig.name())).thenReturn(pipelineConfig);
when(materialConfigConverter.toMaterial(hgMaterialConfig)).thenReturn(hgMaterial);
when(materialConfigConverter.toMaterial(svnMaterialConfig)).thenReturn(svnMaterial);
MaterialUpdateStatusNotifier notifier = new MaterialUpdateStatusNotifier(mock(MaterialUpdateCompletedTopic.class));
buildCauseProducerService = spy(createBuildCauseProducerService(notifier));
buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), new ScheduleOptions(), new ServerHealthStateOperationResult());
final HashMap<String, String> stringStringHashMap = new HashMap<>();
doReturn(ServerHealthState.success(healthStateType)).when(buildCauseProducerService).newProduceBuildCause(eq(pipelineConfig), any(ManualBuild.class), new ScheduleOptions(eq(EMPTY_REVISIONS), stringStringHashMap, new HashMap<>()), any(ServerHealthStateOperationResult.class), eq(12345L));
assertThat(notifier.hasListenerFor(pipelineConfig), is(true));
notifier.onMessage(new MaterialUpdateSuccessfulMessage(hgMaterial, 1111L));
assertThat(notifier.hasListenerFor(pipelineConfig), is(true));
notifier.onMessage(new MaterialUpdateSuccessfulMessage(svnMaterial, 2222L));
assertThat(notifier.hasListenerFor(pipelineConfig), is(false));
verify(buildCauseProducerService).newProduceBuildCause(eq(pipelineConfig), any(ManualBuild.class), eq(new ScheduleOptions()), any(ServerHealthStateOperationResult.class), eq(2222L));
}
use of com.thoughtworks.go.server.service.GoConfigService in project gocd by gocd.
the class SecurityAuthConfigUpdateCommandTest method setUp.
@Before
public void setUp() throws Exception {
currentUser = new Username("bob");
goConfigService = mock(GoConfigService.class);
cruiseConfig = GoConfigMother.defaultCruiseConfig();
}
use of com.thoughtworks.go.server.service.GoConfigService in project gocd by gocd.
the class SCMMaterialSourceTest method setUp.
@Before
public void setUp() throws Exception {
goConfigService = mock(GoConfigService.class);
systemEnvironment = new SystemEnvironment();
serverHealthService = mock(ServerHealthService.class);
materialConfigConverter = mock(MaterialConfigConverter.class);
materialUpdateService = mock(MaterialUpdateService.class);
source = new SCMMaterialSource(goConfigService, systemEnvironment, materialConfigConverter, materialUpdateService);
}
use of com.thoughtworks.go.server.service.GoConfigService in project gocd by gocd.
the class IsSecurityEnabledVoterTest method shouldNotVoteAccessGrantedIfSecurityIsEnabledButAnonymousIsNot.
@Test
public void shouldNotVoteAccessGrantedIfSecurityIsEnabledButAnonymousIsNot() {
configHelper.addSecurityWithBogusLdapConfig(false);
GoConfigService configService = new GoConfigService(goConfigDao, null, new SystemTimeClock(), mock(GoConfigMigration.class), null, null, ConfigElementImplementationRegistryMother.withNoPlugins(), new InstanceFactory(), mock(CachedGoPartials.class), null);
IsSecurityEnabledVoter voter = new IsSecurityEnabledVoter(configService);
int accessStatus = voter.vote(null, null, null);
assertThat(accessStatus, Is.is(AccessDecisionVoter.ACCESS_ABSTAIN));
}
use of com.thoughtworks.go.server.service.GoConfigService in project gocd by gocd.
the class InvalidConfigMessageRemoverTest method shouldRemoveServerHealthServiceMessageAboutStartedWithInvalidConfigurationOnPipelineConfigSave.
@Test
public void shouldRemoveServerHealthServiceMessageAboutStartedWithInvalidConfigurationOnPipelineConfigSave() {
GoConfigService goConfigService = mock(GoConfigService.class);
ServerHealthService serverHealthService = mock(ServerHealthService.class);
ArgumentCaptor<ConfigChangedListener> configChangedListenerArgumentCaptor = ArgumentCaptor.forClass(ConfigChangedListener.class);
doNothing().when(goConfigService).register(configChangedListenerArgumentCaptor.capture());
InvalidConfigMessageRemover invalidConfigMessageRemover = new InvalidConfigMessageRemover(goConfigService, serverHealthService);
invalidConfigMessageRemover.initialize();
invalidConfigMessageRemover.onConfigChange(null);
List<ConfigChangedListener> listeners = configChangedListenerArgumentCaptor.getAllValues();
assertThat(listeners.get(1) instanceof EntityConfigChangedListener, is(true));
EntityConfigChangedListener listener = (EntityConfigChangedListener) listeners.get(1);
assertThat(listener.shouldCareAbout(mock(PipelineConfig.class)), is(true));
invalidConfigMessageRemover.pipelineConfigChangedListener().onEntityConfigChange(mock(PipelineConfig.class));
ArgumentCaptor<HealthStateScope> captor = ArgumentCaptor.forClass(HealthStateScope.class);
verify(serverHealthService).removeByScope(captor.capture());
assertThat(captor.getValue().compareTo(HealthStateScope.forInvalidConfig()), is(0));
}
Aggregations