use of io.github.jhipster.sample.domain.Operation in project jhipster-sample-app-dto by jhipster.
the class OperationResource method updateOperation.
/**
* PUT /operations : Updates an existing operation.
*
* @param operationDTO the operationDTO to update
* @return the ResponseEntity with status 200 (OK) and with body the updated operationDTO,
* or with status 400 (Bad Request) if the operationDTO is not valid,
* or with status 500 (Internal Server Error) if the operationDTO couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/operations")
@Timed
public ResponseEntity<OperationDTO> updateOperation(@Valid @RequestBody OperationDTO operationDTO) throws URISyntaxException {
log.debug("REST request to update Operation : {}", operationDTO);
if (operationDTO.getId() == null) {
return createOperation(operationDTO);
}
Operation operation = operationMapper.toEntity(operationDTO);
operation = operationRepository.save(operation);
OperationDTO result = operationMapper.toDto(operation);
return ResponseEntity.ok().headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, operationDTO.getId().toString())).body(result);
}
use of io.github.jhipster.sample.domain.Operation in project jhipster-sample-app-dto by jhipster.
the class OperationResourceIntTest method equalsVerifier.
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Operation.class);
Operation operation1 = new Operation();
operation1.setId(1L);
Operation operation2 = new Operation();
operation2.setId(operation1.getId());
assertThat(operation1).isEqualTo(operation2);
operation2.setId(2L);
assertThat(operation1).isNotEqualTo(operation2);
operation1.setId(null);
assertThat(operation1).isNotEqualTo(operation2);
}
use of io.github.jhipster.sample.domain.Operation in project jhipster-sample-app-dto by jhipster.
the class OperationResourceIntTest method createEntity.
/**
* Create an entity for this test.
*
* This is a static method, as tests for other entities might also need it,
* if they test an entity which requires the current entity.
*/
public static Operation createEntity(EntityManager em) {
Operation operation = new Operation();
operation.setDate(DEFAULT_DATE);
operation.setDescription(DEFAULT_DESCRIPTION);
operation.setAmount(DEFAULT_AMOUNT);
return operation;
}
use of io.github.jhipster.sample.domain.Operation in project jhipster-sample-app-dto by jhipster.
the class OperationResourceIntTest method createOperation.
@Test
@Transactional
public void createOperation() throws Exception {
int databaseSizeBeforeCreate = operationRepository.findAll().size();
// Create the Operation
OperationDTO operationDTO = operationMapper.toDto(operation);
restOperationMockMvc.perform(post("/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(databaseSizeBeforeCreate + 1);
Operation testOperation = operationList.get(operationList.size() - 1);
assertThat(testOperation.getDate()).isEqualTo(DEFAULT_DATE);
assertThat(testOperation.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
assertThat(testOperation.getAmount()).isEqualTo(DEFAULT_AMOUNT);
}
use of io.github.jhipster.sample.domain.Operation in project jhipster-sample-app-dto by jhipster.
the class OperationResourceIntTest method checkDateIsRequired.
@Test
@Transactional
public void checkDateIsRequired() throws Exception {
int databaseSizeBeforeTest = operationRepository.findAll().size();
// set the field null
operation.setDate(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);
}
Aggregations