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());
}
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());
}
Aggregations