@Test
  @Transactional
  public void getCommercialOperation() throws Exception {
    // Initialize the database
    commercialOperationRepository.saveAndFlush(commercialOperation);

    // Get the commercialOperation
    restCommercialOperationMockMvc
        .perform(get("/api/commercialOperations/{id}", commercialOperation.getId()))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.id").value(commercialOperation.getId().intValue()))
        .andExpect(jsonPath("$.providerCode").value(DEFAULT_PROVIDER_CODE.toString()));
  }
  @Test
  @Transactional
  public void createCommercialOperation() throws Exception {
    int databaseSizeBeforeCreate = commercialOperationRepository.findAll().size();

    // Create the CommercialOperation
    restCommercialOperationMockMvc
        .perform(
            post("/api/commercialOperations")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(
                    TestUtil.convertObjectToJsonBytes(
                        new DetailedCommercialOperationDTO(
                            new DetailedCommercialOperation(commercialOperation)))))
        .andExpect(status().isCreated());

    // Validate the CommercialOperation in the database
    List<CommercialOperation> commercialOperations = commercialOperationRepository.findAll();
    assertThat(commercialOperations).hasSize(databaseSizeBeforeCreate + 1);
    CommercialOperation testCommercialOperation =
        commercialOperations.get(commercialOperations.size() - 1);
    assertThat(testCommercialOperation.getProviderCode()).isEqualTo(DEFAULT_PROVIDER_CODE);
  }
  @Test
  @Transactional
  public void updateCommercialOperation() throws Exception {
    // Initialize the database
    commercialOperationRepository.saveAndFlush(commercialOperation);

    int databaseSizeBeforeUpdate = commercialOperationRepository.findAll().size();

    // Update the commercialOperation
    commercialOperation.setProviderCode(UPDATED_PROVIDER_CODE);
    restCommercialOperationMockMvc
        .perform(
            put("/api/commercialOperations")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(commercialOperation)))
        .andExpect(status().isOk());

    // Validate the CommercialOperation in the database
    List<CommercialOperation> commercialOperations = commercialOperationRepository.findAll();
    assertThat(commercialOperations).hasSize(databaseSizeBeforeUpdate);
    CommercialOperation testCommercialOperation =
        commercialOperations.get(commercialOperations.size() - 1);
    assertThat(testCommercialOperation.getProviderCode()).isEqualTo(UPDATED_PROVIDER_CODE);
  }
  @Test
  @Transactional
  public void deleteCommercialOperation() throws Exception {
    // Initialize the database
    commercialOperationRepository.saveAndFlush(commercialOperation);

    int databaseSizeBeforeDelete = commercialOperationRepository.findAll().size();

    // Get the commercialOperation
    restCommercialOperationMockMvc
        .perform(
            delete("/api/commercialOperations/{id}", commercialOperation.getId())
                .accept(TestUtil.APPLICATION_JSON_UTF8))
        .andExpect(status().isOk());

    // Validate the database is empty
    List<CommercialOperation> commercialOperations = commercialOperationRepository.findAll();
    assertThat(commercialOperations).hasSize(databaseSizeBeforeDelete - 1);
  }
 @Before
 public void initTest() {
   commercialOperation = new CommercialOperation();
   commercialOperation.setProviderCode(DEFAULT_PROVIDER_CODE);
 }