1
0

Generated

This commit is contained in:
Michael Hierweck
2019-04-18 16:31:39 +02:00
parent c6be30895e
commit fa0ba61de3
171 changed files with 15676 additions and 0 deletions

View File

@@ -0,0 +1,716 @@
package org.hostsharing.hsadminng.web.rest;
import org.hostsharing.hsadminng.HsadminNgApp;
import org.hostsharing.hsadminng.domain.Asset;
import org.hostsharing.hsadminng.domain.Membership;
import org.hostsharing.hsadminng.repository.AssetRepository;
import org.hostsharing.hsadminng.service.AssetService;
import org.hostsharing.hsadminng.service.dto.AssetDTO;
import org.hostsharing.hsadminng.service.mapper.AssetMapper;
import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator;
import org.hostsharing.hsadminng.service.dto.AssetCriteria;
import org.hostsharing.hsadminng.service.AssetQueryService;
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.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.math.BigDecimal;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.List;
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
/**
* Test class for the AssetResource REST controller.
*
* @see AssetResource
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = HsadminNgApp.class)
public class AssetResourceIntTest {
private static final LocalDate DEFAULT_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_VALUE_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_VALUE_DATE = LocalDate.now(ZoneId.systemDefault());
private static final AssetAction DEFAULT_ACTION = AssetAction.PAYMENT;
private static final AssetAction UPDATED_ACTION = AssetAction.HANDOVER;
private static final BigDecimal DEFAULT_AMOUNT = new BigDecimal(1);
private static final BigDecimal UPDATED_AMOUNT = new BigDecimal(2);
private static final String DEFAULT_REMARK = "AAAAAAAAAA";
private static final String UPDATED_REMARK = "BBBBBBBBBB";
@Autowired
private AssetRepository assetRepository;
@Autowired
private AssetMapper assetMapper;
@Autowired
private AssetService assetService;
@Autowired
private AssetQueryService assetQueryService;
@Autowired
private MappingJackson2HttpMessageConverter jacksonMessageConverter;
@Autowired
private PageableHandlerMethodArgumentResolver pageableArgumentResolver;
@Autowired
private ExceptionTranslator exceptionTranslator;
@Autowired
private EntityManager em;
@Autowired
private Validator validator;
private MockMvc restAssetMockMvc;
private Asset asset;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
final AssetResource assetResource = new AssetResource(assetService, assetQueryService);
this.restAssetMockMvc = MockMvcBuilders.standaloneSetup(assetResource)
.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 Asset createEntity(EntityManager em) {
Asset asset = new Asset()
.documentDate(DEFAULT_DOCUMENT_DATE)
.valueDate(DEFAULT_VALUE_DATE)
.action(DEFAULT_ACTION)
.amount(DEFAULT_AMOUNT)
.remark(DEFAULT_REMARK);
// Add required entity
Membership membership = MembershipResourceIntTest.createEntity(em);
em.persist(membership);
em.flush();
asset.setMembership(membership);
return asset;
}
@Before
public void initTest() {
asset = createEntity(em);
}
@Test
@Transactional
public void createAsset() throws Exception {
int databaseSizeBeforeCreate = assetRepository.findAll().size();
// Create the Asset
AssetDTO assetDTO = assetMapper.toDto(asset);
restAssetMockMvc.perform(post("/api/assets")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(assetDTO)))
.andExpect(status().isCreated());
// Validate the Asset in the database
List<Asset> assetList = assetRepository.findAll();
assertThat(assetList).hasSize(databaseSizeBeforeCreate + 1);
Asset testAsset = assetList.get(assetList.size() - 1);
assertThat(testAsset.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE);
assertThat(testAsset.getValueDate()).isEqualTo(DEFAULT_VALUE_DATE);
assertThat(testAsset.getAction()).isEqualTo(DEFAULT_ACTION);
assertThat(testAsset.getAmount()).isEqualTo(DEFAULT_AMOUNT);
assertThat(testAsset.getRemark()).isEqualTo(DEFAULT_REMARK);
}
@Test
@Transactional
public void createAssetWithExistingId() throws Exception {
int databaseSizeBeforeCreate = assetRepository.findAll().size();
// Create the Asset with an existing ID
asset.setId(1L);
AssetDTO assetDTO = assetMapper.toDto(asset);
// An entity with an existing ID cannot be created, so this API call must fail
restAssetMockMvc.perform(post("/api/assets")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(assetDTO)))
.andExpect(status().isBadRequest());
// Validate the Asset in the database
List<Asset> assetList = assetRepository.findAll();
assertThat(assetList).hasSize(databaseSizeBeforeCreate);
}
@Test
@Transactional
public void checkDocumentDateIsRequired() throws Exception {
int databaseSizeBeforeTest = assetRepository.findAll().size();
// set the field null
asset.setDocumentDate(null);
// Create the Asset, which fails.
AssetDTO assetDTO = assetMapper.toDto(asset);
restAssetMockMvc.perform(post("/api/assets")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(assetDTO)))
.andExpect(status().isBadRequest());
List<Asset> assetList = assetRepository.findAll();
assertThat(assetList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkValueDateIsRequired() throws Exception {
int databaseSizeBeforeTest = assetRepository.findAll().size();
// set the field null
asset.setValueDate(null);
// Create the Asset, which fails.
AssetDTO assetDTO = assetMapper.toDto(asset);
restAssetMockMvc.perform(post("/api/assets")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(assetDTO)))
.andExpect(status().isBadRequest());
List<Asset> assetList = assetRepository.findAll();
assertThat(assetList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkActionIsRequired() throws Exception {
int databaseSizeBeforeTest = assetRepository.findAll().size();
// set the field null
asset.setAction(null);
// Create the Asset, which fails.
AssetDTO assetDTO = assetMapper.toDto(asset);
restAssetMockMvc.perform(post("/api/assets")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(assetDTO)))
.andExpect(status().isBadRequest());
List<Asset> assetList = assetRepository.findAll();
assertThat(assetList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkAmountIsRequired() throws Exception {
int databaseSizeBeforeTest = assetRepository.findAll().size();
// set the field null
asset.setAmount(null);
// Create the Asset, which fails.
AssetDTO assetDTO = assetMapper.toDto(asset);
restAssetMockMvc.perform(post("/api/assets")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(assetDTO)))
.andExpect(status().isBadRequest());
List<Asset> assetList = assetRepository.findAll();
assertThat(assetList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void getAllAssets() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList
restAssetMockMvc.perform(get("/api/assets?sort=id,desc"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(asset.getId().intValue())))
.andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].valueDate").value(hasItem(DEFAULT_VALUE_DATE.toString())))
.andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString())))
.andExpect(jsonPath("$.[*].amount").value(hasItem(DEFAULT_AMOUNT.intValue())))
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString())));
}
@Test
@Transactional
public void getAsset() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get the asset
restAssetMockMvc.perform(get("/api/assets/{id}", asset.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.id").value(asset.getId().intValue()))
.andExpect(jsonPath("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString()))
.andExpect(jsonPath("$.valueDate").value(DEFAULT_VALUE_DATE.toString()))
.andExpect(jsonPath("$.action").value(DEFAULT_ACTION.toString()))
.andExpect(jsonPath("$.amount").value(DEFAULT_AMOUNT.intValue()))
.andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString()));
}
@Test
@Transactional
public void getAllAssetsByDocumentDateIsEqualToSomething() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where documentDate equals to DEFAULT_DOCUMENT_DATE
defaultAssetShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE);
// Get all the assetList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultAssetShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllAssetsByDocumentDateIsInShouldWork() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE
defaultAssetShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE);
// Get all the assetList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultAssetShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllAssetsByDocumentDateIsNullOrNotNull() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where documentDate is not null
defaultAssetShouldBeFound("documentDate.specified=true");
// Get all the assetList where documentDate is null
defaultAssetShouldNotBeFound("documentDate.specified=false");
}
@Test
@Transactional
public void getAllAssetsByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE
defaultAssetShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the assetList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE
defaultAssetShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllAssetsByDocumentDateIsLessThanSomething() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE
defaultAssetShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the assetList where documentDate less than or equals to UPDATED_DOCUMENT_DATE
defaultAssetShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllAssetsByValueDateIsEqualToSomething() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where valueDate equals to DEFAULT_VALUE_DATE
defaultAssetShouldBeFound("valueDate.equals=" + DEFAULT_VALUE_DATE);
// Get all the assetList where valueDate equals to UPDATED_VALUE_DATE
defaultAssetShouldNotBeFound("valueDate.equals=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllAssetsByValueDateIsInShouldWork() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where valueDate in DEFAULT_VALUE_DATE or UPDATED_VALUE_DATE
defaultAssetShouldBeFound("valueDate.in=" + DEFAULT_VALUE_DATE + "," + UPDATED_VALUE_DATE);
// Get all the assetList where valueDate equals to UPDATED_VALUE_DATE
defaultAssetShouldNotBeFound("valueDate.in=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllAssetsByValueDateIsNullOrNotNull() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where valueDate is not null
defaultAssetShouldBeFound("valueDate.specified=true");
// Get all the assetList where valueDate is null
defaultAssetShouldNotBeFound("valueDate.specified=false");
}
@Test
@Transactional
public void getAllAssetsByValueDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where valueDate greater than or equals to DEFAULT_VALUE_DATE
defaultAssetShouldBeFound("valueDate.greaterOrEqualThan=" + DEFAULT_VALUE_DATE);
// Get all the assetList where valueDate greater than or equals to UPDATED_VALUE_DATE
defaultAssetShouldNotBeFound("valueDate.greaterOrEqualThan=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllAssetsByValueDateIsLessThanSomething() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where valueDate less than or equals to DEFAULT_VALUE_DATE
defaultAssetShouldNotBeFound("valueDate.lessThan=" + DEFAULT_VALUE_DATE);
// Get all the assetList where valueDate less than or equals to UPDATED_VALUE_DATE
defaultAssetShouldBeFound("valueDate.lessThan=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllAssetsByActionIsEqualToSomething() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where action equals to DEFAULT_ACTION
defaultAssetShouldBeFound("action.equals=" + DEFAULT_ACTION);
// Get all the assetList where action equals to UPDATED_ACTION
defaultAssetShouldNotBeFound("action.equals=" + UPDATED_ACTION);
}
@Test
@Transactional
public void getAllAssetsByActionIsInShouldWork() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where action in DEFAULT_ACTION or UPDATED_ACTION
defaultAssetShouldBeFound("action.in=" + DEFAULT_ACTION + "," + UPDATED_ACTION);
// Get all the assetList where action equals to UPDATED_ACTION
defaultAssetShouldNotBeFound("action.in=" + UPDATED_ACTION);
}
@Test
@Transactional
public void getAllAssetsByActionIsNullOrNotNull() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where action is not null
defaultAssetShouldBeFound("action.specified=true");
// Get all the assetList where action is null
defaultAssetShouldNotBeFound("action.specified=false");
}
@Test
@Transactional
public void getAllAssetsByAmountIsEqualToSomething() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where amount equals to DEFAULT_AMOUNT
defaultAssetShouldBeFound("amount.equals=" + DEFAULT_AMOUNT);
// Get all the assetList where amount equals to UPDATED_AMOUNT
defaultAssetShouldNotBeFound("amount.equals=" + UPDATED_AMOUNT);
}
@Test
@Transactional
public void getAllAssetsByAmountIsInShouldWork() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where amount in DEFAULT_AMOUNT or UPDATED_AMOUNT
defaultAssetShouldBeFound("amount.in=" + DEFAULT_AMOUNT + "," + UPDATED_AMOUNT);
// Get all the assetList where amount equals to UPDATED_AMOUNT
defaultAssetShouldNotBeFound("amount.in=" + UPDATED_AMOUNT);
}
@Test
@Transactional
public void getAllAssetsByAmountIsNullOrNotNull() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where amount is not null
defaultAssetShouldBeFound("amount.specified=true");
// Get all the assetList where amount is null
defaultAssetShouldNotBeFound("amount.specified=false");
}
@Test
@Transactional
public void getAllAssetsByRemarkIsEqualToSomething() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where remark equals to DEFAULT_REMARK
defaultAssetShouldBeFound("remark.equals=" + DEFAULT_REMARK);
// Get all the assetList where remark equals to UPDATED_REMARK
defaultAssetShouldNotBeFound("remark.equals=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllAssetsByRemarkIsInShouldWork() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where remark in DEFAULT_REMARK or UPDATED_REMARK
defaultAssetShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK);
// Get all the assetList where remark equals to UPDATED_REMARK
defaultAssetShouldNotBeFound("remark.in=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllAssetsByRemarkIsNullOrNotNull() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where remark is not null
defaultAssetShouldBeFound("remark.specified=true");
// Get all the assetList where remark is null
defaultAssetShouldNotBeFound("remark.specified=false");
}
@Test
@Transactional
public void getAllAssetsByMembershipIsEqualToSomething() throws Exception {
// Initialize the database
Membership membership = MembershipResourceIntTest.createEntity(em);
em.persist(membership);
em.flush();
asset.setMembership(membership);
assetRepository.saveAndFlush(asset);
Long membershipId = membership.getId();
// Get all the assetList where membership equals to membershipId
defaultAssetShouldBeFound("membershipId.equals=" + membershipId);
// Get all the assetList where membership equals to membershipId + 1
defaultAssetShouldNotBeFound("membershipId.equals=" + (membershipId + 1));
}
/**
* Executes the search, and checks that the default entity is returned
*/
private void defaultAssetShouldBeFound(String filter) throws Exception {
restAssetMockMvc.perform(get("/api/assets?sort=id,desc&" + filter))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(asset.getId().intValue())))
.andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].valueDate").value(hasItem(DEFAULT_VALUE_DATE.toString())))
.andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString())))
.andExpect(jsonPath("$.[*].amount").value(hasItem(DEFAULT_AMOUNT.intValue())))
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK)));
// Check, that the count call also returns 1
restAssetMockMvc.perform(get("/api/assets/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 defaultAssetShouldNotBeFound(String filter) throws Exception {
restAssetMockMvc.perform(get("/api/assets?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
restAssetMockMvc.perform(get("/api/assets/count?sort=id,desc&" + filter))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().string("0"));
}
@Test
@Transactional
public void getNonExistingAsset() throws Exception {
// Get the asset
restAssetMockMvc.perform(get("/api/assets/{id}", Long.MAX_VALUE))
.andExpect(status().isNotFound());
}
@Test
@Transactional
public void updateAsset() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
int databaseSizeBeforeUpdate = assetRepository.findAll().size();
// Update the asset
Asset updatedAsset = assetRepository.findById(asset.getId()).get();
// Disconnect from session so that the updates on updatedAsset are not directly saved in db
em.detach(updatedAsset);
updatedAsset
.documentDate(UPDATED_DOCUMENT_DATE)
.valueDate(UPDATED_VALUE_DATE)
.action(UPDATED_ACTION)
.amount(UPDATED_AMOUNT)
.remark(UPDATED_REMARK);
AssetDTO assetDTO = assetMapper.toDto(updatedAsset);
restAssetMockMvc.perform(put("/api/assets")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(assetDTO)))
.andExpect(status().isOk());
// Validate the Asset in the database
List<Asset> assetList = assetRepository.findAll();
assertThat(assetList).hasSize(databaseSizeBeforeUpdate);
Asset testAsset = assetList.get(assetList.size() - 1);
assertThat(testAsset.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE);
assertThat(testAsset.getValueDate()).isEqualTo(UPDATED_VALUE_DATE);
assertThat(testAsset.getAction()).isEqualTo(UPDATED_ACTION);
assertThat(testAsset.getAmount()).isEqualTo(UPDATED_AMOUNT);
assertThat(testAsset.getRemark()).isEqualTo(UPDATED_REMARK);
}
@Test
@Transactional
public void updateNonExistingAsset() throws Exception {
int databaseSizeBeforeUpdate = assetRepository.findAll().size();
// Create the Asset
AssetDTO assetDTO = assetMapper.toDto(asset);
// If the entity doesn't have an ID, it will throw BadRequestAlertException
restAssetMockMvc.perform(put("/api/assets")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(assetDTO)))
.andExpect(status().isBadRequest());
// Validate the Asset in the database
List<Asset> assetList = assetRepository.findAll();
assertThat(assetList).hasSize(databaseSizeBeforeUpdate);
}
@Test
@Transactional
public void deleteAsset() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
int databaseSizeBeforeDelete = assetRepository.findAll().size();
// Delete the asset
restAssetMockMvc.perform(delete("/api/assets/{id}", asset.getId())
.accept(TestUtil.APPLICATION_JSON_UTF8))
.andExpect(status().isOk());
// Validate the database is empty
List<Asset> assetList = assetRepository.findAll();
assertThat(assetList).hasSize(databaseSizeBeforeDelete - 1);
}
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Asset.class);
Asset asset1 = new Asset();
asset1.setId(1L);
Asset asset2 = new Asset();
asset2.setId(asset1.getId());
assertThat(asset1).isEqualTo(asset2);
asset2.setId(2L);
assertThat(asset1).isNotEqualTo(asset2);
asset1.setId(null);
assertThat(asset1).isNotEqualTo(asset2);
}
@Test
@Transactional
public void dtoEqualsVerifier() throws Exception {
TestUtil.equalsVerifier(AssetDTO.class);
AssetDTO assetDTO1 = new AssetDTO();
assetDTO1.setId(1L);
AssetDTO assetDTO2 = new AssetDTO();
assertThat(assetDTO1).isNotEqualTo(assetDTO2);
assetDTO2.setId(assetDTO1.getId());
assertThat(assetDTO1).isEqualTo(assetDTO2);
assetDTO2.setId(2L);
assertThat(assetDTO1).isNotEqualTo(assetDTO2);
assetDTO1.setId(null);
assertThat(assetDTO1).isNotEqualTo(assetDTO2);
}
@Test
@Transactional
public void testEntityFromId() {
assertThat(assetMapper.fromId(42L).getId()).isEqualTo(42);
assertThat(assetMapper.fromId(null)).isNull();
}
}

View File

@@ -0,0 +1,847 @@
package org.hostsharing.hsadminng.web.rest;
import org.hostsharing.hsadminng.HsadminNgApp;
import org.hostsharing.hsadminng.domain.Customer;
import org.hostsharing.hsadminng.domain.Membership;
import org.hostsharing.hsadminng.domain.SepaMandate;
import org.hostsharing.hsadminng.repository.CustomerRepository;
import org.hostsharing.hsadminng.service.CustomerService;
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
import org.hostsharing.hsadminng.service.mapper.CustomerMapper;
import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator;
import org.hostsharing.hsadminng.service.dto.CustomerCriteria;
import org.hostsharing.hsadminng.service.CustomerQueryService;
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.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.List;
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
* Test class for the CustomerResource REST controller.
*
* @see CustomerResource
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = HsadminNgApp.class)
public class CustomerResourceIntTest {
private static final Integer DEFAULT_REFERENCE = 10000;
private static final Integer UPDATED_REFERENCE = 10001;
private static final String DEFAULT_PREFIX = "hu";
private static final String UPDATED_PREFIX = "umj";
private static final String DEFAULT_NAME = "AAAAAAAAAA";
private static final String UPDATED_NAME = "BBBBBBBBBB";
private static final String DEFAULT_CONTRACTUAL_SALUTATION = "AAAAAAAAAA";
private static final String UPDATED_CONTRACTUAL_SALUTATION = "BBBBBBBBBB";
private static final String DEFAULT_CONTRACTUAL_ADDRESS = "AAAAAAAAAA";
private static final String UPDATED_CONTRACTUAL_ADDRESS = "BBBBBBBBBB";
private static final String DEFAULT_BILLING_SALUTATION = "AAAAAAAAAA";
private static final String UPDATED_BILLING_SALUTATION = "BBBBBBBBBB";
private static final String DEFAULT_BILLING_ADDRESS = "AAAAAAAAAA";
private static final String UPDATED_BILLING_ADDRESS = "BBBBBBBBBB";
private static final String DEFAULT_REMARK = "AAAAAAAAAA";
private static final String UPDATED_REMARK = "BBBBBBBBBB";
@Autowired
private CustomerRepository customerRepository;
@Autowired
private CustomerMapper customerMapper;
@Autowired
private CustomerService customerService;
@Autowired
private CustomerQueryService customerQueryService;
@Autowired
private MappingJackson2HttpMessageConverter jacksonMessageConverter;
@Autowired
private PageableHandlerMethodArgumentResolver pageableArgumentResolver;
@Autowired
private ExceptionTranslator exceptionTranslator;
@Autowired
private EntityManager em;
@Autowired
private Validator validator;
private MockMvc restCustomerMockMvc;
private Customer customer;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
final CustomerResource customerResource = new CustomerResource(customerService, customerQueryService);
this.restCustomerMockMvc = MockMvcBuilders.standaloneSetup(customerResource)
.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 Customer createEntity(EntityManager em) {
Customer customer = new Customer()
.reference(DEFAULT_REFERENCE)
.prefix(DEFAULT_PREFIX)
.name(DEFAULT_NAME)
.contractualSalutation(DEFAULT_CONTRACTUAL_SALUTATION)
.contractualAddress(DEFAULT_CONTRACTUAL_ADDRESS)
.billingSalutation(DEFAULT_BILLING_SALUTATION)
.billingAddress(DEFAULT_BILLING_ADDRESS)
.remark(DEFAULT_REMARK);
return customer;
}
@Before
public void initTest() {
customer = createEntity(em);
}
@Test
@Transactional
public void createCustomer() throws Exception {
int databaseSizeBeforeCreate = customerRepository.findAll().size();
// Create the Customer
CustomerDTO customerDTO = customerMapper.toDto(customer);
restCustomerMockMvc.perform(post("/api/customers")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(customerDTO)))
.andExpect(status().isCreated());
// Validate the Customer in the database
List<Customer> customerList = customerRepository.findAll();
assertThat(customerList).hasSize(databaseSizeBeforeCreate + 1);
Customer testCustomer = customerList.get(customerList.size() - 1);
assertThat(testCustomer.getReference()).isEqualTo(DEFAULT_REFERENCE);
assertThat(testCustomer.getPrefix()).isEqualTo(DEFAULT_PREFIX);
assertThat(testCustomer.getName()).isEqualTo(DEFAULT_NAME);
assertThat(testCustomer.getContractualSalutation()).isEqualTo(DEFAULT_CONTRACTUAL_SALUTATION);
assertThat(testCustomer.getContractualAddress()).isEqualTo(DEFAULT_CONTRACTUAL_ADDRESS);
assertThat(testCustomer.getBillingSalutation()).isEqualTo(DEFAULT_BILLING_SALUTATION);
assertThat(testCustomer.getBillingAddress()).isEqualTo(DEFAULT_BILLING_ADDRESS);
assertThat(testCustomer.getRemark()).isEqualTo(DEFAULT_REMARK);
}
@Test
@Transactional
public void createCustomerWithExistingId() throws Exception {
int databaseSizeBeforeCreate = customerRepository.findAll().size();
// Create the Customer with an existing ID
customer.setId(1L);
CustomerDTO customerDTO = customerMapper.toDto(customer);
// An entity with an existing ID cannot be created, so this API call must fail
restCustomerMockMvc.perform(post("/api/customers")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(customerDTO)))
.andExpect(status().isBadRequest());
// Validate the Customer in the database
List<Customer> customerList = customerRepository.findAll();
assertThat(customerList).hasSize(databaseSizeBeforeCreate);
}
@Test
@Transactional
public void checkReferenceIsRequired() throws Exception {
int databaseSizeBeforeTest = customerRepository.findAll().size();
// set the field null
customer.setReference(null);
// Create the Customer, which fails.
CustomerDTO customerDTO = customerMapper.toDto(customer);
restCustomerMockMvc.perform(post("/api/customers")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(customerDTO)))
.andExpect(status().isBadRequest());
List<Customer> customerList = customerRepository.findAll();
assertThat(customerList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkPrefixIsRequired() throws Exception {
int databaseSizeBeforeTest = customerRepository.findAll().size();
// set the field null
customer.setPrefix(null);
// Create the Customer, which fails.
CustomerDTO customerDTO = customerMapper.toDto(customer);
restCustomerMockMvc.perform(post("/api/customers")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(customerDTO)))
.andExpect(status().isBadRequest());
List<Customer> customerList = customerRepository.findAll();
assertThat(customerList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkNameIsRequired() throws Exception {
int databaseSizeBeforeTest = customerRepository.findAll().size();
// set the field null
customer.setName(null);
// Create the Customer, which fails.
CustomerDTO customerDTO = customerMapper.toDto(customer);
restCustomerMockMvc.perform(post("/api/customers")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(customerDTO)))
.andExpect(status().isBadRequest());
List<Customer> customerList = customerRepository.findAll();
assertThat(customerList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkContractualAddressIsRequired() throws Exception {
int databaseSizeBeforeTest = customerRepository.findAll().size();
// set the field null
customer.setContractualAddress(null);
// Create the Customer, which fails.
CustomerDTO customerDTO = customerMapper.toDto(customer);
restCustomerMockMvc.perform(post("/api/customers")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(customerDTO)))
.andExpect(status().isBadRequest());
List<Customer> customerList = customerRepository.findAll();
assertThat(customerList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void getAllCustomers() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList
restCustomerMockMvc.perform(get("/api/customers?sort=id,desc"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(customer.getId().intValue())))
.andExpect(jsonPath("$.[*].reference").value(hasItem(DEFAULT_REFERENCE)))
.andExpect(jsonPath("$.[*].prefix").value(hasItem(DEFAULT_PREFIX.toString())))
.andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString())))
.andExpect(jsonPath("$.[*].contractualSalutation").value(hasItem(DEFAULT_CONTRACTUAL_SALUTATION.toString())))
.andExpect(jsonPath("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS.toString())))
.andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION.toString())))
.andExpect(jsonPath("$.[*].billingAddress").value(hasItem(DEFAULT_BILLING_ADDRESS.toString())))
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString())));
}
@Test
@Transactional
public void getCustomer() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get the customer
restCustomerMockMvc.perform(get("/api/customers/{id}", customer.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.id").value(customer.getId().intValue()))
.andExpect(jsonPath("$.reference").value(DEFAULT_REFERENCE))
.andExpect(jsonPath("$.prefix").value(DEFAULT_PREFIX.toString()))
.andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString()))
.andExpect(jsonPath("$.contractualSalutation").value(DEFAULT_CONTRACTUAL_SALUTATION.toString()))
.andExpect(jsonPath("$.contractualAddress").value(DEFAULT_CONTRACTUAL_ADDRESS.toString()))
.andExpect(jsonPath("$.billingSalutation").value(DEFAULT_BILLING_SALUTATION.toString()))
.andExpect(jsonPath("$.billingAddress").value(DEFAULT_BILLING_ADDRESS.toString()))
.andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString()));
}
@Test
@Transactional
public void getAllCustomersByReferenceIsEqualToSomething() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where reference equals to DEFAULT_REFERENCE
defaultCustomerShouldBeFound("reference.equals=" + DEFAULT_REFERENCE);
// Get all the customerList where reference equals to UPDATED_REFERENCE
defaultCustomerShouldNotBeFound("reference.equals=" + UPDATED_REFERENCE);
}
@Test
@Transactional
public void getAllCustomersByReferenceIsInShouldWork() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where reference in DEFAULT_REFERENCE or UPDATED_REFERENCE
defaultCustomerShouldBeFound("reference.in=" + DEFAULT_REFERENCE + "," + UPDATED_REFERENCE);
// Get all the customerList where reference equals to UPDATED_REFERENCE
defaultCustomerShouldNotBeFound("reference.in=" + UPDATED_REFERENCE);
}
@Test
@Transactional
public void getAllCustomersByReferenceIsNullOrNotNull() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where reference is not null
defaultCustomerShouldBeFound("reference.specified=true");
// Get all the customerList where reference is null
defaultCustomerShouldNotBeFound("reference.specified=false");
}
@Test
@Transactional
public void getAllCustomersByReferenceIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where reference greater than or equals to DEFAULT_REFERENCE
defaultCustomerShouldBeFound("reference.greaterOrEqualThan=" + DEFAULT_REFERENCE);
// Get all the customerList where reference greater than or equals to (DEFAULT_REFERENCE + 1)
defaultCustomerShouldNotBeFound("reference.greaterOrEqualThan=" + (DEFAULT_REFERENCE + 1));
}
@Test
@Transactional
public void getAllCustomersByReferenceIsLessThanSomething() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where reference less than or equals to DEFAULT_REFERENCE
defaultCustomerShouldNotBeFound("reference.lessThan=" + DEFAULT_REFERENCE);
// Get all the customerList where reference less than or equals to (DEFAULT_REFERENCE + 1)
defaultCustomerShouldBeFound("reference.lessThan=" + (DEFAULT_REFERENCE + 1));
}
@Test
@Transactional
public void getAllCustomersByPrefixIsEqualToSomething() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where prefix equals to DEFAULT_PREFIX
defaultCustomerShouldBeFound("prefix.equals=" + DEFAULT_PREFIX);
// Get all the customerList where prefix equals to UPDATED_PREFIX
defaultCustomerShouldNotBeFound("prefix.equals=" + UPDATED_PREFIX);
}
@Test
@Transactional
public void getAllCustomersByPrefixIsInShouldWork() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where prefix in DEFAULT_PREFIX or UPDATED_PREFIX
defaultCustomerShouldBeFound("prefix.in=" + DEFAULT_PREFIX + "," + UPDATED_PREFIX);
// Get all the customerList where prefix equals to UPDATED_PREFIX
defaultCustomerShouldNotBeFound("prefix.in=" + UPDATED_PREFIX);
}
@Test
@Transactional
public void getAllCustomersByPrefixIsNullOrNotNull() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where prefix is not null
defaultCustomerShouldBeFound("prefix.specified=true");
// Get all the customerList where prefix is null
defaultCustomerShouldNotBeFound("prefix.specified=false");
}
@Test
@Transactional
public void getAllCustomersByNameIsEqualToSomething() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where name equals to DEFAULT_NAME
defaultCustomerShouldBeFound("name.equals=" + DEFAULT_NAME);
// Get all the customerList where name equals to UPDATED_NAME
defaultCustomerShouldNotBeFound("name.equals=" + UPDATED_NAME);
}
@Test
@Transactional
public void getAllCustomersByNameIsInShouldWork() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where name in DEFAULT_NAME or UPDATED_NAME
defaultCustomerShouldBeFound("name.in=" + DEFAULT_NAME + "," + UPDATED_NAME);
// Get all the customerList where name equals to UPDATED_NAME
defaultCustomerShouldNotBeFound("name.in=" + UPDATED_NAME);
}
@Test
@Transactional
public void getAllCustomersByNameIsNullOrNotNull() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where name is not null
defaultCustomerShouldBeFound("name.specified=true");
// Get all the customerList where name is null
defaultCustomerShouldNotBeFound("name.specified=false");
}
@Test
@Transactional
public void getAllCustomersByContractualSalutationIsEqualToSomething() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where contractualSalutation equals to DEFAULT_CONTRACTUAL_SALUTATION
defaultCustomerShouldBeFound("contractualSalutation.equals=" + DEFAULT_CONTRACTUAL_SALUTATION);
// Get all the customerList where contractualSalutation equals to UPDATED_CONTRACTUAL_SALUTATION
defaultCustomerShouldNotBeFound("contractualSalutation.equals=" + UPDATED_CONTRACTUAL_SALUTATION);
}
@Test
@Transactional
public void getAllCustomersByContractualSalutationIsInShouldWork() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where contractualSalutation in DEFAULT_CONTRACTUAL_SALUTATION or UPDATED_CONTRACTUAL_SALUTATION
defaultCustomerShouldBeFound("contractualSalutation.in=" + DEFAULT_CONTRACTUAL_SALUTATION + "," + UPDATED_CONTRACTUAL_SALUTATION);
// Get all the customerList where contractualSalutation equals to UPDATED_CONTRACTUAL_SALUTATION
defaultCustomerShouldNotBeFound("contractualSalutation.in=" + UPDATED_CONTRACTUAL_SALUTATION);
}
@Test
@Transactional
public void getAllCustomersByContractualSalutationIsNullOrNotNull() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where contractualSalutation is not null
defaultCustomerShouldBeFound("contractualSalutation.specified=true");
// Get all the customerList where contractualSalutation is null
defaultCustomerShouldNotBeFound("contractualSalutation.specified=false");
}
@Test
@Transactional
public void getAllCustomersByContractualAddressIsEqualToSomething() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where contractualAddress equals to DEFAULT_CONTRACTUAL_ADDRESS
defaultCustomerShouldBeFound("contractualAddress.equals=" + DEFAULT_CONTRACTUAL_ADDRESS);
// Get all the customerList where contractualAddress equals to UPDATED_CONTRACTUAL_ADDRESS
defaultCustomerShouldNotBeFound("contractualAddress.equals=" + UPDATED_CONTRACTUAL_ADDRESS);
}
@Test
@Transactional
public void getAllCustomersByContractualAddressIsInShouldWork() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where contractualAddress in DEFAULT_CONTRACTUAL_ADDRESS or UPDATED_CONTRACTUAL_ADDRESS
defaultCustomerShouldBeFound("contractualAddress.in=" + DEFAULT_CONTRACTUAL_ADDRESS + "," + UPDATED_CONTRACTUAL_ADDRESS);
// Get all the customerList where contractualAddress equals to UPDATED_CONTRACTUAL_ADDRESS
defaultCustomerShouldNotBeFound("contractualAddress.in=" + UPDATED_CONTRACTUAL_ADDRESS);
}
@Test
@Transactional
public void getAllCustomersByContractualAddressIsNullOrNotNull() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where contractualAddress is not null
defaultCustomerShouldBeFound("contractualAddress.specified=true");
// Get all the customerList where contractualAddress is null
defaultCustomerShouldNotBeFound("contractualAddress.specified=false");
}
@Test
@Transactional
public void getAllCustomersByBillingSalutationIsEqualToSomething() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where billingSalutation equals to DEFAULT_BILLING_SALUTATION
defaultCustomerShouldBeFound("billingSalutation.equals=" + DEFAULT_BILLING_SALUTATION);
// Get all the customerList where billingSalutation equals to UPDATED_BILLING_SALUTATION
defaultCustomerShouldNotBeFound("billingSalutation.equals=" + UPDATED_BILLING_SALUTATION);
}
@Test
@Transactional
public void getAllCustomersByBillingSalutationIsInShouldWork() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where billingSalutation in DEFAULT_BILLING_SALUTATION or UPDATED_BILLING_SALUTATION
defaultCustomerShouldBeFound("billingSalutation.in=" + DEFAULT_BILLING_SALUTATION + "," + UPDATED_BILLING_SALUTATION);
// Get all the customerList where billingSalutation equals to UPDATED_BILLING_SALUTATION
defaultCustomerShouldNotBeFound("billingSalutation.in=" + UPDATED_BILLING_SALUTATION);
}
@Test
@Transactional
public void getAllCustomersByBillingSalutationIsNullOrNotNull() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where billingSalutation is not null
defaultCustomerShouldBeFound("billingSalutation.specified=true");
// Get all the customerList where billingSalutation is null
defaultCustomerShouldNotBeFound("billingSalutation.specified=false");
}
@Test
@Transactional
public void getAllCustomersByBillingAddressIsEqualToSomething() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where billingAddress equals to DEFAULT_BILLING_ADDRESS
defaultCustomerShouldBeFound("billingAddress.equals=" + DEFAULT_BILLING_ADDRESS);
// Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS
defaultCustomerShouldNotBeFound("billingAddress.equals=" + UPDATED_BILLING_ADDRESS);
}
@Test
@Transactional
public void getAllCustomersByBillingAddressIsInShouldWork() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where billingAddress in DEFAULT_BILLING_ADDRESS or UPDATED_BILLING_ADDRESS
defaultCustomerShouldBeFound("billingAddress.in=" + DEFAULT_BILLING_ADDRESS + "," + UPDATED_BILLING_ADDRESS);
// Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS
defaultCustomerShouldNotBeFound("billingAddress.in=" + UPDATED_BILLING_ADDRESS);
}
@Test
@Transactional
public void getAllCustomersByBillingAddressIsNullOrNotNull() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where billingAddress is not null
defaultCustomerShouldBeFound("billingAddress.specified=true");
// Get all the customerList where billingAddress is null
defaultCustomerShouldNotBeFound("billingAddress.specified=false");
}
@Test
@Transactional
public void getAllCustomersByRemarkIsEqualToSomething() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where remark equals to DEFAULT_REMARK
defaultCustomerShouldBeFound("remark.equals=" + DEFAULT_REMARK);
// Get all the customerList where remark equals to UPDATED_REMARK
defaultCustomerShouldNotBeFound("remark.equals=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllCustomersByRemarkIsInShouldWork() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where remark in DEFAULT_REMARK or UPDATED_REMARK
defaultCustomerShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK);
// Get all the customerList where remark equals to UPDATED_REMARK
defaultCustomerShouldNotBeFound("remark.in=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllCustomersByRemarkIsNullOrNotNull() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where remark is not null
defaultCustomerShouldBeFound("remark.specified=true");
// Get all the customerList where remark is null
defaultCustomerShouldNotBeFound("remark.specified=false");
}
@Test
@Transactional
public void getAllCustomersByMembershipIsEqualToSomething() throws Exception {
// Initialize the database
Membership membership = MembershipResourceIntTest.createEntity(em);
em.persist(membership);
em.flush();
customer.addMembership(membership);
customerRepository.saveAndFlush(customer);
Long membershipId = membership.getId();
// Get all the customerList where membership equals to membershipId
defaultCustomerShouldBeFound("membershipId.equals=" + membershipId);
// Get all the customerList where membership equals to membershipId + 1
defaultCustomerShouldNotBeFound("membershipId.equals=" + (membershipId + 1));
}
@Test
@Transactional
public void getAllCustomersBySepamandateIsEqualToSomething() throws Exception {
// Initialize the database
SepaMandate sepamandate = SepaMandateResourceIntTest.createEntity(em);
em.persist(sepamandate);
em.flush();
customer.addSepamandate(sepamandate);
customerRepository.saveAndFlush(customer);
Long sepamandateId = sepamandate.getId();
// Get all the customerList where sepamandate equals to sepamandateId
defaultCustomerShouldBeFound("sepamandateId.equals=" + sepamandateId);
// Get all the customerList where sepamandate equals to sepamandateId + 1
defaultCustomerShouldNotBeFound("sepamandateId.equals=" + (sepamandateId + 1));
}
/**
* Executes the search, and checks that the default entity is returned
*/
private void defaultCustomerShouldBeFound(String filter) throws Exception {
restCustomerMockMvc.perform(get("/api/customers?sort=id,desc&" + filter))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(customer.getId().intValue())))
.andExpect(jsonPath("$.[*].reference").value(hasItem(DEFAULT_REFERENCE)))
.andExpect(jsonPath("$.[*].prefix").value(hasItem(DEFAULT_PREFIX)))
.andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME)))
.andExpect(jsonPath("$.[*].contractualSalutation").value(hasItem(DEFAULT_CONTRACTUAL_SALUTATION)))
.andExpect(jsonPath("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS)))
.andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION)))
.andExpect(jsonPath("$.[*].billingAddress").value(hasItem(DEFAULT_BILLING_ADDRESS)))
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK)));
// Check, that the count call also returns 1
restCustomerMockMvc.perform(get("/api/customers/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 defaultCustomerShouldNotBeFound(String filter) throws Exception {
restCustomerMockMvc.perform(get("/api/customers?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
restCustomerMockMvc.perform(get("/api/customers/count?sort=id,desc&" + filter))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().string("0"));
}
@Test
@Transactional
public void getNonExistingCustomer() throws Exception {
// Get the customer
restCustomerMockMvc.perform(get("/api/customers/{id}", Long.MAX_VALUE))
.andExpect(status().isNotFound());
}
@Test
@Transactional
public void updateCustomer() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
int databaseSizeBeforeUpdate = customerRepository.findAll().size();
// Update the customer
Customer updatedCustomer = customerRepository.findById(customer.getId()).get();
// Disconnect from session so that the updates on updatedCustomer are not directly saved in db
em.detach(updatedCustomer);
updatedCustomer
.reference(UPDATED_REFERENCE)
.prefix(UPDATED_PREFIX)
.name(UPDATED_NAME)
.contractualSalutation(UPDATED_CONTRACTUAL_SALUTATION)
.contractualAddress(UPDATED_CONTRACTUAL_ADDRESS)
.billingSalutation(UPDATED_BILLING_SALUTATION)
.billingAddress(UPDATED_BILLING_ADDRESS)
.remark(UPDATED_REMARK);
CustomerDTO customerDTO = customerMapper.toDto(updatedCustomer);
restCustomerMockMvc.perform(put("/api/customers")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(customerDTO)))
.andExpect(status().isOk());
// Validate the Customer in the database
List<Customer> customerList = customerRepository.findAll();
assertThat(customerList).hasSize(databaseSizeBeforeUpdate);
Customer testCustomer = customerList.get(customerList.size() - 1);
assertThat(testCustomer.getReference()).isEqualTo(UPDATED_REFERENCE);
assertThat(testCustomer.getPrefix()).isEqualTo(UPDATED_PREFIX);
assertThat(testCustomer.getName()).isEqualTo(UPDATED_NAME);
assertThat(testCustomer.getContractualSalutation()).isEqualTo(UPDATED_CONTRACTUAL_SALUTATION);
assertThat(testCustomer.getContractualAddress()).isEqualTo(UPDATED_CONTRACTUAL_ADDRESS);
assertThat(testCustomer.getBillingSalutation()).isEqualTo(UPDATED_BILLING_SALUTATION);
assertThat(testCustomer.getBillingAddress()).isEqualTo(UPDATED_BILLING_ADDRESS);
assertThat(testCustomer.getRemark()).isEqualTo(UPDATED_REMARK);
}
@Test
@Transactional
public void updateNonExistingCustomer() throws Exception {
int databaseSizeBeforeUpdate = customerRepository.findAll().size();
// Create the Customer
CustomerDTO customerDTO = customerMapper.toDto(customer);
// If the entity doesn't have an ID, it will throw BadRequestAlertException
restCustomerMockMvc.perform(put("/api/customers")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(customerDTO)))
.andExpect(status().isBadRequest());
// Validate the Customer in the database
List<Customer> customerList = customerRepository.findAll();
assertThat(customerList).hasSize(databaseSizeBeforeUpdate);
}
@Test
@Transactional
public void deleteCustomer() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
int databaseSizeBeforeDelete = customerRepository.findAll().size();
// Delete the customer
restCustomerMockMvc.perform(delete("/api/customers/{id}", customer.getId())
.accept(TestUtil.APPLICATION_JSON_UTF8))
.andExpect(status().isOk());
// Validate the database is empty
List<Customer> customerList = customerRepository.findAll();
assertThat(customerList).hasSize(databaseSizeBeforeDelete - 1);
}
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Customer.class);
Customer customer1 = new Customer();
customer1.setId(1L);
Customer customer2 = new Customer();
customer2.setId(customer1.getId());
assertThat(customer1).isEqualTo(customer2);
customer2.setId(2L);
assertThat(customer1).isNotEqualTo(customer2);
customer1.setId(null);
assertThat(customer1).isNotEqualTo(customer2);
}
@Test
@Transactional
public void dtoEqualsVerifier() throws Exception {
TestUtil.equalsVerifier(CustomerDTO.class);
CustomerDTO customerDTO1 = new CustomerDTO();
customerDTO1.setId(1L);
CustomerDTO customerDTO2 = new CustomerDTO();
assertThat(customerDTO1).isNotEqualTo(customerDTO2);
customerDTO2.setId(customerDTO1.getId());
assertThat(customerDTO1).isEqualTo(customerDTO2);
customerDTO2.setId(2L);
assertThat(customerDTO1).isNotEqualTo(customerDTO2);
customerDTO1.setId(null);
assertThat(customerDTO1).isNotEqualTo(customerDTO2);
}
@Test
@Transactional
public void testEntityFromId() {
assertThat(customerMapper.fromId(42L).getId()).isEqualTo(42);
assertThat(customerMapper.fromId(null)).isNull();
}
}

View File

@@ -0,0 +1,694 @@
package org.hostsharing.hsadminng.web.rest;
import org.hostsharing.hsadminng.HsadminNgApp;
import org.hostsharing.hsadminng.domain.Membership;
import org.hostsharing.hsadminng.domain.Share;
import org.hostsharing.hsadminng.domain.Asset;
import org.hostsharing.hsadminng.domain.Customer;
import org.hostsharing.hsadminng.repository.MembershipRepository;
import org.hostsharing.hsadminng.service.MembershipService;
import org.hostsharing.hsadminng.service.dto.MembershipDTO;
import org.hostsharing.hsadminng.service.mapper.MembershipMapper;
import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator;
import org.hostsharing.hsadminng.service.dto.MembershipCriteria;
import org.hostsharing.hsadminng.service.MembershipQueryService;
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.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.LocalDate;
import java.time.ZoneId;
import java.util.List;
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
* Test class for the MembershipResource REST controller.
*
* @see MembershipResource
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = HsadminNgApp.class)
public class MembershipResourceIntTest {
private static final LocalDate DEFAULT_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_MEMBER_FROM = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_MEMBER_FROM = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_MEMBER_UNTIL = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_MEMBER_UNTIL = LocalDate.now(ZoneId.systemDefault());
private static final String DEFAULT_REMARK = "AAAAAAAAAA";
private static final String UPDATED_REMARK = "BBBBBBBBBB";
@Autowired
private MembershipRepository membershipRepository;
@Autowired
private MembershipMapper membershipMapper;
@Autowired
private MembershipService membershipService;
@Autowired
private MembershipQueryService membershipQueryService;
@Autowired
private MappingJackson2HttpMessageConverter jacksonMessageConverter;
@Autowired
private PageableHandlerMethodArgumentResolver pageableArgumentResolver;
@Autowired
private ExceptionTranslator exceptionTranslator;
@Autowired
private EntityManager em;
@Autowired
private Validator validator;
private MockMvc restMembershipMockMvc;
private Membership membership;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
final MembershipResource membershipResource = new MembershipResource(membershipService, membershipQueryService);
this.restMembershipMockMvc = MockMvcBuilders.standaloneSetup(membershipResource)
.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 Membership createEntity(EntityManager em) {
Membership membership = new Membership()
.documentDate(DEFAULT_DOCUMENT_DATE)
.memberFrom(DEFAULT_MEMBER_FROM)
.memberUntil(DEFAULT_MEMBER_UNTIL)
.remark(DEFAULT_REMARK);
// Add required entity
Customer customer = CustomerResourceIntTest.createEntity(em);
em.persist(customer);
em.flush();
membership.setCustomer(customer);
return membership;
}
@Before
public void initTest() {
membership = createEntity(em);
}
@Test
@Transactional
public void createMembership() throws Exception {
int databaseSizeBeforeCreate = membershipRepository.findAll().size();
// Create the Membership
MembershipDTO membershipDTO = membershipMapper.toDto(membership);
restMembershipMockMvc.perform(post("/api/memberships")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(membershipDTO)))
.andExpect(status().isCreated());
// Validate the Membership in the database
List<Membership> membershipList = membershipRepository.findAll();
assertThat(membershipList).hasSize(databaseSizeBeforeCreate + 1);
Membership testMembership = membershipList.get(membershipList.size() - 1);
assertThat(testMembership.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE);
assertThat(testMembership.getMemberFrom()).isEqualTo(DEFAULT_MEMBER_FROM);
assertThat(testMembership.getMemberUntil()).isEqualTo(DEFAULT_MEMBER_UNTIL);
assertThat(testMembership.getRemark()).isEqualTo(DEFAULT_REMARK);
}
@Test
@Transactional
public void createMembershipWithExistingId() throws Exception {
int databaseSizeBeforeCreate = membershipRepository.findAll().size();
// Create the Membership with an existing ID
membership.setId(1L);
MembershipDTO membershipDTO = membershipMapper.toDto(membership);
// An entity with an existing ID cannot be created, so this API call must fail
restMembershipMockMvc.perform(post("/api/memberships")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(membershipDTO)))
.andExpect(status().isBadRequest());
// Validate the Membership in the database
List<Membership> membershipList = membershipRepository.findAll();
assertThat(membershipList).hasSize(databaseSizeBeforeCreate);
}
@Test
@Transactional
public void checkDocumentDateIsRequired() throws Exception {
int databaseSizeBeforeTest = membershipRepository.findAll().size();
// set the field null
membership.setDocumentDate(null);
// Create the Membership, which fails.
MembershipDTO membershipDTO = membershipMapper.toDto(membership);
restMembershipMockMvc.perform(post("/api/memberships")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(membershipDTO)))
.andExpect(status().isBadRequest());
List<Membership> membershipList = membershipRepository.findAll();
assertThat(membershipList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkMemberFromIsRequired() throws Exception {
int databaseSizeBeforeTest = membershipRepository.findAll().size();
// set the field null
membership.setMemberFrom(null);
// Create the Membership, which fails.
MembershipDTO membershipDTO = membershipMapper.toDto(membership);
restMembershipMockMvc.perform(post("/api/memberships")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(membershipDTO)))
.andExpect(status().isBadRequest());
List<Membership> membershipList = membershipRepository.findAll();
assertThat(membershipList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void getAllMemberships() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList
restMembershipMockMvc.perform(get("/api/memberships?sort=id,desc"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(membership.getId().intValue())))
.andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].memberFrom").value(hasItem(DEFAULT_MEMBER_FROM.toString())))
.andExpect(jsonPath("$.[*].memberUntil").value(hasItem(DEFAULT_MEMBER_UNTIL.toString())))
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString())));
}
@Test
@Transactional
public void getMembership() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get the membership
restMembershipMockMvc.perform(get("/api/memberships/{id}", membership.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.id").value(membership.getId().intValue()))
.andExpect(jsonPath("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString()))
.andExpect(jsonPath("$.memberFrom").value(DEFAULT_MEMBER_FROM.toString()))
.andExpect(jsonPath("$.memberUntil").value(DEFAULT_MEMBER_UNTIL.toString()))
.andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString()));
}
@Test
@Transactional
public void getAllMembershipsByDocumentDateIsEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where documentDate equals to DEFAULT_DOCUMENT_DATE
defaultMembershipShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE);
// Get all the membershipList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByDocumentDateIsInShouldWork() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE
defaultMembershipShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE);
// Get all the membershipList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByDocumentDateIsNullOrNotNull() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where documentDate is not null
defaultMembershipShouldBeFound("documentDate.specified=true");
// Get all the membershipList where documentDate is null
defaultMembershipShouldNotBeFound("documentDate.specified=false");
}
@Test
@Transactional
public void getAllMembershipsByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE
defaultMembershipShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the membershipList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByDocumentDateIsLessThanSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the membershipList where documentDate less than or equals to UPDATED_DOCUMENT_DATE
defaultMembershipShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByMemberFromIsEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberFrom equals to DEFAULT_MEMBER_FROM
defaultMembershipShouldBeFound("memberFrom.equals=" + DEFAULT_MEMBER_FROM);
// Get all the membershipList where memberFrom equals to UPDATED_MEMBER_FROM
defaultMembershipShouldNotBeFound("memberFrom.equals=" + UPDATED_MEMBER_FROM);
}
@Test
@Transactional
public void getAllMembershipsByMemberFromIsInShouldWork() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberFrom in DEFAULT_MEMBER_FROM or UPDATED_MEMBER_FROM
defaultMembershipShouldBeFound("memberFrom.in=" + DEFAULT_MEMBER_FROM + "," + UPDATED_MEMBER_FROM);
// Get all the membershipList where memberFrom equals to UPDATED_MEMBER_FROM
defaultMembershipShouldNotBeFound("memberFrom.in=" + UPDATED_MEMBER_FROM);
}
@Test
@Transactional
public void getAllMembershipsByMemberFromIsNullOrNotNull() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberFrom is not null
defaultMembershipShouldBeFound("memberFrom.specified=true");
// Get all the membershipList where memberFrom is null
defaultMembershipShouldNotBeFound("memberFrom.specified=false");
}
@Test
@Transactional
public void getAllMembershipsByMemberFromIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberFrom greater than or equals to DEFAULT_MEMBER_FROM
defaultMembershipShouldBeFound("memberFrom.greaterOrEqualThan=" + DEFAULT_MEMBER_FROM);
// Get all the membershipList where memberFrom greater than or equals to UPDATED_MEMBER_FROM
defaultMembershipShouldNotBeFound("memberFrom.greaterOrEqualThan=" + UPDATED_MEMBER_FROM);
}
@Test
@Transactional
public void getAllMembershipsByMemberFromIsLessThanSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberFrom less than or equals to DEFAULT_MEMBER_FROM
defaultMembershipShouldNotBeFound("memberFrom.lessThan=" + DEFAULT_MEMBER_FROM);
// Get all the membershipList where memberFrom less than or equals to UPDATED_MEMBER_FROM
defaultMembershipShouldBeFound("memberFrom.lessThan=" + UPDATED_MEMBER_FROM);
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilIsEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntil equals to DEFAULT_MEMBER_UNTIL
defaultMembershipShouldBeFound("memberUntil.equals=" + DEFAULT_MEMBER_UNTIL);
// Get all the membershipList where memberUntil equals to UPDATED_MEMBER_UNTIL
defaultMembershipShouldNotBeFound("memberUntil.equals=" + UPDATED_MEMBER_UNTIL);
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilIsInShouldWork() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntil in DEFAULT_MEMBER_UNTIL or UPDATED_MEMBER_UNTIL
defaultMembershipShouldBeFound("memberUntil.in=" + DEFAULT_MEMBER_UNTIL + "," + UPDATED_MEMBER_UNTIL);
// Get all the membershipList where memberUntil equals to UPDATED_MEMBER_UNTIL
defaultMembershipShouldNotBeFound("memberUntil.in=" + UPDATED_MEMBER_UNTIL);
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilIsNullOrNotNull() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntil is not null
defaultMembershipShouldBeFound("memberUntil.specified=true");
// Get all the membershipList where memberUntil is null
defaultMembershipShouldNotBeFound("memberUntil.specified=false");
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntil greater than or equals to DEFAULT_MEMBER_UNTIL
defaultMembershipShouldBeFound("memberUntil.greaterOrEqualThan=" + DEFAULT_MEMBER_UNTIL);
// Get all the membershipList where memberUntil greater than or equals to UPDATED_MEMBER_UNTIL
defaultMembershipShouldNotBeFound("memberUntil.greaterOrEqualThan=" + UPDATED_MEMBER_UNTIL);
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilIsLessThanSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntil less than or equals to DEFAULT_MEMBER_UNTIL
defaultMembershipShouldNotBeFound("memberUntil.lessThan=" + DEFAULT_MEMBER_UNTIL);
// Get all the membershipList where memberUntil less than or equals to UPDATED_MEMBER_UNTIL
defaultMembershipShouldBeFound("memberUntil.lessThan=" + UPDATED_MEMBER_UNTIL);
}
@Test
@Transactional
public void getAllMembershipsByRemarkIsEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where remark equals to DEFAULT_REMARK
defaultMembershipShouldBeFound("remark.equals=" + DEFAULT_REMARK);
// Get all the membershipList where remark equals to UPDATED_REMARK
defaultMembershipShouldNotBeFound("remark.equals=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllMembershipsByRemarkIsInShouldWork() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where remark in DEFAULT_REMARK or UPDATED_REMARK
defaultMembershipShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK);
// Get all the membershipList where remark equals to UPDATED_REMARK
defaultMembershipShouldNotBeFound("remark.in=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllMembershipsByRemarkIsNullOrNotNull() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where remark is not null
defaultMembershipShouldBeFound("remark.specified=true");
// Get all the membershipList where remark is null
defaultMembershipShouldNotBeFound("remark.specified=false");
}
@Test
@Transactional
public void getAllMembershipsByShareIsEqualToSomething() throws Exception {
// Initialize the database
Share share = ShareResourceIntTest.createEntity(em);
em.persist(share);
em.flush();
membership.addShare(share);
membershipRepository.saveAndFlush(membership);
Long shareId = share.getId();
// Get all the membershipList where share equals to shareId
defaultMembershipShouldBeFound("shareId.equals=" + shareId);
// Get all the membershipList where share equals to shareId + 1
defaultMembershipShouldNotBeFound("shareId.equals=" + (shareId + 1));
}
@Test
@Transactional
public void getAllMembershipsByAssetIsEqualToSomething() throws Exception {
// Initialize the database
Asset asset = AssetResourceIntTest.createEntity(em);
em.persist(asset);
em.flush();
membership.addAsset(asset);
membershipRepository.saveAndFlush(membership);
Long assetId = asset.getId();
// Get all the membershipList where asset equals to assetId
defaultMembershipShouldBeFound("assetId.equals=" + assetId);
// Get all the membershipList where asset equals to assetId + 1
defaultMembershipShouldNotBeFound("assetId.equals=" + (assetId + 1));
}
@Test
@Transactional
public void getAllMembershipsByCustomerIsEqualToSomething() throws Exception {
// Initialize the database
Customer customer = CustomerResourceIntTest.createEntity(em);
em.persist(customer);
em.flush();
membership.setCustomer(customer);
membershipRepository.saveAndFlush(membership);
Long customerId = customer.getId();
// Get all the membershipList where customer equals to customerId
defaultMembershipShouldBeFound("customerId.equals=" + customerId);
// Get all the membershipList where customer equals to customerId + 1
defaultMembershipShouldNotBeFound("customerId.equals=" + (customerId + 1));
}
/**
* Executes the search, and checks that the default entity is returned
*/
private void defaultMembershipShouldBeFound(String filter) throws Exception {
restMembershipMockMvc.perform(get("/api/memberships?sort=id,desc&" + filter))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(membership.getId().intValue())))
.andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].memberFrom").value(hasItem(DEFAULT_MEMBER_FROM.toString())))
.andExpect(jsonPath("$.[*].memberUntil").value(hasItem(DEFAULT_MEMBER_UNTIL.toString())))
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK)));
// Check, that the count call also returns 1
restMembershipMockMvc.perform(get("/api/memberships/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 defaultMembershipShouldNotBeFound(String filter) throws Exception {
restMembershipMockMvc.perform(get("/api/memberships?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
restMembershipMockMvc.perform(get("/api/memberships/count?sort=id,desc&" + filter))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().string("0"));
}
@Test
@Transactional
public void getNonExistingMembership() throws Exception {
// Get the membership
restMembershipMockMvc.perform(get("/api/memberships/{id}", Long.MAX_VALUE))
.andExpect(status().isNotFound());
}
@Test
@Transactional
public void updateMembership() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
int databaseSizeBeforeUpdate = membershipRepository.findAll().size();
// Update the membership
Membership updatedMembership = membershipRepository.findById(membership.getId()).get();
// Disconnect from session so that the updates on updatedMembership are not directly saved in db
em.detach(updatedMembership);
updatedMembership
.documentDate(UPDATED_DOCUMENT_DATE)
.memberFrom(UPDATED_MEMBER_FROM)
.memberUntil(UPDATED_MEMBER_UNTIL)
.remark(UPDATED_REMARK);
MembershipDTO membershipDTO = membershipMapper.toDto(updatedMembership);
restMembershipMockMvc.perform(put("/api/memberships")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(membershipDTO)))
.andExpect(status().isOk());
// Validate the Membership in the database
List<Membership> membershipList = membershipRepository.findAll();
assertThat(membershipList).hasSize(databaseSizeBeforeUpdate);
Membership testMembership = membershipList.get(membershipList.size() - 1);
assertThat(testMembership.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE);
assertThat(testMembership.getMemberFrom()).isEqualTo(UPDATED_MEMBER_FROM);
assertThat(testMembership.getMemberUntil()).isEqualTo(UPDATED_MEMBER_UNTIL);
assertThat(testMembership.getRemark()).isEqualTo(UPDATED_REMARK);
}
@Test
@Transactional
public void updateNonExistingMembership() throws Exception {
int databaseSizeBeforeUpdate = membershipRepository.findAll().size();
// Create the Membership
MembershipDTO membershipDTO = membershipMapper.toDto(membership);
// If the entity doesn't have an ID, it will throw BadRequestAlertException
restMembershipMockMvc.perform(put("/api/memberships")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(membershipDTO)))
.andExpect(status().isBadRequest());
// Validate the Membership in the database
List<Membership> membershipList = membershipRepository.findAll();
assertThat(membershipList).hasSize(databaseSizeBeforeUpdate);
}
@Test
@Transactional
public void deleteMembership() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
int databaseSizeBeforeDelete = membershipRepository.findAll().size();
// Delete the membership
restMembershipMockMvc.perform(delete("/api/memberships/{id}", membership.getId())
.accept(TestUtil.APPLICATION_JSON_UTF8))
.andExpect(status().isOk());
// Validate the database is empty
List<Membership> membershipList = membershipRepository.findAll();
assertThat(membershipList).hasSize(databaseSizeBeforeDelete - 1);
}
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Membership.class);
Membership membership1 = new Membership();
membership1.setId(1L);
Membership membership2 = new Membership();
membership2.setId(membership1.getId());
assertThat(membership1).isEqualTo(membership2);
membership2.setId(2L);
assertThat(membership1).isNotEqualTo(membership2);
membership1.setId(null);
assertThat(membership1).isNotEqualTo(membership2);
}
@Test
@Transactional
public void dtoEqualsVerifier() throws Exception {
TestUtil.equalsVerifier(MembershipDTO.class);
MembershipDTO membershipDTO1 = new MembershipDTO();
membershipDTO1.setId(1L);
MembershipDTO membershipDTO2 = new MembershipDTO();
assertThat(membershipDTO1).isNotEqualTo(membershipDTO2);
membershipDTO2.setId(membershipDTO1.getId());
assertThat(membershipDTO1).isEqualTo(membershipDTO2);
membershipDTO2.setId(2L);
assertThat(membershipDTO1).isNotEqualTo(membershipDTO2);
membershipDTO1.setId(null);
assertThat(membershipDTO1).isNotEqualTo(membershipDTO2);
}
@Test
@Transactional
public void testEntityFromId() {
assertThat(membershipMapper.fromId(42L).getId()).isEqualTo(42);
assertThat(membershipMapper.fromId(null)).isNull();
}
}

View File

@@ -0,0 +1,972 @@
package org.hostsharing.hsadminng.web.rest;
import org.hostsharing.hsadminng.HsadminNgApp;
import org.hostsharing.hsadminng.domain.SepaMandate;
import org.hostsharing.hsadminng.domain.Customer;
import org.hostsharing.hsadminng.repository.SepaMandateRepository;
import org.hostsharing.hsadminng.service.SepaMandateService;
import org.hostsharing.hsadminng.service.dto.SepaMandateDTO;
import org.hostsharing.hsadminng.service.mapper.SepaMandateMapper;
import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator;
import org.hostsharing.hsadminng.service.dto.SepaMandateCriteria;
import org.hostsharing.hsadminng.service.SepaMandateQueryService;
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.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.LocalDate;
import java.time.ZoneId;
import java.util.List;
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
* Test class for the SepaMandateResource REST controller.
*
* @see SepaMandateResource
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = HsadminNgApp.class)
public class SepaMandateResourceIntTest {
private static final String DEFAULT_REFERENCE = "AAAAAAAAAA";
private static final String UPDATED_REFERENCE = "BBBBBBBBBB";
private static final String DEFAULT_IBAN = "AAAAAAAAAA";
private static final String UPDATED_IBAN = "BBBBBBBBBB";
private static final String DEFAULT_BIC = "AAAAAAAAAA";
private static final String UPDATED_BIC = "BBBBBBBBBB";
private static final LocalDate DEFAULT_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_VALID_FROM = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_VALID_FROM = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_VALID_UNTIL = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_VALID_UNTIL = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_LAST_USED = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_LAST_USED = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_CANCELLATION_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_CANCELLATION_DATE = LocalDate.now(ZoneId.systemDefault());
private static final String DEFAULT_REMARK = "AAAAAAAAAA";
private static final String UPDATED_REMARK = "BBBBBBBBBB";
@Autowired
private SepaMandateRepository sepaMandateRepository;
@Autowired
private SepaMandateMapper sepaMandateMapper;
@Autowired
private SepaMandateService sepaMandateService;
@Autowired
private SepaMandateQueryService sepaMandateQueryService;
@Autowired
private MappingJackson2HttpMessageConverter jacksonMessageConverter;
@Autowired
private PageableHandlerMethodArgumentResolver pageableArgumentResolver;
@Autowired
private ExceptionTranslator exceptionTranslator;
@Autowired
private EntityManager em;
@Autowired
private Validator validator;
private MockMvc restSepaMandateMockMvc;
private SepaMandate sepaMandate;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
final SepaMandateResource sepaMandateResource = new SepaMandateResource(sepaMandateService, sepaMandateQueryService);
this.restSepaMandateMockMvc = MockMvcBuilders.standaloneSetup(sepaMandateResource)
.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 SepaMandate createEntity(EntityManager em) {
SepaMandate sepaMandate = new SepaMandate()
.reference(DEFAULT_REFERENCE)
.iban(DEFAULT_IBAN)
.bic(DEFAULT_BIC)
.documentDate(DEFAULT_DOCUMENT_DATE)
.validFrom(DEFAULT_VALID_FROM)
.validUntil(DEFAULT_VALID_UNTIL)
.lastUsed(DEFAULT_LAST_USED)
.cancellationDate(DEFAULT_CANCELLATION_DATE)
.remark(DEFAULT_REMARK);
// Add required entity
Customer customer = CustomerResourceIntTest.createEntity(em);
em.persist(customer);
em.flush();
sepaMandate.setCustomer(customer);
return sepaMandate;
}
@Before
public void initTest() {
sepaMandate = createEntity(em);
}
@Test
@Transactional
public void createSepaMandate() throws Exception {
int databaseSizeBeforeCreate = sepaMandateRepository.findAll().size();
// Create the SepaMandate
SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate);
restSepaMandateMockMvc.perform(post("/api/sepa-mandates")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO)))
.andExpect(status().isCreated());
// Validate the SepaMandate in the database
List<SepaMandate> sepaMandateList = sepaMandateRepository.findAll();
assertThat(sepaMandateList).hasSize(databaseSizeBeforeCreate + 1);
SepaMandate testSepaMandate = sepaMandateList.get(sepaMandateList.size() - 1);
assertThat(testSepaMandate.getReference()).isEqualTo(DEFAULT_REFERENCE);
assertThat(testSepaMandate.getIban()).isEqualTo(DEFAULT_IBAN);
assertThat(testSepaMandate.getBic()).isEqualTo(DEFAULT_BIC);
assertThat(testSepaMandate.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE);
assertThat(testSepaMandate.getValidFrom()).isEqualTo(DEFAULT_VALID_FROM);
assertThat(testSepaMandate.getValidUntil()).isEqualTo(DEFAULT_VALID_UNTIL);
assertThat(testSepaMandate.getLastUsed()).isEqualTo(DEFAULT_LAST_USED);
assertThat(testSepaMandate.getCancellationDate()).isEqualTo(DEFAULT_CANCELLATION_DATE);
assertThat(testSepaMandate.getRemark()).isEqualTo(DEFAULT_REMARK);
}
@Test
@Transactional
public void createSepaMandateWithExistingId() throws Exception {
int databaseSizeBeforeCreate = sepaMandateRepository.findAll().size();
// Create the SepaMandate with an existing ID
sepaMandate.setId(1L);
SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate);
// An entity with an existing ID cannot be created, so this API call must fail
restSepaMandateMockMvc.perform(post("/api/sepa-mandates")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO)))
.andExpect(status().isBadRequest());
// Validate the SepaMandate in the database
List<SepaMandate> sepaMandateList = sepaMandateRepository.findAll();
assertThat(sepaMandateList).hasSize(databaseSizeBeforeCreate);
}
@Test
@Transactional
public void checkReferenceIsRequired() throws Exception {
int databaseSizeBeforeTest = sepaMandateRepository.findAll().size();
// set the field null
sepaMandate.setReference(null);
// Create the SepaMandate, which fails.
SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate);
restSepaMandateMockMvc.perform(post("/api/sepa-mandates")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO)))
.andExpect(status().isBadRequest());
List<SepaMandate> sepaMandateList = sepaMandateRepository.findAll();
assertThat(sepaMandateList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkDocumentDateIsRequired() throws Exception {
int databaseSizeBeforeTest = sepaMandateRepository.findAll().size();
// set the field null
sepaMandate.setDocumentDate(null);
// Create the SepaMandate, which fails.
SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate);
restSepaMandateMockMvc.perform(post("/api/sepa-mandates")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO)))
.andExpect(status().isBadRequest());
List<SepaMandate> sepaMandateList = sepaMandateRepository.findAll();
assertThat(sepaMandateList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkValidFromIsRequired() throws Exception {
int databaseSizeBeforeTest = sepaMandateRepository.findAll().size();
// set the field null
sepaMandate.setValidFrom(null);
// Create the SepaMandate, which fails.
SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate);
restSepaMandateMockMvc.perform(post("/api/sepa-mandates")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO)))
.andExpect(status().isBadRequest());
List<SepaMandate> sepaMandateList = sepaMandateRepository.findAll();
assertThat(sepaMandateList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void getAllSepaMandates() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList
restSepaMandateMockMvc.perform(get("/api/sepa-mandates?sort=id,desc"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(sepaMandate.getId().intValue())))
.andExpect(jsonPath("$.[*].reference").value(hasItem(DEFAULT_REFERENCE.toString())))
.andExpect(jsonPath("$.[*].iban").value(hasItem(DEFAULT_IBAN.toString())))
.andExpect(jsonPath("$.[*].bic").value(hasItem(DEFAULT_BIC.toString())))
.andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].validFrom").value(hasItem(DEFAULT_VALID_FROM.toString())))
.andExpect(jsonPath("$.[*].validUntil").value(hasItem(DEFAULT_VALID_UNTIL.toString())))
.andExpect(jsonPath("$.[*].lastUsed").value(hasItem(DEFAULT_LAST_USED.toString())))
.andExpect(jsonPath("$.[*].cancellationDate").value(hasItem(DEFAULT_CANCELLATION_DATE.toString())))
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString())));
}
@Test
@Transactional
public void getSepaMandate() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get the sepaMandate
restSepaMandateMockMvc.perform(get("/api/sepa-mandates/{id}", sepaMandate.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.id").value(sepaMandate.getId().intValue()))
.andExpect(jsonPath("$.reference").value(DEFAULT_REFERENCE.toString()))
.andExpect(jsonPath("$.iban").value(DEFAULT_IBAN.toString()))
.andExpect(jsonPath("$.bic").value(DEFAULT_BIC.toString()))
.andExpect(jsonPath("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString()))
.andExpect(jsonPath("$.validFrom").value(DEFAULT_VALID_FROM.toString()))
.andExpect(jsonPath("$.validUntil").value(DEFAULT_VALID_UNTIL.toString()))
.andExpect(jsonPath("$.lastUsed").value(DEFAULT_LAST_USED.toString()))
.andExpect(jsonPath("$.cancellationDate").value(DEFAULT_CANCELLATION_DATE.toString()))
.andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString()));
}
@Test
@Transactional
public void getAllSepaMandatesByReferenceIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where reference equals to DEFAULT_REFERENCE
defaultSepaMandateShouldBeFound("reference.equals=" + DEFAULT_REFERENCE);
// Get all the sepaMandateList where reference equals to UPDATED_REFERENCE
defaultSepaMandateShouldNotBeFound("reference.equals=" + UPDATED_REFERENCE);
}
@Test
@Transactional
public void getAllSepaMandatesByReferenceIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where reference in DEFAULT_REFERENCE or UPDATED_REFERENCE
defaultSepaMandateShouldBeFound("reference.in=" + DEFAULT_REFERENCE + "," + UPDATED_REFERENCE);
// Get all the sepaMandateList where reference equals to UPDATED_REFERENCE
defaultSepaMandateShouldNotBeFound("reference.in=" + UPDATED_REFERENCE);
}
@Test
@Transactional
public void getAllSepaMandatesByReferenceIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where reference is not null
defaultSepaMandateShouldBeFound("reference.specified=true");
// Get all the sepaMandateList where reference is null
defaultSepaMandateShouldNotBeFound("reference.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByIbanIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where iban equals to DEFAULT_IBAN
defaultSepaMandateShouldBeFound("iban.equals=" + DEFAULT_IBAN);
// Get all the sepaMandateList where iban equals to UPDATED_IBAN
defaultSepaMandateShouldNotBeFound("iban.equals=" + UPDATED_IBAN);
}
@Test
@Transactional
public void getAllSepaMandatesByIbanIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where iban in DEFAULT_IBAN or UPDATED_IBAN
defaultSepaMandateShouldBeFound("iban.in=" + DEFAULT_IBAN + "," + UPDATED_IBAN);
// Get all the sepaMandateList where iban equals to UPDATED_IBAN
defaultSepaMandateShouldNotBeFound("iban.in=" + UPDATED_IBAN);
}
@Test
@Transactional
public void getAllSepaMandatesByIbanIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where iban is not null
defaultSepaMandateShouldBeFound("iban.specified=true");
// Get all the sepaMandateList where iban is null
defaultSepaMandateShouldNotBeFound("iban.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByBicIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where bic equals to DEFAULT_BIC
defaultSepaMandateShouldBeFound("bic.equals=" + DEFAULT_BIC);
// Get all the sepaMandateList where bic equals to UPDATED_BIC
defaultSepaMandateShouldNotBeFound("bic.equals=" + UPDATED_BIC);
}
@Test
@Transactional
public void getAllSepaMandatesByBicIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where bic in DEFAULT_BIC or UPDATED_BIC
defaultSepaMandateShouldBeFound("bic.in=" + DEFAULT_BIC + "," + UPDATED_BIC);
// Get all the sepaMandateList where bic equals to UPDATED_BIC
defaultSepaMandateShouldNotBeFound("bic.in=" + UPDATED_BIC);
}
@Test
@Transactional
public void getAllSepaMandatesByBicIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where bic is not null
defaultSepaMandateShouldBeFound("bic.specified=true");
// Get all the sepaMandateList where bic is null
defaultSepaMandateShouldNotBeFound("bic.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByDocumentDateIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where documentDate equals to DEFAULT_DOCUMENT_DATE
defaultSepaMandateShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE);
// Get all the sepaMandateList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultSepaMandateShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByDocumentDateIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE
defaultSepaMandateShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE);
// Get all the sepaMandateList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultSepaMandateShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByDocumentDateIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where documentDate is not null
defaultSepaMandateShouldBeFound("documentDate.specified=true");
// Get all the sepaMandateList where documentDate is null
defaultSepaMandateShouldNotBeFound("documentDate.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE
defaultSepaMandateShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the sepaMandateList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE
defaultSepaMandateShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByDocumentDateIsLessThanSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE
defaultSepaMandateShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the sepaMandateList where documentDate less than or equals to UPDATED_DOCUMENT_DATE
defaultSepaMandateShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByValidFromIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validFrom equals to DEFAULT_VALID_FROM
defaultSepaMandateShouldBeFound("validFrom.equals=" + DEFAULT_VALID_FROM);
// Get all the sepaMandateList where validFrom equals to UPDATED_VALID_FROM
defaultSepaMandateShouldNotBeFound("validFrom.equals=" + UPDATED_VALID_FROM);
}
@Test
@Transactional
public void getAllSepaMandatesByValidFromIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validFrom in DEFAULT_VALID_FROM or UPDATED_VALID_FROM
defaultSepaMandateShouldBeFound("validFrom.in=" + DEFAULT_VALID_FROM + "," + UPDATED_VALID_FROM);
// Get all the sepaMandateList where validFrom equals to UPDATED_VALID_FROM
defaultSepaMandateShouldNotBeFound("validFrom.in=" + UPDATED_VALID_FROM);
}
@Test
@Transactional
public void getAllSepaMandatesByValidFromIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validFrom is not null
defaultSepaMandateShouldBeFound("validFrom.specified=true");
// Get all the sepaMandateList where validFrom is null
defaultSepaMandateShouldNotBeFound("validFrom.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByValidFromIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validFrom greater than or equals to DEFAULT_VALID_FROM
defaultSepaMandateShouldBeFound("validFrom.greaterOrEqualThan=" + DEFAULT_VALID_FROM);
// Get all the sepaMandateList where validFrom greater than or equals to UPDATED_VALID_FROM
defaultSepaMandateShouldNotBeFound("validFrom.greaterOrEqualThan=" + UPDATED_VALID_FROM);
}
@Test
@Transactional
public void getAllSepaMandatesByValidFromIsLessThanSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validFrom less than or equals to DEFAULT_VALID_FROM
defaultSepaMandateShouldNotBeFound("validFrom.lessThan=" + DEFAULT_VALID_FROM);
// Get all the sepaMandateList where validFrom less than or equals to UPDATED_VALID_FROM
defaultSepaMandateShouldBeFound("validFrom.lessThan=" + UPDATED_VALID_FROM);
}
@Test
@Transactional
public void getAllSepaMandatesByValidUntilIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validUntil equals to DEFAULT_VALID_UNTIL
defaultSepaMandateShouldBeFound("validUntil.equals=" + DEFAULT_VALID_UNTIL);
// Get all the sepaMandateList where validUntil equals to UPDATED_VALID_UNTIL
defaultSepaMandateShouldNotBeFound("validUntil.equals=" + UPDATED_VALID_UNTIL);
}
@Test
@Transactional
public void getAllSepaMandatesByValidUntilIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validUntil in DEFAULT_VALID_UNTIL or UPDATED_VALID_UNTIL
defaultSepaMandateShouldBeFound("validUntil.in=" + DEFAULT_VALID_UNTIL + "," + UPDATED_VALID_UNTIL);
// Get all the sepaMandateList where validUntil equals to UPDATED_VALID_UNTIL
defaultSepaMandateShouldNotBeFound("validUntil.in=" + UPDATED_VALID_UNTIL);
}
@Test
@Transactional
public void getAllSepaMandatesByValidUntilIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validUntil is not null
defaultSepaMandateShouldBeFound("validUntil.specified=true");
// Get all the sepaMandateList where validUntil is null
defaultSepaMandateShouldNotBeFound("validUntil.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByValidUntilIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validUntil greater than or equals to DEFAULT_VALID_UNTIL
defaultSepaMandateShouldBeFound("validUntil.greaterOrEqualThan=" + DEFAULT_VALID_UNTIL);
// Get all the sepaMandateList where validUntil greater than or equals to UPDATED_VALID_UNTIL
defaultSepaMandateShouldNotBeFound("validUntil.greaterOrEqualThan=" + UPDATED_VALID_UNTIL);
}
@Test
@Transactional
public void getAllSepaMandatesByValidUntilIsLessThanSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validUntil less than or equals to DEFAULT_VALID_UNTIL
defaultSepaMandateShouldNotBeFound("validUntil.lessThan=" + DEFAULT_VALID_UNTIL);
// Get all the sepaMandateList where validUntil less than or equals to UPDATED_VALID_UNTIL
defaultSepaMandateShouldBeFound("validUntil.lessThan=" + UPDATED_VALID_UNTIL);
}
@Test
@Transactional
public void getAllSepaMandatesByLastUsedIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where lastUsed equals to DEFAULT_LAST_USED
defaultSepaMandateShouldBeFound("lastUsed.equals=" + DEFAULT_LAST_USED);
// Get all the sepaMandateList where lastUsed equals to UPDATED_LAST_USED
defaultSepaMandateShouldNotBeFound("lastUsed.equals=" + UPDATED_LAST_USED);
}
@Test
@Transactional
public void getAllSepaMandatesByLastUsedIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where lastUsed in DEFAULT_LAST_USED or UPDATED_LAST_USED
defaultSepaMandateShouldBeFound("lastUsed.in=" + DEFAULT_LAST_USED + "," + UPDATED_LAST_USED);
// Get all the sepaMandateList where lastUsed equals to UPDATED_LAST_USED
defaultSepaMandateShouldNotBeFound("lastUsed.in=" + UPDATED_LAST_USED);
}
@Test
@Transactional
public void getAllSepaMandatesByLastUsedIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where lastUsed is not null
defaultSepaMandateShouldBeFound("lastUsed.specified=true");
// Get all the sepaMandateList where lastUsed is null
defaultSepaMandateShouldNotBeFound("lastUsed.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByLastUsedIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where lastUsed greater than or equals to DEFAULT_LAST_USED
defaultSepaMandateShouldBeFound("lastUsed.greaterOrEqualThan=" + DEFAULT_LAST_USED);
// Get all the sepaMandateList where lastUsed greater than or equals to UPDATED_LAST_USED
defaultSepaMandateShouldNotBeFound("lastUsed.greaterOrEqualThan=" + UPDATED_LAST_USED);
}
@Test
@Transactional
public void getAllSepaMandatesByLastUsedIsLessThanSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where lastUsed less than or equals to DEFAULT_LAST_USED
defaultSepaMandateShouldNotBeFound("lastUsed.lessThan=" + DEFAULT_LAST_USED);
// Get all the sepaMandateList where lastUsed less than or equals to UPDATED_LAST_USED
defaultSepaMandateShouldBeFound("lastUsed.lessThan=" + UPDATED_LAST_USED);
}
@Test
@Transactional
public void getAllSepaMandatesByCancellationDateIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where cancellationDate equals to DEFAULT_CANCELLATION_DATE
defaultSepaMandateShouldBeFound("cancellationDate.equals=" + DEFAULT_CANCELLATION_DATE);
// Get all the sepaMandateList where cancellationDate equals to UPDATED_CANCELLATION_DATE
defaultSepaMandateShouldNotBeFound("cancellationDate.equals=" + UPDATED_CANCELLATION_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByCancellationDateIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where cancellationDate in DEFAULT_CANCELLATION_DATE or UPDATED_CANCELLATION_DATE
defaultSepaMandateShouldBeFound("cancellationDate.in=" + DEFAULT_CANCELLATION_DATE + "," + UPDATED_CANCELLATION_DATE);
// Get all the sepaMandateList where cancellationDate equals to UPDATED_CANCELLATION_DATE
defaultSepaMandateShouldNotBeFound("cancellationDate.in=" + UPDATED_CANCELLATION_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByCancellationDateIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where cancellationDate is not null
defaultSepaMandateShouldBeFound("cancellationDate.specified=true");
// Get all the sepaMandateList where cancellationDate is null
defaultSepaMandateShouldNotBeFound("cancellationDate.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByCancellationDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where cancellationDate greater than or equals to DEFAULT_CANCELLATION_DATE
defaultSepaMandateShouldBeFound("cancellationDate.greaterOrEqualThan=" + DEFAULT_CANCELLATION_DATE);
// Get all the sepaMandateList where cancellationDate greater than or equals to UPDATED_CANCELLATION_DATE
defaultSepaMandateShouldNotBeFound("cancellationDate.greaterOrEqualThan=" + UPDATED_CANCELLATION_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByCancellationDateIsLessThanSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where cancellationDate less than or equals to DEFAULT_CANCELLATION_DATE
defaultSepaMandateShouldNotBeFound("cancellationDate.lessThan=" + DEFAULT_CANCELLATION_DATE);
// Get all the sepaMandateList where cancellationDate less than or equals to UPDATED_CANCELLATION_DATE
defaultSepaMandateShouldBeFound("cancellationDate.lessThan=" + UPDATED_CANCELLATION_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByRemarkIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where remark equals to DEFAULT_REMARK
defaultSepaMandateShouldBeFound("remark.equals=" + DEFAULT_REMARK);
// Get all the sepaMandateList where remark equals to UPDATED_REMARK
defaultSepaMandateShouldNotBeFound("remark.equals=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllSepaMandatesByRemarkIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where remark in DEFAULT_REMARK or UPDATED_REMARK
defaultSepaMandateShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK);
// Get all the sepaMandateList where remark equals to UPDATED_REMARK
defaultSepaMandateShouldNotBeFound("remark.in=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllSepaMandatesByRemarkIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where remark is not null
defaultSepaMandateShouldBeFound("remark.specified=true");
// Get all the sepaMandateList where remark is null
defaultSepaMandateShouldNotBeFound("remark.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByCustomerIsEqualToSomething() throws Exception {
// Initialize the database
Customer customer = CustomerResourceIntTest.createEntity(em);
em.persist(customer);
em.flush();
sepaMandate.setCustomer(customer);
sepaMandateRepository.saveAndFlush(sepaMandate);
Long customerId = customer.getId();
// Get all the sepaMandateList where customer equals to customerId
defaultSepaMandateShouldBeFound("customerId.equals=" + customerId);
// Get all the sepaMandateList where customer equals to customerId + 1
defaultSepaMandateShouldNotBeFound("customerId.equals=" + (customerId + 1));
}
/**
* Executes the search, and checks that the default entity is returned
*/
private void defaultSepaMandateShouldBeFound(String filter) throws Exception {
restSepaMandateMockMvc.perform(get("/api/sepa-mandates?sort=id,desc&" + filter))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(sepaMandate.getId().intValue())))
.andExpect(jsonPath("$.[*].reference").value(hasItem(DEFAULT_REFERENCE)))
.andExpect(jsonPath("$.[*].iban").value(hasItem(DEFAULT_IBAN)))
.andExpect(jsonPath("$.[*].bic").value(hasItem(DEFAULT_BIC)))
.andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].validFrom").value(hasItem(DEFAULT_VALID_FROM.toString())))
.andExpect(jsonPath("$.[*].validUntil").value(hasItem(DEFAULT_VALID_UNTIL.toString())))
.andExpect(jsonPath("$.[*].lastUsed").value(hasItem(DEFAULT_LAST_USED.toString())))
.andExpect(jsonPath("$.[*].cancellationDate").value(hasItem(DEFAULT_CANCELLATION_DATE.toString())))
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK)));
// Check, that the count call also returns 1
restSepaMandateMockMvc.perform(get("/api/sepa-mandates/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 defaultSepaMandateShouldNotBeFound(String filter) throws Exception {
restSepaMandateMockMvc.perform(get("/api/sepa-mandates?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
restSepaMandateMockMvc.perform(get("/api/sepa-mandates/count?sort=id,desc&" + filter))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().string("0"));
}
@Test
@Transactional
public void getNonExistingSepaMandate() throws Exception {
// Get the sepaMandate
restSepaMandateMockMvc.perform(get("/api/sepa-mandates/{id}", Long.MAX_VALUE))
.andExpect(status().isNotFound());
}
@Test
@Transactional
public void updateSepaMandate() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
int databaseSizeBeforeUpdate = sepaMandateRepository.findAll().size();
// Update the sepaMandate
SepaMandate updatedSepaMandate = sepaMandateRepository.findById(sepaMandate.getId()).get();
// Disconnect from session so that the updates on updatedSepaMandate are not directly saved in db
em.detach(updatedSepaMandate);
updatedSepaMandate
.reference(UPDATED_REFERENCE)
.iban(UPDATED_IBAN)
.bic(UPDATED_BIC)
.documentDate(UPDATED_DOCUMENT_DATE)
.validFrom(UPDATED_VALID_FROM)
.validUntil(UPDATED_VALID_UNTIL)
.lastUsed(UPDATED_LAST_USED)
.cancellationDate(UPDATED_CANCELLATION_DATE)
.remark(UPDATED_REMARK);
SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(updatedSepaMandate);
restSepaMandateMockMvc.perform(put("/api/sepa-mandates")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO)))
.andExpect(status().isOk());
// Validate the SepaMandate in the database
List<SepaMandate> sepaMandateList = sepaMandateRepository.findAll();
assertThat(sepaMandateList).hasSize(databaseSizeBeforeUpdate);
SepaMandate testSepaMandate = sepaMandateList.get(sepaMandateList.size() - 1);
assertThat(testSepaMandate.getReference()).isEqualTo(UPDATED_REFERENCE);
assertThat(testSepaMandate.getIban()).isEqualTo(UPDATED_IBAN);
assertThat(testSepaMandate.getBic()).isEqualTo(UPDATED_BIC);
assertThat(testSepaMandate.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE);
assertThat(testSepaMandate.getValidFrom()).isEqualTo(UPDATED_VALID_FROM);
assertThat(testSepaMandate.getValidUntil()).isEqualTo(UPDATED_VALID_UNTIL);
assertThat(testSepaMandate.getLastUsed()).isEqualTo(UPDATED_LAST_USED);
assertThat(testSepaMandate.getCancellationDate()).isEqualTo(UPDATED_CANCELLATION_DATE);
assertThat(testSepaMandate.getRemark()).isEqualTo(UPDATED_REMARK);
}
@Test
@Transactional
public void updateNonExistingSepaMandate() throws Exception {
int databaseSizeBeforeUpdate = sepaMandateRepository.findAll().size();
// Create the SepaMandate
SepaMandateDTO sepaMandateDTO = sepaMandateMapper.toDto(sepaMandate);
// If the entity doesn't have an ID, it will throw BadRequestAlertException
restSepaMandateMockMvc.perform(put("/api/sepa-mandates")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(sepaMandateDTO)))
.andExpect(status().isBadRequest());
// Validate the SepaMandate in the database
List<SepaMandate> sepaMandateList = sepaMandateRepository.findAll();
assertThat(sepaMandateList).hasSize(databaseSizeBeforeUpdate);
}
@Test
@Transactional
public void deleteSepaMandate() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
int databaseSizeBeforeDelete = sepaMandateRepository.findAll().size();
// Delete the sepaMandate
restSepaMandateMockMvc.perform(delete("/api/sepa-mandates/{id}", sepaMandate.getId())
.accept(TestUtil.APPLICATION_JSON_UTF8))
.andExpect(status().isOk());
// Validate the database is empty
List<SepaMandate> sepaMandateList = sepaMandateRepository.findAll();
assertThat(sepaMandateList).hasSize(databaseSizeBeforeDelete - 1);
}
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(SepaMandate.class);
SepaMandate sepaMandate1 = new SepaMandate();
sepaMandate1.setId(1L);
SepaMandate sepaMandate2 = new SepaMandate();
sepaMandate2.setId(sepaMandate1.getId());
assertThat(sepaMandate1).isEqualTo(sepaMandate2);
sepaMandate2.setId(2L);
assertThat(sepaMandate1).isNotEqualTo(sepaMandate2);
sepaMandate1.setId(null);
assertThat(sepaMandate1).isNotEqualTo(sepaMandate2);
}
@Test
@Transactional
public void dtoEqualsVerifier() throws Exception {
TestUtil.equalsVerifier(SepaMandateDTO.class);
SepaMandateDTO sepaMandateDTO1 = new SepaMandateDTO();
sepaMandateDTO1.setId(1L);
SepaMandateDTO sepaMandateDTO2 = new SepaMandateDTO();
assertThat(sepaMandateDTO1).isNotEqualTo(sepaMandateDTO2);
sepaMandateDTO2.setId(sepaMandateDTO1.getId());
assertThat(sepaMandateDTO1).isEqualTo(sepaMandateDTO2);
sepaMandateDTO2.setId(2L);
assertThat(sepaMandateDTO1).isNotEqualTo(sepaMandateDTO2);
sepaMandateDTO1.setId(null);
assertThat(sepaMandateDTO1).isNotEqualTo(sepaMandateDTO2);
}
@Test
@Transactional
public void testEntityFromId() {
assertThat(sepaMandateMapper.fromId(42L).getId()).isEqualTo(42);
assertThat(sepaMandateMapper.fromId(null)).isNull();
}
}

View File

@@ -0,0 +1,742 @@
package org.hostsharing.hsadminng.web.rest;
import org.hostsharing.hsadminng.HsadminNgApp;
import org.hostsharing.hsadminng.domain.Share;
import org.hostsharing.hsadminng.domain.Membership;
import org.hostsharing.hsadminng.repository.ShareRepository;
import org.hostsharing.hsadminng.service.ShareService;
import org.hostsharing.hsadminng.service.dto.ShareDTO;
import org.hostsharing.hsadminng.service.mapper.ShareMapper;
import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator;
import org.hostsharing.hsadminng.service.dto.ShareCriteria;
import org.hostsharing.hsadminng.service.ShareQueryService;
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.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.LocalDate;
import java.time.ZoneId;
import java.util.List;
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
/**
* Test class for the ShareResource REST controller.
*
* @see ShareResource
*/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = HsadminNgApp.class)
public class ShareResourceIntTest {
private static final LocalDate DEFAULT_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_VALUE_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_VALUE_DATE = LocalDate.now(ZoneId.systemDefault());
private static final ShareAction DEFAULT_ACTION = ShareAction.SUBSCRIPTION;
private static final ShareAction UPDATED_ACTION = ShareAction.CANCELLATION;
private static final Integer DEFAULT_QUANTITY = 1;
private static final Integer UPDATED_QUANTITY = 2;
private static final String DEFAULT_REMARK = "AAAAAAAAAA";
private static final String UPDATED_REMARK = "BBBBBBBBBB";
@Autowired
private ShareRepository shareRepository;
@Autowired
private ShareMapper shareMapper;
@Autowired
private ShareService shareService;
@Autowired
private ShareQueryService shareQueryService;
@Autowired
private MappingJackson2HttpMessageConverter jacksonMessageConverter;
@Autowired
private PageableHandlerMethodArgumentResolver pageableArgumentResolver;
@Autowired
private ExceptionTranslator exceptionTranslator;
@Autowired
private EntityManager em;
@Autowired
private Validator validator;
private MockMvc restShareMockMvc;
private Share share;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
final ShareResource shareResource = new ShareResource(shareService, shareQueryService);
this.restShareMockMvc = MockMvcBuilders.standaloneSetup(shareResource)
.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 Share createEntity(EntityManager em) {
Share share = new Share()
.documentDate(DEFAULT_DOCUMENT_DATE)
.valueDate(DEFAULT_VALUE_DATE)
.action(DEFAULT_ACTION)
.quantity(DEFAULT_QUANTITY)
.remark(DEFAULT_REMARK);
// Add required entity
Membership membership = MembershipResourceIntTest.createEntity(em);
em.persist(membership);
em.flush();
share.setMembership(membership);
return share;
}
@Before
public void initTest() {
share = createEntity(em);
}
@Test
@Transactional
public void createShare() throws Exception {
int databaseSizeBeforeCreate = shareRepository.findAll().size();
// Create the Share
ShareDTO shareDTO = shareMapper.toDto(share);
restShareMockMvc.perform(post("/api/shares")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(shareDTO)))
.andExpect(status().isCreated());
// Validate the Share in the database
List<Share> shareList = shareRepository.findAll();
assertThat(shareList).hasSize(databaseSizeBeforeCreate + 1);
Share testShare = shareList.get(shareList.size() - 1);
assertThat(testShare.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE);
assertThat(testShare.getValueDate()).isEqualTo(DEFAULT_VALUE_DATE);
assertThat(testShare.getAction()).isEqualTo(DEFAULT_ACTION);
assertThat(testShare.getQuantity()).isEqualTo(DEFAULT_QUANTITY);
assertThat(testShare.getRemark()).isEqualTo(DEFAULT_REMARK);
}
@Test
@Transactional
public void createShareWithExistingId() throws Exception {
int databaseSizeBeforeCreate = shareRepository.findAll().size();
// Create the Share with an existing ID
share.setId(1L);
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> shareList = shareRepository.findAll();
assertThat(shareList).hasSize(databaseSizeBeforeCreate);
}
@Test
@Transactional
public void checkDocumentDateIsRequired() throws Exception {
int databaseSizeBeforeTest = shareRepository.findAll().size();
// set the field null
share.setDocumentDate(null);
// Create the Share, which fails.
ShareDTO shareDTO = shareMapper.toDto(share);
restShareMockMvc.perform(post("/api/shares")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(shareDTO)))
.andExpect(status().isBadRequest());
List<Share> shareList = shareRepository.findAll();
assertThat(shareList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkValueDateIsRequired() throws Exception {
int databaseSizeBeforeTest = shareRepository.findAll().size();
// set the field null
share.setValueDate(null);
// Create the Share, which fails.
ShareDTO shareDTO = shareMapper.toDto(share);
restShareMockMvc.perform(post("/api/shares")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(shareDTO)))
.andExpect(status().isBadRequest());
List<Share> shareList = shareRepository.findAll();
assertThat(shareList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkActionIsRequired() throws Exception {
int databaseSizeBeforeTest = shareRepository.findAll().size();
// set the field null
share.setAction(null);
// Create the Share, which fails.
ShareDTO shareDTO = shareMapper.toDto(share);
restShareMockMvc.perform(post("/api/shares")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(shareDTO)))
.andExpect(status().isBadRequest());
List<Share> shareList = shareRepository.findAll();
assertThat(shareList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkQuantityIsRequired() throws Exception {
int databaseSizeBeforeTest = shareRepository.findAll().size();
// set the field null
share.setQuantity(null);
// Create the Share, which fails.
ShareDTO shareDTO = shareMapper.toDto(share);
restShareMockMvc.perform(post("/api/shares")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(shareDTO)))
.andExpect(status().isBadRequest());
List<Share> shareList = shareRepository.findAll();
assertThat(shareList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void getAllShares() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList
restShareMockMvc.perform(get("/api/shares?sort=id,desc"))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(share.getId().intValue())))
.andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].valueDate").value(hasItem(DEFAULT_VALUE_DATE.toString())))
.andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString())))
.andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY)))
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString())));
}
@Test
@Transactional
public void getShare() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get the share
restShareMockMvc.perform(get("/api/shares/{id}", share.getId()))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.id").value(share.getId().intValue()))
.andExpect(jsonPath("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString()))
.andExpect(jsonPath("$.valueDate").value(DEFAULT_VALUE_DATE.toString()))
.andExpect(jsonPath("$.action").value(DEFAULT_ACTION.toString()))
.andExpect(jsonPath("$.quantity").value(DEFAULT_QUANTITY))
.andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString()));
}
@Test
@Transactional
public void getAllSharesByDocumentDateIsEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where documentDate equals to DEFAULT_DOCUMENT_DATE
defaultShareShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE);
// Get all the shareList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultShareShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSharesByDocumentDateIsInShouldWork() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE
defaultShareShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE);
// Get all the shareList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultShareShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSharesByDocumentDateIsNullOrNotNull() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where documentDate is not null
defaultShareShouldBeFound("documentDate.specified=true");
// Get all the shareList where documentDate is null
defaultShareShouldNotBeFound("documentDate.specified=false");
}
@Test
@Transactional
public void getAllSharesByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE
defaultShareShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the shareList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE
defaultShareShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSharesByDocumentDateIsLessThanSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE
defaultShareShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the shareList where documentDate less than or equals to UPDATED_DOCUMENT_DATE
defaultShareShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSharesByValueDateIsEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where valueDate equals to DEFAULT_VALUE_DATE
defaultShareShouldBeFound("valueDate.equals=" + DEFAULT_VALUE_DATE);
// Get all the shareList where valueDate equals to UPDATED_VALUE_DATE
defaultShareShouldNotBeFound("valueDate.equals=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllSharesByValueDateIsInShouldWork() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where valueDate in DEFAULT_VALUE_DATE or UPDATED_VALUE_DATE
defaultShareShouldBeFound("valueDate.in=" + DEFAULT_VALUE_DATE + "," + UPDATED_VALUE_DATE);
// Get all the shareList where valueDate equals to UPDATED_VALUE_DATE
defaultShareShouldNotBeFound("valueDate.in=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllSharesByValueDateIsNullOrNotNull() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where valueDate is not null
defaultShareShouldBeFound("valueDate.specified=true");
// Get all the shareList where valueDate is null
defaultShareShouldNotBeFound("valueDate.specified=false");
}
@Test
@Transactional
public void getAllSharesByValueDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where valueDate greater than or equals to DEFAULT_VALUE_DATE
defaultShareShouldBeFound("valueDate.greaterOrEqualThan=" + DEFAULT_VALUE_DATE);
// Get all the shareList where valueDate greater than or equals to UPDATED_VALUE_DATE
defaultShareShouldNotBeFound("valueDate.greaterOrEqualThan=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllSharesByValueDateIsLessThanSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where valueDate less than or equals to DEFAULT_VALUE_DATE
defaultShareShouldNotBeFound("valueDate.lessThan=" + DEFAULT_VALUE_DATE);
// Get all the shareList where valueDate less than or equals to UPDATED_VALUE_DATE
defaultShareShouldBeFound("valueDate.lessThan=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllSharesByActionIsEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where action equals to DEFAULT_ACTION
defaultShareShouldBeFound("action.equals=" + DEFAULT_ACTION);
// Get all the shareList where action equals to UPDATED_ACTION
defaultShareShouldNotBeFound("action.equals=" + UPDATED_ACTION);
}
@Test
@Transactional
public void getAllSharesByActionIsInShouldWork() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where action in DEFAULT_ACTION or UPDATED_ACTION
defaultShareShouldBeFound("action.in=" + DEFAULT_ACTION + "," + UPDATED_ACTION);
// Get all the shareList where action equals to UPDATED_ACTION
defaultShareShouldNotBeFound("action.in=" + UPDATED_ACTION);
}
@Test
@Transactional
public void getAllSharesByActionIsNullOrNotNull() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where action is not null
defaultShareShouldBeFound("action.specified=true");
// Get all the shareList where action is null
defaultShareShouldNotBeFound("action.specified=false");
}
@Test
@Transactional
public void getAllSharesByQuantityIsEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where quantity equals to DEFAULT_QUANTITY
defaultShareShouldBeFound("quantity.equals=" + DEFAULT_QUANTITY);
// Get all the shareList where quantity equals to UPDATED_QUANTITY
defaultShareShouldNotBeFound("quantity.equals=" + UPDATED_QUANTITY);
}
@Test
@Transactional
public void getAllSharesByQuantityIsInShouldWork() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where quantity in DEFAULT_QUANTITY or UPDATED_QUANTITY
defaultShareShouldBeFound("quantity.in=" + DEFAULT_QUANTITY + "," + UPDATED_QUANTITY);
// Get all the shareList where quantity equals to UPDATED_QUANTITY
defaultShareShouldNotBeFound("quantity.in=" + UPDATED_QUANTITY);
}
@Test
@Transactional
public void getAllSharesByQuantityIsNullOrNotNull() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where quantity is not null
defaultShareShouldBeFound("quantity.specified=true");
// Get all the shareList where quantity is null
defaultShareShouldNotBeFound("quantity.specified=false");
}
@Test
@Transactional
public void getAllSharesByQuantityIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where quantity greater than or equals to DEFAULT_QUANTITY
defaultShareShouldBeFound("quantity.greaterOrEqualThan=" + DEFAULT_QUANTITY);
// Get all the shareList where quantity greater than or equals to UPDATED_QUANTITY
defaultShareShouldNotBeFound("quantity.greaterOrEqualThan=" + UPDATED_QUANTITY);
}
@Test
@Transactional
public void getAllSharesByQuantityIsLessThanSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where quantity less than or equals to DEFAULT_QUANTITY
defaultShareShouldNotBeFound("quantity.lessThan=" + DEFAULT_QUANTITY);
// Get all the shareList where quantity less than or equals to UPDATED_QUANTITY
defaultShareShouldBeFound("quantity.lessThan=" + UPDATED_QUANTITY);
}
@Test
@Transactional
public void getAllSharesByRemarkIsEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where remark equals to DEFAULT_REMARK
defaultShareShouldBeFound("remark.equals=" + DEFAULT_REMARK);
// Get all the shareList where remark equals to UPDATED_REMARK
defaultShareShouldNotBeFound("remark.equals=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllSharesByRemarkIsInShouldWork() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where remark in DEFAULT_REMARK or UPDATED_REMARK
defaultShareShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK);
// Get all the shareList where remark equals to UPDATED_REMARK
defaultShareShouldNotBeFound("remark.in=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllSharesByRemarkIsNullOrNotNull() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where remark is not null
defaultShareShouldBeFound("remark.specified=true");
// Get all the shareList where remark is null
defaultShareShouldNotBeFound("remark.specified=false");
}
@Test
@Transactional
public void getAllSharesByMembershipIsEqualToSomething() throws Exception {
// Initialize the database
Membership membership = MembershipResourceIntTest.createEntity(em);
em.persist(membership);
em.flush();
share.setMembership(membership);
shareRepository.saveAndFlush(share);
Long membershipId = membership.getId();
// Get all the shareList where membership equals to membershipId
defaultShareShouldBeFound("membershipId.equals=" + membershipId);
// Get all the shareList where membership equals to membershipId + 1
defaultShareShouldNotBeFound("membershipId.equals=" + (membershipId + 1));
}
/**
* Executes the search, and checks that the default entity is returned
*/
private void defaultShareShouldBeFound(String filter) throws Exception {
restShareMockMvc.perform(get("/api/shares?sort=id,desc&" + filter))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(jsonPath("$.[*].id").value(hasItem(share.getId().intValue())))
.andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].valueDate").value(hasItem(DEFAULT_VALUE_DATE.toString())))
.andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString())))
.andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY)))
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK)));
// Check, that the count call also returns 1
restShareMockMvc.perform(get("/api/shares/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 defaultShareShouldNotBeFound(String filter) throws Exception {
restShareMockMvc.perform(get("/api/shares?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
restShareMockMvc.perform(get("/api/shares/count?sort=id,desc&" + filter))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
.andExpect(content().string("0"));
}
@Test
@Transactional
public void getNonExistingShare() throws Exception {
// Get the share
restShareMockMvc.perform(get("/api/shares/{id}", Long.MAX_VALUE))
.andExpect(status().isNotFound());
}
@Test
@Transactional
public void updateShare() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
int databaseSizeBeforeUpdate = shareRepository.findAll().size();
// Update the share
Share updatedShare = shareRepository.findById(share.getId()).get();
// Disconnect from session so that the updates on updatedShare are not directly saved in db
em.detach(updatedShare);
updatedShare
.documentDate(UPDATED_DOCUMENT_DATE)
.valueDate(UPDATED_VALUE_DATE)
.action(UPDATED_ACTION)
.quantity(UPDATED_QUANTITY)
.remark(UPDATED_REMARK);
ShareDTO shareDTO = shareMapper.toDto(updatedShare);
restShareMockMvc.perform(put("/api/shares")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(shareDTO)))
.andExpect(status().isOk());
// Validate the Share in the database
List<Share> shareList = shareRepository.findAll();
assertThat(shareList).hasSize(databaseSizeBeforeUpdate);
Share testShare = shareList.get(shareList.size() - 1);
assertThat(testShare.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE);
assertThat(testShare.getValueDate()).isEqualTo(UPDATED_VALUE_DATE);
assertThat(testShare.getAction()).isEqualTo(UPDATED_ACTION);
assertThat(testShare.getQuantity()).isEqualTo(UPDATED_QUANTITY);
assertThat(testShare.getRemark()).isEqualTo(UPDATED_REMARK);
}
@Test
@Transactional
public void updateNonExistingShare() throws Exception {
int databaseSizeBeforeUpdate = shareRepository.findAll().size();
// Create the Share
ShareDTO shareDTO = shareMapper.toDto(share);
// If the entity doesn't have an ID, it will throw BadRequestAlertException
restShareMockMvc.perform(put("/api/shares")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(shareDTO)))
.andExpect(status().isBadRequest());
// Validate the Share in the database
List<Share> shareList = shareRepository.findAll();
assertThat(shareList).hasSize(databaseSizeBeforeUpdate);
}
@Test
@Transactional
public void deleteShare() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
int databaseSizeBeforeDelete = shareRepository.findAll().size();
// Delete the share
restShareMockMvc.perform(delete("/api/shares/{id}", share.getId())
.accept(TestUtil.APPLICATION_JSON_UTF8))
.andExpect(status().isOk());
// Validate the database is empty
List<Share> shareList = shareRepository.findAll();
assertThat(shareList).hasSize(databaseSizeBeforeDelete - 1);
}
@Test
@Transactional
public void equalsVerifier() throws Exception {
TestUtil.equalsVerifier(Share.class);
Share share1 = new Share();
share1.setId(1L);
Share share2 = new Share();
share2.setId(share1.getId());
assertThat(share1).isEqualTo(share2);
share2.setId(2L);
assertThat(share1).isNotEqualTo(share2);
share1.setId(null);
assertThat(share1).isNotEqualTo(share2);
}
@Test
@Transactional
public void dtoEqualsVerifier() throws Exception {
TestUtil.equalsVerifier(ShareDTO.class);
ShareDTO shareDTO1 = new ShareDTO();
shareDTO1.setId(1L);
ShareDTO shareDTO2 = new ShareDTO();
assertThat(shareDTO1).isNotEqualTo(shareDTO2);
shareDTO2.setId(shareDTO1.getId());
assertThat(shareDTO1).isEqualTo(shareDTO2);
shareDTO2.setId(2L);
assertThat(shareDTO1).isNotEqualTo(shareDTO2);
shareDTO1.setId(null);
assertThat(shareDTO1).isNotEqualTo(shareDTO2);
}
@Test
@Transactional
public void testEntityFromId() {
assertThat(shareMapper.fromId(42L).getId()).isEqualTo(42);
assertThat(shareMapper.fromId(null)).isNull();
}
}

View File

@@ -0,0 +1,52 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, of } from 'rxjs';
import { JhiEventManager } from 'ng-jhipster';
import { HsadminNgTestModule } from '../../../test.module';
import { AssetDeleteDialogComponent } from 'app/entities/asset/asset-delete-dialog.component';
import { AssetService } from 'app/entities/asset/asset.service';
describe('Component Tests', () => {
describe('Asset Management Delete Component', () => {
let comp: AssetDeleteDialogComponent;
let fixture: ComponentFixture<AssetDeleteDialogComponent>;
let service: AssetService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [AssetDeleteDialogComponent]
})
.overrideTemplate(AssetDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(AssetDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(AssetService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete', inject(
[],
fakeAsync(() => {
// GIVEN
spyOn(service, 'delete').and.returnValue(of({}));
// WHEN
comp.confirmDelete(123);
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith(123);
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
})
));
});
});
});

View File

@@ -0,0 +1,40 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { AssetDetailComponent } from 'app/entities/asset/asset-detail.component';
import { Asset } from 'app/shared/model/asset.model';
describe('Component Tests', () => {
describe('Asset Management Detail Component', () => {
let comp: AssetDetailComponent;
let fixture: ComponentFixture<AssetDetailComponent>;
const route = ({ data: of({ asset: new Asset(123) }) } as any) as ActivatedRoute;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [AssetDetailComponent],
providers: [{ provide: ActivatedRoute, useValue: route }]
})
.overrideTemplate(AssetDetailComponent, '')
.compileComponents();
fixture = TestBed.createComponent(AssetDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
// WHEN
comp.ngOnInit();
// THEN
expect(comp.asset).toEqual(jasmine.objectContaining({ id: 123 }));
});
});
});
});

View File

@@ -0,0 +1,60 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { AssetUpdateComponent } from 'app/entities/asset/asset-update.component';
import { AssetService } from 'app/entities/asset/asset.service';
import { Asset } from 'app/shared/model/asset.model';
describe('Component Tests', () => {
describe('Asset Management Update Component', () => {
let comp: AssetUpdateComponent;
let fixture: ComponentFixture<AssetUpdateComponent>;
let service: AssetService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [AssetUpdateComponent]
})
.overrideTemplate(AssetUpdateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(AssetUpdateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(AssetService);
});
describe('save', () => {
it('Should call update service on save for existing entity', fakeAsync(() => {
// GIVEN
const entity = new Asset(123);
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
comp.asset = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
it('Should call create service on save for new entity', fakeAsync(() => {
// GIVEN
const entity = new Asset();
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
comp.asset = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
});
});
});

View File

@@ -0,0 +1,128 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Data } from '@angular/router';
import { HsadminNgTestModule } from '../../../test.module';
import { AssetComponent } from 'app/entities/asset/asset.component';
import { AssetService } from 'app/entities/asset/asset.service';
import { Asset } from 'app/shared/model/asset.model';
describe('Component Tests', () => {
describe('Asset Management Component', () => {
let comp: AssetComponent;
let fixture: ComponentFixture<AssetComponent>;
let service: AssetService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [AssetComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) =>
fn({
pagingParams: {
predicate: 'id',
reverse: false,
page: 0
}
})
}
}
}
]
})
.overrideTemplate(AssetComponent, '')
.compileComponents();
fixture = TestBed.createComponent(AssetComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(AssetService);
});
it('Should call load all on init', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Asset(123)],
headers
})
)
);
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.assets[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should load a page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Asset(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.assets[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should re-initialize the page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Asset(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
comp.reset();
// THEN
expect(comp.page).toEqual(0);
expect(service.query).toHaveBeenCalledTimes(2);
expect(comp.assets[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should calculate the sort attribute for an id', () => {
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['id,asc']);
});
it('should calculate the sort attribute for a non-id attribute', () => {
// GIVEN
comp.predicate = 'name';
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['name,asc', 'id']);
});
});
});

View File

@@ -0,0 +1,142 @@
/* tslint:disable max-line-length */
import { TestBed, getTestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { of } from 'rxjs';
import { take, map } from 'rxjs/operators';
import * as moment from 'moment';
import { DATE_FORMAT } from 'app/shared/constants/input.constants';
import { AssetService } from 'app/entities/asset/asset.service';
import { IAsset, Asset, AssetAction } from 'app/shared/model/asset.model';
describe('Service Tests', () => {
describe('Asset Service', () => {
let injector: TestBed;
let service: AssetService;
let httpMock: HttpTestingController;
let elemDefault: IAsset;
let currentDate: moment.Moment;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(AssetService);
httpMock = injector.get(HttpTestingController);
currentDate = moment();
elemDefault = new Asset(0, currentDate, currentDate, AssetAction.PAYMENT, 0, 'AAAAAAA');
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
service
.find(123)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify(returnedFromService));
});
it('should create a Asset', async () => {
const returnedFromService = Object.assign(
{
id: 0,
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
valueDate: currentDate
},
returnedFromService
);
service
.create(new Asset(null))
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'POST' });
req.flush(JSON.stringify(returnedFromService));
});
it('should update a Asset', async () => {
const returnedFromService = Object.assign(
{
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT),
action: 'BBBBBB',
amount: 1,
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
valueDate: currentDate
},
returnedFromService
);
service
.update(expected)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'PUT' });
req.flush(JSON.stringify(returnedFromService));
});
it('should return a list of Asset', async () => {
const returnedFromService = Object.assign(
{
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT),
action: 'BBBBBB',
amount: 1,
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
valueDate: currentDate
},
returnedFromService
);
service
.query(expected)
.pipe(
take(1),
map(resp => resp.body)
)
.subscribe(body => expect(body).toContainEqual(expected));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify([returnedFromService]));
httpMock.verify();
});
it('should delete a Asset', async () => {
const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
const req = httpMock.expectOne({ method: 'DELETE' });
req.flush({ status: 200 });
});
});
afterEach(() => {
httpMock.verify();
});
});
});

View File

@@ -0,0 +1,52 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, of } from 'rxjs';
import { JhiEventManager } from 'ng-jhipster';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerDeleteDialogComponent } from 'app/entities/customer/customer-delete-dialog.component';
import { CustomerService } from 'app/entities/customer/customer.service';
describe('Component Tests', () => {
describe('Customer Management Delete Component', () => {
let comp: CustomerDeleteDialogComponent;
let fixture: ComponentFixture<CustomerDeleteDialogComponent>;
let service: CustomerService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [CustomerDeleteDialogComponent]
})
.overrideTemplate(CustomerDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(CustomerDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(CustomerService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete', inject(
[],
fakeAsync(() => {
// GIVEN
spyOn(service, 'delete').and.returnValue(of({}));
// WHEN
comp.confirmDelete(123);
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith(123);
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
})
));
});
});
});

View File

@@ -0,0 +1,40 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerDetailComponent } from 'app/entities/customer/customer-detail.component';
import { Customer } from 'app/shared/model/customer.model';
describe('Component Tests', () => {
describe('Customer Management Detail Component', () => {
let comp: CustomerDetailComponent;
let fixture: ComponentFixture<CustomerDetailComponent>;
const route = ({ data: of({ customer: new Customer(123) }) } as any) as ActivatedRoute;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [CustomerDetailComponent],
providers: [{ provide: ActivatedRoute, useValue: route }]
})
.overrideTemplate(CustomerDetailComponent, '')
.compileComponents();
fixture = TestBed.createComponent(CustomerDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
// WHEN
comp.ngOnInit();
// THEN
expect(comp.customer).toEqual(jasmine.objectContaining({ id: 123 }));
});
});
});
});

View File

@@ -0,0 +1,60 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerUpdateComponent } from 'app/entities/customer/customer-update.component';
import { CustomerService } from 'app/entities/customer/customer.service';
import { Customer } from 'app/shared/model/customer.model';
describe('Component Tests', () => {
describe('Customer Management Update Component', () => {
let comp: CustomerUpdateComponent;
let fixture: ComponentFixture<CustomerUpdateComponent>;
let service: CustomerService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [CustomerUpdateComponent]
})
.overrideTemplate(CustomerUpdateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(CustomerUpdateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(CustomerService);
});
describe('save', () => {
it('Should call update service on save for existing entity', fakeAsync(() => {
// GIVEN
const entity = new Customer(123);
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
comp.customer = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
it('Should call create service on save for new entity', fakeAsync(() => {
// GIVEN
const entity = new Customer();
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
comp.customer = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
});
});
});

View File

@@ -0,0 +1,128 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Data } from '@angular/router';
import { HsadminNgTestModule } from '../../../test.module';
import { CustomerComponent } from 'app/entities/customer/customer.component';
import { CustomerService } from 'app/entities/customer/customer.service';
import { Customer } from 'app/shared/model/customer.model';
describe('Component Tests', () => {
describe('Customer Management Component', () => {
let comp: CustomerComponent;
let fixture: ComponentFixture<CustomerComponent>;
let service: CustomerService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [CustomerComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) =>
fn({
pagingParams: {
predicate: 'id',
reverse: false,
page: 0
}
})
}
}
}
]
})
.overrideTemplate(CustomerComponent, '')
.compileComponents();
fixture = TestBed.createComponent(CustomerComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(CustomerService);
});
it('Should call load all on init', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Customer(123)],
headers
})
)
);
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.customers[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should load a page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Customer(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.customers[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should re-initialize the page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Customer(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
comp.reset();
// THEN
expect(comp.page).toEqual(0);
expect(service.query).toHaveBeenCalledTimes(2);
expect(comp.customers[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should calculate the sort attribute for an id', () => {
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['id,asc']);
});
it('should calculate the sort attribute for a non-id attribute', () => {
// GIVEN
comp.predicate = 'name';
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['name,asc', 'id']);
});
});
});

View File

@@ -0,0 +1,118 @@
/* tslint:disable max-line-length */
import { TestBed, getTestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { of } from 'rxjs';
import { take, map } from 'rxjs/operators';
import { CustomerService } from 'app/entities/customer/customer.service';
import { ICustomer, Customer } from 'app/shared/model/customer.model';
describe('Service Tests', () => {
describe('Customer Service', () => {
let injector: TestBed;
let service: CustomerService;
let httpMock: HttpTestingController;
let elemDefault: ICustomer;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(CustomerService);
httpMock = injector.get(HttpTestingController);
elemDefault = new Customer(0, 0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA');
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign({}, elemDefault);
service
.find(123)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify(returnedFromService));
});
it('should create a Customer', async () => {
const returnedFromService = Object.assign(
{
id: 0
},
elemDefault
);
const expected = Object.assign({}, returnedFromService);
service
.create(new Customer(null))
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'POST' });
req.flush(JSON.stringify(returnedFromService));
});
it('should update a Customer', async () => {
const returnedFromService = Object.assign(
{
reference: 1,
prefix: 'BBBBBB',
name: 'BBBBBB',
contractualSalutation: 'BBBBBB',
contractualAddress: 'BBBBBB',
billingSalutation: 'BBBBBB',
billingAddress: 'BBBBBB',
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign({}, returnedFromService);
service
.update(expected)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'PUT' });
req.flush(JSON.stringify(returnedFromService));
});
it('should return a list of Customer', async () => {
const returnedFromService = Object.assign(
{
reference: 1,
prefix: 'BBBBBB',
name: 'BBBBBB',
contractualSalutation: 'BBBBBB',
contractualAddress: 'BBBBBB',
billingSalutation: 'BBBBBB',
billingAddress: 'BBBBBB',
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign({}, returnedFromService);
service
.query(expected)
.pipe(
take(1),
map(resp => resp.body)
)
.subscribe(body => expect(body).toContainEqual(expected));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify([returnedFromService]));
httpMock.verify();
});
it('should delete a Customer', async () => {
const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
const req = httpMock.expectOne({ method: 'DELETE' });
req.flush({ status: 200 });
});
});
afterEach(() => {
httpMock.verify();
});
});
});

View File

@@ -0,0 +1,52 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, of } from 'rxjs';
import { JhiEventManager } from 'ng-jhipster';
import { HsadminNgTestModule } from '../../../test.module';
import { MembershipDeleteDialogComponent } from 'app/entities/membership/membership-delete-dialog.component';
import { MembershipService } from 'app/entities/membership/membership.service';
describe('Component Tests', () => {
describe('Membership Management Delete Component', () => {
let comp: MembershipDeleteDialogComponent;
let fixture: ComponentFixture<MembershipDeleteDialogComponent>;
let service: MembershipService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [MembershipDeleteDialogComponent]
})
.overrideTemplate(MembershipDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(MembershipDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(MembershipService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete', inject(
[],
fakeAsync(() => {
// GIVEN
spyOn(service, 'delete').and.returnValue(of({}));
// WHEN
comp.confirmDelete(123);
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith(123);
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
})
));
});
});
});

View File

@@ -0,0 +1,40 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { MembershipDetailComponent } from 'app/entities/membership/membership-detail.component';
import { Membership } from 'app/shared/model/membership.model';
describe('Component Tests', () => {
describe('Membership Management Detail Component', () => {
let comp: MembershipDetailComponent;
let fixture: ComponentFixture<MembershipDetailComponent>;
const route = ({ data: of({ membership: new Membership(123) }) } as any) as ActivatedRoute;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [MembershipDetailComponent],
providers: [{ provide: ActivatedRoute, useValue: route }]
})
.overrideTemplate(MembershipDetailComponent, '')
.compileComponents();
fixture = TestBed.createComponent(MembershipDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
// WHEN
comp.ngOnInit();
// THEN
expect(comp.membership).toEqual(jasmine.objectContaining({ id: 123 }));
});
});
});
});

View File

@@ -0,0 +1,60 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { MembershipUpdateComponent } from 'app/entities/membership/membership-update.component';
import { MembershipService } from 'app/entities/membership/membership.service';
import { Membership } from 'app/shared/model/membership.model';
describe('Component Tests', () => {
describe('Membership Management Update Component', () => {
let comp: MembershipUpdateComponent;
let fixture: ComponentFixture<MembershipUpdateComponent>;
let service: MembershipService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [MembershipUpdateComponent]
})
.overrideTemplate(MembershipUpdateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(MembershipUpdateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(MembershipService);
});
describe('save', () => {
it('Should call update service on save for existing entity', fakeAsync(() => {
// GIVEN
const entity = new Membership(123);
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
comp.membership = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
it('Should call create service on save for new entity', fakeAsync(() => {
// GIVEN
const entity = new Membership();
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
comp.membership = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
});
});
});

View File

@@ -0,0 +1,128 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Data } from '@angular/router';
import { HsadminNgTestModule } from '../../../test.module';
import { MembershipComponent } from 'app/entities/membership/membership.component';
import { MembershipService } from 'app/entities/membership/membership.service';
import { Membership } from 'app/shared/model/membership.model';
describe('Component Tests', () => {
describe('Membership Management Component', () => {
let comp: MembershipComponent;
let fixture: ComponentFixture<MembershipComponent>;
let service: MembershipService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [MembershipComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) =>
fn({
pagingParams: {
predicate: 'id',
reverse: false,
page: 0
}
})
}
}
}
]
})
.overrideTemplate(MembershipComponent, '')
.compileComponents();
fixture = TestBed.createComponent(MembershipComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(MembershipService);
});
it('Should call load all on init', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Membership(123)],
headers
})
)
);
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.memberships[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should load a page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Membership(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.memberships[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should re-initialize the page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Membership(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
comp.reset();
// THEN
expect(comp.page).toEqual(0);
expect(service.query).toHaveBeenCalledTimes(2);
expect(comp.memberships[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should calculate the sort attribute for an id', () => {
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['id,asc']);
});
it('should calculate the sort attribute for a non-id attribute', () => {
// GIVEN
comp.predicate = 'name';
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['name,asc', 'id']);
});
});
});

View File

@@ -0,0 +1,145 @@
/* tslint:disable max-line-length */
import { TestBed, getTestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { of } from 'rxjs';
import { take, map } from 'rxjs/operators';
import * as moment from 'moment';
import { DATE_FORMAT } from 'app/shared/constants/input.constants';
import { MembershipService } from 'app/entities/membership/membership.service';
import { IMembership, Membership } from 'app/shared/model/membership.model';
describe('Service Tests', () => {
describe('Membership Service', () => {
let injector: TestBed;
let service: MembershipService;
let httpMock: HttpTestingController;
let elemDefault: IMembership;
let currentDate: moment.Moment;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(MembershipService);
httpMock = injector.get(HttpTestingController);
currentDate = moment();
elemDefault = new Membership(0, currentDate, currentDate, currentDate, 'AAAAAAA');
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
documentDate: currentDate.format(DATE_FORMAT),
memberFrom: currentDate.format(DATE_FORMAT),
memberUntil: currentDate.format(DATE_FORMAT)
},
elemDefault
);
service
.find(123)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify(returnedFromService));
});
it('should create a Membership', async () => {
const returnedFromService = Object.assign(
{
id: 0,
documentDate: currentDate.format(DATE_FORMAT),
memberFrom: currentDate.format(DATE_FORMAT),
memberUntil: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
memberFrom: currentDate,
memberUntil: currentDate
},
returnedFromService
);
service
.create(new Membership(null))
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'POST' });
req.flush(JSON.stringify(returnedFromService));
});
it('should update a Membership', async () => {
const returnedFromService = Object.assign(
{
documentDate: currentDate.format(DATE_FORMAT),
memberFrom: currentDate.format(DATE_FORMAT),
memberUntil: currentDate.format(DATE_FORMAT),
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
memberFrom: currentDate,
memberUntil: currentDate
},
returnedFromService
);
service
.update(expected)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'PUT' });
req.flush(JSON.stringify(returnedFromService));
});
it('should return a list of Membership', async () => {
const returnedFromService = Object.assign(
{
documentDate: currentDate.format(DATE_FORMAT),
memberFrom: currentDate.format(DATE_FORMAT),
memberUntil: currentDate.format(DATE_FORMAT),
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
memberFrom: currentDate,
memberUntil: currentDate
},
returnedFromService
);
service
.query(expected)
.pipe(
take(1),
map(resp => resp.body)
)
.subscribe(body => expect(body).toContainEqual(expected));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify([returnedFromService]));
httpMock.verify();
});
it('should delete a Membership', async () => {
const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
const req = httpMock.expectOne({ method: 'DELETE' });
req.flush({ status: 200 });
});
});
afterEach(() => {
httpMock.verify();
});
});
});

View File

@@ -0,0 +1,52 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, of } from 'rxjs';
import { JhiEventManager } from 'ng-jhipster';
import { HsadminNgTestModule } from '../../../test.module';
import { SepaMandateDeleteDialogComponent } from 'app/entities/sepa-mandate/sepa-mandate-delete-dialog.component';
import { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service';
describe('Component Tests', () => {
describe('SepaMandate Management Delete Component', () => {
let comp: SepaMandateDeleteDialogComponent;
let fixture: ComponentFixture<SepaMandateDeleteDialogComponent>;
let service: SepaMandateService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [SepaMandateDeleteDialogComponent]
})
.overrideTemplate(SepaMandateDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(SepaMandateDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(SepaMandateService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete', inject(
[],
fakeAsync(() => {
// GIVEN
spyOn(service, 'delete').and.returnValue(of({}));
// WHEN
comp.confirmDelete(123);
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith(123);
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
})
));
});
});
});

View File

@@ -0,0 +1,40 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { SepaMandateDetailComponent } from 'app/entities/sepa-mandate/sepa-mandate-detail.component';
import { SepaMandate } from 'app/shared/model/sepa-mandate.model';
describe('Component Tests', () => {
describe('SepaMandate Management Detail Component', () => {
let comp: SepaMandateDetailComponent;
let fixture: ComponentFixture<SepaMandateDetailComponent>;
const route = ({ data: of({ sepaMandate: new SepaMandate(123) }) } as any) as ActivatedRoute;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [SepaMandateDetailComponent],
providers: [{ provide: ActivatedRoute, useValue: route }]
})
.overrideTemplate(SepaMandateDetailComponent, '')
.compileComponents();
fixture = TestBed.createComponent(SepaMandateDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
// WHEN
comp.ngOnInit();
// THEN
expect(comp.sepaMandate).toEqual(jasmine.objectContaining({ id: 123 }));
});
});
});
});

View File

@@ -0,0 +1,60 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { SepaMandateUpdateComponent } from 'app/entities/sepa-mandate/sepa-mandate-update.component';
import { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service';
import { SepaMandate } from 'app/shared/model/sepa-mandate.model';
describe('Component Tests', () => {
describe('SepaMandate Management Update Component', () => {
let comp: SepaMandateUpdateComponent;
let fixture: ComponentFixture<SepaMandateUpdateComponent>;
let service: SepaMandateService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [SepaMandateUpdateComponent]
})
.overrideTemplate(SepaMandateUpdateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(SepaMandateUpdateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(SepaMandateService);
});
describe('save', () => {
it('Should call update service on save for existing entity', fakeAsync(() => {
// GIVEN
const entity = new SepaMandate(123);
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
comp.sepaMandate = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
it('Should call create service on save for new entity', fakeAsync(() => {
// GIVEN
const entity = new SepaMandate();
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
comp.sepaMandate = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
});
});
});

View File

@@ -0,0 +1,128 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Data } from '@angular/router';
import { HsadminNgTestModule } from '../../../test.module';
import { SepaMandateComponent } from 'app/entities/sepa-mandate/sepa-mandate.component';
import { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service';
import { SepaMandate } from 'app/shared/model/sepa-mandate.model';
describe('Component Tests', () => {
describe('SepaMandate Management Component', () => {
let comp: SepaMandateComponent;
let fixture: ComponentFixture<SepaMandateComponent>;
let service: SepaMandateService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [SepaMandateComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) =>
fn({
pagingParams: {
predicate: 'id',
reverse: false,
page: 0
}
})
}
}
}
]
})
.overrideTemplate(SepaMandateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(SepaMandateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(SepaMandateService);
});
it('Should call load all on init', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new SepaMandate(123)],
headers
})
)
);
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.sepaMandates[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should load a page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new SepaMandate(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.sepaMandates[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should re-initialize the page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new SepaMandate(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
comp.reset();
// THEN
expect(comp.page).toEqual(0);
expect(service.query).toHaveBeenCalledTimes(2);
expect(comp.sepaMandates[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should calculate the sort attribute for an id', () => {
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['id,asc']);
});
it('should calculate the sort attribute for a non-id attribute', () => {
// GIVEN
comp.predicate = 'name';
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['name,asc', 'id']);
});
});
});

View File

@@ -0,0 +1,176 @@
/* tslint:disable max-line-length */
import { TestBed, getTestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { of } from 'rxjs';
import { take, map } from 'rxjs/operators';
import * as moment from 'moment';
import { DATE_FORMAT } from 'app/shared/constants/input.constants';
import { SepaMandateService } from 'app/entities/sepa-mandate/sepa-mandate.service';
import { ISepaMandate, SepaMandate } from 'app/shared/model/sepa-mandate.model';
describe('Service Tests', () => {
describe('SepaMandate Service', () => {
let injector: TestBed;
let service: SepaMandateService;
let httpMock: HttpTestingController;
let elemDefault: ISepaMandate;
let currentDate: moment.Moment;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(SepaMandateService);
httpMock = injector.get(HttpTestingController);
currentDate = moment();
elemDefault = new SepaMandate(
0,
'AAAAAAA',
'AAAAAAA',
'AAAAAAA',
currentDate,
currentDate,
currentDate,
currentDate,
currentDate,
'AAAAAAA'
);
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
documentDate: currentDate.format(DATE_FORMAT),
validFrom: currentDate.format(DATE_FORMAT),
validUntil: currentDate.format(DATE_FORMAT),
lastUsed: currentDate.format(DATE_FORMAT),
cancellationDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
service
.find(123)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify(returnedFromService));
});
it('should create a SepaMandate', async () => {
const returnedFromService = Object.assign(
{
id: 0,
documentDate: currentDate.format(DATE_FORMAT),
validFrom: currentDate.format(DATE_FORMAT),
validUntil: currentDate.format(DATE_FORMAT),
lastUsed: currentDate.format(DATE_FORMAT),
cancellationDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
validFrom: currentDate,
validUntil: currentDate,
lastUsed: currentDate,
cancellationDate: currentDate
},
returnedFromService
);
service
.create(new SepaMandate(null))
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'POST' });
req.flush(JSON.stringify(returnedFromService));
});
it('should update a SepaMandate', async () => {
const returnedFromService = Object.assign(
{
reference: 'BBBBBB',
iban: 'BBBBBB',
bic: 'BBBBBB',
documentDate: currentDate.format(DATE_FORMAT),
validFrom: currentDate.format(DATE_FORMAT),
validUntil: currentDate.format(DATE_FORMAT),
lastUsed: currentDate.format(DATE_FORMAT),
cancellationDate: currentDate.format(DATE_FORMAT),
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
validFrom: currentDate,
validUntil: currentDate,
lastUsed: currentDate,
cancellationDate: currentDate
},
returnedFromService
);
service
.update(expected)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'PUT' });
req.flush(JSON.stringify(returnedFromService));
});
it('should return a list of SepaMandate', async () => {
const returnedFromService = Object.assign(
{
reference: 'BBBBBB',
iban: 'BBBBBB',
bic: 'BBBBBB',
documentDate: currentDate.format(DATE_FORMAT),
validFrom: currentDate.format(DATE_FORMAT),
validUntil: currentDate.format(DATE_FORMAT),
lastUsed: currentDate.format(DATE_FORMAT),
cancellationDate: currentDate.format(DATE_FORMAT),
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
validFrom: currentDate,
validUntil: currentDate,
lastUsed: currentDate,
cancellationDate: currentDate
},
returnedFromService
);
service
.query(expected)
.pipe(
take(1),
map(resp => resp.body)
)
.subscribe(body => expect(body).toContainEqual(expected));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify([returnedFromService]));
httpMock.verify();
});
it('should delete a SepaMandate', async () => {
const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
const req = httpMock.expectOne({ method: 'DELETE' });
req.flush({ status: 200 });
});
});
afterEach(() => {
httpMock.verify();
});
});
});

View File

@@ -0,0 +1,52 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, inject, fakeAsync, tick } from '@angular/core/testing';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { Observable, of } from 'rxjs';
import { JhiEventManager } from 'ng-jhipster';
import { HsadminNgTestModule } from '../../../test.module';
import { ShareDeleteDialogComponent } from 'app/entities/share/share-delete-dialog.component';
import { ShareService } from 'app/entities/share/share.service';
describe('Component Tests', () => {
describe('Share Management Delete Component', () => {
let comp: ShareDeleteDialogComponent;
let fixture: ComponentFixture<ShareDeleteDialogComponent>;
let service: ShareService;
let mockEventManager: any;
let mockActiveModal: any;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [ShareDeleteDialogComponent]
})
.overrideTemplate(ShareDeleteDialogComponent, '')
.compileComponents();
fixture = TestBed.createComponent(ShareDeleteDialogComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(ShareService);
mockEventManager = fixture.debugElement.injector.get(JhiEventManager);
mockActiveModal = fixture.debugElement.injector.get(NgbActiveModal);
});
describe('confirmDelete', () => {
it('Should call delete service on confirmDelete', inject(
[],
fakeAsync(() => {
// GIVEN
spyOn(service, 'delete').and.returnValue(of({}));
// WHEN
comp.confirmDelete(123);
tick();
// THEN
expect(service.delete).toHaveBeenCalledWith(123);
expect(mockActiveModal.dismissSpy).toHaveBeenCalled();
expect(mockEventManager.broadcastSpy).toHaveBeenCalled();
})
));
});
});
});

View File

@@ -0,0 +1,40 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ActivatedRoute } from '@angular/router';
import { of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { ShareDetailComponent } from 'app/entities/share/share-detail.component';
import { Share } from 'app/shared/model/share.model';
describe('Component Tests', () => {
describe('Share Management Detail Component', () => {
let comp: ShareDetailComponent;
let fixture: ComponentFixture<ShareDetailComponent>;
const route = ({ data: of({ share: new Share(123) }) } as any) as ActivatedRoute;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [ShareDetailComponent],
providers: [{ provide: ActivatedRoute, useValue: route }]
})
.overrideTemplate(ShareDetailComponent, '')
.compileComponents();
fixture = TestBed.createComponent(ShareDetailComponent);
comp = fixture.componentInstance;
});
describe('OnInit', () => {
it('Should call load all on init', () => {
// GIVEN
// WHEN
comp.ngOnInit();
// THEN
expect(comp.share).toEqual(jasmine.objectContaining({ id: 123 }));
});
});
});
});

View File

@@ -0,0 +1,60 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
import { HttpResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { HsadminNgTestModule } from '../../../test.module';
import { ShareUpdateComponent } from 'app/entities/share/share-update.component';
import { ShareService } from 'app/entities/share/share.service';
import { Share } from 'app/shared/model/share.model';
describe('Component Tests', () => {
describe('Share Management Update Component', () => {
let comp: ShareUpdateComponent;
let fixture: ComponentFixture<ShareUpdateComponent>;
let service: ShareService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [ShareUpdateComponent]
})
.overrideTemplate(ShareUpdateComponent, '')
.compileComponents();
fixture = TestBed.createComponent(ShareUpdateComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(ShareService);
});
describe('save', () => {
it('Should call update service on save for existing entity', fakeAsync(() => {
// GIVEN
const entity = new Share(123);
spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
comp.share = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.update).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
it('Should call create service on save for new entity', fakeAsync(() => {
// GIVEN
const entity = new Share();
spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
comp.share = entity;
// WHEN
comp.save();
tick(); // simulate async
// THEN
expect(service.create).toHaveBeenCalledWith(entity);
expect(comp.isSaving).toEqual(false);
}));
});
});
});

View File

@@ -0,0 +1,128 @@
/* tslint:disable max-line-length */
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { Observable, of } from 'rxjs';
import { HttpHeaders, HttpResponse } from '@angular/common/http';
import { ActivatedRoute, Data } from '@angular/router';
import { HsadminNgTestModule } from '../../../test.module';
import { ShareComponent } from 'app/entities/share/share.component';
import { ShareService } from 'app/entities/share/share.service';
import { Share } from 'app/shared/model/share.model';
describe('Component Tests', () => {
describe('Share Management Component', () => {
let comp: ShareComponent;
let fixture: ComponentFixture<ShareComponent>;
let service: ShareService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HsadminNgTestModule],
declarations: [ShareComponent],
providers: [
{
provide: ActivatedRoute,
useValue: {
data: {
subscribe: (fn: (value: Data) => void) =>
fn({
pagingParams: {
predicate: 'id',
reverse: false,
page: 0
}
})
}
}
}
]
})
.overrideTemplate(ShareComponent, '')
.compileComponents();
fixture = TestBed.createComponent(ShareComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(ShareService);
});
it('Should call load all on init', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Share(123)],
headers
})
)
);
// WHEN
comp.ngOnInit();
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.shares[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should load a page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Share(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
// THEN
expect(service.query).toHaveBeenCalled();
expect(comp.shares[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should re-initialize the page', () => {
// GIVEN
const headers = new HttpHeaders().append('link', 'link;link');
spyOn(service, 'query').and.returnValue(
of(
new HttpResponse({
body: [new Share(123)],
headers
})
)
);
// WHEN
comp.loadPage(1);
comp.reset();
// THEN
expect(comp.page).toEqual(0);
expect(service.query).toHaveBeenCalledTimes(2);
expect(comp.shares[0]).toEqual(jasmine.objectContaining({ id: 123 }));
});
it('should calculate the sort attribute for an id', () => {
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['id,asc']);
});
it('should calculate the sort attribute for a non-id attribute', () => {
// GIVEN
comp.predicate = 'name';
// WHEN
const result = comp.sort();
// THEN
expect(result).toEqual(['name,asc', 'id']);
});
});
});

View File

@@ -0,0 +1,142 @@
/* tslint:disable max-line-length */
import { TestBed, getTestBed } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient, HttpResponse } from '@angular/common/http';
import { of } from 'rxjs';
import { take, map } from 'rxjs/operators';
import * as moment from 'moment';
import { DATE_FORMAT } from 'app/shared/constants/input.constants';
import { ShareService } from 'app/entities/share/share.service';
import { IShare, Share, ShareAction } from 'app/shared/model/share.model';
describe('Service Tests', () => {
describe('Share Service', () => {
let injector: TestBed;
let service: ShareService;
let httpMock: HttpTestingController;
let elemDefault: IShare;
let currentDate: moment.Moment;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(ShareService);
httpMock = injector.get(HttpTestingController);
currentDate = moment();
elemDefault = new Share(0, currentDate, currentDate, ShareAction.SUBSCRIPTION, 0, 'AAAAAAA');
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
service
.find(123)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify(returnedFromService));
});
it('should create a Share', async () => {
const returnedFromService = Object.assign(
{
id: 0,
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
valueDate: currentDate
},
returnedFromService
);
service
.create(new Share(null))
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'POST' });
req.flush(JSON.stringify(returnedFromService));
});
it('should update a Share', async () => {
const returnedFromService = Object.assign(
{
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT),
action: 'BBBBBB',
quantity: 1,
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
valueDate: currentDate
},
returnedFromService
);
service
.update(expected)
.pipe(take(1))
.subscribe(resp => expect(resp).toMatchObject({ body: expected }));
const req = httpMock.expectOne({ method: 'PUT' });
req.flush(JSON.stringify(returnedFromService));
});
it('should return a list of Share', async () => {
const returnedFromService = Object.assign(
{
documentDate: currentDate.format(DATE_FORMAT),
valueDate: currentDate.format(DATE_FORMAT),
action: 'BBBBBB',
quantity: 1,
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
documentDate: currentDate,
valueDate: currentDate
},
returnedFromService
);
service
.query(expected)
.pipe(
take(1),
map(resp => resp.body)
)
.subscribe(body => expect(body).toContainEqual(expected));
const req = httpMock.expectOne({ method: 'GET' });
req.flush(JSON.stringify([returnedFromService]));
httpMock.verify();
});
it('should delete a Share', async () => {
const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
const req = httpMock.expectOne({ method: 'DELETE' });
req.flush({ status: 200 });
});
});
afterEach(() => {
httpMock.verify();
});
});
});