1
0

Preliminary completed customer model.

This commit is contained in:
Michael Hierweck
2019-04-24 13:08:27 +02:00
parent c6be30895e
commit 2a4ee0507c
178 changed files with 17031 additions and 10 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();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,770 @@
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_ADMISSION_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_ADMISSION_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_CANCELLATION_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_CANCELLATION_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_MEMBER_FROM_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_MEMBER_FROM_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_MEMBER_UNTIL_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_MEMBER_UNTIL_DATE = 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()
.admissionDocumentDate(DEFAULT_ADMISSION_DOCUMENT_DATE)
.cancellationDocumentDate(DEFAULT_CANCELLATION_DOCUMENT_DATE)
.memberFromDate(DEFAULT_MEMBER_FROM_DATE)
.memberUntilDate(DEFAULT_MEMBER_UNTIL_DATE)
.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.getAdmissionDocumentDate()).isEqualTo(DEFAULT_ADMISSION_DOCUMENT_DATE);
assertThat(testMembership.getCancellationDocumentDate()).isEqualTo(DEFAULT_CANCELLATION_DOCUMENT_DATE);
assertThat(testMembership.getMemberFromDate()).isEqualTo(DEFAULT_MEMBER_FROM_DATE);
assertThat(testMembership.getMemberUntilDate()).isEqualTo(DEFAULT_MEMBER_UNTIL_DATE);
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 checkAdmissionDocumentDateIsRequired() throws Exception {
int databaseSizeBeforeTest = membershipRepository.findAll().size();
// set the field null
membership.setAdmissionDocumentDate(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 checkMemberFromDateIsRequired() throws Exception {
int databaseSizeBeforeTest = membershipRepository.findAll().size();
// set the field null
membership.setMemberFromDate(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("$.[*].admissionDocumentDate").value(hasItem(DEFAULT_ADMISSION_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].cancellationDocumentDate").value(hasItem(DEFAULT_CANCELLATION_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].memberFromDate").value(hasItem(DEFAULT_MEMBER_FROM_DATE.toString())))
.andExpect(jsonPath("$.[*].memberUntilDate").value(hasItem(DEFAULT_MEMBER_UNTIL_DATE.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("$.admissionDocumentDate").value(DEFAULT_ADMISSION_DOCUMENT_DATE.toString()))
.andExpect(jsonPath("$.cancellationDocumentDate").value(DEFAULT_CANCELLATION_DOCUMENT_DATE.toString()))
.andExpect(jsonPath("$.memberFromDate").value(DEFAULT_MEMBER_FROM_DATE.toString()))
.andExpect(jsonPath("$.memberUntilDate").value(DEFAULT_MEMBER_UNTIL_DATE.toString()))
.andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString()));
}
@Test
@Transactional
public void getAllMembershipsByAdmissionDocumentDateIsEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where admissionDocumentDate equals to DEFAULT_ADMISSION_DOCUMENT_DATE
defaultMembershipShouldBeFound("admissionDocumentDate.equals=" + DEFAULT_ADMISSION_DOCUMENT_DATE);
// Get all the membershipList where admissionDocumentDate equals to UPDATED_ADMISSION_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("admissionDocumentDate.equals=" + UPDATED_ADMISSION_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByAdmissionDocumentDateIsInShouldWork() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where admissionDocumentDate in DEFAULT_ADMISSION_DOCUMENT_DATE or UPDATED_ADMISSION_DOCUMENT_DATE
defaultMembershipShouldBeFound("admissionDocumentDate.in=" + DEFAULT_ADMISSION_DOCUMENT_DATE + "," + UPDATED_ADMISSION_DOCUMENT_DATE);
// Get all the membershipList where admissionDocumentDate equals to UPDATED_ADMISSION_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("admissionDocumentDate.in=" + UPDATED_ADMISSION_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByAdmissionDocumentDateIsNullOrNotNull() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where admissionDocumentDate is not null
defaultMembershipShouldBeFound("admissionDocumentDate.specified=true");
// Get all the membershipList where admissionDocumentDate is null
defaultMembershipShouldNotBeFound("admissionDocumentDate.specified=false");
}
@Test
@Transactional
public void getAllMembershipsByAdmissionDocumentDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where admissionDocumentDate greater than or equals to DEFAULT_ADMISSION_DOCUMENT_DATE
defaultMembershipShouldBeFound("admissionDocumentDate.greaterOrEqualThan=" + DEFAULT_ADMISSION_DOCUMENT_DATE);
// Get all the membershipList where admissionDocumentDate greater than or equals to UPDATED_ADMISSION_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("admissionDocumentDate.greaterOrEqualThan=" + UPDATED_ADMISSION_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByAdmissionDocumentDateIsLessThanSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where admissionDocumentDate less than or equals to DEFAULT_ADMISSION_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("admissionDocumentDate.lessThan=" + DEFAULT_ADMISSION_DOCUMENT_DATE);
// Get all the membershipList where admissionDocumentDate less than or equals to UPDATED_ADMISSION_DOCUMENT_DATE
defaultMembershipShouldBeFound("admissionDocumentDate.lessThan=" + UPDATED_ADMISSION_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByCancellationDocumentDateIsEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where cancellationDocumentDate equals to DEFAULT_CANCELLATION_DOCUMENT_DATE
defaultMembershipShouldBeFound("cancellationDocumentDate.equals=" + DEFAULT_CANCELLATION_DOCUMENT_DATE);
// Get all the membershipList where cancellationDocumentDate equals to UPDATED_CANCELLATION_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("cancellationDocumentDate.equals=" + UPDATED_CANCELLATION_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByCancellationDocumentDateIsInShouldWork() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where cancellationDocumentDate in DEFAULT_CANCELLATION_DOCUMENT_DATE or UPDATED_CANCELLATION_DOCUMENT_DATE
defaultMembershipShouldBeFound("cancellationDocumentDate.in=" + DEFAULT_CANCELLATION_DOCUMENT_DATE + "," + UPDATED_CANCELLATION_DOCUMENT_DATE);
// Get all the membershipList where cancellationDocumentDate equals to UPDATED_CANCELLATION_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("cancellationDocumentDate.in=" + UPDATED_CANCELLATION_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByCancellationDocumentDateIsNullOrNotNull() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where cancellationDocumentDate is not null
defaultMembershipShouldBeFound("cancellationDocumentDate.specified=true");
// Get all the membershipList where cancellationDocumentDate is null
defaultMembershipShouldNotBeFound("cancellationDocumentDate.specified=false");
}
@Test
@Transactional
public void getAllMembershipsByCancellationDocumentDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where cancellationDocumentDate greater than or equals to DEFAULT_CANCELLATION_DOCUMENT_DATE
defaultMembershipShouldBeFound("cancellationDocumentDate.greaterOrEqualThan=" + DEFAULT_CANCELLATION_DOCUMENT_DATE);
// Get all the membershipList where cancellationDocumentDate greater than or equals to UPDATED_CANCELLATION_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("cancellationDocumentDate.greaterOrEqualThan=" + UPDATED_CANCELLATION_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByCancellationDocumentDateIsLessThanSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where cancellationDocumentDate less than or equals to DEFAULT_CANCELLATION_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("cancellationDocumentDate.lessThan=" + DEFAULT_CANCELLATION_DOCUMENT_DATE);
// Get all the membershipList where cancellationDocumentDate less than or equals to UPDATED_CANCELLATION_DOCUMENT_DATE
defaultMembershipShouldBeFound("cancellationDocumentDate.lessThan=" + UPDATED_CANCELLATION_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByMemberFromDateIsEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberFromDate equals to DEFAULT_MEMBER_FROM_DATE
defaultMembershipShouldBeFound("memberFromDate.equals=" + DEFAULT_MEMBER_FROM_DATE);
// Get all the membershipList where memberFromDate equals to UPDATED_MEMBER_FROM_DATE
defaultMembershipShouldNotBeFound("memberFromDate.equals=" + UPDATED_MEMBER_FROM_DATE);
}
@Test
@Transactional
public void getAllMembershipsByMemberFromDateIsInShouldWork() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberFromDate in DEFAULT_MEMBER_FROM_DATE or UPDATED_MEMBER_FROM_DATE
defaultMembershipShouldBeFound("memberFromDate.in=" + DEFAULT_MEMBER_FROM_DATE + "," + UPDATED_MEMBER_FROM_DATE);
// Get all the membershipList where memberFromDate equals to UPDATED_MEMBER_FROM_DATE
defaultMembershipShouldNotBeFound("memberFromDate.in=" + UPDATED_MEMBER_FROM_DATE);
}
@Test
@Transactional
public void getAllMembershipsByMemberFromDateIsNullOrNotNull() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberFromDate is not null
defaultMembershipShouldBeFound("memberFromDate.specified=true");
// Get all the membershipList where memberFromDate is null
defaultMembershipShouldNotBeFound("memberFromDate.specified=false");
}
@Test
@Transactional
public void getAllMembershipsByMemberFromDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberFromDate greater than or equals to DEFAULT_MEMBER_FROM_DATE
defaultMembershipShouldBeFound("memberFromDate.greaterOrEqualThan=" + DEFAULT_MEMBER_FROM_DATE);
// Get all the membershipList where memberFromDate greater than or equals to UPDATED_MEMBER_FROM_DATE
defaultMembershipShouldNotBeFound("memberFromDate.greaterOrEqualThan=" + UPDATED_MEMBER_FROM_DATE);
}
@Test
@Transactional
public void getAllMembershipsByMemberFromDateIsLessThanSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberFromDate less than or equals to DEFAULT_MEMBER_FROM_DATE
defaultMembershipShouldNotBeFound("memberFromDate.lessThan=" + DEFAULT_MEMBER_FROM_DATE);
// Get all the membershipList where memberFromDate less than or equals to UPDATED_MEMBER_FROM_DATE
defaultMembershipShouldBeFound("memberFromDate.lessThan=" + UPDATED_MEMBER_FROM_DATE);
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilDateIsEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntilDate equals to DEFAULT_MEMBER_UNTIL_DATE
defaultMembershipShouldBeFound("memberUntilDate.equals=" + DEFAULT_MEMBER_UNTIL_DATE);
// Get all the membershipList where memberUntilDate equals to UPDATED_MEMBER_UNTIL_DATE
defaultMembershipShouldNotBeFound("memberUntilDate.equals=" + UPDATED_MEMBER_UNTIL_DATE);
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilDateIsInShouldWork() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntilDate in DEFAULT_MEMBER_UNTIL_DATE or UPDATED_MEMBER_UNTIL_DATE
defaultMembershipShouldBeFound("memberUntilDate.in=" + DEFAULT_MEMBER_UNTIL_DATE + "," + UPDATED_MEMBER_UNTIL_DATE);
// Get all the membershipList where memberUntilDate equals to UPDATED_MEMBER_UNTIL_DATE
defaultMembershipShouldNotBeFound("memberUntilDate.in=" + UPDATED_MEMBER_UNTIL_DATE);
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilDateIsNullOrNotNull() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntilDate is not null
defaultMembershipShouldBeFound("memberUntilDate.specified=true");
// Get all the membershipList where memberUntilDate is null
defaultMembershipShouldNotBeFound("memberUntilDate.specified=false");
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntilDate greater than or equals to DEFAULT_MEMBER_UNTIL_DATE
defaultMembershipShouldBeFound("memberUntilDate.greaterOrEqualThan=" + DEFAULT_MEMBER_UNTIL_DATE);
// Get all the membershipList where memberUntilDate greater than or equals to UPDATED_MEMBER_UNTIL_DATE
defaultMembershipShouldNotBeFound("memberUntilDate.greaterOrEqualThan=" + UPDATED_MEMBER_UNTIL_DATE);
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilDateIsLessThanSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntilDate less than or equals to DEFAULT_MEMBER_UNTIL_DATE
defaultMembershipShouldNotBeFound("memberUntilDate.lessThan=" + DEFAULT_MEMBER_UNTIL_DATE);
// Get all the membershipList where memberUntilDate less than or equals to UPDATED_MEMBER_UNTIL_DATE
defaultMembershipShouldBeFound("memberUntilDate.lessThan=" + UPDATED_MEMBER_UNTIL_DATE);
}
@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("$.[*].admissionDocumentDate").value(hasItem(DEFAULT_ADMISSION_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].cancellationDocumentDate").value(hasItem(DEFAULT_CANCELLATION_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].memberFromDate").value(hasItem(DEFAULT_MEMBER_FROM_DATE.toString())))
.andExpect(jsonPath("$.[*].memberUntilDate").value(hasItem(DEFAULT_MEMBER_UNTIL_DATE.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
.admissionDocumentDate(UPDATED_ADMISSION_DOCUMENT_DATE)
.cancellationDocumentDate(UPDATED_CANCELLATION_DOCUMENT_DATE)
.memberFromDate(UPDATED_MEMBER_FROM_DATE)
.memberUntilDate(UPDATED_MEMBER_UNTIL_DATE)
.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.getAdmissionDocumentDate()).isEqualTo(UPDATED_ADMISSION_DOCUMENT_DATE);
assertThat(testMembership.getCancellationDocumentDate()).isEqualTo(UPDATED_CANCELLATION_DOCUMENT_DATE);
assertThat(testMembership.getMemberFromDate()).isEqualTo(UPDATED_MEMBER_FROM_DATE);
assertThat(testMembership.getMemberUntilDate()).isEqualTo(UPDATED_MEMBER_UNTIL_DATE);
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_GRANTING_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_GRANTING_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_REVOKATION_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_REVOKATION_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_VALID_FROM_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_VALID_FROM_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_VALID_UNTIL_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_VALID_UNTIL_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_LAST_USED_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_LAST_USED_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)
.grantingDocumentDate(DEFAULT_GRANTING_DOCUMENT_DATE)
.revokationDocumentDate(DEFAULT_REVOKATION_DOCUMENT_DATE)
.validFromDate(DEFAULT_VALID_FROM_DATE)
.validUntilDate(DEFAULT_VALID_UNTIL_DATE)
.lastUsedDate(DEFAULT_LAST_USED_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.getGrantingDocumentDate()).isEqualTo(DEFAULT_GRANTING_DOCUMENT_DATE);
assertThat(testSepaMandate.getRevokationDocumentDate()).isEqualTo(DEFAULT_REVOKATION_DOCUMENT_DATE);
assertThat(testSepaMandate.getValidFromDate()).isEqualTo(DEFAULT_VALID_FROM_DATE);
assertThat(testSepaMandate.getValidUntilDate()).isEqualTo(DEFAULT_VALID_UNTIL_DATE);
assertThat(testSepaMandate.getLastUsedDate()).isEqualTo(DEFAULT_LAST_USED_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 checkGrantingDocumentDateIsRequired() throws Exception {
int databaseSizeBeforeTest = sepaMandateRepository.findAll().size();
// set the field null
sepaMandate.setGrantingDocumentDate(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 checkValidFromDateIsRequired() throws Exception {
int databaseSizeBeforeTest = sepaMandateRepository.findAll().size();
// set the field null
sepaMandate.setValidFromDate(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("$.[*].grantingDocumentDate").value(hasItem(DEFAULT_GRANTING_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].revokationDocumentDate").value(hasItem(DEFAULT_REVOKATION_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].validFromDate").value(hasItem(DEFAULT_VALID_FROM_DATE.toString())))
.andExpect(jsonPath("$.[*].validUntilDate").value(hasItem(DEFAULT_VALID_UNTIL_DATE.toString())))
.andExpect(jsonPath("$.[*].lastUsedDate").value(hasItem(DEFAULT_LAST_USED_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("$.grantingDocumentDate").value(DEFAULT_GRANTING_DOCUMENT_DATE.toString()))
.andExpect(jsonPath("$.revokationDocumentDate").value(DEFAULT_REVOKATION_DOCUMENT_DATE.toString()))
.andExpect(jsonPath("$.validFromDate").value(DEFAULT_VALID_FROM_DATE.toString()))
.andExpect(jsonPath("$.validUntilDate").value(DEFAULT_VALID_UNTIL_DATE.toString()))
.andExpect(jsonPath("$.lastUsedDate").value(DEFAULT_LAST_USED_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 getAllSepaMandatesByGrantingDocumentDateIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where grantingDocumentDate equals to DEFAULT_GRANTING_DOCUMENT_DATE
defaultSepaMandateShouldBeFound("grantingDocumentDate.equals=" + DEFAULT_GRANTING_DOCUMENT_DATE);
// Get all the sepaMandateList where grantingDocumentDate equals to UPDATED_GRANTING_DOCUMENT_DATE
defaultSepaMandateShouldNotBeFound("grantingDocumentDate.equals=" + UPDATED_GRANTING_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByGrantingDocumentDateIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where grantingDocumentDate in DEFAULT_GRANTING_DOCUMENT_DATE or UPDATED_GRANTING_DOCUMENT_DATE
defaultSepaMandateShouldBeFound("grantingDocumentDate.in=" + DEFAULT_GRANTING_DOCUMENT_DATE + "," + UPDATED_GRANTING_DOCUMENT_DATE);
// Get all the sepaMandateList where grantingDocumentDate equals to UPDATED_GRANTING_DOCUMENT_DATE
defaultSepaMandateShouldNotBeFound("grantingDocumentDate.in=" + UPDATED_GRANTING_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByGrantingDocumentDateIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where grantingDocumentDate is not null
defaultSepaMandateShouldBeFound("grantingDocumentDate.specified=true");
// Get all the sepaMandateList where grantingDocumentDate is null
defaultSepaMandateShouldNotBeFound("grantingDocumentDate.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByGrantingDocumentDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where grantingDocumentDate greater than or equals to DEFAULT_GRANTING_DOCUMENT_DATE
defaultSepaMandateShouldBeFound("grantingDocumentDate.greaterOrEqualThan=" + DEFAULT_GRANTING_DOCUMENT_DATE);
// Get all the sepaMandateList where grantingDocumentDate greater than or equals to UPDATED_GRANTING_DOCUMENT_DATE
defaultSepaMandateShouldNotBeFound("grantingDocumentDate.greaterOrEqualThan=" + UPDATED_GRANTING_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByGrantingDocumentDateIsLessThanSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where grantingDocumentDate less than or equals to DEFAULT_GRANTING_DOCUMENT_DATE
defaultSepaMandateShouldNotBeFound("grantingDocumentDate.lessThan=" + DEFAULT_GRANTING_DOCUMENT_DATE);
// Get all the sepaMandateList where grantingDocumentDate less than or equals to UPDATED_GRANTING_DOCUMENT_DATE
defaultSepaMandateShouldBeFound("grantingDocumentDate.lessThan=" + UPDATED_GRANTING_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByRevokationDocumentDateIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where revokationDocumentDate equals to DEFAULT_REVOKATION_DOCUMENT_DATE
defaultSepaMandateShouldBeFound("revokationDocumentDate.equals=" + DEFAULT_REVOKATION_DOCUMENT_DATE);
// Get all the sepaMandateList where revokationDocumentDate equals to UPDATED_REVOKATION_DOCUMENT_DATE
defaultSepaMandateShouldNotBeFound("revokationDocumentDate.equals=" + UPDATED_REVOKATION_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByRevokationDocumentDateIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where revokationDocumentDate in DEFAULT_REVOKATION_DOCUMENT_DATE or UPDATED_REVOKATION_DOCUMENT_DATE
defaultSepaMandateShouldBeFound("revokationDocumentDate.in=" + DEFAULT_REVOKATION_DOCUMENT_DATE + "," + UPDATED_REVOKATION_DOCUMENT_DATE);
// Get all the sepaMandateList where revokationDocumentDate equals to UPDATED_REVOKATION_DOCUMENT_DATE
defaultSepaMandateShouldNotBeFound("revokationDocumentDate.in=" + UPDATED_REVOKATION_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByRevokationDocumentDateIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where revokationDocumentDate is not null
defaultSepaMandateShouldBeFound("revokationDocumentDate.specified=true");
// Get all the sepaMandateList where revokationDocumentDate is null
defaultSepaMandateShouldNotBeFound("revokationDocumentDate.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByRevokationDocumentDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where revokationDocumentDate greater than or equals to DEFAULT_REVOKATION_DOCUMENT_DATE
defaultSepaMandateShouldBeFound("revokationDocumentDate.greaterOrEqualThan=" + DEFAULT_REVOKATION_DOCUMENT_DATE);
// Get all the sepaMandateList where revokationDocumentDate greater than or equals to UPDATED_REVOKATION_DOCUMENT_DATE
defaultSepaMandateShouldNotBeFound("revokationDocumentDate.greaterOrEqualThan=" + UPDATED_REVOKATION_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByRevokationDocumentDateIsLessThanSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where revokationDocumentDate less than or equals to DEFAULT_REVOKATION_DOCUMENT_DATE
defaultSepaMandateShouldNotBeFound("revokationDocumentDate.lessThan=" + DEFAULT_REVOKATION_DOCUMENT_DATE);
// Get all the sepaMandateList where revokationDocumentDate less than or equals to UPDATED_REVOKATION_DOCUMENT_DATE
defaultSepaMandateShouldBeFound("revokationDocumentDate.lessThan=" + UPDATED_REVOKATION_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByValidFromDateIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validFromDate equals to DEFAULT_VALID_FROM_DATE
defaultSepaMandateShouldBeFound("validFromDate.equals=" + DEFAULT_VALID_FROM_DATE);
// Get all the sepaMandateList where validFromDate equals to UPDATED_VALID_FROM_DATE
defaultSepaMandateShouldNotBeFound("validFromDate.equals=" + UPDATED_VALID_FROM_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByValidFromDateIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validFromDate in DEFAULT_VALID_FROM_DATE or UPDATED_VALID_FROM_DATE
defaultSepaMandateShouldBeFound("validFromDate.in=" + DEFAULT_VALID_FROM_DATE + "," + UPDATED_VALID_FROM_DATE);
// Get all the sepaMandateList where validFromDate equals to UPDATED_VALID_FROM_DATE
defaultSepaMandateShouldNotBeFound("validFromDate.in=" + UPDATED_VALID_FROM_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByValidFromDateIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validFromDate is not null
defaultSepaMandateShouldBeFound("validFromDate.specified=true");
// Get all the sepaMandateList where validFromDate is null
defaultSepaMandateShouldNotBeFound("validFromDate.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByValidFromDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validFromDate greater than or equals to DEFAULT_VALID_FROM_DATE
defaultSepaMandateShouldBeFound("validFromDate.greaterOrEqualThan=" + DEFAULT_VALID_FROM_DATE);
// Get all the sepaMandateList where validFromDate greater than or equals to UPDATED_VALID_FROM_DATE
defaultSepaMandateShouldNotBeFound("validFromDate.greaterOrEqualThan=" + UPDATED_VALID_FROM_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByValidFromDateIsLessThanSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validFromDate less than or equals to DEFAULT_VALID_FROM_DATE
defaultSepaMandateShouldNotBeFound("validFromDate.lessThan=" + DEFAULT_VALID_FROM_DATE);
// Get all the sepaMandateList where validFromDate less than or equals to UPDATED_VALID_FROM_DATE
defaultSepaMandateShouldBeFound("validFromDate.lessThan=" + UPDATED_VALID_FROM_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByValidUntilDateIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validUntilDate equals to DEFAULT_VALID_UNTIL_DATE
defaultSepaMandateShouldBeFound("validUntilDate.equals=" + DEFAULT_VALID_UNTIL_DATE);
// Get all the sepaMandateList where validUntilDate equals to UPDATED_VALID_UNTIL_DATE
defaultSepaMandateShouldNotBeFound("validUntilDate.equals=" + UPDATED_VALID_UNTIL_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByValidUntilDateIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validUntilDate in DEFAULT_VALID_UNTIL_DATE or UPDATED_VALID_UNTIL_DATE
defaultSepaMandateShouldBeFound("validUntilDate.in=" + DEFAULT_VALID_UNTIL_DATE + "," + UPDATED_VALID_UNTIL_DATE);
// Get all the sepaMandateList where validUntilDate equals to UPDATED_VALID_UNTIL_DATE
defaultSepaMandateShouldNotBeFound("validUntilDate.in=" + UPDATED_VALID_UNTIL_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByValidUntilDateIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validUntilDate is not null
defaultSepaMandateShouldBeFound("validUntilDate.specified=true");
// Get all the sepaMandateList where validUntilDate is null
defaultSepaMandateShouldNotBeFound("validUntilDate.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByValidUntilDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validUntilDate greater than or equals to DEFAULT_VALID_UNTIL_DATE
defaultSepaMandateShouldBeFound("validUntilDate.greaterOrEqualThan=" + DEFAULT_VALID_UNTIL_DATE);
// Get all the sepaMandateList where validUntilDate greater than or equals to UPDATED_VALID_UNTIL_DATE
defaultSepaMandateShouldNotBeFound("validUntilDate.greaterOrEqualThan=" + UPDATED_VALID_UNTIL_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByValidUntilDateIsLessThanSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where validUntilDate less than or equals to DEFAULT_VALID_UNTIL_DATE
defaultSepaMandateShouldNotBeFound("validUntilDate.lessThan=" + DEFAULT_VALID_UNTIL_DATE);
// Get all the sepaMandateList where validUntilDate less than or equals to UPDATED_VALID_UNTIL_DATE
defaultSepaMandateShouldBeFound("validUntilDate.lessThan=" + UPDATED_VALID_UNTIL_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByLastUsedDateIsEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where lastUsedDate equals to DEFAULT_LAST_USED_DATE
defaultSepaMandateShouldBeFound("lastUsedDate.equals=" + DEFAULT_LAST_USED_DATE);
// Get all the sepaMandateList where lastUsedDate equals to UPDATED_LAST_USED_DATE
defaultSepaMandateShouldNotBeFound("lastUsedDate.equals=" + UPDATED_LAST_USED_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByLastUsedDateIsInShouldWork() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where lastUsedDate in DEFAULT_LAST_USED_DATE or UPDATED_LAST_USED_DATE
defaultSepaMandateShouldBeFound("lastUsedDate.in=" + DEFAULT_LAST_USED_DATE + "," + UPDATED_LAST_USED_DATE);
// Get all the sepaMandateList where lastUsedDate equals to UPDATED_LAST_USED_DATE
defaultSepaMandateShouldNotBeFound("lastUsedDate.in=" + UPDATED_LAST_USED_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByLastUsedDateIsNullOrNotNull() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where lastUsedDate is not null
defaultSepaMandateShouldBeFound("lastUsedDate.specified=true");
// Get all the sepaMandateList where lastUsedDate is null
defaultSepaMandateShouldNotBeFound("lastUsedDate.specified=false");
}
@Test
@Transactional
public void getAllSepaMandatesByLastUsedDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where lastUsedDate greater than or equals to DEFAULT_LAST_USED_DATE
defaultSepaMandateShouldBeFound("lastUsedDate.greaterOrEqualThan=" + DEFAULT_LAST_USED_DATE);
// Get all the sepaMandateList where lastUsedDate greater than or equals to UPDATED_LAST_USED_DATE
defaultSepaMandateShouldNotBeFound("lastUsedDate.greaterOrEqualThan=" + UPDATED_LAST_USED_DATE);
}
@Test
@Transactional
public void getAllSepaMandatesByLastUsedDateIsLessThanSomething() throws Exception {
// Initialize the database
sepaMandateRepository.saveAndFlush(sepaMandate);
// Get all the sepaMandateList where lastUsedDate less than or equals to DEFAULT_LAST_USED_DATE
defaultSepaMandateShouldNotBeFound("lastUsedDate.lessThan=" + DEFAULT_LAST_USED_DATE);
// Get all the sepaMandateList where lastUsedDate less than or equals to UPDATED_LAST_USED_DATE
defaultSepaMandateShouldBeFound("lastUsedDate.lessThan=" + UPDATED_LAST_USED_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("$.[*].grantingDocumentDate").value(hasItem(DEFAULT_GRANTING_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].revokationDocumentDate").value(hasItem(DEFAULT_REVOKATION_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].validFromDate").value(hasItem(DEFAULT_VALID_FROM_DATE.toString())))
.andExpect(jsonPath("$.[*].validUntilDate").value(hasItem(DEFAULT_VALID_UNTIL_DATE.toString())))
.andExpect(jsonPath("$.[*].lastUsedDate").value(hasItem(DEFAULT_LAST_USED_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)
.grantingDocumentDate(UPDATED_GRANTING_DOCUMENT_DATE)
.revokationDocumentDate(UPDATED_REVOKATION_DOCUMENT_DATE)
.validFromDate(UPDATED_VALID_FROM_DATE)
.validUntilDate(UPDATED_VALID_UNTIL_DATE)
.lastUsedDate(UPDATED_LAST_USED_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.getGrantingDocumentDate()).isEqualTo(UPDATED_GRANTING_DOCUMENT_DATE);
assertThat(testSepaMandate.getRevokationDocumentDate()).isEqualTo(UPDATED_REVOKATION_DOCUMENT_DATE);
assertThat(testSepaMandate.getValidFromDate()).isEqualTo(UPDATED_VALID_FROM_DATE);
assertThat(testSepaMandate.getValidUntilDate()).isEqualTo(UPDATED_VALID_UNTIL_DATE);
assertThat(testSepaMandate.getLastUsedDate()).isEqualTo(UPDATED_LAST_USED_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,174 @@
/* 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 { CustomerService } from 'app/entities/customer/customer.service';
import { ICustomer, Customer, CustomerKind, VatRegion } from 'app/shared/model/customer.model';
describe('Service Tests', () => {
describe('Customer Service', () => {
let injector: TestBed;
let service: CustomerService;
let httpMock: HttpTestingController;
let elemDefault: ICustomer;
let currentDate: moment.Moment;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule]
});
injector = getTestBed();
service = injector.get(CustomerService);
httpMock = injector.get(HttpTestingController);
currentDate = moment();
elemDefault = new Customer(
0,
0,
'AAAAAAA',
'AAAAAAA',
CustomerKind.NATURAL,
currentDate,
'AAAAAAA',
'AAAAAAA',
'AAAAAAA',
VatRegion.DOMESTIC,
'AAAAAAA',
'AAAAAAA',
'AAAAAAA',
'AAAAAAA',
'AAAAAAA',
'AAAAAAA'
);
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
birthDate: 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 Customer', async () => {
const returnedFromService = Object.assign(
{
id: 0,
birthDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
birthDate: currentDate
},
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',
kind: 'BBBBBB',
birthDate: currentDate.format(DATE_FORMAT),
birthPlace: 'BBBBBB',
registrationCourt: 'BBBBBB',
registrationNumber: 'BBBBBB',
vatRegion: 'BBBBBB',
vatNumber: 'BBBBBB',
contractualSalutation: 'BBBBBB',
contractualAddress: 'BBBBBB',
billingSalutation: 'BBBBBB',
billingAddress: 'BBBBBB',
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
birthDate: 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 Customer', async () => {
const returnedFromService = Object.assign(
{
reference: 1,
prefix: 'BBBBBB',
name: 'BBBBBB',
kind: 'BBBBBB',
birthDate: currentDate.format(DATE_FORMAT),
birthPlace: 'BBBBBB',
registrationCourt: 'BBBBBB',
registrationNumber: 'BBBBBB',
vatRegion: 'BBBBBB',
vatNumber: 'BBBBBB',
contractualSalutation: 'BBBBBB',
contractualAddress: 'BBBBBB',
billingSalutation: 'BBBBBB',
billingAddress: 'BBBBBB',
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
birthDate: 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 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,152 @@
/* 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, currentDate, 'AAAAAAA');
});
describe('Service methods', async () => {
it('should find an element', async () => {
const returnedFromService = Object.assign(
{
admissionDocumentDate: currentDate.format(DATE_FORMAT),
cancellationDocumentDate: currentDate.format(DATE_FORMAT),
memberFromDate: currentDate.format(DATE_FORMAT),
memberUntilDate: 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,
admissionDocumentDate: currentDate.format(DATE_FORMAT),
cancellationDocumentDate: currentDate.format(DATE_FORMAT),
memberFromDate: currentDate.format(DATE_FORMAT),
memberUntilDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
admissionDocumentDate: currentDate,
cancellationDocumentDate: currentDate,
memberFromDate: currentDate,
memberUntilDate: 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(
{
admissionDocumentDate: currentDate.format(DATE_FORMAT),
cancellationDocumentDate: currentDate.format(DATE_FORMAT),
memberFromDate: currentDate.format(DATE_FORMAT),
memberUntilDate: currentDate.format(DATE_FORMAT),
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
admissionDocumentDate: currentDate,
cancellationDocumentDate: currentDate,
memberFromDate: currentDate,
memberUntilDate: 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(
{
admissionDocumentDate: currentDate.format(DATE_FORMAT),
cancellationDocumentDate: currentDate.format(DATE_FORMAT),
memberFromDate: currentDate.format(DATE_FORMAT),
memberUntilDate: currentDate.format(DATE_FORMAT),
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
admissionDocumentDate: currentDate,
cancellationDocumentDate: currentDate,
memberFromDate: currentDate,
memberUntilDate: 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(
{
grantingDocumentDate: currentDate.format(DATE_FORMAT),
revokationDocumentDate: currentDate.format(DATE_FORMAT),
validFromDate: currentDate.format(DATE_FORMAT),
validUntilDate: currentDate.format(DATE_FORMAT),
lastUsedDate: 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,
grantingDocumentDate: currentDate.format(DATE_FORMAT),
revokationDocumentDate: currentDate.format(DATE_FORMAT),
validFromDate: currentDate.format(DATE_FORMAT),
validUntilDate: currentDate.format(DATE_FORMAT),
lastUsedDate: currentDate.format(DATE_FORMAT)
},
elemDefault
);
const expected = Object.assign(
{
grantingDocumentDate: currentDate,
revokationDocumentDate: currentDate,
validFromDate: currentDate,
validUntilDate: currentDate,
lastUsedDate: 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',
grantingDocumentDate: currentDate.format(DATE_FORMAT),
revokationDocumentDate: currentDate.format(DATE_FORMAT),
validFromDate: currentDate.format(DATE_FORMAT),
validUntilDate: currentDate.format(DATE_FORMAT),
lastUsedDate: currentDate.format(DATE_FORMAT),
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
grantingDocumentDate: currentDate,
revokationDocumentDate: currentDate,
validFromDate: currentDate,
validUntilDate: currentDate,
lastUsedDate: 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',
grantingDocumentDate: currentDate.format(DATE_FORMAT),
revokationDocumentDate: currentDate.format(DATE_FORMAT),
validFromDate: currentDate.format(DATE_FORMAT),
validUntilDate: currentDate.format(DATE_FORMAT),
lastUsedDate: currentDate.format(DATE_FORMAT),
remark: 'BBBBBB'
},
elemDefault
);
const expected = Object.assign(
{
grantingDocumentDate: currentDate,
revokationDocumentDate: currentDate,
validFromDate: currentDate,
validUntilDate: currentDate,
lastUsedDate: 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();
});
});
});