Search in sources :

Example 31 with PipelineSelections

use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.

the class PipelineSelectionsService method persistSelectedPipelines.

public long persistSelectedPipelines(String id, Long userId, List<String> selectedPipelines, boolean isBlacklist) {
    PipelineSelections pipelineSelections = findOrCreateCurrentPipelineSelectionsFor(id, userId);
    if (isBlacklist) {
        List<String> unselectedPipelines = invertSelections(selectedPipelines);
        pipelineSelections.update(unselectedPipelines, clock.currentTime(), userId, isBlacklist);
    } else {
        pipelineSelections.update(selectedPipelines, clock.currentTime(), userId, isBlacklist);
    }
    return pipelineRepository.saveSelectedPipelines(pipelineSelections);
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 32 with PipelineSelections

use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.

the class PipelineRepositoryIntegrationTest method shouldSaveSelectedPipelinesWithBlacklistPreferenceFalse.

@Test
public void shouldSaveSelectedPipelinesWithBlacklistPreferenceFalse() {
    User user = createUser();
    List<String> unSelected = Arrays.asList("pipeline1", "pipeline2");
    long id = pipelineRepository.saveSelectedPipelines(new PipelineSelections(unSelected, new Date(), user.getId(), false));
    assertThat(pipelineRepository.findPipelineSelectionsById(id).isBlacklist(), is(false));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Test(org.junit.Test)

Example 33 with PipelineSelections

use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.

the class PipelineRepositoryIntegrationTest method shouldSaveSelectedPipelinesWithBlacklistPreferenceTrue.

@Test
public void shouldSaveSelectedPipelinesWithBlacklistPreferenceTrue() {
    User user = createUser();
    List<String> unSelected = Arrays.asList("pipeline1", "pipeline2");
    long id = pipelineRepository.saveSelectedPipelines(new PipelineSelections(unSelected, new Date(), user.getId(), true));
    assertThat(pipelineRepository.findPipelineSelectionsById(id).isBlacklist(), is(true));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Test(org.junit.Test)

Example 34 with PipelineSelections

use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.

the class PipelineRepositoryIntegrationTest method shouldSaveSelectedPipelinesWithoutUserId.

@Test
public void shouldSaveSelectedPipelinesWithoutUserId() {
    Date date = new Date();
    List<String> unSelected = Arrays.asList("pipeline1", "pipeline2");
    long id = pipelineRepository.saveSelectedPipelines(new PipelineSelections(unSelected, date, null, true));
    PipelineSelections found = pipelineRepository.findPipelineSelectionsById(id);
    assertHasPipelines(found, new String[] { "pipeline3", "pipeline4" });
    assertHasPipelines(found, new String[] { "pipeline1", "pipeline2" }, false);
    assertThat(found.userId(), is(nullValue()));
    assertEquals(date, found.lastUpdated());
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) Test(org.junit.Test)

Example 35 with PipelineSelections

use of com.thoughtworks.go.server.domain.user.PipelineSelections in project gocd by gocd.

the class GoConfigService method persistSelectedPipelines.

public long persistSelectedPipelines(String id, Long userId, List<String> selectedPipelines, boolean isBlacklist) {
    PipelineSelections pipelineSelections = findOrCreateCurrentPipelineSelectionsFor(id, userId);
    if (isBlacklist) {
        List<String> unselectedPipelines = invertSelections(selectedPipelines);
        pipelineSelections.update(unselectedPipelines, clock.currentTime(), userId, isBlacklist);
    } else {
        pipelineSelections.update(selectedPipelines, clock.currentTime(), userId, isBlacklist);
    }
    return pipelineRepository.saveSelectedPipelines(pipelineSelections);
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections)

Aggregations

PipelineSelections (com.thoughtworks.go.server.domain.user.PipelineSelections)57 Test (org.junit.Test)44 DateTime (org.joda.time.DateTime)12 Username (com.thoughtworks.go.server.domain.Username)9 User (com.thoughtworks.go.domain.User)8 Date (java.util.Date)8 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)5 BaseMatcher (org.hamcrest.BaseMatcher)4 Description (org.hamcrest.Description)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 Permissions (com.thoughtworks.go.config.security.Permissions)2 PipelineInstanceModels.createPipelineInstanceModels (com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels.createPipelineInstanceModels)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 PipelineSelectionResponse (com.thoughtworks.go.apiv1.pipelineselection.representers.PipelineSelectionResponse)1 DashboardFor (com.thoughtworks.go.apiv2.dashboard.representers.DashboardFor)1 PipelineConfigs (com.thoughtworks.go.config.PipelineConfigs)1 AllowedUsers (com.thoughtworks.go.config.security.users.AllowedUsers)1 GoDashboardPipelineGroup (com.thoughtworks.go.server.dashboard.GoDashboardPipelineGroup)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1