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