use of io.github.jhipster.sample.service.dto.OperationDTO in project jhipster-sample-app-dto by jhipster.
the class OperationResourceIntTest method dtoEqualsVerifier.
@Test
@Transactional
public void dtoEqualsVerifier() throws Exception {
TestUtil.equalsVerifier(OperationDTO.class);
OperationDTO operationDTO1 = new OperationDTO();
operationDTO1.setId(1L);
OperationDTO operationDTO2 = new OperationDTO();
assertThat(operationDTO1).isNotEqualTo(operationDTO2);
operationDTO2.setId(operationDTO1.getId());
assertThat(operationDTO1).isEqualTo(operationDTO2);
operationDTO2.setId(2L);
assertThat(operationDTO1).isNotEqualTo(operationDTO2);
operationDTO1.setId(null);
assertThat(operationDTO1).isNotEqualTo(operationDTO2);
}
use of io.github.jhipster.sample.service.dto.OperationDTO in project jhipster-sample-app-dto by jhipster.
the class OperationResourceIntTest method checkAmountIsRequired.
@Test
@Transactional
public void checkAmountIsRequired() throws Exception {
int databaseSizeBeforeTest = operationRepository.findAll().size();
// set the field null
operation.setAmount(null);
// Create the Operation, which fails.
OperationDTO operationDTO = operationMapper.toDto(operation);
restOperationMockMvc.perform(post("/api/operations").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(operationDTO))).andExpect(status().isBadRequest());
List<Operation> operationList = operationRepository.findAll();
assertThat(operationList).hasSize(databaseSizeBeforeTest);
}
use of io.github.jhipster.sample.service.dto.OperationDTO in project jhipster-sample-app-dto by jhipster.
the class OperationResourceIntTest method createOperationWithExistingId.
@Test
@Transactional
public void createOperationWithExistingId() throws Exception {
int databaseSizeBeforeCreate = operationRepository.findAll().size();
// Create the Operation with an existing ID
operation.setId(1L);
OperationDTO operationDTO = operationMapper.toDto(operation);
// An entity with an existing ID cannot be created, so this API call must fail
restOperationMockMvc.perform(post("/api/operations").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(operationDTO))).andExpect(status().isBadRequest());
// Validate the Operation in the database
List<Operation> operationList = operationRepository.findAll();
assertThat(operationList).hasSize(databaseSizeBeforeCreate);
}
use of io.github.jhipster.sample.service.dto.OperationDTO in project jhipster-sample-app-dto by jhipster.
the class OperationResourceIntTest method updateNonExistingOperation.
@Test
@Transactional
public void updateNonExistingOperation() throws Exception {
int databaseSizeBeforeUpdate = operationRepository.findAll().size();
// Create the Operation
OperationDTO operationDTO = operationMapper.toDto(operation);
// If the entity doesn't have an ID, it will be created instead of just being updated
restOperationMockMvc.perform(put("/api/operations").contentType(TestUtil.APPLICATION_JSON_UTF8).content(TestUtil.convertObjectToJsonBytes(operationDTO))).andExpect(status().isCreated());
// Validate the Operation in the database
List<Operation> operationList = operationRepository.findAll();
assertThat(operationList).hasSize(databaseSizeBeforeUpdate + 1);
}
use of io.github.jhipster.sample.service.dto.OperationDTO in project jhipster-sample-app-dto by jhipster.
the class OperationResource method createOperation.
/**
* POST /operations : Create a new operation.
*
* @param operationDTO the operationDTO to create
* @return the ResponseEntity with status 201 (Created) and with body the new operationDTO, or with status 400 (Bad Request) if the operation has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/operations")
@Timed
public ResponseEntity<OperationDTO> createOperation(@Valid @RequestBody OperationDTO operationDTO) throws URISyntaxException {
log.debug("REST request to save Operation : {}", operationDTO);
if (operationDTO.getId() != null) {
throw new BadRequestAlertException("A new operation cannot already have an ID", ENTITY_NAME, "idexists");
}
Operation operation = operationMapper.toEntity(operationDTO);
operation = operationRepository.save(operation);
OperationDTO result = operationMapper.toDto(operation);
return ResponseEntity.created(new URI("/api/operations/" + result.getId())).headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString())).body(result);
}
Aggregations