| @@ -1,16 +0,0 @@ | |||
| package vn.azteam.tpf.repository.search; | |||
| import org.springframework.boot.test.mock.mockito.MockBean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| /** | |||
| * Configure a Mock version of TBBlockDetailsLogSearchRepository to test the | |||
| * application without starting Elasticsearch. | |||
| */ | |||
| @Configuration | |||
| public class TBBlockDetailsLogSearchRepositoryMockConfiguration { | |||
| @MockBean | |||
| private TBBlockDetailsLogSearchRepository mockTBBlockDetailsLogSearchRepository; | |||
| } | |||
| @@ -1,16 +0,0 @@ | |||
| package vn.azteam.tpf.repository.search; | |||
| import org.springframework.boot.test.mock.mockito.MockBean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| /** | |||
| * Configure a Mock version of TBBlockDetailsReportSearchRepository to test the | |||
| * application without starting Elasticsearch. | |||
| */ | |||
| @Configuration | |||
| public class TBBlockDetailsReportSearchRepositoryMockConfiguration { | |||
| @MockBean | |||
| private TBBlockDetailsReportSearchRepository mockTBBlockDetailsReportSearchRepository; | |||
| } | |||
| @@ -1,16 +0,0 @@ | |||
| package vn.azteam.tpf.repository.search; | |||
| import org.springframework.boot.test.mock.mockito.MockBean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| /** | |||
| * Configure a Mock version of TBProductBlockDetailsLogSearchRepository to test the | |||
| * application without starting Elasticsearch. | |||
| */ | |||
| @Configuration | |||
| public class TBProductBlockDetailsLogSearchRepositoryMockConfiguration { | |||
| @MockBean | |||
| private TBProductBlockDetailsLogSearchRepository mockTBProductBlockDetailsLogSearchRepository; | |||
| } | |||
| @@ -1,16 +0,0 @@ | |||
| package vn.azteam.tpf.repository.search; | |||
| import org.springframework.boot.test.mock.mockito.MockBean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| /** | |||
| * Configure a Mock version of TBProductBlockDetailsReportSearchRepository to test the | |||
| * application without starting Elasticsearch. | |||
| */ | |||
| @Configuration | |||
| public class TBProductBlockDetailsReportSearchRepositoryMockConfiguration { | |||
| @MockBean | |||
| private TBProductBlockDetailsReportSearchRepository mockTBProductBlockDetailsReportSearchRepository; | |||
| } | |||
| @@ -1,346 +0,0 @@ | |||
| package vn.azteam.tpf.web.rest; | |||
| import vn.azteam.tpf.TpfApp; | |||
| import vn.azteam.tpf.web.rest.errors.ExceptionTranslator; | |||
| import org.junit.Before; | |||
| import org.junit.Test; | |||
| import org.junit.runner.RunWith; | |||
| import org.mockito.MockitoAnnotations; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.boot.test.context.SpringBootTest; | |||
| import org.springframework.data.domain.PageImpl; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.data.web.PageableHandlerMethodArgumentResolver; | |||
| import org.springframework.http.MediaType; | |||
| import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |||
| import org.springframework.test.context.junit4.SpringRunner; | |||
| import org.springframework.test.web.servlet.MockMvc; | |||
| import org.springframework.test.web.servlet.setup.MockMvcBuilders; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import org.springframework.validation.Validator; | |||
| import javax.persistence.EntityManager; | |||
| import java.util.Collections; | |||
| import java.util.List; | |||
| import static vn.azteam.tpf.web.rest.TestUtil.createFormattingConversionService; | |||
| import static org.assertj.core.api.Assertions.assertThat; | |||
| import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery; | |||
| import static org.hamcrest.Matchers.hasItem; | |||
| import static org.mockito.Mockito.*; | |||
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | |||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | |||
| /** | |||
| * Test class for the TBBlockDetailsLogResource REST controller. | |||
| * | |||
| * @see TBBlockDetailsLogResource | |||
| */ | |||
| @RunWith(SpringRunner.class) | |||
| @SpringBootTest(classes = TpfApp.class) | |||
| public class TBBlockDetailsLogResourceIntTest { | |||
| @Autowired | |||
| private TBBlockDetailsLogRepository tBBlockDetailsLogRepository; | |||
| @Autowired | |||
| private TBBlockDetailsLogMapper tBBlockDetailsLogMapper; | |||
| @Autowired | |||
| private TBBlockDetailsLogService tBBlockDetailsLogService; | |||
| /** | |||
| * This repository is mocked in the vn.azteam.tpf.repository.search test package. | |||
| * | |||
| * @see vn.azteam.tpf.repository.search.TBBlockDetailsLogSearchRepositoryMockConfiguration | |||
| */ | |||
| @Autowired | |||
| private TBBlockDetailsLogSearchRepository mockTBBlockDetailsLogSearchRepository; | |||
| @Autowired | |||
| private TBBlockDetailsLogQueryService tBBlockDetailsLogQueryService; | |||
| @Autowired | |||
| private MappingJackson2HttpMessageConverter jacksonMessageConverter; | |||
| @Autowired | |||
| private PageableHandlerMethodArgumentResolver pageableArgumentResolver; | |||
| @Autowired | |||
| private ExceptionTranslator exceptionTranslator; | |||
| @Autowired | |||
| private EntityManager em; | |||
| @Autowired | |||
| private Validator validator; | |||
| private MockMvc restTBBlockDetailsLogMockMvc; | |||
| private TBBlockDetailsLog tBBlockDetailsLog; | |||
| @Before | |||
| public void setup() { | |||
| MockitoAnnotations.initMocks(this); | |||
| final TBBlockDetailsLogResource tBBlockDetailsLogResource = new TBBlockDetailsLogResource(tBBlockDetailsLogService, tBBlockDetailsLogQueryService); | |||
| this.restTBBlockDetailsLogMockMvc = MockMvcBuilders.standaloneSetup(tBBlockDetailsLogResource) | |||
| .setCustomArgumentResolvers(pageableArgumentResolver) | |||
| .setControllerAdvice(exceptionTranslator) | |||
| .setConversionService(createFormattingConversionService()) | |||
| .setMessageConverters(jacksonMessageConverter) | |||
| .setValidator(validator).build(); | |||
| } | |||
| /** | |||
| * 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 TBBlockDetailsLog createEntity(EntityManager em) { | |||
| TBBlockDetailsLog tBBlockDetailsLog = new TBBlockDetailsLog(); | |||
| return tBBlockDetailsLog; | |||
| } | |||
| @Before | |||
| public void initTest() { | |||
| tBBlockDetailsLog = createEntity(em); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void createTBBlockDetailsLog() throws Exception { | |||
| int databaseSizeBeforeCreate = tBBlockDetailsLogRepository.findAll().size(); | |||
| // Create the TBBlockDetailsLog | |||
| TBBlockDetailsLogDTO tBBlockDetailsLogDTO = tBBlockDetailsLogMapper.toDto(tBBlockDetailsLog); | |||
| restTBBlockDetailsLogMockMvc.perform(post("/api/tb-block-details-logs") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBBlockDetailsLogDTO))) | |||
| .andExpect(status().isCreated()); | |||
| // Validate the TBBlockDetailsLog in the database | |||
| List<TBBlockDetailsLog> tBBlockDetailsLogList = tBBlockDetailsLogRepository.findAll(); | |||
| assertThat(tBBlockDetailsLogList).hasSize(databaseSizeBeforeCreate + 1); | |||
| TBBlockDetailsLog testTBBlockDetailsLog = tBBlockDetailsLogList.get(tBBlockDetailsLogList.size() - 1); | |||
| // Validate the TBBlockDetailsLog in Elasticsearch | |||
| verify(mockTBBlockDetailsLogSearchRepository, times(1)).save(testTBBlockDetailsLog); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void createTBBlockDetailsLogWithExistingId() throws Exception { | |||
| int databaseSizeBeforeCreate = tBBlockDetailsLogRepository.findAll().size(); | |||
| // Create the TBBlockDetailsLog with an existing ID | |||
| tBBlockDetailsLog.setId(1L); | |||
| TBBlockDetailsLogDTO tBBlockDetailsLogDTO = tBBlockDetailsLogMapper.toDto(tBBlockDetailsLog); | |||
| // An entity with an existing ID cannot be created, so this API call must fail | |||
| restTBBlockDetailsLogMockMvc.perform(post("/api/tb-block-details-logs") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBBlockDetailsLogDTO))) | |||
| .andExpect(status().isBadRequest()); | |||
| // Validate the TBBlockDetailsLog in the database | |||
| List<TBBlockDetailsLog> tBBlockDetailsLogList = tBBlockDetailsLogRepository.findAll(); | |||
| assertThat(tBBlockDetailsLogList).hasSize(databaseSizeBeforeCreate); | |||
| // Validate the TBBlockDetailsLog in Elasticsearch | |||
| verify(mockTBBlockDetailsLogSearchRepository, times(0)).save(tBBlockDetailsLog); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsLogs() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsLogRepository.saveAndFlush(tBBlockDetailsLog); | |||
| // Get all the tBBlockDetailsLogList | |||
| restTBBlockDetailsLogMockMvc.perform(get("/api/tb-block-details-logs?sort=id,desc")) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.[*].id").value(hasItem(tBBlockDetailsLog.getId().intValue()))); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getTBBlockDetailsLog() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsLogRepository.saveAndFlush(tBBlockDetailsLog); | |||
| // Get the tBBlockDetailsLog | |||
| restTBBlockDetailsLogMockMvc.perform(get("/api/tb-block-details-logs/{id}", tBBlockDetailsLog.getId())) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.id").value(tBBlockDetailsLog.getId().intValue())); | |||
| } | |||
| /** | |||
| * Executes the search, and checks that the default entity is returned | |||
| */ | |||
| private void defaultTBBlockDetailsLogShouldBeFound(String filter) throws Exception { | |||
| restTBBlockDetailsLogMockMvc.perform(get("/api/tb-block-details-logs?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.[*].id").value(hasItem(tBBlockDetailsLog.getId().intValue()))); | |||
| // Check, that the count call also returns 1 | |||
| restTBBlockDetailsLogMockMvc.perform(get("/api/tb-block-details-logs/count?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(content().string("1")); | |||
| } | |||
| /** | |||
| * Executes the search, and checks that the default entity is not returned | |||
| */ | |||
| private void defaultTBBlockDetailsLogShouldNotBeFound(String filter) throws Exception { | |||
| restTBBlockDetailsLogMockMvc.perform(get("/api/tb-block-details-logs?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$").isArray()) | |||
| .andExpect(jsonPath("$").isEmpty()); | |||
| // Check, that the count call also returns 0 | |||
| restTBBlockDetailsLogMockMvc.perform(get("/api/tb-block-details-logs/count?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(content().string("0")); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getNonExistingTBBlockDetailsLog() throws Exception { | |||
| // Get the tBBlockDetailsLog | |||
| restTBBlockDetailsLogMockMvc.perform(get("/api/tb-block-details-logs/{id}", Long.MAX_VALUE)) | |||
| .andExpect(status().isNotFound()); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void updateTBBlockDetailsLog() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsLogRepository.saveAndFlush(tBBlockDetailsLog); | |||
| int databaseSizeBeforeUpdate = tBBlockDetailsLogRepository.findAll().size(); | |||
| // Update the tBBlockDetailsLog | |||
| TBBlockDetailsLog updatedTBBlockDetailsLog = tBBlockDetailsLogRepository.findById(tBBlockDetailsLog.getId()).get(); | |||
| // Disconnect from session so that the updates on updatedTBBlockDetailsLog are not directly saved in db | |||
| em.detach(updatedTBBlockDetailsLog); | |||
| TBBlockDetailsLogDTO tBBlockDetailsLogDTO = tBBlockDetailsLogMapper.toDto(updatedTBBlockDetailsLog); | |||
| restTBBlockDetailsLogMockMvc.perform(put("/api/tb-block-details-logs") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBBlockDetailsLogDTO))) | |||
| .andExpect(status().isOk()); | |||
| // Validate the TBBlockDetailsLog in the database | |||
| List<TBBlockDetailsLog> tBBlockDetailsLogList = tBBlockDetailsLogRepository.findAll(); | |||
| assertThat(tBBlockDetailsLogList).hasSize(databaseSizeBeforeUpdate); | |||
| TBBlockDetailsLog testTBBlockDetailsLog = tBBlockDetailsLogList.get(tBBlockDetailsLogList.size() - 1); | |||
| // Validate the TBBlockDetailsLog in Elasticsearch | |||
| verify(mockTBBlockDetailsLogSearchRepository, times(1)).save(testTBBlockDetailsLog); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void updateNonExistingTBBlockDetailsLog() throws Exception { | |||
| int databaseSizeBeforeUpdate = tBBlockDetailsLogRepository.findAll().size(); | |||
| // Create the TBBlockDetailsLog | |||
| TBBlockDetailsLogDTO tBBlockDetailsLogDTO = tBBlockDetailsLogMapper.toDto(tBBlockDetailsLog); | |||
| // If the entity doesn't have an ID, it will throw BadRequestAlertException | |||
| restTBBlockDetailsLogMockMvc.perform(put("/api/tb-block-details-logs") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBBlockDetailsLogDTO))) | |||
| .andExpect(status().isBadRequest()); | |||
| // Validate the TBBlockDetailsLog in the database | |||
| List<TBBlockDetailsLog> tBBlockDetailsLogList = tBBlockDetailsLogRepository.findAll(); | |||
| assertThat(tBBlockDetailsLogList).hasSize(databaseSizeBeforeUpdate); | |||
| // Validate the TBBlockDetailsLog in Elasticsearch | |||
| verify(mockTBBlockDetailsLogSearchRepository, times(0)).save(tBBlockDetailsLog); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void deleteTBBlockDetailsLog() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsLogRepository.saveAndFlush(tBBlockDetailsLog); | |||
| int databaseSizeBeforeDelete = tBBlockDetailsLogRepository.findAll().size(); | |||
| // Get the tBBlockDetailsLog | |||
| restTBBlockDetailsLogMockMvc.perform(delete("/api/tb-block-details-logs/{id}", tBBlockDetailsLog.getId()) | |||
| .accept(TestUtil.APPLICATION_JSON_UTF8)) | |||
| .andExpect(status().isOk()); | |||
| // Validate the database is empty | |||
| List<TBBlockDetailsLog> tBBlockDetailsLogList = tBBlockDetailsLogRepository.findAll(); | |||
| assertThat(tBBlockDetailsLogList).hasSize(databaseSizeBeforeDelete - 1); | |||
| // Validate the TBBlockDetailsLog in Elasticsearch | |||
| verify(mockTBBlockDetailsLogSearchRepository, times(1)).deleteById(tBBlockDetailsLog.getId()); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void searchTBBlockDetailsLog() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsLogRepository.saveAndFlush(tBBlockDetailsLog); | |||
| when(mockTBBlockDetailsLogSearchRepository.search(queryStringQuery("id:" + tBBlockDetailsLog.getId()), PageRequest.of(0, 20))) | |||
| .thenReturn(new PageImpl<>(Collections.singletonList(tBBlockDetailsLog), PageRequest.of(0, 1), 1)); | |||
| // Search the tBBlockDetailsLog | |||
| restTBBlockDetailsLogMockMvc.perform(get("/api/_search/tb-block-details-logs?query=id:" + tBBlockDetailsLog.getId())) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.[*].id").value(hasItem(tBBlockDetailsLog.getId().intValue()))); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void equalsVerifier() throws Exception { | |||
| TestUtil.equalsVerifier(TBBlockDetailsLog.class); | |||
| TBBlockDetailsLog tBBlockDetailsLog1 = new TBBlockDetailsLog(); | |||
| tBBlockDetailsLog1.setId(1L); | |||
| TBBlockDetailsLog tBBlockDetailsLog2 = new TBBlockDetailsLog(); | |||
| tBBlockDetailsLog2.setId(tBBlockDetailsLog1.getId()); | |||
| assertThat(tBBlockDetailsLog1).isEqualTo(tBBlockDetailsLog2); | |||
| tBBlockDetailsLog2.setId(2L); | |||
| assertThat(tBBlockDetailsLog1).isNotEqualTo(tBBlockDetailsLog2); | |||
| tBBlockDetailsLog1.setId(null); | |||
| assertThat(tBBlockDetailsLog1).isNotEqualTo(tBBlockDetailsLog2); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void dtoEqualsVerifier() throws Exception { | |||
| TestUtil.equalsVerifier(TBBlockDetailsLogDTO.class); | |||
| TBBlockDetailsLogDTO tBBlockDetailsLogDTO1 = new TBBlockDetailsLogDTO(); | |||
| tBBlockDetailsLogDTO1.setId(1L); | |||
| TBBlockDetailsLogDTO tBBlockDetailsLogDTO2 = new TBBlockDetailsLogDTO(); | |||
| assertThat(tBBlockDetailsLogDTO1).isNotEqualTo(tBBlockDetailsLogDTO2); | |||
| tBBlockDetailsLogDTO2.setId(tBBlockDetailsLogDTO1.getId()); | |||
| assertThat(tBBlockDetailsLogDTO1).isEqualTo(tBBlockDetailsLogDTO2); | |||
| tBBlockDetailsLogDTO2.setId(2L); | |||
| assertThat(tBBlockDetailsLogDTO1).isNotEqualTo(tBBlockDetailsLogDTO2); | |||
| tBBlockDetailsLogDTO1.setId(null); | |||
| assertThat(tBBlockDetailsLogDTO1).isNotEqualTo(tBBlockDetailsLogDTO2); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void testEntityFromId() { | |||
| assertThat(tBBlockDetailsLogMapper.fromId(42L).getId()).isEqualTo(42); | |||
| assertThat(tBBlockDetailsLogMapper.fromId(null)).isNull(); | |||
| } | |||
| } | |||
| @@ -1,567 +0,0 @@ | |||
| package vn.azteam.tpf.web.rest; | |||
| import vn.azteam.tpf.TpfApp; | |||
| import vn.azteam.tpf.domain.TBBlockDetailsReport; | |||
| import vn.azteam.tpf.domain.TBBlockDetails; | |||
| import vn.azteam.tpf.domain.TBSuppliesType; | |||
| import vn.azteam.tpf.domain.TBSuppliesInWarehouse; | |||
| import vn.azteam.tpf.repository.TBBlockDetailsReportRepository; | |||
| import vn.azteam.tpf.repository.search.TBBlockDetailsReportSearchRepository; | |||
| import vn.azteam.tpf.service.TBBlockDetailsReportService; | |||
| import vn.azteam.tpf.service.dto.TBBlockDetailsReportDTO; | |||
| import vn.azteam.tpf.service.mapper.TBBlockDetailsReportMapper; | |||
| import vn.azteam.tpf.web.rest.errors.ExceptionTranslator; | |||
| import vn.azteam.tpf.service.dto.TBBlockDetailsReportCriteria; | |||
| import vn.azteam.tpf.service.TBBlockDetailsReportQueryService; | |||
| import org.junit.Before; | |||
| import org.junit.Test; | |||
| import org.junit.runner.RunWith; | |||
| import org.mockito.MockitoAnnotations; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.boot.test.context.SpringBootTest; | |||
| import org.springframework.data.domain.PageImpl; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.data.web.PageableHandlerMethodArgumentResolver; | |||
| import org.springframework.http.MediaType; | |||
| import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |||
| import org.springframework.test.context.junit4.SpringRunner; | |||
| import org.springframework.test.web.servlet.MockMvc; | |||
| import org.springframework.test.web.servlet.setup.MockMvcBuilders; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import org.springframework.validation.Validator; | |||
| import javax.persistence.EntityManager; | |||
| import java.time.Instant; | |||
| import java.time.temporal.ChronoUnit; | |||
| import java.util.Collections; | |||
| import java.util.List; | |||
| import static vn.azteam.tpf.web.rest.TestUtil.createFormattingConversionService; | |||
| import static org.assertj.core.api.Assertions.assertThat; | |||
| import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery; | |||
| import static org.hamcrest.Matchers.hasItem; | |||
| import static org.mockito.Mockito.*; | |||
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | |||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | |||
| /** | |||
| * Test class for the TBBlockDetailsReportResource REST controller. | |||
| * | |||
| * @see TBBlockDetailsReportResource | |||
| */ | |||
| @RunWith(SpringRunner.class) | |||
| @SpringBootTest(classes = TpfApp.class) | |||
| public class TBBlockDetailsReportResourceIntTest { | |||
| private static final String DEFAULT_CODE = "AAAAAAAAAA"; | |||
| private static final String UPDATED_CODE = "BBBBBBBBBB"; | |||
| private static final Double DEFAULT_QUANTITY = 1D; | |||
| private static final Double UPDATED_QUANTITY = 2D; | |||
| private static final Instant DEFAULT_CREATE_DATE = Instant.ofEpochMilli(0L); | |||
| private static final Instant UPDATED_CREATE_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS); | |||
| @Autowired | |||
| private TBBlockDetailsReportRepository tBBlockDetailsReportRepository; | |||
| @Autowired | |||
| private TBBlockDetailsReportMapper tBBlockDetailsReportMapper; | |||
| @Autowired | |||
| private TBBlockDetailsReportService tBBlockDetailsReportService; | |||
| /** | |||
| * This repository is mocked in the vn.azteam.tpf.repository.search test package. | |||
| * | |||
| * @see vn.azteam.tpf.repository.search.TBBlockDetailsReportSearchRepositoryMockConfiguration | |||
| */ | |||
| @Autowired | |||
| private TBBlockDetailsReportSearchRepository mockTBBlockDetailsReportSearchRepository; | |||
| @Autowired | |||
| private TBBlockDetailsReportQueryService tBBlockDetailsReportQueryService; | |||
| @Autowired | |||
| private MappingJackson2HttpMessageConverter jacksonMessageConverter; | |||
| @Autowired | |||
| private PageableHandlerMethodArgumentResolver pageableArgumentResolver; | |||
| @Autowired | |||
| private ExceptionTranslator exceptionTranslator; | |||
| @Autowired | |||
| private EntityManager em; | |||
| @Autowired | |||
| private Validator validator; | |||
| private MockMvc restTBBlockDetailsReportMockMvc; | |||
| private TBBlockDetailsReport tBBlockDetailsReport; | |||
| @Before | |||
| public void setup() { | |||
| MockitoAnnotations.initMocks(this); | |||
| final TBBlockDetailsReportResource tBBlockDetailsReportResource = new TBBlockDetailsReportResource(tBBlockDetailsReportService, tBBlockDetailsReportQueryService); | |||
| this.restTBBlockDetailsReportMockMvc = MockMvcBuilders.standaloneSetup(tBBlockDetailsReportResource) | |||
| .setCustomArgumentResolvers(pageableArgumentResolver) | |||
| .setControllerAdvice(exceptionTranslator) | |||
| .setConversionService(createFormattingConversionService()) | |||
| .setMessageConverters(jacksonMessageConverter) | |||
| .setValidator(validator).build(); | |||
| } | |||
| /** | |||
| * 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 TBBlockDetailsReport createEntity(EntityManager em) { | |||
| TBBlockDetailsReport tBBlockDetailsReport = new TBBlockDetailsReport() | |||
| .code(DEFAULT_CODE) | |||
| .quantity(DEFAULT_QUANTITY) | |||
| .createDate(DEFAULT_CREATE_DATE); | |||
| return tBBlockDetailsReport; | |||
| } | |||
| @Before | |||
| public void initTest() { | |||
| tBBlockDetailsReport = createEntity(em); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void createTBBlockDetailsReport() throws Exception { | |||
| int databaseSizeBeforeCreate = tBBlockDetailsReportRepository.findAll().size(); | |||
| // Create the TBBlockDetailsReport | |||
| TBBlockDetailsReportDTO tBBlockDetailsReportDTO = tBBlockDetailsReportMapper.toDto(tBBlockDetailsReport); | |||
| restTBBlockDetailsReportMockMvc.perform(post("/api/tb-block-details-reports") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBBlockDetailsReportDTO))) | |||
| .andExpect(status().isCreated()); | |||
| // Validate the TBBlockDetailsReport in the database | |||
| List<TBBlockDetailsReport> tBBlockDetailsReportList = tBBlockDetailsReportRepository.findAll(); | |||
| assertThat(tBBlockDetailsReportList).hasSize(databaseSizeBeforeCreate + 1); | |||
| TBBlockDetailsReport testTBBlockDetailsReport = tBBlockDetailsReportList.get(tBBlockDetailsReportList.size() - 1); | |||
| assertThat(testTBBlockDetailsReport.getCode()).isEqualTo(DEFAULT_CODE); | |||
| assertThat(testTBBlockDetailsReport.getQuantity()).isEqualTo(DEFAULT_QUANTITY); | |||
| assertThat(testTBBlockDetailsReport.getCreateDate()).isEqualTo(DEFAULT_CREATE_DATE); | |||
| // Validate the TBBlockDetailsReport in Elasticsearch | |||
| verify(mockTBBlockDetailsReportSearchRepository, times(1)).save(testTBBlockDetailsReport); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void createTBBlockDetailsReportWithExistingId() throws Exception { | |||
| int databaseSizeBeforeCreate = tBBlockDetailsReportRepository.findAll().size(); | |||
| // Create the TBBlockDetailsReport with an existing ID | |||
| tBBlockDetailsReport.setId(1L); | |||
| TBBlockDetailsReportDTO tBBlockDetailsReportDTO = tBBlockDetailsReportMapper.toDto(tBBlockDetailsReport); | |||
| // An entity with an existing ID cannot be created, so this API call must fail | |||
| restTBBlockDetailsReportMockMvc.perform(post("/api/tb-block-details-reports") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBBlockDetailsReportDTO))) | |||
| .andExpect(status().isBadRequest()); | |||
| // Validate the TBBlockDetailsReport in the database | |||
| List<TBBlockDetailsReport> tBBlockDetailsReportList = tBBlockDetailsReportRepository.findAll(); | |||
| assertThat(tBBlockDetailsReportList).hasSize(databaseSizeBeforeCreate); | |||
| // Validate the TBBlockDetailsReport in Elasticsearch | |||
| verify(mockTBBlockDetailsReportSearchRepository, times(0)).save(tBBlockDetailsReport); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReports() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| // Get all the tBBlockDetailsReportList | |||
| restTBBlockDetailsReportMockMvc.perform(get("/api/tb-block-details-reports?sort=id,desc")) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.[*].id").value(hasItem(tBBlockDetailsReport.getId().intValue()))) | |||
| .andExpect(jsonPath("$.[*].code").value(hasItem(DEFAULT_CODE.toString()))) | |||
| .andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY.doubleValue()))) | |||
| .andExpect(jsonPath("$.[*].createDate").value(hasItem(DEFAULT_CREATE_DATE.toString()))); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getTBBlockDetailsReport() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| // Get the tBBlockDetailsReport | |||
| restTBBlockDetailsReportMockMvc.perform(get("/api/tb-block-details-reports/{id}", tBBlockDetailsReport.getId())) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.id").value(tBBlockDetailsReport.getId().intValue())) | |||
| .andExpect(jsonPath("$.code").value(DEFAULT_CODE.toString())) | |||
| .andExpect(jsonPath("$.quantity").value(DEFAULT_QUANTITY.doubleValue())) | |||
| .andExpect(jsonPath("$.createDate").value(DEFAULT_CREATE_DATE.toString())); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReportsByCodeIsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| // Get all the tBBlockDetailsReportList where code equals to DEFAULT_CODE | |||
| defaultTBBlockDetailsReportShouldBeFound("code.equals=" + DEFAULT_CODE); | |||
| // Get all the tBBlockDetailsReportList where code equals to UPDATED_CODE | |||
| defaultTBBlockDetailsReportShouldNotBeFound("code.equals=" + UPDATED_CODE); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReportsByCodeIsInShouldWork() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| // Get all the tBBlockDetailsReportList where code in DEFAULT_CODE or UPDATED_CODE | |||
| defaultTBBlockDetailsReportShouldBeFound("code.in=" + DEFAULT_CODE + "," + UPDATED_CODE); | |||
| // Get all the tBBlockDetailsReportList where code equals to UPDATED_CODE | |||
| defaultTBBlockDetailsReportShouldNotBeFound("code.in=" + UPDATED_CODE); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReportsByCodeIsNullOrNotNull() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| // Get all the tBBlockDetailsReportList where code is not null | |||
| defaultTBBlockDetailsReportShouldBeFound("code.specified=true"); | |||
| // Get all the tBBlockDetailsReportList where code is null | |||
| defaultTBBlockDetailsReportShouldNotBeFound("code.specified=false"); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReportsByQuantityIsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| // Get all the tBBlockDetailsReportList where quantity equals to DEFAULT_QUANTITY | |||
| defaultTBBlockDetailsReportShouldBeFound("quantity.equals=" + DEFAULT_QUANTITY); | |||
| // Get all the tBBlockDetailsReportList where quantity equals to UPDATED_QUANTITY | |||
| defaultTBBlockDetailsReportShouldNotBeFound("quantity.equals=" + UPDATED_QUANTITY); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReportsByQuantityIsInShouldWork() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| // Get all the tBBlockDetailsReportList where quantity in DEFAULT_QUANTITY or UPDATED_QUANTITY | |||
| defaultTBBlockDetailsReportShouldBeFound("quantity.in=" + DEFAULT_QUANTITY + "," + UPDATED_QUANTITY); | |||
| // Get all the tBBlockDetailsReportList where quantity equals to UPDATED_QUANTITY | |||
| defaultTBBlockDetailsReportShouldNotBeFound("quantity.in=" + UPDATED_QUANTITY); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReportsByQuantityIsNullOrNotNull() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| // Get all the tBBlockDetailsReportList where quantity is not null | |||
| defaultTBBlockDetailsReportShouldBeFound("quantity.specified=true"); | |||
| // Get all the tBBlockDetailsReportList where quantity is null | |||
| defaultTBBlockDetailsReportShouldNotBeFound("quantity.specified=false"); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReportsByCreateDateIsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| // Get all the tBBlockDetailsReportList where createDate equals to DEFAULT_CREATE_DATE | |||
| defaultTBBlockDetailsReportShouldBeFound("createDate.equals=" + DEFAULT_CREATE_DATE); | |||
| // Get all the tBBlockDetailsReportList where createDate equals to UPDATED_CREATE_DATE | |||
| defaultTBBlockDetailsReportShouldNotBeFound("createDate.equals=" + UPDATED_CREATE_DATE); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReportsByCreateDateIsInShouldWork() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| // Get all the tBBlockDetailsReportList where createDate in DEFAULT_CREATE_DATE or UPDATED_CREATE_DATE | |||
| defaultTBBlockDetailsReportShouldBeFound("createDate.in=" + DEFAULT_CREATE_DATE + "," + UPDATED_CREATE_DATE); | |||
| // Get all the tBBlockDetailsReportList where createDate equals to UPDATED_CREATE_DATE | |||
| defaultTBBlockDetailsReportShouldNotBeFound("createDate.in=" + UPDATED_CREATE_DATE); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReportsByCreateDateIsNullOrNotNull() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| // Get all the tBBlockDetailsReportList where createDate is not null | |||
| defaultTBBlockDetailsReportShouldBeFound("createDate.specified=true"); | |||
| // Get all the tBBlockDetailsReportList where createDate is null | |||
| defaultTBBlockDetailsReportShouldNotBeFound("createDate.specified=false"); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReportsByTbBlockDetailsIsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| TBBlockDetails tbBlockDetails = TBBlockDetailsResourceIntTest.createEntity(em); | |||
| em.persist(tbBlockDetails); | |||
| em.flush(); | |||
| tBBlockDetailsReport.setTbBlockDetails(tbBlockDetails); | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| Long tbBlockDetailsId = tbBlockDetails.getId(); | |||
| // Get all the tBBlockDetailsReportList where tbBlockDetails equals to tbBlockDetailsId | |||
| defaultTBBlockDetailsReportShouldBeFound("tbBlockDetailsId.equals=" + tbBlockDetailsId); | |||
| // Get all the tBBlockDetailsReportList where tbBlockDetails equals to tbBlockDetailsId + 1 | |||
| defaultTBBlockDetailsReportShouldNotBeFound("tbBlockDetailsId.equals=" + (tbBlockDetailsId + 1)); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReportsByTbSuppliesTypeIsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| TBSuppliesType tbSuppliesType = TBSuppliesTypeResourceIntTest.createEntity(em); | |||
| em.persist(tbSuppliesType); | |||
| em.flush(); | |||
| tBBlockDetailsReport.setTbSuppliesType(tbSuppliesType); | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| Long tbSuppliesTypeId = tbSuppliesType.getId(); | |||
| // Get all the tBBlockDetailsReportList where tbSuppliesType equals to tbSuppliesTypeId | |||
| defaultTBBlockDetailsReportShouldBeFound("tbSuppliesTypeId.equals=" + tbSuppliesTypeId); | |||
| // Get all the tBBlockDetailsReportList where tbSuppliesType equals to tbSuppliesTypeId + 1 | |||
| defaultTBBlockDetailsReportShouldNotBeFound("tbSuppliesTypeId.equals=" + (tbSuppliesTypeId + 1)); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBBlockDetailsReportsByTbSuppliesInWarehouseIsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| TBSuppliesInWarehouse tbSuppliesInWarehouse = TBSuppliesInWarehouseResourceIntTest.createEntity(em); | |||
| em.persist(tbSuppliesInWarehouse); | |||
| em.flush(); | |||
| tBBlockDetailsReport.setTbSuppliesInWarehouse(tbSuppliesInWarehouse); | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| Long tbSuppliesInWarehouseId = tbSuppliesInWarehouse.getId(); | |||
| // Get all the tBBlockDetailsReportList where tbSuppliesInWarehouse equals to tbSuppliesInWarehouseId | |||
| defaultTBBlockDetailsReportShouldBeFound("tbSuppliesInWarehouseId.equals=" + tbSuppliesInWarehouseId); | |||
| // Get all the tBBlockDetailsReportList where tbSuppliesInWarehouse equals to tbSuppliesInWarehouseId + 1 | |||
| defaultTBBlockDetailsReportShouldNotBeFound("tbSuppliesInWarehouseId.equals=" + (tbSuppliesInWarehouseId + 1)); | |||
| } | |||
| /** | |||
| * Executes the search, and checks that the default entity is returned | |||
| */ | |||
| private void defaultTBBlockDetailsReportShouldBeFound(String filter) throws Exception { | |||
| restTBBlockDetailsReportMockMvc.perform(get("/api/tb-block-details-reports?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.[*].id").value(hasItem(tBBlockDetailsReport.getId().intValue()))) | |||
| .andExpect(jsonPath("$.[*].code").value(hasItem(DEFAULT_CODE.toString()))) | |||
| .andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY.doubleValue()))) | |||
| .andExpect(jsonPath("$.[*].createDate").value(hasItem(DEFAULT_CREATE_DATE.toString()))); | |||
| // Check, that the count call also returns 1 | |||
| restTBBlockDetailsReportMockMvc.perform(get("/api/tb-block-details-reports/count?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(content().string("1")); | |||
| } | |||
| /** | |||
| * Executes the search, and checks that the default entity is not returned | |||
| */ | |||
| private void defaultTBBlockDetailsReportShouldNotBeFound(String filter) throws Exception { | |||
| restTBBlockDetailsReportMockMvc.perform(get("/api/tb-block-details-reports?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$").isArray()) | |||
| .andExpect(jsonPath("$").isEmpty()); | |||
| // Check, that the count call also returns 0 | |||
| restTBBlockDetailsReportMockMvc.perform(get("/api/tb-block-details-reports/count?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(content().string("0")); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getNonExistingTBBlockDetailsReport() throws Exception { | |||
| // Get the tBBlockDetailsReport | |||
| restTBBlockDetailsReportMockMvc.perform(get("/api/tb-block-details-reports/{id}", Long.MAX_VALUE)) | |||
| .andExpect(status().isNotFound()); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void updateTBBlockDetailsReport() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| int databaseSizeBeforeUpdate = tBBlockDetailsReportRepository.findAll().size(); | |||
| // Update the tBBlockDetailsReport | |||
| TBBlockDetailsReport updatedTBBlockDetailsReport = tBBlockDetailsReportRepository.findById(tBBlockDetailsReport.getId()).get(); | |||
| // Disconnect from session so that the updates on updatedTBBlockDetailsReport are not directly saved in db | |||
| em.detach(updatedTBBlockDetailsReport); | |||
| updatedTBBlockDetailsReport | |||
| .code(UPDATED_CODE) | |||
| .quantity(UPDATED_QUANTITY) | |||
| .createDate(UPDATED_CREATE_DATE); | |||
| TBBlockDetailsReportDTO tBBlockDetailsReportDTO = tBBlockDetailsReportMapper.toDto(updatedTBBlockDetailsReport); | |||
| restTBBlockDetailsReportMockMvc.perform(put("/api/tb-block-details-reports") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBBlockDetailsReportDTO))) | |||
| .andExpect(status().isOk()); | |||
| // Validate the TBBlockDetailsReport in the database | |||
| List<TBBlockDetailsReport> tBBlockDetailsReportList = tBBlockDetailsReportRepository.findAll(); | |||
| assertThat(tBBlockDetailsReportList).hasSize(databaseSizeBeforeUpdate); | |||
| TBBlockDetailsReport testTBBlockDetailsReport = tBBlockDetailsReportList.get(tBBlockDetailsReportList.size() - 1); | |||
| assertThat(testTBBlockDetailsReport.getCode()).isEqualTo(UPDATED_CODE); | |||
| assertThat(testTBBlockDetailsReport.getQuantity()).isEqualTo(UPDATED_QUANTITY); | |||
| assertThat(testTBBlockDetailsReport.getCreateDate()).isEqualTo(UPDATED_CREATE_DATE); | |||
| // Validate the TBBlockDetailsReport in Elasticsearch | |||
| verify(mockTBBlockDetailsReportSearchRepository, times(1)).save(testTBBlockDetailsReport); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void updateNonExistingTBBlockDetailsReport() throws Exception { | |||
| int databaseSizeBeforeUpdate = tBBlockDetailsReportRepository.findAll().size(); | |||
| // Create the TBBlockDetailsReport | |||
| TBBlockDetailsReportDTO tBBlockDetailsReportDTO = tBBlockDetailsReportMapper.toDto(tBBlockDetailsReport); | |||
| // If the entity doesn't have an ID, it will throw BadRequestAlertException | |||
| restTBBlockDetailsReportMockMvc.perform(put("/api/tb-block-details-reports") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBBlockDetailsReportDTO))) | |||
| .andExpect(status().isBadRequest()); | |||
| // Validate the TBBlockDetailsReport in the database | |||
| List<TBBlockDetailsReport> tBBlockDetailsReportList = tBBlockDetailsReportRepository.findAll(); | |||
| assertThat(tBBlockDetailsReportList).hasSize(databaseSizeBeforeUpdate); | |||
| // Validate the TBBlockDetailsReport in Elasticsearch | |||
| verify(mockTBBlockDetailsReportSearchRepository, times(0)).save(tBBlockDetailsReport); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void deleteTBBlockDetailsReport() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| int databaseSizeBeforeDelete = tBBlockDetailsReportRepository.findAll().size(); | |||
| // Get the tBBlockDetailsReport | |||
| restTBBlockDetailsReportMockMvc.perform(delete("/api/tb-block-details-reports/{id}", tBBlockDetailsReport.getId()) | |||
| .accept(TestUtil.APPLICATION_JSON_UTF8)) | |||
| .andExpect(status().isOk()); | |||
| // Validate the database is empty | |||
| List<TBBlockDetailsReport> tBBlockDetailsReportList = tBBlockDetailsReportRepository.findAll(); | |||
| assertThat(tBBlockDetailsReportList).hasSize(databaseSizeBeforeDelete - 1); | |||
| // Validate the TBBlockDetailsReport in Elasticsearch | |||
| verify(mockTBBlockDetailsReportSearchRepository, times(1)).deleteById(tBBlockDetailsReport.getId()); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void searchTBBlockDetailsReport() throws Exception { | |||
| // Initialize the database | |||
| tBBlockDetailsReportRepository.saveAndFlush(tBBlockDetailsReport); | |||
| when(mockTBBlockDetailsReportSearchRepository.search(queryStringQuery("id:" + tBBlockDetailsReport.getId()), PageRequest.of(0, 20))) | |||
| .thenReturn(new PageImpl<>(Collections.singletonList(tBBlockDetailsReport), PageRequest.of(0, 1), 1)); | |||
| // Search the tBBlockDetailsReport | |||
| restTBBlockDetailsReportMockMvc.perform(get("/api/_search/tb-block-details-reports?query=id:" + tBBlockDetailsReport.getId())) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.[*].id").value(hasItem(tBBlockDetailsReport.getId().intValue()))) | |||
| .andExpect(jsonPath("$.[*].code").value(hasItem(DEFAULT_CODE))) | |||
| .andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY.doubleValue()))) | |||
| .andExpect(jsonPath("$.[*].createDate").value(hasItem(DEFAULT_CREATE_DATE.toString()))); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void equalsVerifier() throws Exception { | |||
| TestUtil.equalsVerifier(TBBlockDetailsReport.class); | |||
| TBBlockDetailsReport tBBlockDetailsReport1 = new TBBlockDetailsReport(); | |||
| tBBlockDetailsReport1.setId(1L); | |||
| TBBlockDetailsReport tBBlockDetailsReport2 = new TBBlockDetailsReport(); | |||
| tBBlockDetailsReport2.setId(tBBlockDetailsReport1.getId()); | |||
| assertThat(tBBlockDetailsReport1).isEqualTo(tBBlockDetailsReport2); | |||
| tBBlockDetailsReport2.setId(2L); | |||
| assertThat(tBBlockDetailsReport1).isNotEqualTo(tBBlockDetailsReport2); | |||
| tBBlockDetailsReport1.setId(null); | |||
| assertThat(tBBlockDetailsReport1).isNotEqualTo(tBBlockDetailsReport2); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void dtoEqualsVerifier() throws Exception { | |||
| TestUtil.equalsVerifier(TBBlockDetailsReportDTO.class); | |||
| TBBlockDetailsReportDTO tBBlockDetailsReportDTO1 = new TBBlockDetailsReportDTO(); | |||
| tBBlockDetailsReportDTO1.setId(1L); | |||
| TBBlockDetailsReportDTO tBBlockDetailsReportDTO2 = new TBBlockDetailsReportDTO(); | |||
| assertThat(tBBlockDetailsReportDTO1).isNotEqualTo(tBBlockDetailsReportDTO2); | |||
| tBBlockDetailsReportDTO2.setId(tBBlockDetailsReportDTO1.getId()); | |||
| assertThat(tBBlockDetailsReportDTO1).isEqualTo(tBBlockDetailsReportDTO2); | |||
| tBBlockDetailsReportDTO2.setId(2L); | |||
| assertThat(tBBlockDetailsReportDTO1).isNotEqualTo(tBBlockDetailsReportDTO2); | |||
| tBBlockDetailsReportDTO1.setId(null); | |||
| assertThat(tBBlockDetailsReportDTO1).isNotEqualTo(tBBlockDetailsReportDTO2); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void testEntityFromId() { | |||
| assertThat(tBBlockDetailsReportMapper.fromId(42L).getId()).isEqualTo(42); | |||
| assertThat(tBBlockDetailsReportMapper.fromId(null)).isNull(); | |||
| } | |||
| } | |||
| @@ -1,346 +0,0 @@ | |||
| package vn.azteam.tpf.web.rest; | |||
| import vn.azteam.tpf.TpfApp; | |||
| import vn.azteam.tpf.web.rest.errors.ExceptionTranslator; | |||
| import org.junit.Before; | |||
| import org.junit.Test; | |||
| import org.junit.runner.RunWith; | |||
| import org.mockito.MockitoAnnotations; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.boot.test.context.SpringBootTest; | |||
| import org.springframework.data.domain.PageImpl; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.data.web.PageableHandlerMethodArgumentResolver; | |||
| import org.springframework.http.MediaType; | |||
| import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |||
| import org.springframework.test.context.junit4.SpringRunner; | |||
| import org.springframework.test.web.servlet.MockMvc; | |||
| import org.springframework.test.web.servlet.setup.MockMvcBuilders; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import org.springframework.validation.Validator; | |||
| import javax.persistence.EntityManager; | |||
| import java.util.Collections; | |||
| import java.util.List; | |||
| import static vn.azteam.tpf.web.rest.TestUtil.createFormattingConversionService; | |||
| import static org.assertj.core.api.Assertions.assertThat; | |||
| import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery; | |||
| import static org.hamcrest.Matchers.hasItem; | |||
| import static org.mockito.Mockito.*; | |||
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | |||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | |||
| /** | |||
| * Test class for the TBProductBlockDetailsLogResource REST controller. | |||
| * | |||
| * @see TBProductBlockDetailsLogResource | |||
| */ | |||
| @RunWith(SpringRunner.class) | |||
| @SpringBootTest(classes = TpfApp.class) | |||
| public class TBProductBlockDetailsLogResourceIntTest { | |||
| @Autowired | |||
| private TBProductBlockDetailsLogRepository tBProductBlockDetailsLogRepository; | |||
| @Autowired | |||
| private TBProductBlockDetailsLogMapper tBProductBlockDetailsLogMapper; | |||
| @Autowired | |||
| private TBProductBlockDetailsLogService tBProductBlockDetailsLogService; | |||
| /** | |||
| * This repository is mocked in the vn.azteam.tpf.repository.search test package. | |||
| * | |||
| * @see vn.azteam.tpf.repository.search.TBProductBlockDetailsLogSearchRepositoryMockConfiguration | |||
| */ | |||
| @Autowired | |||
| private TBProductBlockDetailsLogSearchRepository mockTBProductBlockDetailsLogSearchRepository; | |||
| @Autowired | |||
| private TBProductBlockDetailsLogQueryService tBProductBlockDetailsLogQueryService; | |||
| @Autowired | |||
| private MappingJackson2HttpMessageConverter jacksonMessageConverter; | |||
| @Autowired | |||
| private PageableHandlerMethodArgumentResolver pageableArgumentResolver; | |||
| @Autowired | |||
| private ExceptionTranslator exceptionTranslator; | |||
| @Autowired | |||
| private EntityManager em; | |||
| @Autowired | |||
| private Validator validator; | |||
| private MockMvc restTBProductBlockDetailsLogMockMvc; | |||
| private TBProductBlockDetailsLog tBProductBlockDetailsLog; | |||
| @Before | |||
| public void setup() { | |||
| MockitoAnnotations.initMocks(this); | |||
| final TBProductBlockDetailsLogResource tBProductBlockDetailsLogResource = new TBProductBlockDetailsLogResource(tBProductBlockDetailsLogService, tBProductBlockDetailsLogQueryService); | |||
| this.restTBProductBlockDetailsLogMockMvc = MockMvcBuilders.standaloneSetup(tBProductBlockDetailsLogResource) | |||
| .setCustomArgumentResolvers(pageableArgumentResolver) | |||
| .setControllerAdvice(exceptionTranslator) | |||
| .setConversionService(createFormattingConversionService()) | |||
| .setMessageConverters(jacksonMessageConverter) | |||
| .setValidator(validator).build(); | |||
| } | |||
| /** | |||
| * 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 TBProductBlockDetailsLog createEntity(EntityManager em) { | |||
| TBProductBlockDetailsLog tBProductBlockDetailsLog = new TBProductBlockDetailsLog(); | |||
| return tBProductBlockDetailsLog; | |||
| } | |||
| @Before | |||
| public void initTest() { | |||
| tBProductBlockDetailsLog = createEntity(em); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void createTBProductBlockDetailsLog() throws Exception { | |||
| int databaseSizeBeforeCreate = tBProductBlockDetailsLogRepository.findAll().size(); | |||
| // Create the TBProductBlockDetailsLog | |||
| TBProductBlockDetailsLogDTO tBProductBlockDetailsLogDTO = tBProductBlockDetailsLogMapper.toDto(tBProductBlockDetailsLog); | |||
| restTBProductBlockDetailsLogMockMvc.perform(post("/api/tb-product-block-details-logs") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBProductBlockDetailsLogDTO))) | |||
| .andExpect(status().isCreated()); | |||
| // Validate the TBProductBlockDetailsLog in the database | |||
| List<TBProductBlockDetailsLog> tBProductBlockDetailsLogList = tBProductBlockDetailsLogRepository.findAll(); | |||
| assertThat(tBProductBlockDetailsLogList).hasSize(databaseSizeBeforeCreate + 1); | |||
| TBProductBlockDetailsLog testTBProductBlockDetailsLog = tBProductBlockDetailsLogList.get(tBProductBlockDetailsLogList.size() - 1); | |||
| // Validate the TBProductBlockDetailsLog in Elasticsearch | |||
| verify(mockTBProductBlockDetailsLogSearchRepository, times(1)).save(testTBProductBlockDetailsLog); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void createTBProductBlockDetailsLogWithExistingId() throws Exception { | |||
| int databaseSizeBeforeCreate = tBProductBlockDetailsLogRepository.findAll().size(); | |||
| // Create the TBProductBlockDetailsLog with an existing ID | |||
| tBProductBlockDetailsLog.setId(1L); | |||
| TBProductBlockDetailsLogDTO tBProductBlockDetailsLogDTO = tBProductBlockDetailsLogMapper.toDto(tBProductBlockDetailsLog); | |||
| // An entity with an existing ID cannot be created, so this API call must fail | |||
| restTBProductBlockDetailsLogMockMvc.perform(post("/api/tb-product-block-details-logs") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBProductBlockDetailsLogDTO))) | |||
| .andExpect(status().isBadRequest()); | |||
| // Validate the TBProductBlockDetailsLog in the database | |||
| List<TBProductBlockDetailsLog> tBProductBlockDetailsLogList = tBProductBlockDetailsLogRepository.findAll(); | |||
| assertThat(tBProductBlockDetailsLogList).hasSize(databaseSizeBeforeCreate); | |||
| // Validate the TBProductBlockDetailsLog in Elasticsearch | |||
| verify(mockTBProductBlockDetailsLogSearchRepository, times(0)).save(tBProductBlockDetailsLog); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsLogs() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsLogRepository.saveAndFlush(tBProductBlockDetailsLog); | |||
| // Get all the tBProductBlockDetailsLogList | |||
| restTBProductBlockDetailsLogMockMvc.perform(get("/api/tb-product-block-details-logs?sort=id,desc")) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.[*].id").value(hasItem(tBProductBlockDetailsLog.getId().intValue()))); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getTBProductBlockDetailsLog() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsLogRepository.saveAndFlush(tBProductBlockDetailsLog); | |||
| // Get the tBProductBlockDetailsLog | |||
| restTBProductBlockDetailsLogMockMvc.perform(get("/api/tb-product-block-details-logs/{id}", tBProductBlockDetailsLog.getId())) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.id").value(tBProductBlockDetailsLog.getId().intValue())); | |||
| } | |||
| /** | |||
| * Executes the search, and checks that the default entity is returned | |||
| */ | |||
| private void defaultTBProductBlockDetailsLogShouldBeFound(String filter) throws Exception { | |||
| restTBProductBlockDetailsLogMockMvc.perform(get("/api/tb-product-block-details-logs?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.[*].id").value(hasItem(tBProductBlockDetailsLog.getId().intValue()))); | |||
| // Check, that the count call also returns 1 | |||
| restTBProductBlockDetailsLogMockMvc.perform(get("/api/tb-product-block-details-logs/count?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(content().string("1")); | |||
| } | |||
| /** | |||
| * Executes the search, and checks that the default entity is not returned | |||
| */ | |||
| private void defaultTBProductBlockDetailsLogShouldNotBeFound(String filter) throws Exception { | |||
| restTBProductBlockDetailsLogMockMvc.perform(get("/api/tb-product-block-details-logs?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$").isArray()) | |||
| .andExpect(jsonPath("$").isEmpty()); | |||
| // Check, that the count call also returns 0 | |||
| restTBProductBlockDetailsLogMockMvc.perform(get("/api/tb-product-block-details-logs/count?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(content().string("0")); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getNonExistingTBProductBlockDetailsLog() throws Exception { | |||
| // Get the tBProductBlockDetailsLog | |||
| restTBProductBlockDetailsLogMockMvc.perform(get("/api/tb-product-block-details-logs/{id}", Long.MAX_VALUE)) | |||
| .andExpect(status().isNotFound()); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void updateTBProductBlockDetailsLog() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsLogRepository.saveAndFlush(tBProductBlockDetailsLog); | |||
| int databaseSizeBeforeUpdate = tBProductBlockDetailsLogRepository.findAll().size(); | |||
| // Update the tBProductBlockDetailsLog | |||
| TBProductBlockDetailsLog updatedTBProductBlockDetailsLog = tBProductBlockDetailsLogRepository.findById(tBProductBlockDetailsLog.getId()).get(); | |||
| // Disconnect from session so that the updates on updatedTBProductBlockDetailsLog are not directly saved in db | |||
| em.detach(updatedTBProductBlockDetailsLog); | |||
| TBProductBlockDetailsLogDTO tBProductBlockDetailsLogDTO = tBProductBlockDetailsLogMapper.toDto(updatedTBProductBlockDetailsLog); | |||
| restTBProductBlockDetailsLogMockMvc.perform(put("/api/tb-product-block-details-logs") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBProductBlockDetailsLogDTO))) | |||
| .andExpect(status().isOk()); | |||
| // Validate the TBProductBlockDetailsLog in the database | |||
| List<TBProductBlockDetailsLog> tBProductBlockDetailsLogList = tBProductBlockDetailsLogRepository.findAll(); | |||
| assertThat(tBProductBlockDetailsLogList).hasSize(databaseSizeBeforeUpdate); | |||
| TBProductBlockDetailsLog testTBProductBlockDetailsLog = tBProductBlockDetailsLogList.get(tBProductBlockDetailsLogList.size() - 1); | |||
| // Validate the TBProductBlockDetailsLog in Elasticsearch | |||
| verify(mockTBProductBlockDetailsLogSearchRepository, times(1)).save(testTBProductBlockDetailsLog); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void updateNonExistingTBProductBlockDetailsLog() throws Exception { | |||
| int databaseSizeBeforeUpdate = tBProductBlockDetailsLogRepository.findAll().size(); | |||
| // Create the TBProductBlockDetailsLog | |||
| TBProductBlockDetailsLogDTO tBProductBlockDetailsLogDTO = tBProductBlockDetailsLogMapper.toDto(tBProductBlockDetailsLog); | |||
| // If the entity doesn't have an ID, it will throw BadRequestAlertException | |||
| restTBProductBlockDetailsLogMockMvc.perform(put("/api/tb-product-block-details-logs") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBProductBlockDetailsLogDTO))) | |||
| .andExpect(status().isBadRequest()); | |||
| // Validate the TBProductBlockDetailsLog in the database | |||
| List<TBProductBlockDetailsLog> tBProductBlockDetailsLogList = tBProductBlockDetailsLogRepository.findAll(); | |||
| assertThat(tBProductBlockDetailsLogList).hasSize(databaseSizeBeforeUpdate); | |||
| // Validate the TBProductBlockDetailsLog in Elasticsearch | |||
| verify(mockTBProductBlockDetailsLogSearchRepository, times(0)).save(tBProductBlockDetailsLog); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void deleteTBProductBlockDetailsLog() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsLogRepository.saveAndFlush(tBProductBlockDetailsLog); | |||
| int databaseSizeBeforeDelete = tBProductBlockDetailsLogRepository.findAll().size(); | |||
| // Get the tBProductBlockDetailsLog | |||
| restTBProductBlockDetailsLogMockMvc.perform(delete("/api/tb-product-block-details-logs/{id}", tBProductBlockDetailsLog.getId()) | |||
| .accept(TestUtil.APPLICATION_JSON_UTF8)) | |||
| .andExpect(status().isOk()); | |||
| // Validate the database is empty | |||
| List<TBProductBlockDetailsLog> tBProductBlockDetailsLogList = tBProductBlockDetailsLogRepository.findAll(); | |||
| assertThat(tBProductBlockDetailsLogList).hasSize(databaseSizeBeforeDelete - 1); | |||
| // Validate the TBProductBlockDetailsLog in Elasticsearch | |||
| verify(mockTBProductBlockDetailsLogSearchRepository, times(1)).deleteById(tBProductBlockDetailsLog.getId()); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void searchTBProductBlockDetailsLog() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsLogRepository.saveAndFlush(tBProductBlockDetailsLog); | |||
| when(mockTBProductBlockDetailsLogSearchRepository.search(queryStringQuery("id:" + tBProductBlockDetailsLog.getId()), PageRequest.of(0, 20))) | |||
| .thenReturn(new PageImpl<>(Collections.singletonList(tBProductBlockDetailsLog), PageRequest.of(0, 1), 1)); | |||
| // Search the tBProductBlockDetailsLog | |||
| restTBProductBlockDetailsLogMockMvc.perform(get("/api/_search/tb-product-block-details-logs?query=id:" + tBProductBlockDetailsLog.getId())) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.[*].id").value(hasItem(tBProductBlockDetailsLog.getId().intValue()))); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void equalsVerifier() throws Exception { | |||
| TestUtil.equalsVerifier(TBProductBlockDetailsLog.class); | |||
| TBProductBlockDetailsLog tBProductBlockDetailsLog1 = new TBProductBlockDetailsLog(); | |||
| tBProductBlockDetailsLog1.setId(1L); | |||
| TBProductBlockDetailsLog tBProductBlockDetailsLog2 = new TBProductBlockDetailsLog(); | |||
| tBProductBlockDetailsLog2.setId(tBProductBlockDetailsLog1.getId()); | |||
| assertThat(tBProductBlockDetailsLog1).isEqualTo(tBProductBlockDetailsLog2); | |||
| tBProductBlockDetailsLog2.setId(2L); | |||
| assertThat(tBProductBlockDetailsLog1).isNotEqualTo(tBProductBlockDetailsLog2); | |||
| tBProductBlockDetailsLog1.setId(null); | |||
| assertThat(tBProductBlockDetailsLog1).isNotEqualTo(tBProductBlockDetailsLog2); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void dtoEqualsVerifier() throws Exception { | |||
| TestUtil.equalsVerifier(TBProductBlockDetailsLogDTO.class); | |||
| TBProductBlockDetailsLogDTO tBProductBlockDetailsLogDTO1 = new TBProductBlockDetailsLogDTO(); | |||
| tBProductBlockDetailsLogDTO1.setId(1L); | |||
| TBProductBlockDetailsLogDTO tBProductBlockDetailsLogDTO2 = new TBProductBlockDetailsLogDTO(); | |||
| assertThat(tBProductBlockDetailsLogDTO1).isNotEqualTo(tBProductBlockDetailsLogDTO2); | |||
| tBProductBlockDetailsLogDTO2.setId(tBProductBlockDetailsLogDTO1.getId()); | |||
| assertThat(tBProductBlockDetailsLogDTO1).isEqualTo(tBProductBlockDetailsLogDTO2); | |||
| tBProductBlockDetailsLogDTO2.setId(2L); | |||
| assertThat(tBProductBlockDetailsLogDTO1).isNotEqualTo(tBProductBlockDetailsLogDTO2); | |||
| tBProductBlockDetailsLogDTO1.setId(null); | |||
| assertThat(tBProductBlockDetailsLogDTO1).isNotEqualTo(tBProductBlockDetailsLogDTO2); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void testEntityFromId() { | |||
| assertThat(tBProductBlockDetailsLogMapper.fromId(42L).getId()).isEqualTo(42); | |||
| assertThat(tBProductBlockDetailsLogMapper.fromId(null)).isNull(); | |||
| } | |||
| } | |||
| @@ -1,647 +0,0 @@ | |||
| package vn.azteam.tpf.web.rest; | |||
| import vn.azteam.tpf.TpfApp; | |||
| import vn.azteam.tpf.domain.TBProductBlockDetailsReport; | |||
| import vn.azteam.tpf.domain.TBProductBlockDetails; | |||
| import vn.azteam.tpf.domain.TBCrop; | |||
| import vn.azteam.tpf.repository.TBProductBlockDetailsReportRepository; | |||
| import vn.azteam.tpf.repository.search.TBProductBlockDetailsReportSearchRepository; | |||
| import vn.azteam.tpf.service.TBProductBlockDetailsReportService; | |||
| import vn.azteam.tpf.service.dto.TBProductBlockDetailsReportDTO; | |||
| import vn.azteam.tpf.service.mapper.TBProductBlockDetailsReportMapper; | |||
| import vn.azteam.tpf.web.rest.errors.ExceptionTranslator; | |||
| import vn.azteam.tpf.service.dto.TBProductBlockDetailsReportCriteria; | |||
| import vn.azteam.tpf.service.TBProductBlockDetailsReportQueryService; | |||
| import org.junit.Before; | |||
| import org.junit.Test; | |||
| import org.junit.runner.RunWith; | |||
| import org.mockito.MockitoAnnotations; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.boot.test.context.SpringBootTest; | |||
| import org.springframework.data.domain.PageImpl; | |||
| import org.springframework.data.domain.PageRequest; | |||
| import org.springframework.data.web.PageableHandlerMethodArgumentResolver; | |||
| import org.springframework.http.MediaType; | |||
| import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |||
| import org.springframework.test.context.junit4.SpringRunner; | |||
| import org.springframework.test.web.servlet.MockMvc; | |||
| import org.springframework.test.web.servlet.setup.MockMvcBuilders; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import org.springframework.validation.Validator; | |||
| import javax.persistence.EntityManager; | |||
| import java.time.Instant; | |||
| import java.time.temporal.ChronoUnit; | |||
| import java.util.Collections; | |||
| import java.util.List; | |||
| import static vn.azteam.tpf.web.rest.TestUtil.createFormattingConversionService; | |||
| import static org.assertj.core.api.Assertions.assertThat; | |||
| import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery; | |||
| import static org.hamcrest.Matchers.hasItem; | |||
| import static org.mockito.Mockito.*; | |||
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | |||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | |||
| /** | |||
| * Test class for the TBProductBlockDetailsReportResource REST controller. | |||
| * | |||
| * @see TBProductBlockDetailsReportResource | |||
| */ | |||
| @RunWith(SpringRunner.class) | |||
| @SpringBootTest(classes = TpfApp.class) | |||
| public class TBProductBlockDetailsReportResourceIntTest { | |||
| private static final String DEFAULT_CODE = "AAAAAAAAAA"; | |||
| private static final String UPDATED_CODE = "BBBBBBBBBB"; | |||
| private static final Double DEFAULT_PRODUCT_LEVEL_1 = 1D; | |||
| private static final Double UPDATED_PRODUCT_LEVEL_1 = 2D; | |||
| private static final Double DEFAULT_PRODUCT_LEVEL_2 = 1D; | |||
| private static final Double UPDATED_PRODUCT_LEVEL_2 = 2D; | |||
| private static final Double DEFAULT_PRODUCT_LEVEL_3 = 1D; | |||
| private static final Double UPDATED_PRODUCT_LEVEL_3 = 2D; | |||
| private static final Instant DEFAULT_CREATE_DATE = Instant.ofEpochMilli(0L); | |||
| private static final Instant UPDATED_CREATE_DATE = Instant.now().truncatedTo(ChronoUnit.MILLIS); | |||
| @Autowired | |||
| private TBProductBlockDetailsReportRepository tBProductBlockDetailsReportRepository; | |||
| @Autowired | |||
| private TBProductBlockDetailsReportMapper tBProductBlockDetailsReportMapper; | |||
| @Autowired | |||
| private TBProductBlockDetailsReportService tBProductBlockDetailsReportService; | |||
| /** | |||
| * This repository is mocked in the vn.azteam.tpf.repository.search test package. | |||
| * | |||
| * @see vn.azteam.tpf.repository.search.TBProductBlockDetailsReportSearchRepositoryMockConfiguration | |||
| */ | |||
| @Autowired | |||
| private TBProductBlockDetailsReportSearchRepository mockTBProductBlockDetailsReportSearchRepository; | |||
| @Autowired | |||
| private TBProductBlockDetailsReportQueryService tBProductBlockDetailsReportQueryService; | |||
| @Autowired | |||
| private MappingJackson2HttpMessageConverter jacksonMessageConverter; | |||
| @Autowired | |||
| private PageableHandlerMethodArgumentResolver pageableArgumentResolver; | |||
| @Autowired | |||
| private ExceptionTranslator exceptionTranslator; | |||
| @Autowired | |||
| private EntityManager em; | |||
| @Autowired | |||
| private Validator validator; | |||
| private MockMvc restTBProductBlockDetailsReportMockMvc; | |||
| private TBProductBlockDetailsReport tBProductBlockDetailsReport; | |||
| @Before | |||
| public void setup() { | |||
| MockitoAnnotations.initMocks(this); | |||
| final TBProductBlockDetailsReportResource tBProductBlockDetailsReportResource = new TBProductBlockDetailsReportResource(tBProductBlockDetailsReportService, tBProductBlockDetailsReportQueryService); | |||
| this.restTBProductBlockDetailsReportMockMvc = MockMvcBuilders.standaloneSetup(tBProductBlockDetailsReportResource) | |||
| .setCustomArgumentResolvers(pageableArgumentResolver) | |||
| .setControllerAdvice(exceptionTranslator) | |||
| .setConversionService(createFormattingConversionService()) | |||
| .setMessageConverters(jacksonMessageConverter) | |||
| .setValidator(validator).build(); | |||
| } | |||
| /** | |||
| * 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 TBProductBlockDetailsReport createEntity(EntityManager em) { | |||
| TBProductBlockDetailsReport tBProductBlockDetailsReport = new TBProductBlockDetailsReport() | |||
| .code(DEFAULT_CODE) | |||
| .productLevel1(DEFAULT_PRODUCT_LEVEL_1) | |||
| .productLevel2(DEFAULT_PRODUCT_LEVEL_2) | |||
| .productLevel3(DEFAULT_PRODUCT_LEVEL_3) | |||
| .createDate(DEFAULT_CREATE_DATE); | |||
| return tBProductBlockDetailsReport; | |||
| } | |||
| @Before | |||
| public void initTest() { | |||
| tBProductBlockDetailsReport = createEntity(em); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void createTBProductBlockDetailsReport() throws Exception { | |||
| int databaseSizeBeforeCreate = tBProductBlockDetailsReportRepository.findAll().size(); | |||
| // Create the TBProductBlockDetailsReport | |||
| TBProductBlockDetailsReportDTO tBProductBlockDetailsReportDTO = tBProductBlockDetailsReportMapper.toDto(tBProductBlockDetailsReport); | |||
| restTBProductBlockDetailsReportMockMvc.perform(post("/api/tb-product-block-details-reports") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBProductBlockDetailsReportDTO))) | |||
| .andExpect(status().isCreated()); | |||
| // Validate the TBProductBlockDetailsReport in the database | |||
| List<TBProductBlockDetailsReport> tBProductBlockDetailsReportList = tBProductBlockDetailsReportRepository.findAll(); | |||
| assertThat(tBProductBlockDetailsReportList).hasSize(databaseSizeBeforeCreate + 1); | |||
| TBProductBlockDetailsReport testTBProductBlockDetailsReport = tBProductBlockDetailsReportList.get(tBProductBlockDetailsReportList.size() - 1); | |||
| assertThat(testTBProductBlockDetailsReport.getCode()).isEqualTo(DEFAULT_CODE); | |||
| assertThat(testTBProductBlockDetailsReport.getProductLevel1()).isEqualTo(DEFAULT_PRODUCT_LEVEL_1); | |||
| assertThat(testTBProductBlockDetailsReport.getProductLevel2()).isEqualTo(DEFAULT_PRODUCT_LEVEL_2); | |||
| assertThat(testTBProductBlockDetailsReport.getProductLevel3()).isEqualTo(DEFAULT_PRODUCT_LEVEL_3); | |||
| assertThat(testTBProductBlockDetailsReport.getCreateDate()).isEqualTo(DEFAULT_CREATE_DATE); | |||
| // Validate the TBProductBlockDetailsReport in Elasticsearch | |||
| verify(mockTBProductBlockDetailsReportSearchRepository, times(1)).save(testTBProductBlockDetailsReport); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void createTBProductBlockDetailsReportWithExistingId() throws Exception { | |||
| int databaseSizeBeforeCreate = tBProductBlockDetailsReportRepository.findAll().size(); | |||
| // Create the TBProductBlockDetailsReport with an existing ID | |||
| tBProductBlockDetailsReport.setId(1L); | |||
| TBProductBlockDetailsReportDTO tBProductBlockDetailsReportDTO = tBProductBlockDetailsReportMapper.toDto(tBProductBlockDetailsReport); | |||
| // An entity with an existing ID cannot be created, so this API call must fail | |||
| restTBProductBlockDetailsReportMockMvc.perform(post("/api/tb-product-block-details-reports") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBProductBlockDetailsReportDTO))) | |||
| .andExpect(status().isBadRequest()); | |||
| // Validate the TBProductBlockDetailsReport in the database | |||
| List<TBProductBlockDetailsReport> tBProductBlockDetailsReportList = tBProductBlockDetailsReportRepository.findAll(); | |||
| assertThat(tBProductBlockDetailsReportList).hasSize(databaseSizeBeforeCreate); | |||
| // Validate the TBProductBlockDetailsReport in Elasticsearch | |||
| verify(mockTBProductBlockDetailsReportSearchRepository, times(0)).save(tBProductBlockDetailsReport); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReports() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList | |||
| restTBProductBlockDetailsReportMockMvc.perform(get("/api/tb-product-block-details-reports?sort=id,desc")) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.[*].id").value(hasItem(tBProductBlockDetailsReport.getId().intValue()))) | |||
| .andExpect(jsonPath("$.[*].code").value(hasItem(DEFAULT_CODE.toString()))) | |||
| .andExpect(jsonPath("$.[*].productLevel1").value(hasItem(DEFAULT_PRODUCT_LEVEL_1.doubleValue()))) | |||
| .andExpect(jsonPath("$.[*].productLevel2").value(hasItem(DEFAULT_PRODUCT_LEVEL_2.doubleValue()))) | |||
| .andExpect(jsonPath("$.[*].productLevel3").value(hasItem(DEFAULT_PRODUCT_LEVEL_3.doubleValue()))) | |||
| .andExpect(jsonPath("$.[*].createDate").value(hasItem(DEFAULT_CREATE_DATE.toString()))); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getTBProductBlockDetailsReport() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get the tBProductBlockDetailsReport | |||
| restTBProductBlockDetailsReportMockMvc.perform(get("/api/tb-product-block-details-reports/{id}", tBProductBlockDetailsReport.getId())) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.id").value(tBProductBlockDetailsReport.getId().intValue())) | |||
| .andExpect(jsonPath("$.code").value(DEFAULT_CODE.toString())) | |||
| .andExpect(jsonPath("$.productLevel1").value(DEFAULT_PRODUCT_LEVEL_1.doubleValue())) | |||
| .andExpect(jsonPath("$.productLevel2").value(DEFAULT_PRODUCT_LEVEL_2.doubleValue())) | |||
| .andExpect(jsonPath("$.productLevel3").value(DEFAULT_PRODUCT_LEVEL_3.doubleValue())) | |||
| .andExpect(jsonPath("$.createDate").value(DEFAULT_CREATE_DATE.toString())); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByCodeIsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where code equals to DEFAULT_CODE | |||
| defaultTBProductBlockDetailsReportShouldBeFound("code.equals=" + DEFAULT_CODE); | |||
| // Get all the tBProductBlockDetailsReportList where code equals to UPDATED_CODE | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("code.equals=" + UPDATED_CODE); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByCodeIsInShouldWork() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where code in DEFAULT_CODE or UPDATED_CODE | |||
| defaultTBProductBlockDetailsReportShouldBeFound("code.in=" + DEFAULT_CODE + "," + UPDATED_CODE); | |||
| // Get all the tBProductBlockDetailsReportList where code equals to UPDATED_CODE | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("code.in=" + UPDATED_CODE); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByCodeIsNullOrNotNull() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where code is not null | |||
| defaultTBProductBlockDetailsReportShouldBeFound("code.specified=true"); | |||
| // Get all the tBProductBlockDetailsReportList where code is null | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("code.specified=false"); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByProductLevel1IsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel1 equals to DEFAULT_PRODUCT_LEVEL_1 | |||
| defaultTBProductBlockDetailsReportShouldBeFound("productLevel1.equals=" + DEFAULT_PRODUCT_LEVEL_1); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel1 equals to UPDATED_PRODUCT_LEVEL_1 | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("productLevel1.equals=" + UPDATED_PRODUCT_LEVEL_1); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByProductLevel1IsInShouldWork() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel1 in DEFAULT_PRODUCT_LEVEL_1 or UPDATED_PRODUCT_LEVEL_1 | |||
| defaultTBProductBlockDetailsReportShouldBeFound("productLevel1.in=" + DEFAULT_PRODUCT_LEVEL_1 + "," + UPDATED_PRODUCT_LEVEL_1); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel1 equals to UPDATED_PRODUCT_LEVEL_1 | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("productLevel1.in=" + UPDATED_PRODUCT_LEVEL_1); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByProductLevel1IsNullOrNotNull() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel1 is not null | |||
| defaultTBProductBlockDetailsReportShouldBeFound("productLevel1.specified=true"); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel1 is null | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("productLevel1.specified=false"); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByProductLevel2IsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel2 equals to DEFAULT_PRODUCT_LEVEL_2 | |||
| defaultTBProductBlockDetailsReportShouldBeFound("productLevel2.equals=" + DEFAULT_PRODUCT_LEVEL_2); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel2 equals to UPDATED_PRODUCT_LEVEL_2 | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("productLevel2.equals=" + UPDATED_PRODUCT_LEVEL_2); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByProductLevel2IsInShouldWork() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel2 in DEFAULT_PRODUCT_LEVEL_2 or UPDATED_PRODUCT_LEVEL_2 | |||
| defaultTBProductBlockDetailsReportShouldBeFound("productLevel2.in=" + DEFAULT_PRODUCT_LEVEL_2 + "," + UPDATED_PRODUCT_LEVEL_2); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel2 equals to UPDATED_PRODUCT_LEVEL_2 | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("productLevel2.in=" + UPDATED_PRODUCT_LEVEL_2); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByProductLevel2IsNullOrNotNull() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel2 is not null | |||
| defaultTBProductBlockDetailsReportShouldBeFound("productLevel2.specified=true"); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel2 is null | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("productLevel2.specified=false"); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByProductLevel3IsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel3 equals to DEFAULT_PRODUCT_LEVEL_3 | |||
| defaultTBProductBlockDetailsReportShouldBeFound("productLevel3.equals=" + DEFAULT_PRODUCT_LEVEL_3); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel3 equals to UPDATED_PRODUCT_LEVEL_3 | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("productLevel3.equals=" + UPDATED_PRODUCT_LEVEL_3); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByProductLevel3IsInShouldWork() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel3 in DEFAULT_PRODUCT_LEVEL_3 or UPDATED_PRODUCT_LEVEL_3 | |||
| defaultTBProductBlockDetailsReportShouldBeFound("productLevel3.in=" + DEFAULT_PRODUCT_LEVEL_3 + "," + UPDATED_PRODUCT_LEVEL_3); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel3 equals to UPDATED_PRODUCT_LEVEL_3 | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("productLevel3.in=" + UPDATED_PRODUCT_LEVEL_3); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByProductLevel3IsNullOrNotNull() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel3 is not null | |||
| defaultTBProductBlockDetailsReportShouldBeFound("productLevel3.specified=true"); | |||
| // Get all the tBProductBlockDetailsReportList where productLevel3 is null | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("productLevel3.specified=false"); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByCreateDateIsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where createDate equals to DEFAULT_CREATE_DATE | |||
| defaultTBProductBlockDetailsReportShouldBeFound("createDate.equals=" + DEFAULT_CREATE_DATE); | |||
| // Get all the tBProductBlockDetailsReportList where createDate equals to UPDATED_CREATE_DATE | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("createDate.equals=" + UPDATED_CREATE_DATE); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByCreateDateIsInShouldWork() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where createDate in DEFAULT_CREATE_DATE or UPDATED_CREATE_DATE | |||
| defaultTBProductBlockDetailsReportShouldBeFound("createDate.in=" + DEFAULT_CREATE_DATE + "," + UPDATED_CREATE_DATE); | |||
| // Get all the tBProductBlockDetailsReportList where createDate equals to UPDATED_CREATE_DATE | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("createDate.in=" + UPDATED_CREATE_DATE); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByCreateDateIsNullOrNotNull() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| // Get all the tBProductBlockDetailsReportList where createDate is not null | |||
| defaultTBProductBlockDetailsReportShouldBeFound("createDate.specified=true"); | |||
| // Get all the tBProductBlockDetailsReportList where createDate is null | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("createDate.specified=false"); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByTbProductBlockDetailsIsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| TBProductBlockDetails tbProductBlockDetails = TBProductBlockDetailsResourceIntTest.createEntity(em); | |||
| em.persist(tbProductBlockDetails); | |||
| em.flush(); | |||
| tBProductBlockDetailsReport.setTbProductBlockDetails(tbProductBlockDetails); | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| Long tbProductBlockDetailsId = tbProductBlockDetails.getId(); | |||
| // Get all the tBProductBlockDetailsReportList where tbProductBlockDetails equals to tbProductBlockDetailsId | |||
| defaultTBProductBlockDetailsReportShouldBeFound("tbProductBlockDetailsId.equals=" + tbProductBlockDetailsId); | |||
| // Get all the tBProductBlockDetailsReportList where tbProductBlockDetails equals to tbProductBlockDetailsId + 1 | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("tbProductBlockDetailsId.equals=" + (tbProductBlockDetailsId + 1)); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getAllTBProductBlockDetailsReportsByTbCropIsEqualToSomething() throws Exception { | |||
| // Initialize the database | |||
| TBCrop tbCrop = TBCropResourceIntTest.createEntity(em); | |||
| em.persist(tbCrop); | |||
| em.flush(); | |||
| tBProductBlockDetailsReport.setTbCrop(tbCrop); | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| Long tbCropId = tbCrop.getId(); | |||
| // Get all the tBProductBlockDetailsReportList where tbCrop equals to tbCropId | |||
| defaultTBProductBlockDetailsReportShouldBeFound("tbCropId.equals=" + tbCropId); | |||
| // Get all the tBProductBlockDetailsReportList where tbCrop equals to tbCropId + 1 | |||
| defaultTBProductBlockDetailsReportShouldNotBeFound("tbCropId.equals=" + (tbCropId + 1)); | |||
| } | |||
| /** | |||
| * Executes the search, and checks that the default entity is returned | |||
| */ | |||
| private void defaultTBProductBlockDetailsReportShouldBeFound(String filter) throws Exception { | |||
| restTBProductBlockDetailsReportMockMvc.perform(get("/api/tb-product-block-details-reports?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.[*].id").value(hasItem(tBProductBlockDetailsReport.getId().intValue()))) | |||
| .andExpect(jsonPath("$.[*].code").value(hasItem(DEFAULT_CODE.toString()))) | |||
| .andExpect(jsonPath("$.[*].productLevel1").value(hasItem(DEFAULT_PRODUCT_LEVEL_1.doubleValue()))) | |||
| .andExpect(jsonPath("$.[*].productLevel2").value(hasItem(DEFAULT_PRODUCT_LEVEL_2.doubleValue()))) | |||
| .andExpect(jsonPath("$.[*].productLevel3").value(hasItem(DEFAULT_PRODUCT_LEVEL_3.doubleValue()))) | |||
| .andExpect(jsonPath("$.[*].createDate").value(hasItem(DEFAULT_CREATE_DATE.toString()))); | |||
| // Check, that the count call also returns 1 | |||
| restTBProductBlockDetailsReportMockMvc.perform(get("/api/tb-product-block-details-reports/count?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(content().string("1")); | |||
| } | |||
| /** | |||
| * Executes the search, and checks that the default entity is not returned | |||
| */ | |||
| private void defaultTBProductBlockDetailsReportShouldNotBeFound(String filter) throws Exception { | |||
| restTBProductBlockDetailsReportMockMvc.perform(get("/api/tb-product-block-details-reports?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$").isArray()) | |||
| .andExpect(jsonPath("$").isEmpty()); | |||
| // Check, that the count call also returns 0 | |||
| restTBProductBlockDetailsReportMockMvc.perform(get("/api/tb-product-block-details-reports/count?sort=id,desc&" + filter)) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(content().string("0")); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void getNonExistingTBProductBlockDetailsReport() throws Exception { | |||
| // Get the tBProductBlockDetailsReport | |||
| restTBProductBlockDetailsReportMockMvc.perform(get("/api/tb-product-block-details-reports/{id}", Long.MAX_VALUE)) | |||
| .andExpect(status().isNotFound()); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void updateTBProductBlockDetailsReport() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| int databaseSizeBeforeUpdate = tBProductBlockDetailsReportRepository.findAll().size(); | |||
| // Update the tBProductBlockDetailsReport | |||
| TBProductBlockDetailsReport updatedTBProductBlockDetailsReport = tBProductBlockDetailsReportRepository.findById(tBProductBlockDetailsReport.getId()).get(); | |||
| // Disconnect from session so that the updates on updatedTBProductBlockDetailsReport are not directly saved in db | |||
| em.detach(updatedTBProductBlockDetailsReport); | |||
| updatedTBProductBlockDetailsReport | |||
| .code(UPDATED_CODE) | |||
| .productLevel1(UPDATED_PRODUCT_LEVEL_1) | |||
| .productLevel2(UPDATED_PRODUCT_LEVEL_2) | |||
| .productLevel3(UPDATED_PRODUCT_LEVEL_3) | |||
| .createDate(UPDATED_CREATE_DATE); | |||
| TBProductBlockDetailsReportDTO tBProductBlockDetailsReportDTO = tBProductBlockDetailsReportMapper.toDto(updatedTBProductBlockDetailsReport); | |||
| restTBProductBlockDetailsReportMockMvc.perform(put("/api/tb-product-block-details-reports") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBProductBlockDetailsReportDTO))) | |||
| .andExpect(status().isOk()); | |||
| // Validate the TBProductBlockDetailsReport in the database | |||
| List<TBProductBlockDetailsReport> tBProductBlockDetailsReportList = tBProductBlockDetailsReportRepository.findAll(); | |||
| assertThat(tBProductBlockDetailsReportList).hasSize(databaseSizeBeforeUpdate); | |||
| TBProductBlockDetailsReport testTBProductBlockDetailsReport = tBProductBlockDetailsReportList.get(tBProductBlockDetailsReportList.size() - 1); | |||
| assertThat(testTBProductBlockDetailsReport.getCode()).isEqualTo(UPDATED_CODE); | |||
| assertThat(testTBProductBlockDetailsReport.getProductLevel1()).isEqualTo(UPDATED_PRODUCT_LEVEL_1); | |||
| assertThat(testTBProductBlockDetailsReport.getProductLevel2()).isEqualTo(UPDATED_PRODUCT_LEVEL_2); | |||
| assertThat(testTBProductBlockDetailsReport.getProductLevel3()).isEqualTo(UPDATED_PRODUCT_LEVEL_3); | |||
| assertThat(testTBProductBlockDetailsReport.getCreateDate()).isEqualTo(UPDATED_CREATE_DATE); | |||
| // Validate the TBProductBlockDetailsReport in Elasticsearch | |||
| verify(mockTBProductBlockDetailsReportSearchRepository, times(1)).save(testTBProductBlockDetailsReport); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void updateNonExistingTBProductBlockDetailsReport() throws Exception { | |||
| int databaseSizeBeforeUpdate = tBProductBlockDetailsReportRepository.findAll().size(); | |||
| // Create the TBProductBlockDetailsReport | |||
| TBProductBlockDetailsReportDTO tBProductBlockDetailsReportDTO = tBProductBlockDetailsReportMapper.toDto(tBProductBlockDetailsReport); | |||
| // If the entity doesn't have an ID, it will throw BadRequestAlertException | |||
| restTBProductBlockDetailsReportMockMvc.perform(put("/api/tb-product-block-details-reports") | |||
| .contentType(TestUtil.APPLICATION_JSON_UTF8) | |||
| .content(TestUtil.convertObjectToJsonBytes(tBProductBlockDetailsReportDTO))) | |||
| .andExpect(status().isBadRequest()); | |||
| // Validate the TBProductBlockDetailsReport in the database | |||
| List<TBProductBlockDetailsReport> tBProductBlockDetailsReportList = tBProductBlockDetailsReportRepository.findAll(); | |||
| assertThat(tBProductBlockDetailsReportList).hasSize(databaseSizeBeforeUpdate); | |||
| // Validate the TBProductBlockDetailsReport in Elasticsearch | |||
| verify(mockTBProductBlockDetailsReportSearchRepository, times(0)).save(tBProductBlockDetailsReport); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void deleteTBProductBlockDetailsReport() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| int databaseSizeBeforeDelete = tBProductBlockDetailsReportRepository.findAll().size(); | |||
| // Get the tBProductBlockDetailsReport | |||
| restTBProductBlockDetailsReportMockMvc.perform(delete("/api/tb-product-block-details-reports/{id}", tBProductBlockDetailsReport.getId()) | |||
| .accept(TestUtil.APPLICATION_JSON_UTF8)) | |||
| .andExpect(status().isOk()); | |||
| // Validate the database is empty | |||
| List<TBProductBlockDetailsReport> tBProductBlockDetailsReportList = tBProductBlockDetailsReportRepository.findAll(); | |||
| assertThat(tBProductBlockDetailsReportList).hasSize(databaseSizeBeforeDelete - 1); | |||
| // Validate the TBProductBlockDetailsReport in Elasticsearch | |||
| verify(mockTBProductBlockDetailsReportSearchRepository, times(1)).deleteById(tBProductBlockDetailsReport.getId()); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void searchTBProductBlockDetailsReport() throws Exception { | |||
| // Initialize the database | |||
| tBProductBlockDetailsReportRepository.saveAndFlush(tBProductBlockDetailsReport); | |||
| when(mockTBProductBlockDetailsReportSearchRepository.search(queryStringQuery("id:" + tBProductBlockDetailsReport.getId()), PageRequest.of(0, 20))) | |||
| .thenReturn(new PageImpl<>(Collections.singletonList(tBProductBlockDetailsReport), PageRequest.of(0, 1), 1)); | |||
| // Search the tBProductBlockDetailsReport | |||
| restTBProductBlockDetailsReportMockMvc.perform(get("/api/_search/tb-product-block-details-reports?query=id:" + tBProductBlockDetailsReport.getId())) | |||
| .andExpect(status().isOk()) | |||
| .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)) | |||
| .andExpect(jsonPath("$.[*].id").value(hasItem(tBProductBlockDetailsReport.getId().intValue()))) | |||
| .andExpect(jsonPath("$.[*].code").value(hasItem(DEFAULT_CODE))) | |||
| .andExpect(jsonPath("$.[*].productLevel1").value(hasItem(DEFAULT_PRODUCT_LEVEL_1.doubleValue()))) | |||
| .andExpect(jsonPath("$.[*].productLevel2").value(hasItem(DEFAULT_PRODUCT_LEVEL_2.doubleValue()))) | |||
| .andExpect(jsonPath("$.[*].productLevel3").value(hasItem(DEFAULT_PRODUCT_LEVEL_3.doubleValue()))) | |||
| .andExpect(jsonPath("$.[*].createDate").value(hasItem(DEFAULT_CREATE_DATE.toString()))); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void equalsVerifier() throws Exception { | |||
| TestUtil.equalsVerifier(TBProductBlockDetailsReport.class); | |||
| TBProductBlockDetailsReport tBProductBlockDetailsReport1 = new TBProductBlockDetailsReport(); | |||
| tBProductBlockDetailsReport1.setId(1L); | |||
| TBProductBlockDetailsReport tBProductBlockDetailsReport2 = new TBProductBlockDetailsReport(); | |||
| tBProductBlockDetailsReport2.setId(tBProductBlockDetailsReport1.getId()); | |||
| assertThat(tBProductBlockDetailsReport1).isEqualTo(tBProductBlockDetailsReport2); | |||
| tBProductBlockDetailsReport2.setId(2L); | |||
| assertThat(tBProductBlockDetailsReport1).isNotEqualTo(tBProductBlockDetailsReport2); | |||
| tBProductBlockDetailsReport1.setId(null); | |||
| assertThat(tBProductBlockDetailsReport1).isNotEqualTo(tBProductBlockDetailsReport2); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void dtoEqualsVerifier() throws Exception { | |||
| TestUtil.equalsVerifier(TBProductBlockDetailsReportDTO.class); | |||
| TBProductBlockDetailsReportDTO tBProductBlockDetailsReportDTO1 = new TBProductBlockDetailsReportDTO(); | |||
| tBProductBlockDetailsReportDTO1.setId(1L); | |||
| TBProductBlockDetailsReportDTO tBProductBlockDetailsReportDTO2 = new TBProductBlockDetailsReportDTO(); | |||
| assertThat(tBProductBlockDetailsReportDTO1).isNotEqualTo(tBProductBlockDetailsReportDTO2); | |||
| tBProductBlockDetailsReportDTO2.setId(tBProductBlockDetailsReportDTO1.getId()); | |||
| assertThat(tBProductBlockDetailsReportDTO1).isEqualTo(tBProductBlockDetailsReportDTO2); | |||
| tBProductBlockDetailsReportDTO2.setId(2L); | |||
| assertThat(tBProductBlockDetailsReportDTO1).isNotEqualTo(tBProductBlockDetailsReportDTO2); | |||
| tBProductBlockDetailsReportDTO1.setId(null); | |||
| assertThat(tBProductBlockDetailsReportDTO1).isNotEqualTo(tBProductBlockDetailsReportDTO2); | |||
| } | |||
| @Test | |||
| @Transactional | |||
| public void testEntityFromId() { | |||
| assertThat(tBProductBlockDetailsReportMapper.fromId(42L).getId()).isEqualTo(42); | |||
| assertThat(tBProductBlockDetailsReportMapper.fromId(null)).isNull(); | |||
| } | |||
| } | |||