Search in sources :

Example 1 with DeploymentGroupExistsException

use of com.spotify.helios.master.DeploymentGroupExistsException in project helios by spotify.

the class DeploymentGroupResourceTest method testCreateExistingSameDeploymentGroup.

@Test
public void testCreateExistingSameDeploymentGroup() throws Exception {
    final DeploymentGroup dg = mock(DeploymentGroup.class);
    when(dg.getName()).thenReturn("foo");
    when(dg.getHostSelectors()).thenReturn(Lists.newArrayList(FOO_SELECTOR));
    doThrow(new DeploymentGroupExistsException("")).when(model).addDeploymentGroup(dg);
    when(model.getDeploymentGroup("foo")).thenReturn(dg);
    final Response response = resource.createDeploymentGroup(dg);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    assertEquals(new CreateDeploymentGroupResponse(CreateDeploymentGroupResponse.Status.NOT_MODIFIED), response.getEntity());
}
Also used : RemoveDeploymentGroupResponse(com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse) RollingUpdateResponse(com.spotify.helios.common.protocol.RollingUpdateResponse) CreateDeploymentGroupResponse(com.spotify.helios.common.protocol.CreateDeploymentGroupResponse) Response(javax.ws.rs.core.Response) CreateDeploymentGroupResponse(com.spotify.helios.common.protocol.CreateDeploymentGroupResponse) DeploymentGroupExistsException(com.spotify.helios.master.DeploymentGroupExistsException) DeploymentGroup(com.spotify.helios.common.descriptors.DeploymentGroup) Test(org.junit.Test)

Example 2 with DeploymentGroupExistsException

use of com.spotify.helios.master.DeploymentGroupExistsException in project helios by spotify.

the class DeploymentGroupResourceTest method testCreateExistingConflictingDeploymentGroup.

@Test
public void testCreateExistingConflictingDeploymentGroup() throws Exception {
    final DeploymentGroup dg = mock(DeploymentGroup.class);
    when(dg.getName()).thenReturn("foo");
    when(dg.getHostSelectors()).thenReturn(Lists.newArrayList(FOO_SELECTOR));
    doThrow(new DeploymentGroupExistsException("")).when(model).addDeploymentGroup(dg);
    final DeploymentGroup existing = mock(DeploymentGroup.class);
    when(existing.getHostSelectors()).thenReturn(Lists.newArrayList(BAZ_SELECTOR));
    when(model.getDeploymentGroup("foo")).thenReturn(existing);
    final Response response = resource.createDeploymentGroup(dg);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    assertEquals(new CreateDeploymentGroupResponse(CreateDeploymentGroupResponse.Status.CONFLICT), response.getEntity());
}
Also used : RemoveDeploymentGroupResponse(com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse) RollingUpdateResponse(com.spotify.helios.common.protocol.RollingUpdateResponse) CreateDeploymentGroupResponse(com.spotify.helios.common.protocol.CreateDeploymentGroupResponse) Response(javax.ws.rs.core.Response) CreateDeploymentGroupResponse(com.spotify.helios.common.protocol.CreateDeploymentGroupResponse) DeploymentGroupExistsException(com.spotify.helios.master.DeploymentGroupExistsException) DeploymentGroup(com.spotify.helios.common.descriptors.DeploymentGroup) Test(org.junit.Test)

Aggregations

DeploymentGroup (com.spotify.helios.common.descriptors.DeploymentGroup)2 CreateDeploymentGroupResponse (com.spotify.helios.common.protocol.CreateDeploymentGroupResponse)2 RemoveDeploymentGroupResponse (com.spotify.helios.common.protocol.RemoveDeploymentGroupResponse)2 RollingUpdateResponse (com.spotify.helios.common.protocol.RollingUpdateResponse)2 DeploymentGroupExistsException (com.spotify.helios.master.DeploymentGroupExistsException)2 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2