Search in sources :

Example 6 with BankAccountDTO

use of io.github.jhipster.sample.service.dto.BankAccountDTO in project jhipster-sample-app-dto by jhipster.

the class BankAccountResourceIntTest method createBankAccount.

@Test
@Transactional
public void createBankAccount() throws Exception {
    int databaseSizeBeforeCreate = bankAccountRepository.findAll().size();
    // Create the BankAccount
    BankAccountDTO bankAccountDTO = bankAccountMapper.toDto(bankAccount);
    restBankAccountMockMvc.perform(post("/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(databaseSizeBeforeCreate + 1);
    BankAccount testBankAccount = bankAccountList.get(bankAccountList.size() - 1);
    assertThat(testBankAccount.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testBankAccount.getBalance()).isEqualTo(DEFAULT_BALANCE);
}
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 BankAccountDTO

use of io.github.jhipster.sample.service.dto.BankAccountDTO in project jhipster-sample-app-dto by jhipster.

the class BankAccountResourceIntTest method dtoEqualsVerifier.

@Test
@Transactional
public void dtoEqualsVerifier() throws Exception {
    TestUtil.equalsVerifier(BankAccountDTO.class);
    BankAccountDTO bankAccountDTO1 = new BankAccountDTO();
    bankAccountDTO1.setId(1L);
    BankAccountDTO bankAccountDTO2 = new BankAccountDTO();
    assertThat(bankAccountDTO1).isNotEqualTo(bankAccountDTO2);
    bankAccountDTO2.setId(bankAccountDTO1.getId());
    assertThat(bankAccountDTO1).isEqualTo(bankAccountDTO2);
    bankAccountDTO2.setId(2L);
    assertThat(bankAccountDTO1).isNotEqualTo(bankAccountDTO2);
    bankAccountDTO1.setId(null);
    assertThat(bankAccountDTO1).isNotEqualTo(bankAccountDTO2);
}
Also used : BankAccountDTO(io.github.jhipster.sample.service.dto.BankAccountDTO) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 8 with BankAccountDTO

use of io.github.jhipster.sample.service.dto.BankAccountDTO in project jhipster-sample-app-dto by jhipster.

the class BankAccountResourceIntTest method checkNameIsRequired.

@Test
@Transactional
public void checkNameIsRequired() throws Exception {
    int databaseSizeBeforeTest = bankAccountRepository.findAll().size();
    // set the field null
    bankAccount.setName(null);
    // Create the BankAccount, which fails.
    BankAccountDTO bankAccountDTO = bankAccountMapper.toDto(bankAccount);
    restBankAccountMockMvc.perform(post("/api/bank-accounts").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(bankAccountDTO))).andExpect(status().isBadRequest());
    List<BankAccount> bankAccountList = bankAccountRepository.findAll();
    assertThat(bankAccountList).hasSize(databaseSizeBeforeTest);
}
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 9 with BankAccountDTO

use of io.github.jhipster.sample.service.dto.BankAccountDTO in project jhipster-sample-app-dto by jhipster.

the class BankAccountResource method createBankAccount.

/**
 * POST  /bank-accounts : Create a new bankAccount.
 *
 * @param bankAccountDTO the bankAccountDTO to create
 * @return the ResponseEntity with status 201 (Created) and with body the new bankAccountDTO, 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<BankAccountDTO> createBankAccount(@Valid @RequestBody BankAccountDTO bankAccountDTO) throws URISyntaxException {
    log.debug("REST request to save BankAccount : {}", bankAccountDTO);
    if (bankAccountDTO.getId() != null) {
        throw new BadRequestAlertException("A new bankAccount cannot already have an ID", ENTITY_NAME, "idexists");
    }
    BankAccount bankAccount = bankAccountMapper.toEntity(bankAccountDTO);
    bankAccount = bankAccountRepository.save(bankAccount);
    BankAccountDTO result = bankAccountMapper.toDto(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) BankAccountDTO(io.github.jhipster.sample.service.dto.BankAccountDTO) BankAccount(io.github.jhipster.sample.domain.BankAccount) URI(java.net.URI) Timed(com.codahale.metrics.annotation.Timed)

Aggregations

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