@Test @Transactional public void updateOperation() throws Exception { // Initialize the database operationRepository.saveAndFlush(operation); operationSearchRepository.save(operation); int databaseSizeBeforeUpdate = operationRepository.findAll().size(); // Update the operation Operation updatedOperation = operationRepository.findOne(operation.getId()); updatedOperation.setDate(UPDATED_DATE); updatedOperation.setDescription(UPDATED_DESCRIPTION); updatedOperation.setAmount(UPDATED_AMOUNT); restOperationMockMvc .perform( put("/api/operations") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(updatedOperation))) .andExpect(status().isOk()); // Validate the Operation in the database List<Operation> operations = operationRepository.findAll(); assertThat(operations).hasSize(databaseSizeBeforeUpdate); Operation testOperation = operations.get(operations.size() - 1); assertThat(testOperation.getDate()).isEqualTo(UPDATED_DATE); assertThat(testOperation.getDescription()).isEqualTo(UPDATED_DESCRIPTION); assertThat(testOperation.getAmount()).isEqualTo(UPDATED_AMOUNT); // Validate the Operation in ElasticSearch Operation operationEs = operationSearchRepository.findOne(testOperation.getId()); assertThat(operationEs).isEqualToComparingFieldByField(testOperation); }
/** * Create an entity for this test. * * <p>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; }
@Test @Transactional public void checkDateIsRequired() throws Exception { int databaseSizeBeforeTest = operationRepository.findAll().size(); // set the field null operation.setDate(null); // Create the Operation, which fails. restOperationMockMvc .perform( post("/api/operations") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(operation))) .andExpect(status().isBadRequest()); List<Operation> operations = operationRepository.findAll(); assertThat(operations).hasSize(databaseSizeBeforeTest); }