use of com.thoughtworks.go.config.Resource in project gocd by gocd.
the class ResourcesTest method shouldReturnListOfResoucesAsCommaSeperatedList.
@Test
public void shouldReturnListOfResoucesAsCommaSeperatedList() {
Resources actual = new Resources();
actual.add(new Resource(" a "));
actual.add(new Resource(" b"));
actual.add(new Resource("c"));
assertThat(actual.exportToCsv(), is("a, b, c, "));
}
use of com.thoughtworks.go.config.Resource in project gocd by gocd.
the class ResourcesTest method shouldNotBeAbleToAddResourceWithWhiteSpaceAsName.
@Test
public void shouldNotBeAbleToAddResourceWithWhiteSpaceAsName() {
Resources actual = new Resources();
actual.add(new Resource(" "));
assertThat(actual.size(), is(0));
}
use of com.thoughtworks.go.config.Resource in project gocd by gocd.
the class ResourceRepositoryIntegrationTest method shouldSaveACopyOfAResource.
@Test
public void shouldSaveACopyOfAResource() {
// Arrange
JobInstance firstJobInstance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME + "1"));
JobInstance secondJobInstance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME + "2"));
Resource resource = new Resource("something");
// Act
Resource resourceOfFirstJob = resourceRepository.saveCopyOf(firstJobInstance.getId(), resource);
Resource resourceOfSecondJob = resourceRepository.saveCopyOf(secondJobInstance.getId(), resource);
// Assert
List<Resource> firstJobResources = resourceRepository.findByBuildId(firstJobInstance.getId());
assertThat(firstJobResources.size(), is(1));
assertThat(firstJobResources.get(0).getId(), equalTo(resourceOfFirstJob.getId()));
assertThat(firstJobResources, hasItem(resourceOfFirstJob));
List<Resource> secondJobResources = resourceRepository.findByBuildId(secondJobInstance.getId());
assertThat(secondJobResources.size(), is(1));
assertThat(secondJobResources, hasItem(resourceOfSecondJob));
assertThat(resourceOfFirstJob.getId(), not(equalTo(resourceOfSecondJob.getId())));
}
use of com.thoughtworks.go.config.Resource in project gocd by gocd.
the class ResourceRepositoryIntegrationTest method shouldSaveResource.
@Test
public void shouldSaveResource() {
// Arrange
JobInstance jobInstance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME));
Resource resource = new Resource("something");
resource.setBuildId(jobInstance.getId());
// Act
resourceRepository.save(resource);
// Assert
assertThat(resource.getId(), is(not(nullValue())));
}
use of com.thoughtworks.go.config.Resource in project gocd by gocd.
the class AgentInstance method createFromConfig.
public static AgentInstance createFromConfig(AgentConfig agentInConfig, SystemEnvironment systemEnvironment) {
AgentType type = agentInConfig.isFromLocalHost() ? AgentType.LOCAL : AgentType.REMOTE;
AgentInstance result = new AgentInstance(agentInConfig, type, systemEnvironment);
result.agentConfigStatus = agentInConfig.isDisabled() ? AgentConfigStatus.Disabled : AgentConfigStatus.Enabled;
result.errors = new ConfigErrors();
result.errors.addAll(agentInConfig.errors());
for (Resource resource : agentInConfig.getResources()) {
result.errors.addAll(resource.errors());
}
return result;
}
Aggregations