Search in sources :

Example 11 with BankAccount

use of io.github.jhipster.sample.domain.BankAccount in project jhipster-sample-app-hazelcast by jhipster.

the class BankAccountResourceIntTest method createBankAccount.

@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);
}
Also used : BankAccount(io.github.jhipster.sample.domain.BankAccount) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with BankAccount

use of io.github.jhipster.sample.domain.BankAccount in project jhipster-sample-app-elasticsearch by jhipster.

the class BankAccountResourceIntTest method createBankAccount.

@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);
    // Validate the BankAccount in Elasticsearch
    verify(mockBankAccountSearchRepository, times(1)).save(testBankAccount);
}
Also used : BankAccount(io.github.jhipster.sample.domain.BankAccount) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with BankAccount

use of io.github.jhipster.sample.domain.BankAccount in project jhipster-sample-app-elasticsearch by jhipster.

the class BankAccountResource method updateBankAccount.

/**
 * PUT  /bank-accounts : Updates an existing bankAccount.
 *
 * @param bankAccount the bankAccount to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated bankAccount,
 * or with status 400 (Bad Request) if the bankAccount is not valid,
 * or with status 500 (Internal Server Error) if the bankAccount couldn't be updated
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PutMapping("/bank-accounts")
@Timed
public ResponseEntity<BankAccount> updateBankAccount(@Valid @RequestBody BankAccount bankAccount) throws URISyntaxException {
    log.debug("REST request to update BankAccount : {}", bankAccount);
    if (bankAccount.getId() == null) {
        return createBankAccount(bankAccount);
    }
    BankAccount result = bankAccountRepository.save(bankAccount);
    bankAccountSearchRepository.save(result);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, bankAccount.getId().toString())).body(result);
}
Also used : BankAccount(io.github.jhipster.sample.domain.BankAccount) Timed(com.codahale.metrics.annotation.Timed)

Example 14 with BankAccount

use of io.github.jhipster.sample.domain.BankAccount in project jhipster-sample-app-mongodb by jhipster.

the class BankAccountResource method updateBankAccount.

/**
 * PUT  /bank-accounts : Updates an existing bankAccount.
 *
 * @param bankAccount the bankAccount to update
 * @return the ResponseEntity with status 200 (OK) and with body the updated bankAccount,
 * or with status 400 (Bad Request) if the bankAccount is not valid,
 * or with status 500 (Internal Server Error) if the bankAccount couldn't be updated
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PutMapping("/bank-accounts")
@Timed
public ResponseEntity<BankAccount> updateBankAccount(@Valid @RequestBody BankAccount bankAccount) throws URISyntaxException {
    log.debug("REST request to update BankAccount : {}", bankAccount);
    if (bankAccount.getId() == null) {
        return createBankAccount(bankAccount);
    }
    BankAccount result = bankAccountRepository.save(bankAccount);
    return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, bankAccount.getId().toString())).body(result);
}
Also used : BankAccount(io.github.jhipster.sample.domain.BankAccount) Timed(com.codahale.metrics.annotation.Timed)

Example 15 with BankAccount

use of io.github.jhipster.sample.domain.BankAccount in project jhipster-sample-app-hazelcast by jhipster.

the class BankAccountResourceIntTest method updateBankAccount.

@Test
@Transactional
public void updateBankAccount() throws Exception {
    // Initialize the database
    bankAccountRepository.saveAndFlush(bankAccount);
    int databaseSizeBeforeUpdate = bankAccountRepository.findAll().size();
    // Update the bankAccount
    BankAccount updatedBankAccount = bankAccountRepository.findById(bankAccount.getId()).get();
    // Disconnect from session so that the updates on updatedBankAccount are not directly saved in db
    em.detach(updatedBankAccount);
    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);
}
Also used : BankAccount(io.github.jhipster.sample.domain.BankAccount) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

BankAccount (io.github.jhipster.sample.domain.BankAccount)28 Test (org.junit.Test)16 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 Transactional (org.springframework.transaction.annotation.Transactional)13 Timed (com.codahale.metrics.annotation.Timed)8 BankAccountDTO (io.github.jhipster.sample.service.dto.BankAccountDTO)8 BadRequestAlertException (io.github.jhipster.sample.web.rest.errors.BadRequestAlertException)4 URI (java.net.URI)4