public BaseServiceResponse <ShrinkResponseBody> Shrink([FromBody] ShrinkRequestBody request) { BaseServiceResponse <ShrinkResponseBody> response = new BaseServiceResponse <ShrinkResponseBody>(); try { #region Validations // Request's body can't be null. if (request == null) { throw new ArgumentNullException(nameof(request)); } // Index prefix must be informed. if (string.IsNullOrWhiteSpace((request.IndexName))) { throw new ArgumentNullException(nameof(request.IndexName)); } #endregion // Performs the shrink operation on index. ElasticsearchResponse <VoidResponse> operationResponse = Processor.Shrink(request.IndexName); } catch (Exception ex) { response = new BaseServiceResponse <ShrinkResponseBody>(ex); } return(response); }
public void Shrink_when_index_name_is_null() { ShrinkRequestBody request = new ShrinkRequestBody(); BaseServiceResponse <ShrinkResponseBody> response = Controller.Shrink(request); Assert.IsTrue(response.Operation.Failed); Assert.IsNull(response.Body); Assert.AreEqual(nameof(ArgumentNullException), response.Operation.Error.ClassName); }