@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); }
@Test @Transactional public void getOperation() throws Exception { // Initialize the database operationRepository.saveAndFlush(operation); // Get the operation restOperationMockMvc .perform(get("/api/operations/{id}", operation.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) .andExpect(jsonPath("$.id").value(operation.getId().intValue())) .andExpect(jsonPath("$.date").value(DEFAULT_DATE_STR)) .andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString())) .andExpect(jsonPath("$.amount").value(DEFAULT_AMOUNT.intValue())); }
@Test @Transactional public void createOperation() throws Exception { int databaseSizeBeforeCreate = operationRepository.findAll().size(); // Create the Operation restOperationMockMvc .perform( post("/api/operations") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(operation))) .andExpect(status().isCreated()); // Validate the Operation in the database List<Operation> operations = operationRepository.findAll(); assertThat(operations).hasSize(databaseSizeBeforeCreate + 1); Operation testOperation = operations.get(operations.size() - 1); assertThat(testOperation.getDate()).isEqualTo(DEFAULT_DATE); assertThat(testOperation.getDescription()).isEqualTo(DEFAULT_DESCRIPTION); assertThat(testOperation.getAmount()).isEqualTo(DEFAULT_AMOUNT); // Validate the Operation in ElasticSearch Operation operationEs = operationSearchRepository.findOne(testOperation.getId()); assertThat(operationEs).isEqualToComparingFieldByField(testOperation); }
@Test @Transactional public void deleteOperation() throws Exception { // Initialize the database operationRepository.saveAndFlush(operation); operationSearchRepository.save(operation); int databaseSizeBeforeDelete = operationRepository.findAll().size(); // Get the operation restOperationMockMvc .perform( delete("/api/operations/{id}", operation.getId()) .accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate ElasticSearch is empty boolean operationExistsInEs = operationSearchRepository.exists(operation.getId()); assertThat(operationExistsInEs).isFalse(); // Validate the database is empty List<Operation> operations = operationRepository.findAll(); assertThat(operations).hasSize(databaseSizeBeforeDelete - 1); }