improved code coverage for ShareResource
This commit is contained in:
parent
5835f15cd9
commit
8267cef973
@ -37,6 +37,7 @@ import static org.hamcrest.Matchers.hasItem;
|
|||||||
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
|
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
|
||||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for the ShareResource REST controller.
|
* Test class for the ShareResource REST controller.
|
||||||
*
|
*
|
||||||
@ -109,7 +110,7 @@ public class ShareResourceIntTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an entity for this test.
|
* Create an entity for this test.
|
||||||
*
|
* <p>
|
||||||
* This is a static method, as tests for other entities might also need it,
|
* This is a static method, as tests for other entities might also need it,
|
||||||
* if they test an entity which requires the current entity.
|
* if they test an entity which requires the current entity.
|
||||||
*/
|
*/
|
||||||
@ -130,7 +131,7 @@ public class ShareResourceIntTest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a persistent entity related to the given persistent membership for testing purposes.
|
* Create a persistent entity related to the given persistent membership for testing purposes.
|
||||||
*
|
* <p>
|
||||||
* This is a static method, as tests for other entities might also need it,
|
* This is a static method, as tests for other entities might also need it,
|
||||||
* if they test an entity which requires the current entity.
|
* if they test an entity which requires the current entity.
|
||||||
*/
|
*/
|
||||||
@ -180,10 +181,10 @@ public class ShareResourceIntTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Transactional
|
@Transactional
|
||||||
public void createShareWithExistingId() throws Exception {
|
public void createShareWithIdForNonExistingEntity() throws Exception {
|
||||||
int databaseSizeBeforeCreate = shareRepository.findAll().size();
|
int databaseSizeBeforeCreate = shareRepository.findAll().size();
|
||||||
|
|
||||||
// Create the Share with an existing ID
|
// Create the Share with an ID
|
||||||
share.setId(1L);
|
share.setId(1L);
|
||||||
ShareDTO shareDTO = shareMapper.toDto(share);
|
ShareDTO shareDTO = shareMapper.toDto(share);
|
||||||
|
|
||||||
@ -198,6 +199,27 @@ public class ShareResourceIntTest {
|
|||||||
assertThat(shareList).hasSize(databaseSizeBeforeCreate);
|
assertThat(shareList).hasSize(databaseSizeBeforeCreate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Transactional
|
||||||
|
public void createShareWithExistingExistingEntity() throws Exception {
|
||||||
|
// Initialize the database
|
||||||
|
shareRepository.saveAndFlush(share);
|
||||||
|
int databaseSizeBeforeCreate = shareRepository.findAll().size();
|
||||||
|
|
||||||
|
// Create the Share with the ID of an existing ID
|
||||||
|
ShareDTO shareDTO = shareMapper.toDto(share);
|
||||||
|
|
||||||
|
// An entity with an existing ID cannot be created, so this API call must fail
|
||||||
|
restShareMockMvc.perform(post("/api/shares")
|
||||||
|
.contentType(TestUtil.APPLICATION_JSON_UTF8)
|
||||||
|
.content(TestUtil.convertObjectToJsonBytes(shareDTO)))
|
||||||
|
.andExpect(status().isBadRequest());
|
||||||
|
|
||||||
|
// Validate the Share in the database
|
||||||
|
List<Share> assetList = shareRepository.findAll();
|
||||||
|
assertThat(assetList).hasSize(databaseSizeBeforeCreate);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Transactional
|
@Transactional
|
||||||
public void checkDocumentDateIsRequired() throws Exception {
|
public void checkDocumentDateIsRequired() throws Exception {
|
||||||
@ -291,7 +313,7 @@ public class ShareResourceIntTest {
|
|||||||
.andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY)))
|
.andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY)))
|
||||||
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString())));
|
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Transactional
|
@Transactional
|
||||||
public void getShare() throws Exception {
|
public void getShare() throws Exception {
|
||||||
|
Loading…
Reference in New Issue
Block a user