Search in sources :

Example 6 with Resource

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, "));
}
Also used : Resource(com.thoughtworks.go.config.Resource) Resources(com.thoughtworks.go.config.Resources) Test(org.junit.Test)

Example 7 with Resource

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));
}
Also used : Resource(com.thoughtworks.go.config.Resource) Resources(com.thoughtworks.go.config.Resources) Test(org.junit.Test)

Example 8 with Resource

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())));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Resource(com.thoughtworks.go.config.Resource) Test(org.junit.Test)

Example 9 with Resource

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())));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Resource(com.thoughtworks.go.config.Resource) Test(org.junit.Test)

Example 10 with Resource

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;
}
Also used : Resource(com.thoughtworks.go.config.Resource)

Aggregations

Resource (com.thoughtworks.go.config.Resource)18 Test (org.junit.Test)16 Resources (com.thoughtworks.go.config.Resources)13 JobInstance (com.thoughtworks.go.domain.JobInstance)3 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 ArrayList (java.util.ArrayList)1