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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations