Search in sources :

Example 6 with BankAccount

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

the class BankAccountResourceIntTest method updateNonExistingBankAccount.

@Test
@Transactional
public void updateNonExistingBankAccount() throws Exception {
    int databaseSizeBeforeUpdate = bankAccountRepository.findAll().size();
    // Create the BankAccount
    BankAccountDTO bankAccountDTO = bankAccountMapper.toDto(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(bankAccountDTO))).andExpect(status().isCreated());
    // Validate the BankAccount in the database
    List<BankAccount> bankAccountList = bankAccountRepository.findAll();
    assertThat(bankAccountList).hasSize(databaseSizeBeforeUpdate + 1);
}
Also used : BankAccountDTO(io.github.jhipster.sample.service.dto.BankAccountDTO) 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 7 with BankAccount

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

the class BankAccountResource method createBankAccount.

/**
 * POST  /bank-accounts : Create a new bankAccount.
 *
 * @param bankAccount the bankAccount to create
 * @return the ResponseEntity with status 201 (Created) and with body the new bankAccount, or with status 400 (Bad Request) if the bankAccount has already an ID
 * @throws URISyntaxException if the Location URI syntax is incorrect
 */
@PostMapping("/bank-accounts")
@Timed
public ResponseEntity<BankAccount> createBankAccount(@Valid @RequestBody BankAccount bankAccount) throws URISyntaxException {
    log.debug("REST request to save BankAccount : {}", bankAccount);
    if (bankAccount.getId() != null) {
        throw new BadRequestAlertException("A new bankAccount cannot already have an ID", ENTITY_NAME, "idexists");
    }
    BankAccount result = bankAccountRepository.save(bankAccount);
    return ResponseEntity.created(new URI("/api/bank-accounts/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Also used : BadRequestAlertException(io.github.jhipster.sample.web.rest.errors.BadRequestAlertException) BankAccount(io.github.jhipster.sample.domain.BankAccount) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Example 8 with BankAccount

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

the class BankAccountResourceIntTest method updateBankAccount.

@Test
public void updateBankAccount() throws Exception {
    // Initialize the database
    bankAccountRepository.save(bankAccount);
    int databaseSizeBeforeUpdate = bankAccountRepository.findAll().size();
    // Update the bankAccount
    BankAccount updatedBankAccount = bankAccountRepository.findById(bankAccount.getId()).get();
    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)

Example 9 with BankAccount

use of io.github.jhipster.sample.domain.BankAccount in project jhipster-sample-app-hazelcast 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 10 with BankAccount

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

the class BankAccountResourceIntTest method equalsVerifier.

@Test
@Transactional
public void equalsVerifier() throws Exception {
    TestUtil.equalsVerifier(BankAccount.class);
    BankAccount bankAccount1 = new BankAccount();
    bankAccount1.setId(1L);
    BankAccount bankAccount2 = new BankAccount();
    bankAccount2.setId(bankAccount1.getId());
    assertThat(bankAccount1).isEqualTo(bankAccount2);
    bankAccount2.setId(2L);
    assertThat(bankAccount1).isNotEqualTo(bankAccount2);
    bankAccount1.setId(null);
    assertThat(bankAccount1).isNotEqualTo(bankAccount2);
}
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