@PUT
    @Path("{id}")
    @Timed
    @ApiOperation(value = "Update index set")
    @AuditEvent(type = AuditEventTypes.INDEX_SET_UPDATE)
    @ApiResponses(value = {
            @ApiResponse(code = 403, message = "Unauthorized"),
            @ApiResponse(code = 409, message = "Mismatch of IDs in URI path and payload"),
    })
    public IndexSetSummary update(@ApiParam(name = "id", required = true)
                                  @PathParam("id") String id,
                                  @ApiParam(name = "Index set configuration", required = true)
                                  @Valid @NotNull IndexSetUpdateRequest updateRequest) {
        checkPermission(RestPermissions.INDEXSETS_EDIT, id);

        final IndexSetConfig oldConfig = indexSetService.get(id)
                .orElseThrow(() -> new NotFoundException("Index set <" + id + "> not found"));

        final IndexSetConfig defaultIndexSet = indexSetService.getDefault();
        final boolean isDefaultSet = oldConfig.equals(defaultIndexSet);

        if (isDefaultSet && !updateRequest.isWritable()) {
            throw new ClientErrorException("Default index set must be writable.", Response.Status.CONFLICT);
        }

        checkDataTieringNotNull(updateRequest.useLegacyRotation(), updateRequest.dataTieringConfig());

        final IndexSetConfig indexSetConfig = updateRequest.toIndexSetConfig(id, oldConfig);

        final Optional<Violation> violation = indexSetValidator.validate(indexSetConfig);
        if (violation.isPresent()) {
            throw new BadRequestException(violation.get().message());
        }

        final IndexSetConfig savedObject = indexSetService.save(indexSetConfig);

        return IndexSetSummary.fromIndexSetConfig(savedObject, isDefaultSet);
    }
@Test
    public void update() {
        final IndexSetConfig indexSetConfig = IndexSetConfig.create(
                "id",
                "new title",
                "description",
                true, false,
                "prefix",
                1,
                0,
                MessageCountRotationStrategy.class.getCanonicalName(),
                MessageCountRotationStrategyConfig.create(1000),
                NoopRetentionStrategy.class.getCanonicalName(),
                NoopRetentionStrategyConfig.create(1),
                ZonedDateTime.of(2016, 10, 10, 12, 0, 0, 0, ZoneOffset.UTC),
                "standard",
                "index-template",
                null,
                1,
                false
        );
        final IndexSetConfig updatedIndexSetConfig = indexSetConfig.toBuilder()
                .title("new title")
                .build();

        when(indexSetService.get("id")).thenReturn(Optional.of(indexSetConfig));
        when(indexSetService.save(indexSetConfig)).thenReturn(updatedIndexSetConfig);

        final IndexSetSummary summary = indexSetsResource.update("id", IndexSetUpdateRequest.fromIndexSetConfig(indexSetConfig));

        verify(indexSetService, times(1)).get("id");
        verify(indexSetService, times(1)).save(indexSetConfig);
        verify(indexSetService, times(1)).getDefault();
        verifyNoMoreInteractions(indexSetService);

        // The real update wouldn't replace the index template name…
        final IndexSetConfig actual = summary.toIndexSetConfig(false).toBuilder()
                .indexTemplateName("index-template")
                .build();
        assertThat(actual).isEqualTo(updatedIndexSetConfig);
    }