@Test
  public void testSetAdminGroupsSuccess() throws Exception {
    Task task = new Task();
    task.setId(taskId);

    when(deploymentFeClient.setSecurityGroups(eq(deploymentId), anyListOf(String.class)))
        .thenReturn(task);

    ResourceList<String> adminGroups =
        new ResourceList<>(
            Arrays.asList(new String[] {"tenant\\adminGroup1", "tenant\\adminGroup2"}));

    Response response =
        client()
            .target(deploymentRoutePath)
            .request()
            .post(Entity.entity(adminGroups, MediaType.APPLICATION_JSON_TYPE));

    assertThat(response.getStatus(), is(200));

    Task responseTask = response.readEntity(Task.class);
    assertThat(responseTask, is(task));
    assertThat(new URI(responseTask.getSelfLink()).isAbsolute(), is(true));
    assertThat(responseTask.getSelfLink().endsWith(taskRoutePath), is(true));
  }
  @Test
  public void testSetAdminGroupsFailWithInvalidSecurityGroup() throws Exception {
    ResourceList<String> adminGroups =
        new ResourceList<>(Arrays.asList(new String[] {"adminGroup1", "adminGroup2"}));
    when(deploymentFeClient.setSecurityGroups(eq(deploymentId), anyListOf(String.class)))
        .thenThrow(
            new InvalidAuthConfigException(
                "Auth is not enabled, and security groups cannot be set."));

    Response response =
        client()
            .target(deploymentRoutePath)
            .request()
            .post(Entity.entity(adminGroups, MediaType.APPLICATION_JSON_TYPE));
    assertThat(response.getStatus(), is(400));

    ApiError errors = response.readEntity(ApiError.class);
    assertThat(errors.getCode(), is("InvalidSecurityGroupFormat"));
    assertThat(
        errors.getMessage(),
        containsString("The security group format should match domain\\group"));
  }