@Test
  @Transactional
  public void updateBankAccount() throws Exception {
    // Initialize the database
    bankAccountRepository.saveAndFlush(bankAccount);
    int databaseSizeBeforeUpdate = bankAccountRepository.findAll().size();

    // Update the bankAccount
    BankAccount updatedBankAccount = bankAccountRepository.findOne(bankAccount.getId());
    updatedBankAccount.setName(UPDATED_NAME);
    updatedBankAccount.setBalance(UPDATED_BALANCE);

    restBankAccountMockMvc
        .perform(
            put("/api/bank-accounts")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(updatedBankAccount)))
        .andExpect(status().isOk());

    // Validate the BankAccount in the database
    List<BankAccount> bankAccountList = bankAccountRepository.findAll();
    assertThat(bankAccountList).hasSize(databaseSizeBeforeUpdate);
    BankAccount testBankAccount = bankAccountList.get(bankAccountList.size() - 1);
    assertThat(testBankAccount.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testBankAccount.getBalance()).isEqualTo(UPDATED_BALANCE);
  }
  @Test
  @Transactional
  public void deleteBankAccount() throws Exception {
    // Initialize the database
    bankAccountRepository.saveAndFlush(bankAccount);
    int databaseSizeBeforeDelete = bankAccountRepository.findAll().size();

    // Get the bankAccount
    restBankAccountMockMvc
        .perform(
            delete("/api/bank-accounts/{id}", bankAccount.getId())
                .accept(TestUtil.APPLICATION_JSON_UTF8))
        .andExpect(status().isOk());

    // Validate the database is empty
    List<BankAccount> bankAccountList = bankAccountRepository.findAll();
    assertThat(bankAccountList).hasSize(databaseSizeBeforeDelete - 1);
  }
  @Test
  @Transactional
  public void updateNonExistingBankAccount() throws Exception {
    int databaseSizeBeforeUpdate = bankAccountRepository.findAll().size();

    // Create the BankAccount

    // If the entity doesn't have an ID, it will be created instead of just being updated
    restBankAccountMockMvc
        .perform(
            put("/api/bank-accounts")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(bankAccount)))
        .andExpect(status().isCreated());

    // Validate the BankAccount in the database
    List<BankAccount> bankAccountList = bankAccountRepository.findAll();
    assertThat(bankAccountList).hasSize(databaseSizeBeforeUpdate + 1);
  }
  @Test
  @Transactional
  public void checkBalanceIsRequired() throws Exception {
    int databaseSizeBeforeTest = bankAccountRepository.findAll().size();
    // set the field null
    bankAccount.setBalance(null);

    // Create the BankAccount, which fails.

    restBankAccountMockMvc
        .perform(
            post("/api/bank-accounts")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(bankAccount)))
        .andExpect(status().isBadRequest());

    List<BankAccount> bankAccountList = bankAccountRepository.findAll();
    assertThat(bankAccountList).hasSize(databaseSizeBeforeTest);
  }
  @Test
  @Transactional
  public void createBankAccount() throws Exception {
    int databaseSizeBeforeCreate = bankAccountRepository.findAll().size();

    // Create the BankAccount

    restBankAccountMockMvc
        .perform(
            post("/api/bank-accounts")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(bankAccount)))
        .andExpect(status().isCreated());

    // Validate the BankAccount in the database
    List<BankAccount> bankAccountList = bankAccountRepository.findAll();
    assertThat(bankAccountList).hasSize(databaseSizeBeforeCreate + 1);
    BankAccount testBankAccount = bankAccountList.get(bankAccountList.size() - 1);
    assertThat(testBankAccount.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testBankAccount.getBalance()).isEqualTo(DEFAULT_BALANCE);
  }
  @Test
  @Transactional
  public void createBankAccountWithExistingId() throws Exception {
    int databaseSizeBeforeCreate = bankAccountRepository.findAll().size();

    // Create the BankAccount with an existing ID
    BankAccount existingBankAccount = new BankAccount();
    existingBankAccount.setId(1L);

    // An entity with an existing ID cannot be created, so this API call must fail
    restBankAccountMockMvc
        .perform(
            post("/api/bank-accounts")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(existingBankAccount)))
        .andExpect(status().isBadRequest());

    // Validate the Alice in the database
    List<BankAccount> bankAccountList = bankAccountRepository.findAll();
    assertThat(bankAccountList).hasSize(databaseSizeBeforeCreate);
  }
  @Test
  @Transactional
  public void getBankAccount() throws Exception {
    // Initialize the database
    bankAccountRepository.saveAndFlush(bankAccount);

    // Get the bankAccount
    restBankAccountMockMvc
        .perform(get("/api/bank-accounts/{id}", bankAccount.getId()))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
        .andExpect(jsonPath("$.id").value(bankAccount.getId().intValue()))
        .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString()))
        .andExpect(jsonPath("$.balance").value(DEFAULT_BALANCE.intValue()));
  }