Customer JDL
This commit is contained in:
		@@ -1,616 +0,0 @@
 | 
			
		||||
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.domain.enumeration.AssetAction;
 | 
			
		||||
import org.hostsharing.hsadminng.repository.AssetRepository;
 | 
			
		||||
import org.hostsharing.hsadminng.service.AssetQueryService;
 | 
			
		||||
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.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.assertj.core.api.Assertions.assertThat;
 | 
			
		||||
import static org.hamcrest.Matchers.hasItem;
 | 
			
		||||
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
 | 
			
		||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
 | 
			
		||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 | 
			
		||||
/**
 | 
			
		||||
 * Test class for the AssetResource REST controller.
 | 
			
		||||
 *
 | 
			
		||||
 * @see AssetResource
 | 
			
		||||
 */
 | 
			
		||||
@RunWith(SpringRunner.class)
 | 
			
		||||
@SpringBootTest(classes = HsadminNgApp.class)
 | 
			
		||||
public class AssetResourceIntTest {
 | 
			
		||||
 | 
			
		||||
    private static final LocalDate DEFAULT_DATE = LocalDate.ofEpochDay(0L);
 | 
			
		||||
    private static final LocalDate UPDATED_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_COMMENT = "AAAAAAAAAA";
 | 
			
		||||
    private static final String UPDATED_COMMENT = "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()
 | 
			
		||||
            .date(DEFAULT_DATE)
 | 
			
		||||
            .action(DEFAULT_ACTION)
 | 
			
		||||
            .amount(DEFAULT_AMOUNT)
 | 
			
		||||
            .comment(DEFAULT_COMMENT);
 | 
			
		||||
        // Add required entity
 | 
			
		||||
        Membership membership = MembershipResourceIntTest.createEntity(em);
 | 
			
		||||
        em.persist(membership);
 | 
			
		||||
        em.flush();
 | 
			
		||||
        asset.setMember(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.getDate()).isEqualTo(DEFAULT_DATE);
 | 
			
		||||
        assertThat(testAsset.getAction()).isEqualTo(DEFAULT_ACTION);
 | 
			
		||||
        assertThat(testAsset.getAmount()).isEqualTo(DEFAULT_AMOUNT);
 | 
			
		||||
        assertThat(testAsset.getComment()).isEqualTo(DEFAULT_COMMENT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @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 checkDateIsRequired() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeTest = assetRepository.findAll().size();
 | 
			
		||||
        // set the field null
 | 
			
		||||
        asset.setDate(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("$.[*].date").value(hasItem(DEFAULT_DATE.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].amount").value(hasItem(DEFAULT_AMOUNT.intValue())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT.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("$.date").value(DEFAULT_DATE.toString()))
 | 
			
		||||
            .andExpect(jsonPath("$.action").value(DEFAULT_ACTION.toString()))
 | 
			
		||||
            .andExpect(jsonPath("$.amount").value(DEFAULT_AMOUNT.intValue()))
 | 
			
		||||
            .andExpect(jsonPath("$.comment").value(DEFAULT_COMMENT.toString()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllAssetsByDateIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        assetRepository.saveAndFlush(asset);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where date equals to DEFAULT_DATE
 | 
			
		||||
        defaultAssetShouldBeFound("date.equals=" + DEFAULT_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where date equals to UPDATED_DATE
 | 
			
		||||
        defaultAssetShouldNotBeFound("date.equals=" + UPDATED_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllAssetsByDateIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        assetRepository.saveAndFlush(asset);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where date in DEFAULT_DATE or UPDATED_DATE
 | 
			
		||||
        defaultAssetShouldBeFound("date.in=" + DEFAULT_DATE + "," + UPDATED_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where date equals to UPDATED_DATE
 | 
			
		||||
        defaultAssetShouldNotBeFound("date.in=" + UPDATED_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllAssetsByDateIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        assetRepository.saveAndFlush(asset);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where date is not null
 | 
			
		||||
        defaultAssetShouldBeFound("date.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where date is null
 | 
			
		||||
        defaultAssetShouldNotBeFound("date.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllAssetsByDateIsGreaterThanOrEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        assetRepository.saveAndFlush(asset);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where date greater than or equals to DEFAULT_DATE
 | 
			
		||||
        defaultAssetShouldBeFound("date.greaterOrEqualThan=" + DEFAULT_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where date greater than or equals to UPDATED_DATE
 | 
			
		||||
        defaultAssetShouldNotBeFound("date.greaterOrEqualThan=" + UPDATED_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllAssetsByDateIsLessThanSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        assetRepository.saveAndFlush(asset);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where date less than or equals to DEFAULT_DATE
 | 
			
		||||
        defaultAssetShouldNotBeFound("date.lessThan=" + DEFAULT_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where date less than or equals to UPDATED_DATE
 | 
			
		||||
        defaultAssetShouldBeFound("date.lessThan=" + UPDATED_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 getAllAssetsByCommentIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        assetRepository.saveAndFlush(asset);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where comment equals to DEFAULT_COMMENT
 | 
			
		||||
        defaultAssetShouldBeFound("comment.equals=" + DEFAULT_COMMENT);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where comment equals to UPDATED_COMMENT
 | 
			
		||||
        defaultAssetShouldNotBeFound("comment.equals=" + UPDATED_COMMENT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllAssetsByCommentIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        assetRepository.saveAndFlush(asset);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where comment in DEFAULT_COMMENT or UPDATED_COMMENT
 | 
			
		||||
        defaultAssetShouldBeFound("comment.in=" + DEFAULT_COMMENT + "," + UPDATED_COMMENT);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where comment equals to UPDATED_COMMENT
 | 
			
		||||
        defaultAssetShouldNotBeFound("comment.in=" + UPDATED_COMMENT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllAssetsByCommentIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        assetRepository.saveAndFlush(asset);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where comment is not null
 | 
			
		||||
        defaultAssetShouldBeFound("comment.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where comment is null
 | 
			
		||||
        defaultAssetShouldNotBeFound("comment.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllAssetsByMemberIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        Membership member = MembershipResourceIntTest.createEntity(em);
 | 
			
		||||
        em.persist(member);
 | 
			
		||||
        em.flush();
 | 
			
		||||
        asset.setMember(member);
 | 
			
		||||
        assetRepository.saveAndFlush(asset);
 | 
			
		||||
        Long memberId = member.getId();
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where member equals to memberId
 | 
			
		||||
        defaultAssetShouldBeFound("memberId.equals=" + memberId);
 | 
			
		||||
 | 
			
		||||
        // Get all the assetList where member equals to memberId + 1
 | 
			
		||||
        defaultAssetShouldNotBeFound("memberId.equals=" + (memberId + 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("$.[*].date").value(hasItem(DEFAULT_DATE.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].amount").value(hasItem(DEFAULT_AMOUNT.intValue())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT)));
 | 
			
		||||
 | 
			
		||||
        // 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
 | 
			
		||||
            .date(UPDATED_DATE)
 | 
			
		||||
            .action(UPDATED_ACTION)
 | 
			
		||||
            .amount(UPDATED_AMOUNT)
 | 
			
		||||
            .comment(UPDATED_COMMENT);
 | 
			
		||||
        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.getDate()).isEqualTo(UPDATED_DATE);
 | 
			
		||||
        assertThat(testAsset.getAction()).isEqualTo(UPDATED_ACTION);
 | 
			
		||||
        assertThat(testAsset.getAmount()).isEqualTo(UPDATED_AMOUNT);
 | 
			
		||||
        assertThat(testAsset.getComment()).isEqualTo(UPDATED_COMMENT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,536 +0,0 @@
 | 
			
		||||
package org.hostsharing.hsadminng.web.rest;
 | 
			
		||||
 | 
			
		||||
import org.hostsharing.hsadminng.HsadminNgApp;
 | 
			
		||||
 | 
			
		||||
import org.hostsharing.hsadminng.domain.Contact;
 | 
			
		||||
import org.hostsharing.hsadminng.domain.CustomerContact;
 | 
			
		||||
import org.hostsharing.hsadminng.repository.ContactRepository;
 | 
			
		||||
import org.hostsharing.hsadminng.service.ContactService;
 | 
			
		||||
import org.hostsharing.hsadminng.service.dto.ContactDTO;
 | 
			
		||||
import org.hostsharing.hsadminng.service.mapper.ContactMapper;
 | 
			
		||||
import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator;
 | 
			
		||||
import org.hostsharing.hsadminng.service.dto.ContactCriteria;
 | 
			
		||||
import org.hostsharing.hsadminng.service.ContactQueryService;
 | 
			
		||||
 | 
			
		||||
import org.junit.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.junit.runner.RunWith;
 | 
			
		||||
import org.mockito.MockitoAnnotations;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.boot.test.context.SpringBootTest;
 | 
			
		||||
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
 | 
			
		||||
import org.springframework.http.MediaType;
 | 
			
		||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
 | 
			
		||||
import org.springframework.test.context.junit4.SpringRunner;
 | 
			
		||||
import org.springframework.test.web.servlet.MockMvc;
 | 
			
		||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
import org.springframework.validation.Validator;
 | 
			
		||||
 | 
			
		||||
import javax.persistence.EntityManager;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
 | 
			
		||||
import static org.assertj.core.api.Assertions.assertThat;
 | 
			
		||||
import static org.hamcrest.Matchers.hasItem;
 | 
			
		||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
 | 
			
		||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Test class for the ContactResource REST controller.
 | 
			
		||||
 *
 | 
			
		||||
 * @see ContactResource
 | 
			
		||||
 */
 | 
			
		||||
@RunWith(SpringRunner.class)
 | 
			
		||||
@SpringBootTest(classes = HsadminNgApp.class)
 | 
			
		||||
public class ContactResourceIntTest {
 | 
			
		||||
 | 
			
		||||
    private static final String DEFAULT_FIRST_NAME = "AAAAAAAAAA";
 | 
			
		||||
    private static final String UPDATED_FIRST_NAME = "BBBBBBBBBB";
 | 
			
		||||
 | 
			
		||||
    private static final String DEFAULT_LAST_NAME = "AAAAAAAAAA";
 | 
			
		||||
    private static final String UPDATED_LAST_NAME = "BBBBBBBBBB";
 | 
			
		||||
 | 
			
		||||
    private static final String DEFAULT_EMAIL = "AAAAAAAAAA";
 | 
			
		||||
    private static final String UPDATED_EMAIL = "BBBBBBBBBB";
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ContactRepository contactRepository;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ContactMapper contactMapper;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ContactService contactService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ContactQueryService contactQueryService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private MappingJackson2HttpMessageConverter jacksonMessageConverter;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private PageableHandlerMethodArgumentResolver pageableArgumentResolver;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ExceptionTranslator exceptionTranslator;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private EntityManager em;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private Validator validator;
 | 
			
		||||
 | 
			
		||||
    private MockMvc restContactMockMvc;
 | 
			
		||||
 | 
			
		||||
    private Contact contact;
 | 
			
		||||
 | 
			
		||||
    @Before
 | 
			
		||||
    public void setup() {
 | 
			
		||||
        MockitoAnnotations.initMocks(this);
 | 
			
		||||
        final ContactResource contactResource = new ContactResource(contactService, contactQueryService);
 | 
			
		||||
        this.restContactMockMvc = MockMvcBuilders.standaloneSetup(contactResource)
 | 
			
		||||
            .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 Contact createEntity(EntityManager em) {
 | 
			
		||||
        Contact contact = new Contact()
 | 
			
		||||
            .firstName(DEFAULT_FIRST_NAME)
 | 
			
		||||
            .lastName(DEFAULT_LAST_NAME)
 | 
			
		||||
            .email(DEFAULT_EMAIL);
 | 
			
		||||
        return contact;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Before
 | 
			
		||||
    public void initTest() {
 | 
			
		||||
        contact = createEntity(em);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void createContact() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeCreate = contactRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Create the Contact
 | 
			
		||||
        ContactDTO contactDTO = contactMapper.toDto(contact);
 | 
			
		||||
        restContactMockMvc.perform(post("/api/contacts")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(contactDTO)))
 | 
			
		||||
            .andExpect(status().isCreated());
 | 
			
		||||
 | 
			
		||||
        // Validate the Contact in the database
 | 
			
		||||
        List<Contact> contactList = contactRepository.findAll();
 | 
			
		||||
        assertThat(contactList).hasSize(databaseSizeBeforeCreate + 1);
 | 
			
		||||
        Contact testContact = contactList.get(contactList.size() - 1);
 | 
			
		||||
        assertThat(testContact.getFirstName()).isEqualTo(DEFAULT_FIRST_NAME);
 | 
			
		||||
        assertThat(testContact.getLastName()).isEqualTo(DEFAULT_LAST_NAME);
 | 
			
		||||
        assertThat(testContact.getEmail()).isEqualTo(DEFAULT_EMAIL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void createContactWithExistingId() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeCreate = contactRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Create the Contact with an existing ID
 | 
			
		||||
        contact.setId(1L);
 | 
			
		||||
        ContactDTO contactDTO = contactMapper.toDto(contact);
 | 
			
		||||
 | 
			
		||||
        // An entity with an existing ID cannot be created, so this API call must fail
 | 
			
		||||
        restContactMockMvc.perform(post("/api/contacts")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(contactDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        // Validate the Contact in the database
 | 
			
		||||
        List<Contact> contactList = contactRepository.findAll();
 | 
			
		||||
        assertThat(contactList).hasSize(databaseSizeBeforeCreate);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void checkFirstNameIsRequired() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeTest = contactRepository.findAll().size();
 | 
			
		||||
        // set the field null
 | 
			
		||||
        contact.setFirstName(null);
 | 
			
		||||
 | 
			
		||||
        // Create the Contact, which fails.
 | 
			
		||||
        ContactDTO contactDTO = contactMapper.toDto(contact);
 | 
			
		||||
 | 
			
		||||
        restContactMockMvc.perform(post("/api/contacts")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(contactDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        List<Contact> contactList = contactRepository.findAll();
 | 
			
		||||
        assertThat(contactList).hasSize(databaseSizeBeforeTest);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void checkLastNameIsRequired() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeTest = contactRepository.findAll().size();
 | 
			
		||||
        // set the field null
 | 
			
		||||
        contact.setLastName(null);
 | 
			
		||||
 | 
			
		||||
        // Create the Contact, which fails.
 | 
			
		||||
        ContactDTO contactDTO = contactMapper.toDto(contact);
 | 
			
		||||
 | 
			
		||||
        restContactMockMvc.perform(post("/api/contacts")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(contactDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        List<Contact> contactList = contactRepository.findAll();
 | 
			
		||||
        assertThat(contactList).hasSize(databaseSizeBeforeTest);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void checkEmailIsRequired() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeTest = contactRepository.findAll().size();
 | 
			
		||||
        // set the field null
 | 
			
		||||
        contact.setEmail(null);
 | 
			
		||||
 | 
			
		||||
        // Create the Contact, which fails.
 | 
			
		||||
        ContactDTO contactDTO = contactMapper.toDto(contact);
 | 
			
		||||
 | 
			
		||||
        restContactMockMvc.perform(post("/api/contacts")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(contactDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        List<Contact> contactList = contactRepository.findAll();
 | 
			
		||||
        assertThat(contactList).hasSize(databaseSizeBeforeTest);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllContacts() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList
 | 
			
		||||
        restContactMockMvc.perform(get("/api/contacts?sort=id,desc"))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].id").value(hasItem(contact.getId().intValue())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].firstName").value(hasItem(DEFAULT_FIRST_NAME.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].lastName").value(hasItem(DEFAULT_LAST_NAME.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].email").value(hasItem(DEFAULT_EMAIL.toString())));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getContact() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        // Get the contact
 | 
			
		||||
        restContactMockMvc.perform(get("/api/contacts/{id}", contact.getId()))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(jsonPath("$.id").value(contact.getId().intValue()))
 | 
			
		||||
            .andExpect(jsonPath("$.firstName").value(DEFAULT_FIRST_NAME.toString()))
 | 
			
		||||
            .andExpect(jsonPath("$.lastName").value(DEFAULT_LAST_NAME.toString()))
 | 
			
		||||
            .andExpect(jsonPath("$.email").value(DEFAULT_EMAIL.toString()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllContactsByFirstNameIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where firstName equals to DEFAULT_FIRST_NAME
 | 
			
		||||
        defaultContactShouldBeFound("firstName.equals=" + DEFAULT_FIRST_NAME);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where firstName equals to UPDATED_FIRST_NAME
 | 
			
		||||
        defaultContactShouldNotBeFound("firstName.equals=" + UPDATED_FIRST_NAME);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllContactsByFirstNameIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where firstName in DEFAULT_FIRST_NAME or UPDATED_FIRST_NAME
 | 
			
		||||
        defaultContactShouldBeFound("firstName.in=" + DEFAULT_FIRST_NAME + "," + UPDATED_FIRST_NAME);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where firstName equals to UPDATED_FIRST_NAME
 | 
			
		||||
        defaultContactShouldNotBeFound("firstName.in=" + UPDATED_FIRST_NAME);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllContactsByFirstNameIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where firstName is not null
 | 
			
		||||
        defaultContactShouldBeFound("firstName.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where firstName is null
 | 
			
		||||
        defaultContactShouldNotBeFound("firstName.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllContactsByLastNameIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where lastName equals to DEFAULT_LAST_NAME
 | 
			
		||||
        defaultContactShouldBeFound("lastName.equals=" + DEFAULT_LAST_NAME);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where lastName equals to UPDATED_LAST_NAME
 | 
			
		||||
        defaultContactShouldNotBeFound("lastName.equals=" + UPDATED_LAST_NAME);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllContactsByLastNameIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where lastName in DEFAULT_LAST_NAME or UPDATED_LAST_NAME
 | 
			
		||||
        defaultContactShouldBeFound("lastName.in=" + DEFAULT_LAST_NAME + "," + UPDATED_LAST_NAME);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where lastName equals to UPDATED_LAST_NAME
 | 
			
		||||
        defaultContactShouldNotBeFound("lastName.in=" + UPDATED_LAST_NAME);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllContactsByLastNameIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where lastName is not null
 | 
			
		||||
        defaultContactShouldBeFound("lastName.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where lastName is null
 | 
			
		||||
        defaultContactShouldNotBeFound("lastName.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllContactsByEmailIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where email equals to DEFAULT_EMAIL
 | 
			
		||||
        defaultContactShouldBeFound("email.equals=" + DEFAULT_EMAIL);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where email equals to UPDATED_EMAIL
 | 
			
		||||
        defaultContactShouldNotBeFound("email.equals=" + UPDATED_EMAIL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllContactsByEmailIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where email in DEFAULT_EMAIL or UPDATED_EMAIL
 | 
			
		||||
        defaultContactShouldBeFound("email.in=" + DEFAULT_EMAIL + "," + UPDATED_EMAIL);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where email equals to UPDATED_EMAIL
 | 
			
		||||
        defaultContactShouldNotBeFound("email.in=" + UPDATED_EMAIL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllContactsByEmailIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where email is not null
 | 
			
		||||
        defaultContactShouldBeFound("email.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where email is null
 | 
			
		||||
        defaultContactShouldNotBeFound("email.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllContactsByRoleIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        CustomerContact role = CustomerContactResourceIntTest.createEntity(em);
 | 
			
		||||
        em.persist(role);
 | 
			
		||||
        em.flush();
 | 
			
		||||
        contact.addRole(role);
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
        Long roleId = role.getId();
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where role equals to roleId
 | 
			
		||||
        defaultContactShouldBeFound("roleId.equals=" + roleId);
 | 
			
		||||
 | 
			
		||||
        // Get all the contactList where role equals to roleId + 1
 | 
			
		||||
        defaultContactShouldNotBeFound("roleId.equals=" + (roleId + 1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Executes the search, and checks that the default entity is returned
 | 
			
		||||
     */
 | 
			
		||||
    private void defaultContactShouldBeFound(String filter) throws Exception {
 | 
			
		||||
        restContactMockMvc.perform(get("/api/contacts?sort=id,desc&" + filter))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].id").value(hasItem(contact.getId().intValue())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].firstName").value(hasItem(DEFAULT_FIRST_NAME)))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].lastName").value(hasItem(DEFAULT_LAST_NAME)))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].email").value(hasItem(DEFAULT_EMAIL)));
 | 
			
		||||
 | 
			
		||||
        // Check, that the count call also returns 1
 | 
			
		||||
        restContactMockMvc.perform(get("/api/contacts/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 defaultContactShouldNotBeFound(String filter) throws Exception {
 | 
			
		||||
        restContactMockMvc.perform(get("/api/contacts?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
 | 
			
		||||
        restContactMockMvc.perform(get("/api/contacts/count?sort=id,desc&" + filter))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(content().string("0"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getNonExistingContact() throws Exception {
 | 
			
		||||
        // Get the contact
 | 
			
		||||
        restContactMockMvc.perform(get("/api/contacts/{id}", Long.MAX_VALUE))
 | 
			
		||||
            .andExpect(status().isNotFound());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void updateContact() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        int databaseSizeBeforeUpdate = contactRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Update the contact
 | 
			
		||||
        Contact updatedContact = contactRepository.findById(contact.getId()).get();
 | 
			
		||||
        // Disconnect from session so that the updates on updatedContact are not directly saved in db
 | 
			
		||||
        em.detach(updatedContact);
 | 
			
		||||
        updatedContact
 | 
			
		||||
            .firstName(UPDATED_FIRST_NAME)
 | 
			
		||||
            .lastName(UPDATED_LAST_NAME)
 | 
			
		||||
            .email(UPDATED_EMAIL);
 | 
			
		||||
        ContactDTO contactDTO = contactMapper.toDto(updatedContact);
 | 
			
		||||
 | 
			
		||||
        restContactMockMvc.perform(put("/api/contacts")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(contactDTO)))
 | 
			
		||||
            .andExpect(status().isOk());
 | 
			
		||||
 | 
			
		||||
        // Validate the Contact in the database
 | 
			
		||||
        List<Contact> contactList = contactRepository.findAll();
 | 
			
		||||
        assertThat(contactList).hasSize(databaseSizeBeforeUpdate);
 | 
			
		||||
        Contact testContact = contactList.get(contactList.size() - 1);
 | 
			
		||||
        assertThat(testContact.getFirstName()).isEqualTo(UPDATED_FIRST_NAME);
 | 
			
		||||
        assertThat(testContact.getLastName()).isEqualTo(UPDATED_LAST_NAME);
 | 
			
		||||
        assertThat(testContact.getEmail()).isEqualTo(UPDATED_EMAIL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void updateNonExistingContact() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeUpdate = contactRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Create the Contact
 | 
			
		||||
        ContactDTO contactDTO = contactMapper.toDto(contact);
 | 
			
		||||
 | 
			
		||||
        // If the entity doesn't have an ID, it will throw BadRequestAlertException
 | 
			
		||||
        restContactMockMvc.perform(put("/api/contacts")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(contactDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        // Validate the Contact in the database
 | 
			
		||||
        List<Contact> contactList = contactRepository.findAll();
 | 
			
		||||
        assertThat(contactList).hasSize(databaseSizeBeforeUpdate);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void deleteContact() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        contactRepository.saveAndFlush(contact);
 | 
			
		||||
 | 
			
		||||
        int databaseSizeBeforeDelete = contactRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Delete the contact
 | 
			
		||||
        restContactMockMvc.perform(delete("/api/contacts/{id}", contact.getId())
 | 
			
		||||
            .accept(TestUtil.APPLICATION_JSON_UTF8))
 | 
			
		||||
            .andExpect(status().isOk());
 | 
			
		||||
 | 
			
		||||
        // Validate the database is empty
 | 
			
		||||
        List<Contact> contactList = contactRepository.findAll();
 | 
			
		||||
        assertThat(contactList).hasSize(databaseSizeBeforeDelete - 1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void equalsVerifier() throws Exception {
 | 
			
		||||
        TestUtil.equalsVerifier(Contact.class);
 | 
			
		||||
        Contact contact1 = new Contact();
 | 
			
		||||
        contact1.setId(1L);
 | 
			
		||||
        Contact contact2 = new Contact();
 | 
			
		||||
        contact2.setId(contact1.getId());
 | 
			
		||||
        assertThat(contact1).isEqualTo(contact2);
 | 
			
		||||
        contact2.setId(2L);
 | 
			
		||||
        assertThat(contact1).isNotEqualTo(contact2);
 | 
			
		||||
        contact1.setId(null);
 | 
			
		||||
        assertThat(contact1).isNotEqualTo(contact2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void dtoEqualsVerifier() throws Exception {
 | 
			
		||||
        TestUtil.equalsVerifier(ContactDTO.class);
 | 
			
		||||
        ContactDTO contactDTO1 = new ContactDTO();
 | 
			
		||||
        contactDTO1.setId(1L);
 | 
			
		||||
        ContactDTO contactDTO2 = new ContactDTO();
 | 
			
		||||
        assertThat(contactDTO1).isNotEqualTo(contactDTO2);
 | 
			
		||||
        contactDTO2.setId(contactDTO1.getId());
 | 
			
		||||
        assertThat(contactDTO1).isEqualTo(contactDTO2);
 | 
			
		||||
        contactDTO2.setId(2L);
 | 
			
		||||
        assertThat(contactDTO1).isNotEqualTo(contactDTO2);
 | 
			
		||||
        contactDTO1.setId(null);
 | 
			
		||||
        assertThat(contactDTO1).isNotEqualTo(contactDTO2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void testEntityFromId() {
 | 
			
		||||
        assertThat(contactMapper.fromId(42L).getId()).isEqualTo(42);
 | 
			
		||||
        assertThat(contactMapper.fromId(null)).isNull();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,431 +0,0 @@
 | 
			
		||||
package org.hostsharing.hsadminng.web.rest;
 | 
			
		||||
 | 
			
		||||
import org.hostsharing.hsadminng.HsadminNgApp;
 | 
			
		||||
 | 
			
		||||
import org.hostsharing.hsadminng.domain.CustomerContact;
 | 
			
		||||
import org.hostsharing.hsadminng.domain.Contact;
 | 
			
		||||
import org.hostsharing.hsadminng.domain.Customer;
 | 
			
		||||
import org.hostsharing.hsadminng.repository.CustomerContactRepository;
 | 
			
		||||
import org.hostsharing.hsadminng.service.CustomerContactService;
 | 
			
		||||
import org.hostsharing.hsadminng.service.dto.CustomerContactDTO;
 | 
			
		||||
import org.hostsharing.hsadminng.service.mapper.CustomerContactMapper;
 | 
			
		||||
import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator;
 | 
			
		||||
import org.hostsharing.hsadminng.service.dto.CustomerContactCriteria;
 | 
			
		||||
import org.hostsharing.hsadminng.service.CustomerContactQueryService;
 | 
			
		||||
 | 
			
		||||
import org.junit.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.junit.runner.RunWith;
 | 
			
		||||
import org.mockito.MockitoAnnotations;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.boot.test.context.SpringBootTest;
 | 
			
		||||
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
 | 
			
		||||
import org.springframework.http.MediaType;
 | 
			
		||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
 | 
			
		||||
import org.springframework.test.context.junit4.SpringRunner;
 | 
			
		||||
import org.springframework.test.web.servlet.MockMvc;
 | 
			
		||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
import org.springframework.validation.Validator;
 | 
			
		||||
 | 
			
		||||
import javax.persistence.EntityManager;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
 | 
			
		||||
import static org.assertj.core.api.Assertions.assertThat;
 | 
			
		||||
import static org.hamcrest.Matchers.hasItem;
 | 
			
		||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
 | 
			
		||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 | 
			
		||||
 | 
			
		||||
import org.hostsharing.hsadminng.domain.enumeration.CustomerContactRole;
 | 
			
		||||
/**
 | 
			
		||||
 * Test class for the CustomerContactResource REST controller.
 | 
			
		||||
 *
 | 
			
		||||
 * @see CustomerContactResource
 | 
			
		||||
 */
 | 
			
		||||
@RunWith(SpringRunner.class)
 | 
			
		||||
@SpringBootTest(classes = HsadminNgApp.class)
 | 
			
		||||
public class CustomerContactResourceIntTest {
 | 
			
		||||
 | 
			
		||||
    private static final CustomerContactRole DEFAULT_ROLE = CustomerContactRole.CONTRACTUAL;
 | 
			
		||||
    private static final CustomerContactRole UPDATED_ROLE = CustomerContactRole.TECHNICAL;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private CustomerContactRepository customerContactRepository;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private CustomerContactMapper customerContactMapper;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private CustomerContactService customerContactService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private CustomerContactQueryService customerContactQueryService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private MappingJackson2HttpMessageConverter jacksonMessageConverter;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private PageableHandlerMethodArgumentResolver pageableArgumentResolver;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ExceptionTranslator exceptionTranslator;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private EntityManager em;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private Validator validator;
 | 
			
		||||
 | 
			
		||||
    private MockMvc restCustomerContactMockMvc;
 | 
			
		||||
 | 
			
		||||
    private CustomerContact customerContact;
 | 
			
		||||
 | 
			
		||||
    @Before
 | 
			
		||||
    public void setup() {
 | 
			
		||||
        MockitoAnnotations.initMocks(this);
 | 
			
		||||
        final CustomerContactResource customerContactResource = new CustomerContactResource(customerContactService, customerContactQueryService);
 | 
			
		||||
        this.restCustomerContactMockMvc = MockMvcBuilders.standaloneSetup(customerContactResource)
 | 
			
		||||
            .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 CustomerContact createEntity(EntityManager em) {
 | 
			
		||||
        CustomerContact customerContact = new CustomerContact()
 | 
			
		||||
            .role(DEFAULT_ROLE);
 | 
			
		||||
        // Add required entity
 | 
			
		||||
        Contact contact = ContactResourceIntTest.createEntity(em);
 | 
			
		||||
        em.persist(contact);
 | 
			
		||||
        em.flush();
 | 
			
		||||
        customerContact.setContact(contact);
 | 
			
		||||
        // Add required entity
 | 
			
		||||
        Customer customer = CustomerResourceIntTest.createEntity(em);
 | 
			
		||||
        em.persist(customer);
 | 
			
		||||
        em.flush();
 | 
			
		||||
        customerContact.setCustomer(customer);
 | 
			
		||||
        return customerContact;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Before
 | 
			
		||||
    public void initTest() {
 | 
			
		||||
        customerContact = createEntity(em);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void createCustomerContact() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeCreate = customerContactRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Create the CustomerContact
 | 
			
		||||
        CustomerContactDTO customerContactDTO = customerContactMapper.toDto(customerContact);
 | 
			
		||||
        restCustomerContactMockMvc.perform(post("/api/customer-contacts")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerContactDTO)))
 | 
			
		||||
            .andExpect(status().isCreated());
 | 
			
		||||
 | 
			
		||||
        // Validate the CustomerContact in the database
 | 
			
		||||
        List<CustomerContact> customerContactList = customerContactRepository.findAll();
 | 
			
		||||
        assertThat(customerContactList).hasSize(databaseSizeBeforeCreate + 1);
 | 
			
		||||
        CustomerContact testCustomerContact = customerContactList.get(customerContactList.size() - 1);
 | 
			
		||||
        assertThat(testCustomerContact.getRole()).isEqualTo(DEFAULT_ROLE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void createCustomerContactWithExistingId() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeCreate = customerContactRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Create the CustomerContact with an existing ID
 | 
			
		||||
        customerContact.setId(1L);
 | 
			
		||||
        CustomerContactDTO customerContactDTO = customerContactMapper.toDto(customerContact);
 | 
			
		||||
 | 
			
		||||
        // An entity with an existing ID cannot be created, so this API call must fail
 | 
			
		||||
        restCustomerContactMockMvc.perform(post("/api/customer-contacts")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerContactDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        // Validate the CustomerContact in the database
 | 
			
		||||
        List<CustomerContact> customerContactList = customerContactRepository.findAll();
 | 
			
		||||
        assertThat(customerContactList).hasSize(databaseSizeBeforeCreate);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void checkRoleIsRequired() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeTest = customerContactRepository.findAll().size();
 | 
			
		||||
        // set the field null
 | 
			
		||||
        customerContact.setRole(null);
 | 
			
		||||
 | 
			
		||||
        // Create the CustomerContact, which fails.
 | 
			
		||||
        CustomerContactDTO customerContactDTO = customerContactMapper.toDto(customerContact);
 | 
			
		||||
 | 
			
		||||
        restCustomerContactMockMvc.perform(post("/api/customer-contacts")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerContactDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        List<CustomerContact> customerContactList = customerContactRepository.findAll();
 | 
			
		||||
        assertThat(customerContactList).hasSize(databaseSizeBeforeTest);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomerContacts() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerContactRepository.saveAndFlush(customerContact);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerContactList
 | 
			
		||||
        restCustomerContactMockMvc.perform(get("/api/customer-contacts?sort=id,desc"))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].id").value(hasItem(customerContact.getId().intValue())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].role").value(hasItem(DEFAULT_ROLE.toString())));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getCustomerContact() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerContactRepository.saveAndFlush(customerContact);
 | 
			
		||||
 | 
			
		||||
        // Get the customerContact
 | 
			
		||||
        restCustomerContactMockMvc.perform(get("/api/customer-contacts/{id}", customerContact.getId()))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(jsonPath("$.id").value(customerContact.getId().intValue()))
 | 
			
		||||
            .andExpect(jsonPath("$.role").value(DEFAULT_ROLE.toString()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomerContactsByRoleIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerContactRepository.saveAndFlush(customerContact);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerContactList where role equals to DEFAULT_ROLE
 | 
			
		||||
        defaultCustomerContactShouldBeFound("role.equals=" + DEFAULT_ROLE);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerContactList where role equals to UPDATED_ROLE
 | 
			
		||||
        defaultCustomerContactShouldNotBeFound("role.equals=" + UPDATED_ROLE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomerContactsByRoleIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerContactRepository.saveAndFlush(customerContact);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerContactList where role in DEFAULT_ROLE or UPDATED_ROLE
 | 
			
		||||
        defaultCustomerContactShouldBeFound("role.in=" + DEFAULT_ROLE + "," + UPDATED_ROLE);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerContactList where role equals to UPDATED_ROLE
 | 
			
		||||
        defaultCustomerContactShouldNotBeFound("role.in=" + UPDATED_ROLE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomerContactsByRoleIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerContactRepository.saveAndFlush(customerContact);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerContactList where role is not null
 | 
			
		||||
        defaultCustomerContactShouldBeFound("role.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the customerContactList where role is null
 | 
			
		||||
        defaultCustomerContactShouldNotBeFound("role.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomerContactsByContactIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        Contact contact = ContactResourceIntTest.createEntity(em);
 | 
			
		||||
        em.persist(contact);
 | 
			
		||||
        em.flush();
 | 
			
		||||
        customerContact.setContact(contact);
 | 
			
		||||
        customerContactRepository.saveAndFlush(customerContact);
 | 
			
		||||
        Long contactId = contact.getId();
 | 
			
		||||
 | 
			
		||||
        // Get all the customerContactList where contact equals to contactId
 | 
			
		||||
        defaultCustomerContactShouldBeFound("contactId.equals=" + contactId);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerContactList where contact equals to contactId + 1
 | 
			
		||||
        defaultCustomerContactShouldNotBeFound("contactId.equals=" + (contactId + 1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomerContactsByCustomerIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        Customer customer = CustomerResourceIntTest.createEntity(em);
 | 
			
		||||
        em.persist(customer);
 | 
			
		||||
        em.flush();
 | 
			
		||||
        customerContact.setCustomer(customer);
 | 
			
		||||
        customerContactRepository.saveAndFlush(customerContact);
 | 
			
		||||
        Long customerId = customer.getId();
 | 
			
		||||
 | 
			
		||||
        // Get all the customerContactList where customer equals to customerId
 | 
			
		||||
        defaultCustomerContactShouldBeFound("customerId.equals=" + customerId);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerContactList where customer equals to customerId + 1
 | 
			
		||||
        defaultCustomerContactShouldNotBeFound("customerId.equals=" + (customerId + 1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Executes the search, and checks that the default entity is returned
 | 
			
		||||
     */
 | 
			
		||||
    private void defaultCustomerContactShouldBeFound(String filter) throws Exception {
 | 
			
		||||
        restCustomerContactMockMvc.perform(get("/api/customer-contacts?sort=id,desc&" + filter))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].id").value(hasItem(customerContact.getId().intValue())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].role").value(hasItem(DEFAULT_ROLE.toString())));
 | 
			
		||||
 | 
			
		||||
        // Check, that the count call also returns 1
 | 
			
		||||
        restCustomerContactMockMvc.perform(get("/api/customer-contacts/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 defaultCustomerContactShouldNotBeFound(String filter) throws Exception {
 | 
			
		||||
        restCustomerContactMockMvc.perform(get("/api/customer-contacts?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
 | 
			
		||||
        restCustomerContactMockMvc.perform(get("/api/customer-contacts/count?sort=id,desc&" + filter))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(content().string("0"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getNonExistingCustomerContact() throws Exception {
 | 
			
		||||
        // Get the customerContact
 | 
			
		||||
        restCustomerContactMockMvc.perform(get("/api/customer-contacts/{id}", Long.MAX_VALUE))
 | 
			
		||||
            .andExpect(status().isNotFound());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void updateCustomerContact() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerContactRepository.saveAndFlush(customerContact);
 | 
			
		||||
 | 
			
		||||
        int databaseSizeBeforeUpdate = customerContactRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Update the customerContact
 | 
			
		||||
        CustomerContact updatedCustomerContact = customerContactRepository.findById(customerContact.getId()).get();
 | 
			
		||||
        // Disconnect from session so that the updates on updatedCustomerContact are not directly saved in db
 | 
			
		||||
        em.detach(updatedCustomerContact);
 | 
			
		||||
        updatedCustomerContact
 | 
			
		||||
            .role(UPDATED_ROLE);
 | 
			
		||||
        CustomerContactDTO customerContactDTO = customerContactMapper.toDto(updatedCustomerContact);
 | 
			
		||||
 | 
			
		||||
        restCustomerContactMockMvc.perform(put("/api/customer-contacts")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerContactDTO)))
 | 
			
		||||
            .andExpect(status().isOk());
 | 
			
		||||
 | 
			
		||||
        // Validate the CustomerContact in the database
 | 
			
		||||
        List<CustomerContact> customerContactList = customerContactRepository.findAll();
 | 
			
		||||
        assertThat(customerContactList).hasSize(databaseSizeBeforeUpdate);
 | 
			
		||||
        CustomerContact testCustomerContact = customerContactList.get(customerContactList.size() - 1);
 | 
			
		||||
        assertThat(testCustomerContact.getRole()).isEqualTo(UPDATED_ROLE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void updateNonExistingCustomerContact() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeUpdate = customerContactRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Create the CustomerContact
 | 
			
		||||
        CustomerContactDTO customerContactDTO = customerContactMapper.toDto(customerContact);
 | 
			
		||||
 | 
			
		||||
        // If the entity doesn't have an ID, it will throw BadRequestAlertException
 | 
			
		||||
        restCustomerContactMockMvc.perform(put("/api/customer-contacts")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerContactDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        // Validate the CustomerContact in the database
 | 
			
		||||
        List<CustomerContact> customerContactList = customerContactRepository.findAll();
 | 
			
		||||
        assertThat(customerContactList).hasSize(databaseSizeBeforeUpdate);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void deleteCustomerContact() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerContactRepository.saveAndFlush(customerContact);
 | 
			
		||||
 | 
			
		||||
        int databaseSizeBeforeDelete = customerContactRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Delete the customerContact
 | 
			
		||||
        restCustomerContactMockMvc.perform(delete("/api/customer-contacts/{id}", customerContact.getId())
 | 
			
		||||
            .accept(TestUtil.APPLICATION_JSON_UTF8))
 | 
			
		||||
            .andExpect(status().isOk());
 | 
			
		||||
 | 
			
		||||
        // Validate the database is empty
 | 
			
		||||
        List<CustomerContact> customerContactList = customerContactRepository.findAll();
 | 
			
		||||
        assertThat(customerContactList).hasSize(databaseSizeBeforeDelete - 1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void equalsVerifier() throws Exception {
 | 
			
		||||
        TestUtil.equalsVerifier(CustomerContact.class);
 | 
			
		||||
        CustomerContact customerContact1 = new CustomerContact();
 | 
			
		||||
        customerContact1.setId(1L);
 | 
			
		||||
        CustomerContact customerContact2 = new CustomerContact();
 | 
			
		||||
        customerContact2.setId(customerContact1.getId());
 | 
			
		||||
        assertThat(customerContact1).isEqualTo(customerContact2);
 | 
			
		||||
        customerContact2.setId(2L);
 | 
			
		||||
        assertThat(customerContact1).isNotEqualTo(customerContact2);
 | 
			
		||||
        customerContact1.setId(null);
 | 
			
		||||
        assertThat(customerContact1).isNotEqualTo(customerContact2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void dtoEqualsVerifier() throws Exception {
 | 
			
		||||
        TestUtil.equalsVerifier(CustomerContactDTO.class);
 | 
			
		||||
        CustomerContactDTO customerContactDTO1 = new CustomerContactDTO();
 | 
			
		||||
        customerContactDTO1.setId(1L);
 | 
			
		||||
        CustomerContactDTO customerContactDTO2 = new CustomerContactDTO();
 | 
			
		||||
        assertThat(customerContactDTO1).isNotEqualTo(customerContactDTO2);
 | 
			
		||||
        customerContactDTO2.setId(customerContactDTO1.getId());
 | 
			
		||||
        assertThat(customerContactDTO1).isEqualTo(customerContactDTO2);
 | 
			
		||||
        customerContactDTO2.setId(2L);
 | 
			
		||||
        assertThat(customerContactDTO1).isNotEqualTo(customerContactDTO2);
 | 
			
		||||
        customerContactDTO1.setId(null);
 | 
			
		||||
        assertThat(customerContactDTO1).isNotEqualTo(customerContactDTO2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void testEntityFromId() {
 | 
			
		||||
        assertThat(customerContactMapper.fromId(42L).getId()).isEqualTo(42);
 | 
			
		||||
        assertThat(customerContactMapper.fromId(null)).isNull();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,794 +0,0 @@
 | 
			
		||||
package org.hostsharing.hsadminng.web.rest;
 | 
			
		||||
 | 
			
		||||
import org.hostsharing.hsadminng.HsadminNgApp;
 | 
			
		||||
import org.hostsharing.hsadminng.domain.Customer;
 | 
			
		||||
import org.hostsharing.hsadminng.domain.CustomerContact;
 | 
			
		||||
import org.hostsharing.hsadminng.domain.Membership;
 | 
			
		||||
import org.hostsharing.hsadminng.repository.CustomerRepository;
 | 
			
		||||
import org.hostsharing.hsadminng.service.CustomerQueryService;
 | 
			
		||||
import org.hostsharing.hsadminng.service.CustomerService;
 | 
			
		||||
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
 | 
			
		||||
import org.hostsharing.hsadminng.service.mapper.CustomerMapper;
 | 
			
		||||
import org.hostsharing.hsadminng.web.rest.errors.ExceptionTranslator;
 | 
			
		||||
import org.junit.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
import org.junit.runner.RunWith;
 | 
			
		||||
import org.mockito.MockitoAnnotations;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.boot.test.context.SpringBootTest;
 | 
			
		||||
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
 | 
			
		||||
import org.springframework.http.MediaType;
 | 
			
		||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
 | 
			
		||||
import org.springframework.test.context.junit4.SpringRunner;
 | 
			
		||||
import org.springframework.test.web.servlet.MockMvc;
 | 
			
		||||
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
 | 
			
		||||
import org.springframework.transaction.annotation.Transactional;
 | 
			
		||||
import org.springframework.validation.Validator;
 | 
			
		||||
 | 
			
		||||
import javax.persistence.EntityManager;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static org.assertj.core.api.Assertions.assertThat;
 | 
			
		||||
import static org.hamcrest.Matchers.hasItem;
 | 
			
		||||
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
 | 
			
		||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
 | 
			
		||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Test class for the CustomerResource REST controller.
 | 
			
		||||
 *
 | 
			
		||||
 * @see CustomerResource
 | 
			
		||||
 */
 | 
			
		||||
@RunWith(SpringRunner.class)
 | 
			
		||||
@SpringBootTest(classes = HsadminNgApp.class)
 | 
			
		||||
public class CustomerResourceIntTest {
 | 
			
		||||
 | 
			
		||||
    private static final Integer DEFAULT_NUMBER = 10000;
 | 
			
		||||
    private static final Integer UPDATED_NUMBER = 10001;
 | 
			
		||||
 | 
			
		||||
    private static final String DEFAULT_PREFIX = "lzv";
 | 
			
		||||
    private static final String UPDATED_PREFIX = "zf";
 | 
			
		||||
 | 
			
		||||
    private static final String DEFAULT_NAME = "AAAAAAAAAA";
 | 
			
		||||
    private static final String UPDATED_NAME = "BBBBBBBBBB";
 | 
			
		||||
 | 
			
		||||
    private static final String DEFAULT_CONTRACTUAL_ADDRESS = "AAAAAAAAAA";
 | 
			
		||||
    private static final String UPDATED_CONTRACTUAL_ADDRESS = "BBBBBBBBBB";
 | 
			
		||||
 | 
			
		||||
    private static final String DEFAULT_CONTRACTUAL_SALUTATION = "AAAAAAAAAA";
 | 
			
		||||
    private static final String UPDATED_CONTRACTUAL_SALUTATION = "BBBBBBBBBB";
 | 
			
		||||
 | 
			
		||||
    private static final String DEFAULT_BILLING_ADDRESS = "AAAAAAAAAA";
 | 
			
		||||
    private static final String UPDATED_BILLING_ADDRESS = "BBBBBBBBBB";
 | 
			
		||||
 | 
			
		||||
    private static final String DEFAULT_BILLING_SALUTATION = "AAAAAAAAAA";
 | 
			
		||||
    private static final String UPDATED_BILLING_SALUTATION = "BBBBBBBBBB";
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private CustomerRepository customerRepository;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private CustomerMapper customerMapper;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private CustomerService customerService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private CustomerQueryService customerQueryService;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private MappingJackson2HttpMessageConverter jacksonMessageConverter;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private PageableHandlerMethodArgumentResolver pageableArgumentResolver;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ExceptionTranslator exceptionTranslator;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private EntityManager em;
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private Validator validator;
 | 
			
		||||
 | 
			
		||||
    private MockMvc restCustomerMockMvc;
 | 
			
		||||
 | 
			
		||||
    private Customer customer;
 | 
			
		||||
 | 
			
		||||
    @Before
 | 
			
		||||
    public void setup() {
 | 
			
		||||
        MockitoAnnotations.initMocks(this);
 | 
			
		||||
        final CustomerResource customerResource = new CustomerResource(customerService, customerQueryService);
 | 
			
		||||
        this.restCustomerMockMvc = MockMvcBuilders.standaloneSetup(customerResource)
 | 
			
		||||
            .setCustomArgumentResolvers(pageableArgumentResolver)
 | 
			
		||||
            .setControllerAdvice(exceptionTranslator)
 | 
			
		||||
            .setConversionService(createFormattingConversionService())
 | 
			
		||||
            .setMessageConverters(jacksonMessageConverter)
 | 
			
		||||
            .setValidator(validator).build();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Create an entity for this test.
 | 
			
		||||
     *
 | 
			
		||||
     * This is a static method, as tests for other entities might also need it,
 | 
			
		||||
     * if they test an entity which requires the current entity.
 | 
			
		||||
     */
 | 
			
		||||
    public static Customer createEntity(EntityManager em) {
 | 
			
		||||
        Customer customer = new Customer()
 | 
			
		||||
            .number(DEFAULT_NUMBER)
 | 
			
		||||
            .prefix(DEFAULT_PREFIX)
 | 
			
		||||
            .name(DEFAULT_NAME)
 | 
			
		||||
            .contractualAddress(DEFAULT_CONTRACTUAL_ADDRESS)
 | 
			
		||||
            .contractualSalutation(DEFAULT_CONTRACTUAL_SALUTATION)
 | 
			
		||||
            .billingAddress(DEFAULT_BILLING_ADDRESS)
 | 
			
		||||
            .billingSalutation(DEFAULT_BILLING_SALUTATION);
 | 
			
		||||
        return customer;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Before
 | 
			
		||||
    public void initTest() {
 | 
			
		||||
        customer = createEntity(em);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void createCustomer() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeCreate = customerRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Create the Customer
 | 
			
		||||
        CustomerDTO customerDTO = customerMapper.toDto(customer);
 | 
			
		||||
        restCustomerMockMvc.perform(post("/api/customers")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerDTO)))
 | 
			
		||||
            .andExpect(status().isCreated());
 | 
			
		||||
 | 
			
		||||
        // Validate the Customer in the database
 | 
			
		||||
        List<Customer> customerList = customerRepository.findAll();
 | 
			
		||||
        assertThat(customerList).hasSize(databaseSizeBeforeCreate + 1);
 | 
			
		||||
        Customer testCustomer = customerList.get(customerList.size() - 1);
 | 
			
		||||
        assertThat(testCustomer.getNumber()).isEqualTo(DEFAULT_NUMBER);
 | 
			
		||||
        assertThat(testCustomer.getPrefix()).isEqualTo(DEFAULT_PREFIX);
 | 
			
		||||
        assertThat(testCustomer.getName()).isEqualTo(DEFAULT_NAME);
 | 
			
		||||
        assertThat(testCustomer.getContractualAddress()).isEqualTo(DEFAULT_CONTRACTUAL_ADDRESS);
 | 
			
		||||
        assertThat(testCustomer.getContractualSalutation()).isEqualTo(DEFAULT_CONTRACTUAL_SALUTATION);
 | 
			
		||||
        assertThat(testCustomer.getBillingAddress()).isEqualTo(DEFAULT_BILLING_ADDRESS);
 | 
			
		||||
        assertThat(testCustomer.getBillingSalutation()).isEqualTo(DEFAULT_BILLING_SALUTATION);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void createCustomerWithExistingId() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeCreate = customerRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Create the Customer with an existing ID
 | 
			
		||||
        customer.setId(1L);
 | 
			
		||||
        CustomerDTO customerDTO = customerMapper.toDto(customer);
 | 
			
		||||
 | 
			
		||||
        // An entity with an existing ID cannot be created, so this API call must fail
 | 
			
		||||
        restCustomerMockMvc.perform(post("/api/customers")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        // Validate the Customer in the database
 | 
			
		||||
        List<Customer> customerList = customerRepository.findAll();
 | 
			
		||||
        assertThat(customerList).hasSize(databaseSizeBeforeCreate);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void checkNumberIsRequired() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeTest = customerRepository.findAll().size();
 | 
			
		||||
        // set the field null
 | 
			
		||||
        customer.setNumber(null);
 | 
			
		||||
 | 
			
		||||
        // Create the Customer, which fails.
 | 
			
		||||
        CustomerDTO customerDTO = customerMapper.toDto(customer);
 | 
			
		||||
 | 
			
		||||
        restCustomerMockMvc.perform(post("/api/customers")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        List<Customer> customerList = customerRepository.findAll();
 | 
			
		||||
        assertThat(customerList).hasSize(databaseSizeBeforeTest);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void checkPrefixIsRequired() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeTest = customerRepository.findAll().size();
 | 
			
		||||
        // set the field null
 | 
			
		||||
        customer.setPrefix(null);
 | 
			
		||||
 | 
			
		||||
        // Create the Customer, which fails.
 | 
			
		||||
        CustomerDTO customerDTO = customerMapper.toDto(customer);
 | 
			
		||||
 | 
			
		||||
        restCustomerMockMvc.perform(post("/api/customers")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        List<Customer> customerList = customerRepository.findAll();
 | 
			
		||||
        assertThat(customerList).hasSize(databaseSizeBeforeTest);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void checkNameIsRequired() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeTest = customerRepository.findAll().size();
 | 
			
		||||
        // set the field null
 | 
			
		||||
        customer.setName(null);
 | 
			
		||||
 | 
			
		||||
        // Create the Customer, which fails.
 | 
			
		||||
        CustomerDTO customerDTO = customerMapper.toDto(customer);
 | 
			
		||||
 | 
			
		||||
        restCustomerMockMvc.perform(post("/api/customers")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        List<Customer> customerList = customerRepository.findAll();
 | 
			
		||||
        assertThat(customerList).hasSize(databaseSizeBeforeTest);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void checkContractualAddressIsRequired() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeTest = customerRepository.findAll().size();
 | 
			
		||||
        // set the field null
 | 
			
		||||
        customer.setContractualAddress(null);
 | 
			
		||||
 | 
			
		||||
        // Create the Customer, which fails.
 | 
			
		||||
        CustomerDTO customerDTO = customerMapper.toDto(customer);
 | 
			
		||||
 | 
			
		||||
        restCustomerMockMvc.perform(post("/api/customers")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        List<Customer> customerList = customerRepository.findAll();
 | 
			
		||||
        assertThat(customerList).hasSize(databaseSizeBeforeTest);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomers() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList
 | 
			
		||||
        restCustomerMockMvc.perform(get("/api/customers?sort=id,desc"))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].id").value(hasItem(customer.getId().intValue())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].number").value(hasItem(DEFAULT_NUMBER)))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].prefix").value(hasItem(DEFAULT_PREFIX.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].contractualSalutation").value(hasItem(DEFAULT_CONTRACTUAL_SALUTATION.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].billingAddress").value(hasItem(DEFAULT_BILLING_ADDRESS.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION.toString())));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getCustomer() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get the customer
 | 
			
		||||
        restCustomerMockMvc.perform(get("/api/customers/{id}", customer.getId()))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(jsonPath("$.id").value(customer.getId().intValue()))
 | 
			
		||||
            .andExpect(jsonPath("$.number").value(DEFAULT_NUMBER))
 | 
			
		||||
            .andExpect(jsonPath("$.prefix").value(DEFAULT_PREFIX.toString()))
 | 
			
		||||
            .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString()))
 | 
			
		||||
            .andExpect(jsonPath("$.contractualAddress").value(DEFAULT_CONTRACTUAL_ADDRESS.toString()))
 | 
			
		||||
            .andExpect(jsonPath("$.contractualSalutation").value(DEFAULT_CONTRACTUAL_SALUTATION.toString()))
 | 
			
		||||
            .andExpect(jsonPath("$.billingAddress").value(DEFAULT_BILLING_ADDRESS.toString()))
 | 
			
		||||
            .andExpect(jsonPath("$.billingSalutation").value(DEFAULT_BILLING_SALUTATION.toString()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByNumberIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where number equals to DEFAULT_NUMBER
 | 
			
		||||
        defaultCustomerShouldBeFound("number.equals=" + DEFAULT_NUMBER);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where number equals to UPDATED_NUMBER
 | 
			
		||||
        defaultCustomerShouldNotBeFound("number.equals=" + UPDATED_NUMBER);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByNumberIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where number in DEFAULT_NUMBER or UPDATED_NUMBER
 | 
			
		||||
        defaultCustomerShouldBeFound("number.in=" + DEFAULT_NUMBER + "," + UPDATED_NUMBER);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where number equals to UPDATED_NUMBER
 | 
			
		||||
        defaultCustomerShouldNotBeFound("number.in=" + UPDATED_NUMBER);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByNumberIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where number is not null
 | 
			
		||||
        defaultCustomerShouldBeFound("number.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where number is null
 | 
			
		||||
        defaultCustomerShouldNotBeFound("number.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByNumberIsGreaterThanOrEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where number greater than or equals to DEFAULT_NUMBER
 | 
			
		||||
        defaultCustomerShouldBeFound("number.greaterOrEqualThan=" + DEFAULT_NUMBER);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where number greater than or equals to (DEFAULT_NUMBER + 1)
 | 
			
		||||
        defaultCustomerShouldNotBeFound("number.greaterOrEqualThan=" + (DEFAULT_NUMBER + 1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByNumberIsLessThanSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where number less than or equals to DEFAULT_NUMBER
 | 
			
		||||
        defaultCustomerShouldNotBeFound("number.lessThan=" + DEFAULT_NUMBER);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where number less than or equals to (DEFAULT_NUMBER + 1)
 | 
			
		||||
        defaultCustomerShouldBeFound("number.lessThan=" + (DEFAULT_NUMBER + 1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByPrefixIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where prefix equals to DEFAULT_PREFIX
 | 
			
		||||
        defaultCustomerShouldBeFound("prefix.equals=" + DEFAULT_PREFIX);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where prefix equals to UPDATED_PREFIX
 | 
			
		||||
        defaultCustomerShouldNotBeFound("prefix.equals=" + UPDATED_PREFIX);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByPrefixIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where prefix in DEFAULT_PREFIX or UPDATED_PREFIX
 | 
			
		||||
        defaultCustomerShouldBeFound("prefix.in=" + DEFAULT_PREFIX + "," + UPDATED_PREFIX);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where prefix equals to UPDATED_PREFIX
 | 
			
		||||
        defaultCustomerShouldNotBeFound("prefix.in=" + UPDATED_PREFIX);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByPrefixIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where prefix is not null
 | 
			
		||||
        defaultCustomerShouldBeFound("prefix.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where prefix is null
 | 
			
		||||
        defaultCustomerShouldNotBeFound("prefix.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByNameIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where name equals to DEFAULT_NAME
 | 
			
		||||
        defaultCustomerShouldBeFound("name.equals=" + DEFAULT_NAME);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where name equals to UPDATED_NAME
 | 
			
		||||
        defaultCustomerShouldNotBeFound("name.equals=" + UPDATED_NAME);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByNameIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where name in DEFAULT_NAME or UPDATED_NAME
 | 
			
		||||
        defaultCustomerShouldBeFound("name.in=" + DEFAULT_NAME + "," + UPDATED_NAME);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where name equals to UPDATED_NAME
 | 
			
		||||
        defaultCustomerShouldNotBeFound("name.in=" + UPDATED_NAME);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByNameIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where name is not null
 | 
			
		||||
        defaultCustomerShouldBeFound("name.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where name is null
 | 
			
		||||
        defaultCustomerShouldNotBeFound("name.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByContractualAddressIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where contractualAddress equals to DEFAULT_CONTRACTUAL_ADDRESS
 | 
			
		||||
        defaultCustomerShouldBeFound("contractualAddress.equals=" + DEFAULT_CONTRACTUAL_ADDRESS);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where contractualAddress equals to UPDATED_CONTRACTUAL_ADDRESS
 | 
			
		||||
        defaultCustomerShouldNotBeFound("contractualAddress.equals=" + UPDATED_CONTRACTUAL_ADDRESS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByContractualAddressIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where contractualAddress in DEFAULT_CONTRACTUAL_ADDRESS or UPDATED_CONTRACTUAL_ADDRESS
 | 
			
		||||
        defaultCustomerShouldBeFound("contractualAddress.in=" + DEFAULT_CONTRACTUAL_ADDRESS + "," + UPDATED_CONTRACTUAL_ADDRESS);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where contractualAddress equals to UPDATED_CONTRACTUAL_ADDRESS
 | 
			
		||||
        defaultCustomerShouldNotBeFound("contractualAddress.in=" + UPDATED_CONTRACTUAL_ADDRESS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByContractualAddressIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where contractualAddress is not null
 | 
			
		||||
        defaultCustomerShouldBeFound("contractualAddress.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where contractualAddress is null
 | 
			
		||||
        defaultCustomerShouldNotBeFound("contractualAddress.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByContractualSalutationIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where contractualSalutation equals to DEFAULT_CONTRACTUAL_SALUTATION
 | 
			
		||||
        defaultCustomerShouldBeFound("contractualSalutation.equals=" + DEFAULT_CONTRACTUAL_SALUTATION);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where contractualSalutation equals to UPDATED_CONTRACTUAL_SALUTATION
 | 
			
		||||
        defaultCustomerShouldNotBeFound("contractualSalutation.equals=" + UPDATED_CONTRACTUAL_SALUTATION);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByContractualSalutationIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where contractualSalutation in DEFAULT_CONTRACTUAL_SALUTATION or UPDATED_CONTRACTUAL_SALUTATION
 | 
			
		||||
        defaultCustomerShouldBeFound("contractualSalutation.in=" + DEFAULT_CONTRACTUAL_SALUTATION + "," + UPDATED_CONTRACTUAL_SALUTATION);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where contractualSalutation equals to UPDATED_CONTRACTUAL_SALUTATION
 | 
			
		||||
        defaultCustomerShouldNotBeFound("contractualSalutation.in=" + UPDATED_CONTRACTUAL_SALUTATION);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByContractualSalutationIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where contractualSalutation is not null
 | 
			
		||||
        defaultCustomerShouldBeFound("contractualSalutation.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where contractualSalutation is null
 | 
			
		||||
        defaultCustomerShouldNotBeFound("contractualSalutation.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByBillingAddressIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where billingAddress equals to DEFAULT_BILLING_ADDRESS
 | 
			
		||||
        defaultCustomerShouldBeFound("billingAddress.equals=" + DEFAULT_BILLING_ADDRESS);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS
 | 
			
		||||
        defaultCustomerShouldNotBeFound("billingAddress.equals=" + UPDATED_BILLING_ADDRESS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByBillingAddressIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where billingAddress in DEFAULT_BILLING_ADDRESS or UPDATED_BILLING_ADDRESS
 | 
			
		||||
        defaultCustomerShouldBeFound("billingAddress.in=" + DEFAULT_BILLING_ADDRESS + "," + UPDATED_BILLING_ADDRESS);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS
 | 
			
		||||
        defaultCustomerShouldNotBeFound("billingAddress.in=" + UPDATED_BILLING_ADDRESS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByBillingAddressIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where billingAddress is not null
 | 
			
		||||
        defaultCustomerShouldBeFound("billingAddress.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where billingAddress is null
 | 
			
		||||
        defaultCustomerShouldNotBeFound("billingAddress.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByBillingSalutationIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where billingSalutation equals to DEFAULT_BILLING_SALUTATION
 | 
			
		||||
        defaultCustomerShouldBeFound("billingSalutation.equals=" + DEFAULT_BILLING_SALUTATION);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where billingSalutation equals to UPDATED_BILLING_SALUTATION
 | 
			
		||||
        defaultCustomerShouldNotBeFound("billingSalutation.equals=" + UPDATED_BILLING_SALUTATION);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByBillingSalutationIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where billingSalutation in DEFAULT_BILLING_SALUTATION or UPDATED_BILLING_SALUTATION
 | 
			
		||||
        defaultCustomerShouldBeFound("billingSalutation.in=" + DEFAULT_BILLING_SALUTATION + "," + UPDATED_BILLING_SALUTATION);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where billingSalutation equals to UPDATED_BILLING_SALUTATION
 | 
			
		||||
        defaultCustomerShouldNotBeFound("billingSalutation.in=" + UPDATED_BILLING_SALUTATION);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByBillingSalutationIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where billingSalutation is not null
 | 
			
		||||
        defaultCustomerShouldBeFound("billingSalutation.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where billingSalutation is null
 | 
			
		||||
        defaultCustomerShouldNotBeFound("billingSalutation.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByRoleIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        CustomerContact role = CustomerContactResourceIntTest.createEntity(em);
 | 
			
		||||
        em.persist(role);
 | 
			
		||||
        em.flush();
 | 
			
		||||
        customer.addRole(role);
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
        Long roleId = role.getId();
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where role equals to roleId
 | 
			
		||||
        defaultCustomerShouldBeFound("roleId.equals=" + roleId);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where role equals to roleId + 1
 | 
			
		||||
        defaultCustomerShouldNotBeFound("roleId.equals=" + (roleId + 1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllCustomersByMembershipIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        Membership membership = MembershipResourceIntTest.createEntity(em);
 | 
			
		||||
        em.persist(membership);
 | 
			
		||||
        em.flush();
 | 
			
		||||
        customer.addMembership(membership);
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
        Long membershipId = membership.getId();
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where membership equals to membershipId
 | 
			
		||||
        defaultCustomerShouldBeFound("membershipId.equals=" + membershipId);
 | 
			
		||||
 | 
			
		||||
        // Get all the customerList where membership equals to membershipId + 1
 | 
			
		||||
        defaultCustomerShouldNotBeFound("membershipId.equals=" + (membershipId + 1));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Executes the search, and checks that the default entity is returned
 | 
			
		||||
     */
 | 
			
		||||
    private void defaultCustomerShouldBeFound(String filter) throws Exception {
 | 
			
		||||
        restCustomerMockMvc.perform(get("/api/customers?sort=id,desc&" + filter))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].id").value(hasItem(customer.getId().intValue())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].number").value(hasItem(DEFAULT_NUMBER)))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].prefix").value(hasItem(DEFAULT_PREFIX)))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].name").value(hasItem(DEFAULT_NAME)))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS)))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].contractualSalutation").value(hasItem(DEFAULT_CONTRACTUAL_SALUTATION)))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].billingAddress").value(hasItem(DEFAULT_BILLING_ADDRESS)))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION)));
 | 
			
		||||
 | 
			
		||||
        // Check, that the count call also returns 1
 | 
			
		||||
        restCustomerMockMvc.perform(get("/api/customers/count?sort=id,desc&" + filter))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(content().string("1"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Executes the search, and checks that the default entity is not returned
 | 
			
		||||
     */
 | 
			
		||||
    private void defaultCustomerShouldNotBeFound(String filter) throws Exception {
 | 
			
		||||
        restCustomerMockMvc.perform(get("/api/customers?sort=id,desc&" + filter))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(jsonPath("$").isArray())
 | 
			
		||||
            .andExpect(jsonPath("$").isEmpty());
 | 
			
		||||
 | 
			
		||||
        // Check, that the count call also returns 0
 | 
			
		||||
        restCustomerMockMvc.perform(get("/api/customers/count?sort=id,desc&" + filter))
 | 
			
		||||
            .andExpect(status().isOk())
 | 
			
		||||
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
 | 
			
		||||
            .andExpect(content().string("0"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getNonExistingCustomer() throws Exception {
 | 
			
		||||
        // Get the customer
 | 
			
		||||
        restCustomerMockMvc.perform(get("/api/customers/{id}", Long.MAX_VALUE))
 | 
			
		||||
            .andExpect(status().isNotFound());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void updateCustomer() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        int databaseSizeBeforeUpdate = customerRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Update the customer
 | 
			
		||||
        Customer updatedCustomer = customerRepository.findById(customer.getId()).get();
 | 
			
		||||
        // Disconnect from session so that the updates on updatedCustomer are not directly saved in db
 | 
			
		||||
        em.detach(updatedCustomer);
 | 
			
		||||
        updatedCustomer
 | 
			
		||||
            .number(UPDATED_NUMBER)
 | 
			
		||||
            .prefix(UPDATED_PREFIX)
 | 
			
		||||
            .name(UPDATED_NAME)
 | 
			
		||||
            .contractualAddress(UPDATED_CONTRACTUAL_ADDRESS)
 | 
			
		||||
            .contractualSalutation(UPDATED_CONTRACTUAL_SALUTATION)
 | 
			
		||||
            .billingAddress(UPDATED_BILLING_ADDRESS)
 | 
			
		||||
            .billingSalutation(UPDATED_BILLING_SALUTATION);
 | 
			
		||||
        CustomerDTO customerDTO = customerMapper.toDto(updatedCustomer);
 | 
			
		||||
 | 
			
		||||
        restCustomerMockMvc.perform(put("/api/customers")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerDTO)))
 | 
			
		||||
            .andExpect(status().isOk());
 | 
			
		||||
 | 
			
		||||
        // Validate the Customer in the database
 | 
			
		||||
        List<Customer> customerList = customerRepository.findAll();
 | 
			
		||||
        assertThat(customerList).hasSize(databaseSizeBeforeUpdate);
 | 
			
		||||
        Customer testCustomer = customerList.get(customerList.size() - 1);
 | 
			
		||||
        assertThat(testCustomer.getNumber()).isEqualTo(UPDATED_NUMBER);
 | 
			
		||||
        assertThat(testCustomer.getPrefix()).isEqualTo(UPDATED_PREFIX);
 | 
			
		||||
        assertThat(testCustomer.getName()).isEqualTo(UPDATED_NAME);
 | 
			
		||||
        assertThat(testCustomer.getContractualAddress()).isEqualTo(UPDATED_CONTRACTUAL_ADDRESS);
 | 
			
		||||
        assertThat(testCustomer.getContractualSalutation()).isEqualTo(UPDATED_CONTRACTUAL_SALUTATION);
 | 
			
		||||
        assertThat(testCustomer.getBillingAddress()).isEqualTo(UPDATED_BILLING_ADDRESS);
 | 
			
		||||
        assertThat(testCustomer.getBillingSalutation()).isEqualTo(UPDATED_BILLING_SALUTATION);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void updateNonExistingCustomer() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeUpdate = customerRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Create the Customer
 | 
			
		||||
        CustomerDTO customerDTO = customerMapper.toDto(customer);
 | 
			
		||||
 | 
			
		||||
        // If the entity doesn't have an ID, it will throw BadRequestAlertException
 | 
			
		||||
        restCustomerMockMvc.perform(put("/api/customers")
 | 
			
		||||
            .contentType(TestUtil.APPLICATION_JSON_UTF8)
 | 
			
		||||
            .content(TestUtil.convertObjectToJsonBytes(customerDTO)))
 | 
			
		||||
            .andExpect(status().isBadRequest());
 | 
			
		||||
 | 
			
		||||
        // Validate the Customer in the database
 | 
			
		||||
        List<Customer> customerList = customerRepository.findAll();
 | 
			
		||||
        assertThat(customerList).hasSize(databaseSizeBeforeUpdate);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void deleteCustomer() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        customerRepository.saveAndFlush(customer);
 | 
			
		||||
 | 
			
		||||
        int databaseSizeBeforeDelete = customerRepository.findAll().size();
 | 
			
		||||
 | 
			
		||||
        // Delete the customer
 | 
			
		||||
        restCustomerMockMvc.perform(delete("/api/customers/{id}", customer.getId())
 | 
			
		||||
            .accept(TestUtil.APPLICATION_JSON_UTF8))
 | 
			
		||||
            .andExpect(status().isOk());
 | 
			
		||||
 | 
			
		||||
        // Validate the database is empty
 | 
			
		||||
        List<Customer> customerList = customerRepository.findAll();
 | 
			
		||||
        assertThat(customerList).hasSize(databaseSizeBeforeDelete - 1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void equalsVerifier() throws Exception {
 | 
			
		||||
        TestUtil.equalsVerifier(Customer.class);
 | 
			
		||||
        Customer customer1 = new Customer();
 | 
			
		||||
        customer1.setId(1L);
 | 
			
		||||
        Customer customer2 = new Customer();
 | 
			
		||||
        customer2.setId(customer1.getId());
 | 
			
		||||
        assertThat(customer1).isEqualTo(customer2);
 | 
			
		||||
        customer2.setId(2L);
 | 
			
		||||
        assertThat(customer1).isNotEqualTo(customer2);
 | 
			
		||||
        customer1.setId(null);
 | 
			
		||||
        assertThat(customer1).isNotEqualTo(customer2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void dtoEqualsVerifier() throws Exception {
 | 
			
		||||
        TestUtil.equalsVerifier(CustomerDTO.class);
 | 
			
		||||
        CustomerDTO customerDTO1 = new CustomerDTO();
 | 
			
		||||
        customerDTO1.setId(1L);
 | 
			
		||||
        CustomerDTO customerDTO2 = new CustomerDTO();
 | 
			
		||||
        assertThat(customerDTO1).isNotEqualTo(customerDTO2);
 | 
			
		||||
        customerDTO2.setId(customerDTO1.getId());
 | 
			
		||||
        assertThat(customerDTO1).isEqualTo(customerDTO2);
 | 
			
		||||
        customerDTO2.setId(2L);
 | 
			
		||||
        assertThat(customerDTO1).isNotEqualTo(customerDTO2);
 | 
			
		||||
        customerDTO1.setId(null);
 | 
			
		||||
        assertThat(customerDTO1).isNotEqualTo(customerDTO2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void testEntityFromId() {
 | 
			
		||||
        assertThat(customerMapper.fromId(42L).getId()).isEqualTo(42);
 | 
			
		||||
        assertThat(customerMapper.fromId(null)).isNull();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,546 +0,0 @@
 | 
			
		||||
package org.hostsharing.hsadminng.web.rest;
 | 
			
		||||
 | 
			
		||||
import org.hostsharing.hsadminng.HsadminNgApp;
 | 
			
		||||
import org.hostsharing.hsadminng.domain.Asset;
 | 
			
		||||
import org.hostsharing.hsadminng.domain.Customer;
 | 
			
		||||
import org.hostsharing.hsadminng.domain.Membership;
 | 
			
		||||
import org.hostsharing.hsadminng.domain.Share;
 | 
			
		||||
import org.hostsharing.hsadminng.repository.MembershipRepository;
 | 
			
		||||
import org.hostsharing.hsadminng.service.MembershipQueryService;
 | 
			
		||||
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.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.assertj.core.api.Assertions.assertThat;
 | 
			
		||||
import static org.hamcrest.Matchers.hasItem;
 | 
			
		||||
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
 | 
			
		||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
 | 
			
		||||
import static org.springframework.test.web.servlet.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_SINCE_DATE = LocalDate.ofEpochDay(0L);
 | 
			
		||||
    private static final LocalDate UPDATED_SINCE_DATE = LocalDate.now(ZoneId.systemDefault());
 | 
			
		||||
 | 
			
		||||
    private static final LocalDate DEFAULT_UNTIL_DATE = LocalDate.ofEpochDay(0L);
 | 
			
		||||
    private static final LocalDate UPDATED_UNTIL_DATE = LocalDate.now(ZoneId.systemDefault());
 | 
			
		||||
 | 
			
		||||
    @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()
 | 
			
		||||
            .sinceDate(DEFAULT_SINCE_DATE)
 | 
			
		||||
            .untilDate(DEFAULT_UNTIL_DATE);
 | 
			
		||||
        // 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.getSinceDate()).isEqualTo(DEFAULT_SINCE_DATE);
 | 
			
		||||
        assertThat(testMembership.getUntilDate()).isEqualTo(DEFAULT_UNTIL_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @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 checkSinceDateIsRequired() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeTest = membershipRepository.findAll().size();
 | 
			
		||||
        // set the field null
 | 
			
		||||
        membership.setSinceDate(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("$.[*].sinceDate").value(hasItem(DEFAULT_SINCE_DATE.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].untilDate").value(hasItem(DEFAULT_UNTIL_DATE.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("$.sinceDate").value(DEFAULT_SINCE_DATE.toString()))
 | 
			
		||||
            .andExpect(jsonPath("$.untilDate").value(DEFAULT_UNTIL_DATE.toString()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllMembershipsBySinceDateIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        membershipRepository.saveAndFlush(membership);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where sinceDate equals to DEFAULT_SINCE_DATE
 | 
			
		||||
        defaultMembershipShouldBeFound("sinceDate.equals=" + DEFAULT_SINCE_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where sinceDate equals to UPDATED_SINCE_DATE
 | 
			
		||||
        defaultMembershipShouldNotBeFound("sinceDate.equals=" + UPDATED_SINCE_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllMembershipsBySinceDateIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        membershipRepository.saveAndFlush(membership);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where sinceDate in DEFAULT_SINCE_DATE or UPDATED_SINCE_DATE
 | 
			
		||||
        defaultMembershipShouldBeFound("sinceDate.in=" + DEFAULT_SINCE_DATE + "," + UPDATED_SINCE_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where sinceDate equals to UPDATED_SINCE_DATE
 | 
			
		||||
        defaultMembershipShouldNotBeFound("sinceDate.in=" + UPDATED_SINCE_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllMembershipsBySinceDateIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        membershipRepository.saveAndFlush(membership);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where sinceDate is not null
 | 
			
		||||
        defaultMembershipShouldBeFound("sinceDate.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where sinceDate is null
 | 
			
		||||
        defaultMembershipShouldNotBeFound("sinceDate.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllMembershipsBySinceDateIsGreaterThanOrEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        membershipRepository.saveAndFlush(membership);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where sinceDate greater than or equals to DEFAULT_SINCE_DATE
 | 
			
		||||
        defaultMembershipShouldBeFound("sinceDate.greaterOrEqualThan=" + DEFAULT_SINCE_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where sinceDate greater than or equals to UPDATED_SINCE_DATE
 | 
			
		||||
        defaultMembershipShouldNotBeFound("sinceDate.greaterOrEqualThan=" + UPDATED_SINCE_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllMembershipsBySinceDateIsLessThanSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        membershipRepository.saveAndFlush(membership);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where sinceDate less than or equals to DEFAULT_SINCE_DATE
 | 
			
		||||
        defaultMembershipShouldNotBeFound("sinceDate.lessThan=" + DEFAULT_SINCE_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where sinceDate less than or equals to UPDATED_SINCE_DATE
 | 
			
		||||
        defaultMembershipShouldBeFound("sinceDate.lessThan=" + UPDATED_SINCE_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllMembershipsByUntilDateIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        membershipRepository.saveAndFlush(membership);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where untilDate equals to DEFAULT_UNTIL_DATE
 | 
			
		||||
        defaultMembershipShouldBeFound("untilDate.equals=" + DEFAULT_UNTIL_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where untilDate equals to UPDATED_UNTIL_DATE
 | 
			
		||||
        defaultMembershipShouldNotBeFound("untilDate.equals=" + UPDATED_UNTIL_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllMembershipsByUntilDateIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        membershipRepository.saveAndFlush(membership);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where untilDate in DEFAULT_UNTIL_DATE or UPDATED_UNTIL_DATE
 | 
			
		||||
        defaultMembershipShouldBeFound("untilDate.in=" + DEFAULT_UNTIL_DATE + "," + UPDATED_UNTIL_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where untilDate equals to UPDATED_UNTIL_DATE
 | 
			
		||||
        defaultMembershipShouldNotBeFound("untilDate.in=" + UPDATED_UNTIL_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllMembershipsByUntilDateIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        membershipRepository.saveAndFlush(membership);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where untilDate is not null
 | 
			
		||||
        defaultMembershipShouldBeFound("untilDate.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where untilDate is null
 | 
			
		||||
        defaultMembershipShouldNotBeFound("untilDate.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllMembershipsByUntilDateIsGreaterThanOrEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        membershipRepository.saveAndFlush(membership);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where untilDate greater than or equals to DEFAULT_UNTIL_DATE
 | 
			
		||||
        defaultMembershipShouldBeFound("untilDate.greaterOrEqualThan=" + DEFAULT_UNTIL_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where untilDate greater than or equals to UPDATED_UNTIL_DATE
 | 
			
		||||
        defaultMembershipShouldNotBeFound("untilDate.greaterOrEqualThan=" + UPDATED_UNTIL_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllMembershipsByUntilDateIsLessThanSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        membershipRepository.saveAndFlush(membership);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where untilDate less than or equals to DEFAULT_UNTIL_DATE
 | 
			
		||||
        defaultMembershipShouldNotBeFound("untilDate.lessThan=" + DEFAULT_UNTIL_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the membershipList where untilDate less than or equals to UPDATED_UNTIL_DATE
 | 
			
		||||
        defaultMembershipShouldBeFound("untilDate.lessThan=" + UPDATED_UNTIL_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    @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("$.[*].sinceDate").value(hasItem(DEFAULT_SINCE_DATE.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].untilDate").value(hasItem(DEFAULT_UNTIL_DATE.toString())));
 | 
			
		||||
 | 
			
		||||
        // 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
 | 
			
		||||
            .sinceDate(UPDATED_SINCE_DATE)
 | 
			
		||||
            .untilDate(UPDATED_UNTIL_DATE);
 | 
			
		||||
        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.getSinceDate()).isEqualTo(UPDATED_SINCE_DATE);
 | 
			
		||||
        assertThat(testMembership.getUntilDate()).isEqualTo(UPDATED_UNTIL_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,642 +0,0 @@
 | 
			
		||||
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.enumeration.ShareAction;
 | 
			
		||||
import org.hostsharing.hsadminng.repository.ShareRepository;
 | 
			
		||||
import org.hostsharing.hsadminng.service.ShareQueryService;
 | 
			
		||||
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.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.assertj.core.api.Assertions.assertThat;
 | 
			
		||||
import static org.hamcrest.Matchers.hasItem;
 | 
			
		||||
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
 | 
			
		||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
 | 
			
		||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
 | 
			
		||||
/**
 | 
			
		||||
 * Test class for the ShareResource REST controller.
 | 
			
		||||
 *
 | 
			
		||||
 * @see ShareResource
 | 
			
		||||
 */
 | 
			
		||||
@RunWith(SpringRunner.class)
 | 
			
		||||
@SpringBootTest(classes = HsadminNgApp.class)
 | 
			
		||||
public class ShareResourceIntTest {
 | 
			
		||||
 | 
			
		||||
    private static final LocalDate DEFAULT_DATE = LocalDate.ofEpochDay(0L);
 | 
			
		||||
    private static final LocalDate UPDATED_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_COMMENT = "AAAAAAAAAA";
 | 
			
		||||
    private static final String UPDATED_COMMENT = "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()
 | 
			
		||||
            .date(DEFAULT_DATE)
 | 
			
		||||
            .action(DEFAULT_ACTION)
 | 
			
		||||
            .quantity(DEFAULT_QUANTITY)
 | 
			
		||||
            .comment(DEFAULT_COMMENT);
 | 
			
		||||
        // Add required entity
 | 
			
		||||
        Membership membership = MembershipResourceIntTest.createEntity(em);
 | 
			
		||||
        em.persist(membership);
 | 
			
		||||
        em.flush();
 | 
			
		||||
        share.setMember(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.getDate()).isEqualTo(DEFAULT_DATE);
 | 
			
		||||
        assertThat(testShare.getAction()).isEqualTo(DEFAULT_ACTION);
 | 
			
		||||
        assertThat(testShare.getQuantity()).isEqualTo(DEFAULT_QUANTITY);
 | 
			
		||||
        assertThat(testShare.getComment()).isEqualTo(DEFAULT_COMMENT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @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 checkDateIsRequired() throws Exception {
 | 
			
		||||
        int databaseSizeBeforeTest = shareRepository.findAll().size();
 | 
			
		||||
        // set the field null
 | 
			
		||||
        share.setDate(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("$.[*].date").value(hasItem(DEFAULT_DATE.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY)))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT.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("$.date").value(DEFAULT_DATE.toString()))
 | 
			
		||||
            .andExpect(jsonPath("$.action").value(DEFAULT_ACTION.toString()))
 | 
			
		||||
            .andExpect(jsonPath("$.quantity").value(DEFAULT_QUANTITY))
 | 
			
		||||
            .andExpect(jsonPath("$.comment").value(DEFAULT_COMMENT.toString()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllSharesByDateIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        shareRepository.saveAndFlush(share);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where date equals to DEFAULT_DATE
 | 
			
		||||
        defaultShareShouldBeFound("date.equals=" + DEFAULT_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where date equals to UPDATED_DATE
 | 
			
		||||
        defaultShareShouldNotBeFound("date.equals=" + UPDATED_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllSharesByDateIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        shareRepository.saveAndFlush(share);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where date in DEFAULT_DATE or UPDATED_DATE
 | 
			
		||||
        defaultShareShouldBeFound("date.in=" + DEFAULT_DATE + "," + UPDATED_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where date equals to UPDATED_DATE
 | 
			
		||||
        defaultShareShouldNotBeFound("date.in=" + UPDATED_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllSharesByDateIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        shareRepository.saveAndFlush(share);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where date is not null
 | 
			
		||||
        defaultShareShouldBeFound("date.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where date is null
 | 
			
		||||
        defaultShareShouldNotBeFound("date.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllSharesByDateIsGreaterThanOrEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        shareRepository.saveAndFlush(share);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where date greater than or equals to DEFAULT_DATE
 | 
			
		||||
        defaultShareShouldBeFound("date.greaterOrEqualThan=" + DEFAULT_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where date greater than or equals to UPDATED_DATE
 | 
			
		||||
        defaultShareShouldNotBeFound("date.greaterOrEqualThan=" + UPDATED_DATE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllSharesByDateIsLessThanSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        shareRepository.saveAndFlush(share);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where date less than or equals to DEFAULT_DATE
 | 
			
		||||
        defaultShareShouldNotBeFound("date.lessThan=" + DEFAULT_DATE);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where date less than or equals to UPDATED_DATE
 | 
			
		||||
        defaultShareShouldBeFound("date.lessThan=" + UPDATED_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 getAllSharesByCommentIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        shareRepository.saveAndFlush(share);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where comment equals to DEFAULT_COMMENT
 | 
			
		||||
        defaultShareShouldBeFound("comment.equals=" + DEFAULT_COMMENT);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where comment equals to UPDATED_COMMENT
 | 
			
		||||
        defaultShareShouldNotBeFound("comment.equals=" + UPDATED_COMMENT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllSharesByCommentIsInShouldWork() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        shareRepository.saveAndFlush(share);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where comment in DEFAULT_COMMENT or UPDATED_COMMENT
 | 
			
		||||
        defaultShareShouldBeFound("comment.in=" + DEFAULT_COMMENT + "," + UPDATED_COMMENT);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where comment equals to UPDATED_COMMENT
 | 
			
		||||
        defaultShareShouldNotBeFound("comment.in=" + UPDATED_COMMENT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllSharesByCommentIsNullOrNotNull() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        shareRepository.saveAndFlush(share);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where comment is not null
 | 
			
		||||
        defaultShareShouldBeFound("comment.specified=true");
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where comment is null
 | 
			
		||||
        defaultShareShouldNotBeFound("comment.specified=false");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    @Transactional
 | 
			
		||||
    public void getAllSharesByMemberIsEqualToSomething() throws Exception {
 | 
			
		||||
        // Initialize the database
 | 
			
		||||
        Membership member = MembershipResourceIntTest.createEntity(em);
 | 
			
		||||
        em.persist(member);
 | 
			
		||||
        em.flush();
 | 
			
		||||
        share.setMember(member);
 | 
			
		||||
        shareRepository.saveAndFlush(share);
 | 
			
		||||
        Long memberId = member.getId();
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where member equals to memberId
 | 
			
		||||
        defaultShareShouldBeFound("memberId.equals=" + memberId);
 | 
			
		||||
 | 
			
		||||
        // Get all the shareList where member equals to memberId + 1
 | 
			
		||||
        defaultShareShouldNotBeFound("memberId.equals=" + (memberId + 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("$.[*].date").value(hasItem(DEFAULT_DATE.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString())))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY)))
 | 
			
		||||
            .andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT)));
 | 
			
		||||
 | 
			
		||||
        // 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
 | 
			
		||||
            .date(UPDATED_DATE)
 | 
			
		||||
            .action(UPDATED_ACTION)
 | 
			
		||||
            .quantity(UPDATED_QUANTITY)
 | 
			
		||||
            .comment(UPDATED_COMMENT);
 | 
			
		||||
        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.getDate()).isEqualTo(UPDATED_DATE);
 | 
			
		||||
        assertThat(testShare.getAction()).isEqualTo(UPDATED_ACTION);
 | 
			
		||||
        assertThat(testShare.getQuantity()).isEqualTo(UPDATED_QUANTITY);
 | 
			
		||||
        assertThat(testShare.getComment()).isEqualTo(UPDATED_COMMENT);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @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();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,52 +0,0 @@
 | 
			
		||||
/* 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();
 | 
			
		||||
                })
 | 
			
		||||
            ));
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,40 +0,0 @@
 | 
			
		||||
/* 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 }));
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
/* tslint:disable max-line-length */
 | 
			
		||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
 | 
			
		||||
import { HttpResponse } from '@angular/common/http';
 | 
			
		||||
import { 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);
 | 
			
		||||
            }));
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,128 +0,0 @@
 | 
			
		||||
/* 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']);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,135 +0,0 @@
 | 
			
		||||
/* 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, AssetAction.PAYMENT, 0, 'AAAAAAA');
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        describe('Service methods', async () => {
 | 
			
		||||
            it('should find an element', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        date: 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,
 | 
			
		||||
                        date: currentDate.format(DATE_FORMAT)
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
                const expected = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        date: 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(
 | 
			
		||||
                    {
 | 
			
		||||
                        date: currentDate.format(DATE_FORMAT),
 | 
			
		||||
                        action: 'BBBBBB',
 | 
			
		||||
                        amount: 1,
 | 
			
		||||
                        comment: 'BBBBBB'
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                const expected = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        date: 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(
 | 
			
		||||
                    {
 | 
			
		||||
                        date: currentDate.format(DATE_FORMAT),
 | 
			
		||||
                        action: 'BBBBBB',
 | 
			
		||||
                        amount: 1,
 | 
			
		||||
                        comment: 'BBBBBB'
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
                const expected = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        date: 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();
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,52 +0,0 @@
 | 
			
		||||
/* 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 { ContactDeleteDialogComponent } from 'app/entities/contact/contact-delete-dialog.component';
 | 
			
		||||
import { ContactService } from 'app/entities/contact/contact.service';
 | 
			
		||||
 | 
			
		||||
describe('Component Tests', () => {
 | 
			
		||||
    describe('Contact Management Delete Component', () => {
 | 
			
		||||
        let comp: ContactDeleteDialogComponent;
 | 
			
		||||
        let fixture: ComponentFixture<ContactDeleteDialogComponent>;
 | 
			
		||||
        let service: ContactService;
 | 
			
		||||
        let mockEventManager: any;
 | 
			
		||||
        let mockActiveModal: any;
 | 
			
		||||
 | 
			
		||||
        beforeEach(() => {
 | 
			
		||||
            TestBed.configureTestingModule({
 | 
			
		||||
                imports: [HsadminNgTestModule],
 | 
			
		||||
                declarations: [ContactDeleteDialogComponent]
 | 
			
		||||
            })
 | 
			
		||||
                .overrideTemplate(ContactDeleteDialogComponent, '')
 | 
			
		||||
                .compileComponents();
 | 
			
		||||
            fixture = TestBed.createComponent(ContactDeleteDialogComponent);
 | 
			
		||||
            comp = fixture.componentInstance;
 | 
			
		||||
            service = fixture.debugElement.injector.get(ContactService);
 | 
			
		||||
            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();
 | 
			
		||||
                })
 | 
			
		||||
            ));
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,40 +0,0 @@
 | 
			
		||||
/* 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 { ContactDetailComponent } from 'app/entities/contact/contact-detail.component';
 | 
			
		||||
import { Contact } from 'app/shared/model/contact.model';
 | 
			
		||||
 | 
			
		||||
describe('Component Tests', () => {
 | 
			
		||||
    describe('Contact Management Detail Component', () => {
 | 
			
		||||
        let comp: ContactDetailComponent;
 | 
			
		||||
        let fixture: ComponentFixture<ContactDetailComponent>;
 | 
			
		||||
        const route = ({ data: of({ contact: new Contact(123) }) } as any) as ActivatedRoute;
 | 
			
		||||
 | 
			
		||||
        beforeEach(() => {
 | 
			
		||||
            TestBed.configureTestingModule({
 | 
			
		||||
                imports: [HsadminNgTestModule],
 | 
			
		||||
                declarations: [ContactDetailComponent],
 | 
			
		||||
                providers: [{ provide: ActivatedRoute, useValue: route }]
 | 
			
		||||
            })
 | 
			
		||||
                .overrideTemplate(ContactDetailComponent, '')
 | 
			
		||||
                .compileComponents();
 | 
			
		||||
            fixture = TestBed.createComponent(ContactDetailComponent);
 | 
			
		||||
            comp = fixture.componentInstance;
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        describe('OnInit', () => {
 | 
			
		||||
            it('Should call load all on init', () => {
 | 
			
		||||
                // GIVEN
 | 
			
		||||
 | 
			
		||||
                // WHEN
 | 
			
		||||
                comp.ngOnInit();
 | 
			
		||||
 | 
			
		||||
                // THEN
 | 
			
		||||
                expect(comp.contact).toEqual(jasmine.objectContaining({ id: 123 }));
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
/* 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 { ContactUpdateComponent } from 'app/entities/contact/contact-update.component';
 | 
			
		||||
import { ContactService } from 'app/entities/contact/contact.service';
 | 
			
		||||
import { Contact } from 'app/shared/model/contact.model';
 | 
			
		||||
 | 
			
		||||
describe('Component Tests', () => {
 | 
			
		||||
    describe('Contact Management Update Component', () => {
 | 
			
		||||
        let comp: ContactUpdateComponent;
 | 
			
		||||
        let fixture: ComponentFixture<ContactUpdateComponent>;
 | 
			
		||||
        let service: ContactService;
 | 
			
		||||
 | 
			
		||||
        beforeEach(() => {
 | 
			
		||||
            TestBed.configureTestingModule({
 | 
			
		||||
                imports: [HsadminNgTestModule],
 | 
			
		||||
                declarations: [ContactUpdateComponent]
 | 
			
		||||
            })
 | 
			
		||||
                .overrideTemplate(ContactUpdateComponent, '')
 | 
			
		||||
                .compileComponents();
 | 
			
		||||
 | 
			
		||||
            fixture = TestBed.createComponent(ContactUpdateComponent);
 | 
			
		||||
            comp = fixture.componentInstance;
 | 
			
		||||
            service = fixture.debugElement.injector.get(ContactService);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        describe('save', () => {
 | 
			
		||||
            it('Should call update service on save for existing entity', fakeAsync(() => {
 | 
			
		||||
                // GIVEN
 | 
			
		||||
                const entity = new Contact(123);
 | 
			
		||||
                spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
 | 
			
		||||
                comp.contact = 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 Contact();
 | 
			
		||||
                spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
 | 
			
		||||
                comp.contact = entity;
 | 
			
		||||
                // WHEN
 | 
			
		||||
                comp.save();
 | 
			
		||||
                tick(); // simulate async
 | 
			
		||||
 | 
			
		||||
                // THEN
 | 
			
		||||
                expect(service.create).toHaveBeenCalledWith(entity);
 | 
			
		||||
                expect(comp.isSaving).toEqual(false);
 | 
			
		||||
            }));
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,128 +0,0 @@
 | 
			
		||||
/* 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 { ContactComponent } from 'app/entities/contact/contact.component';
 | 
			
		||||
import { ContactService } from 'app/entities/contact/contact.service';
 | 
			
		||||
import { Contact } from 'app/shared/model/contact.model';
 | 
			
		||||
 | 
			
		||||
describe('Component Tests', () => {
 | 
			
		||||
    describe('Contact Management Component', () => {
 | 
			
		||||
        let comp: ContactComponent;
 | 
			
		||||
        let fixture: ComponentFixture<ContactComponent>;
 | 
			
		||||
        let service: ContactService;
 | 
			
		||||
 | 
			
		||||
        beforeEach(() => {
 | 
			
		||||
            TestBed.configureTestingModule({
 | 
			
		||||
                imports: [HsadminNgTestModule],
 | 
			
		||||
                declarations: [ContactComponent],
 | 
			
		||||
                providers: [
 | 
			
		||||
                    {
 | 
			
		||||
                        provide: ActivatedRoute,
 | 
			
		||||
                        useValue: {
 | 
			
		||||
                            data: {
 | 
			
		||||
                                subscribe: (fn: (value: Data) => void) =>
 | 
			
		||||
                                    fn({
 | 
			
		||||
                                        pagingParams: {
 | 
			
		||||
                                            predicate: 'id',
 | 
			
		||||
                                            reverse: false,
 | 
			
		||||
                                            page: 0
 | 
			
		||||
                                        }
 | 
			
		||||
                                    })
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            })
 | 
			
		||||
                .overrideTemplate(ContactComponent, '')
 | 
			
		||||
                .compileComponents();
 | 
			
		||||
 | 
			
		||||
            fixture = TestBed.createComponent(ContactComponent);
 | 
			
		||||
            comp = fixture.componentInstance;
 | 
			
		||||
            service = fixture.debugElement.injector.get(ContactService);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        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 Contact(123)],
 | 
			
		||||
                        headers
 | 
			
		||||
                    })
 | 
			
		||||
                )
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            // WHEN
 | 
			
		||||
            comp.ngOnInit();
 | 
			
		||||
 | 
			
		||||
            // THEN
 | 
			
		||||
            expect(service.query).toHaveBeenCalled();
 | 
			
		||||
            expect(comp.contacts[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 Contact(123)],
 | 
			
		||||
                        headers
 | 
			
		||||
                    })
 | 
			
		||||
                )
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            // WHEN
 | 
			
		||||
            comp.loadPage(1);
 | 
			
		||||
 | 
			
		||||
            // THEN
 | 
			
		||||
            expect(service.query).toHaveBeenCalled();
 | 
			
		||||
            expect(comp.contacts[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 Contact(123)],
 | 
			
		||||
                        headers
 | 
			
		||||
                    })
 | 
			
		||||
                )
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            // WHEN
 | 
			
		||||
            comp.loadPage(1);
 | 
			
		||||
            comp.reset();
 | 
			
		||||
 | 
			
		||||
            // THEN
 | 
			
		||||
            expect(comp.page).toEqual(0);
 | 
			
		||||
            expect(service.query).toHaveBeenCalledTimes(2);
 | 
			
		||||
            expect(comp.contacts[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']);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,108 +0,0 @@
 | 
			
		||||
/* 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 { ContactService } from 'app/entities/contact/contact.service';
 | 
			
		||||
import { IContact, Contact } from 'app/shared/model/contact.model';
 | 
			
		||||
 | 
			
		||||
describe('Service Tests', () => {
 | 
			
		||||
    describe('Contact Service', () => {
 | 
			
		||||
        let injector: TestBed;
 | 
			
		||||
        let service: ContactService;
 | 
			
		||||
        let httpMock: HttpTestingController;
 | 
			
		||||
        let elemDefault: IContact;
 | 
			
		||||
        beforeEach(() => {
 | 
			
		||||
            TestBed.configureTestingModule({
 | 
			
		||||
                imports: [HttpClientTestingModule]
 | 
			
		||||
            });
 | 
			
		||||
            injector = getTestBed();
 | 
			
		||||
            service = injector.get(ContactService);
 | 
			
		||||
            httpMock = injector.get(HttpTestingController);
 | 
			
		||||
 | 
			
		||||
            elemDefault = new Contact(0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA');
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        describe('Service methods', async () => {
 | 
			
		||||
            it('should find an element', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign({}, elemDefault);
 | 
			
		||||
                service
 | 
			
		||||
                    .find(123)
 | 
			
		||||
                    .pipe(take(1))
 | 
			
		||||
                    .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
 | 
			
		||||
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'GET' });
 | 
			
		||||
                req.flush(JSON.stringify(returnedFromService));
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('should create a Contact', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        id: 0
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
                const expected = Object.assign({}, returnedFromService);
 | 
			
		||||
                service
 | 
			
		||||
                    .create(new Contact(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 Contact', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        firstName: 'BBBBBB',
 | 
			
		||||
                        lastName: 'BBBBBB',
 | 
			
		||||
                        email: 'BBBBBB'
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                const expected = Object.assign({}, returnedFromService);
 | 
			
		||||
                service
 | 
			
		||||
                    .update(expected)
 | 
			
		||||
                    .pipe(take(1))
 | 
			
		||||
                    .subscribe(resp => expect(resp).toMatchObject({ body: expected }));
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'PUT' });
 | 
			
		||||
                req.flush(JSON.stringify(returnedFromService));
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('should return a list of Contact', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        firstName: 'BBBBBB',
 | 
			
		||||
                        lastName: 'BBBBBB',
 | 
			
		||||
                        email: 'BBBBBB'
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
                const expected = Object.assign({}, returnedFromService);
 | 
			
		||||
                service
 | 
			
		||||
                    .query(expected)
 | 
			
		||||
                    .pipe(
 | 
			
		||||
                        take(1),
 | 
			
		||||
                        map(resp => resp.body)
 | 
			
		||||
                    )
 | 
			
		||||
                    .subscribe(body => expect(body).toContainEqual(expected));
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'GET' });
 | 
			
		||||
                req.flush(JSON.stringify([returnedFromService]));
 | 
			
		||||
                httpMock.verify();
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('should delete a Contact', async () => {
 | 
			
		||||
                const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
 | 
			
		||||
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'DELETE' });
 | 
			
		||||
                req.flush({ status: 200 });
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        afterEach(() => {
 | 
			
		||||
            httpMock.verify();
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,52 +0,0 @@
 | 
			
		||||
/* 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 { CustomerContactDeleteDialogComponent } from 'app/entities/customer-contact/customer-contact-delete-dialog.component';
 | 
			
		||||
import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service';
 | 
			
		||||
 | 
			
		||||
describe('Component Tests', () => {
 | 
			
		||||
    describe('CustomerContact Management Delete Component', () => {
 | 
			
		||||
        let comp: CustomerContactDeleteDialogComponent;
 | 
			
		||||
        let fixture: ComponentFixture<CustomerContactDeleteDialogComponent>;
 | 
			
		||||
        let service: CustomerContactService;
 | 
			
		||||
        let mockEventManager: any;
 | 
			
		||||
        let mockActiveModal: any;
 | 
			
		||||
 | 
			
		||||
        beforeEach(() => {
 | 
			
		||||
            TestBed.configureTestingModule({
 | 
			
		||||
                imports: [HsadminNgTestModule],
 | 
			
		||||
                declarations: [CustomerContactDeleteDialogComponent]
 | 
			
		||||
            })
 | 
			
		||||
                .overrideTemplate(CustomerContactDeleteDialogComponent, '')
 | 
			
		||||
                .compileComponents();
 | 
			
		||||
            fixture = TestBed.createComponent(CustomerContactDeleteDialogComponent);
 | 
			
		||||
            comp = fixture.componentInstance;
 | 
			
		||||
            service = fixture.debugElement.injector.get(CustomerContactService);
 | 
			
		||||
            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();
 | 
			
		||||
                })
 | 
			
		||||
            ));
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,40 +0,0 @@
 | 
			
		||||
/* 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 { CustomerContactDetailComponent } from 'app/entities/customer-contact/customer-contact-detail.component';
 | 
			
		||||
import { CustomerContact } from 'app/shared/model/customer-contact.model';
 | 
			
		||||
 | 
			
		||||
describe('Component Tests', () => {
 | 
			
		||||
    describe('CustomerContact Management Detail Component', () => {
 | 
			
		||||
        let comp: CustomerContactDetailComponent;
 | 
			
		||||
        let fixture: ComponentFixture<CustomerContactDetailComponent>;
 | 
			
		||||
        const route = ({ data: of({ customerContact: new CustomerContact(123) }) } as any) as ActivatedRoute;
 | 
			
		||||
 | 
			
		||||
        beforeEach(() => {
 | 
			
		||||
            TestBed.configureTestingModule({
 | 
			
		||||
                imports: [HsadminNgTestModule],
 | 
			
		||||
                declarations: [CustomerContactDetailComponent],
 | 
			
		||||
                providers: [{ provide: ActivatedRoute, useValue: route }]
 | 
			
		||||
            })
 | 
			
		||||
                .overrideTemplate(CustomerContactDetailComponent, '')
 | 
			
		||||
                .compileComponents();
 | 
			
		||||
            fixture = TestBed.createComponent(CustomerContactDetailComponent);
 | 
			
		||||
            comp = fixture.componentInstance;
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        describe('OnInit', () => {
 | 
			
		||||
            it('Should call load all on init', () => {
 | 
			
		||||
                // GIVEN
 | 
			
		||||
 | 
			
		||||
                // WHEN
 | 
			
		||||
                comp.ngOnInit();
 | 
			
		||||
 | 
			
		||||
                // THEN
 | 
			
		||||
                expect(comp.customerContact).toEqual(jasmine.objectContaining({ id: 123 }));
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
/* 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 { CustomerContactUpdateComponent } from 'app/entities/customer-contact/customer-contact-update.component';
 | 
			
		||||
import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service';
 | 
			
		||||
import { CustomerContact } from 'app/shared/model/customer-contact.model';
 | 
			
		||||
 | 
			
		||||
describe('Component Tests', () => {
 | 
			
		||||
    describe('CustomerContact Management Update Component', () => {
 | 
			
		||||
        let comp: CustomerContactUpdateComponent;
 | 
			
		||||
        let fixture: ComponentFixture<CustomerContactUpdateComponent>;
 | 
			
		||||
        let service: CustomerContactService;
 | 
			
		||||
 | 
			
		||||
        beforeEach(() => {
 | 
			
		||||
            TestBed.configureTestingModule({
 | 
			
		||||
                imports: [HsadminNgTestModule],
 | 
			
		||||
                declarations: [CustomerContactUpdateComponent]
 | 
			
		||||
            })
 | 
			
		||||
                .overrideTemplate(CustomerContactUpdateComponent, '')
 | 
			
		||||
                .compileComponents();
 | 
			
		||||
 | 
			
		||||
            fixture = TestBed.createComponent(CustomerContactUpdateComponent);
 | 
			
		||||
            comp = fixture.componentInstance;
 | 
			
		||||
            service = fixture.debugElement.injector.get(CustomerContactService);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        describe('save', () => {
 | 
			
		||||
            it('Should call update service on save for existing entity', fakeAsync(() => {
 | 
			
		||||
                // GIVEN
 | 
			
		||||
                const entity = new CustomerContact(123);
 | 
			
		||||
                spyOn(service, 'update').and.returnValue(of(new HttpResponse({ body: entity })));
 | 
			
		||||
                comp.customerContact = 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 CustomerContact();
 | 
			
		||||
                spyOn(service, 'create').and.returnValue(of(new HttpResponse({ body: entity })));
 | 
			
		||||
                comp.customerContact = entity;
 | 
			
		||||
                // WHEN
 | 
			
		||||
                comp.save();
 | 
			
		||||
                tick(); // simulate async
 | 
			
		||||
 | 
			
		||||
                // THEN
 | 
			
		||||
                expect(service.create).toHaveBeenCalledWith(entity);
 | 
			
		||||
                expect(comp.isSaving).toEqual(false);
 | 
			
		||||
            }));
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,128 +0,0 @@
 | 
			
		||||
/* 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 { CustomerContactComponent } from 'app/entities/customer-contact/customer-contact.component';
 | 
			
		||||
import { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service';
 | 
			
		||||
import { CustomerContact } from 'app/shared/model/customer-contact.model';
 | 
			
		||||
 | 
			
		||||
describe('Component Tests', () => {
 | 
			
		||||
    describe('CustomerContact Management Component', () => {
 | 
			
		||||
        let comp: CustomerContactComponent;
 | 
			
		||||
        let fixture: ComponentFixture<CustomerContactComponent>;
 | 
			
		||||
        let service: CustomerContactService;
 | 
			
		||||
 | 
			
		||||
        beforeEach(() => {
 | 
			
		||||
            TestBed.configureTestingModule({
 | 
			
		||||
                imports: [HsadminNgTestModule],
 | 
			
		||||
                declarations: [CustomerContactComponent],
 | 
			
		||||
                providers: [
 | 
			
		||||
                    {
 | 
			
		||||
                        provide: ActivatedRoute,
 | 
			
		||||
                        useValue: {
 | 
			
		||||
                            data: {
 | 
			
		||||
                                subscribe: (fn: (value: Data) => void) =>
 | 
			
		||||
                                    fn({
 | 
			
		||||
                                        pagingParams: {
 | 
			
		||||
                                            predicate: 'id',
 | 
			
		||||
                                            reverse: false,
 | 
			
		||||
                                            page: 0
 | 
			
		||||
                                        }
 | 
			
		||||
                                    })
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                ]
 | 
			
		||||
            })
 | 
			
		||||
                .overrideTemplate(CustomerContactComponent, '')
 | 
			
		||||
                .compileComponents();
 | 
			
		||||
 | 
			
		||||
            fixture = TestBed.createComponent(CustomerContactComponent);
 | 
			
		||||
            comp = fixture.componentInstance;
 | 
			
		||||
            service = fixture.debugElement.injector.get(CustomerContactService);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        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 CustomerContact(123)],
 | 
			
		||||
                        headers
 | 
			
		||||
                    })
 | 
			
		||||
                )
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            // WHEN
 | 
			
		||||
            comp.ngOnInit();
 | 
			
		||||
 | 
			
		||||
            // THEN
 | 
			
		||||
            expect(service.query).toHaveBeenCalled();
 | 
			
		||||
            expect(comp.customerContacts[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 CustomerContact(123)],
 | 
			
		||||
                        headers
 | 
			
		||||
                    })
 | 
			
		||||
                )
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            // WHEN
 | 
			
		||||
            comp.loadPage(1);
 | 
			
		||||
 | 
			
		||||
            // THEN
 | 
			
		||||
            expect(service.query).toHaveBeenCalled();
 | 
			
		||||
            expect(comp.customerContacts[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 CustomerContact(123)],
 | 
			
		||||
                        headers
 | 
			
		||||
                    })
 | 
			
		||||
                )
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            // WHEN
 | 
			
		||||
            comp.loadPage(1);
 | 
			
		||||
            comp.reset();
 | 
			
		||||
 | 
			
		||||
            // THEN
 | 
			
		||||
            expect(comp.page).toEqual(0);
 | 
			
		||||
            expect(service.query).toHaveBeenCalledTimes(2);
 | 
			
		||||
            expect(comp.customerContacts[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']);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,104 +0,0 @@
 | 
			
		||||
/* 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 { CustomerContactService } from 'app/entities/customer-contact/customer-contact.service';
 | 
			
		||||
import { ICustomerContact, CustomerContact, CustomerContactRole } from 'app/shared/model/customer-contact.model';
 | 
			
		||||
 | 
			
		||||
describe('Service Tests', () => {
 | 
			
		||||
    describe('CustomerContact Service', () => {
 | 
			
		||||
        let injector: TestBed;
 | 
			
		||||
        let service: CustomerContactService;
 | 
			
		||||
        let httpMock: HttpTestingController;
 | 
			
		||||
        let elemDefault: ICustomerContact;
 | 
			
		||||
        beforeEach(() => {
 | 
			
		||||
            TestBed.configureTestingModule({
 | 
			
		||||
                imports: [HttpClientTestingModule]
 | 
			
		||||
            });
 | 
			
		||||
            injector = getTestBed();
 | 
			
		||||
            service = injector.get(CustomerContactService);
 | 
			
		||||
            httpMock = injector.get(HttpTestingController);
 | 
			
		||||
 | 
			
		||||
            elemDefault = new CustomerContact(0, CustomerContactRole.CONTRACTUAL);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        describe('Service methods', async () => {
 | 
			
		||||
            it('should find an element', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign({}, elemDefault);
 | 
			
		||||
                service
 | 
			
		||||
                    .find(123)
 | 
			
		||||
                    .pipe(take(1))
 | 
			
		||||
                    .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
 | 
			
		||||
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'GET' });
 | 
			
		||||
                req.flush(JSON.stringify(returnedFromService));
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('should create a CustomerContact', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        id: 0
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
                const expected = Object.assign({}, returnedFromService);
 | 
			
		||||
                service
 | 
			
		||||
                    .create(new CustomerContact(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 CustomerContact', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        role: 'BBBBBB'
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                const expected = Object.assign({}, returnedFromService);
 | 
			
		||||
                service
 | 
			
		||||
                    .update(expected)
 | 
			
		||||
                    .pipe(take(1))
 | 
			
		||||
                    .subscribe(resp => expect(resp).toMatchObject({ body: expected }));
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'PUT' });
 | 
			
		||||
                req.flush(JSON.stringify(returnedFromService));
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('should return a list of CustomerContact', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        role: 'BBBBBB'
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
                const expected = Object.assign({}, returnedFromService);
 | 
			
		||||
                service
 | 
			
		||||
                    .query(expected)
 | 
			
		||||
                    .pipe(
 | 
			
		||||
                        take(1),
 | 
			
		||||
                        map(resp => resp.body)
 | 
			
		||||
                    )
 | 
			
		||||
                    .subscribe(body => expect(body).toContainEqual(expected));
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'GET' });
 | 
			
		||||
                req.flush(JSON.stringify([returnedFromService]));
 | 
			
		||||
                httpMock.verify();
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('should delete a CustomerContact', async () => {
 | 
			
		||||
                const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
 | 
			
		||||
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'DELETE' });
 | 
			
		||||
                req.flush({ status: 200 });
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        afterEach(() => {
 | 
			
		||||
            httpMock.verify();
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,52 +0,0 @@
 | 
			
		||||
/* 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();
 | 
			
		||||
                })
 | 
			
		||||
            ));
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,40 +0,0 @@
 | 
			
		||||
/* 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 }));
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
/* tslint:disable max-line-length */
 | 
			
		||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
 | 
			
		||||
import { HttpResponse } from '@angular/common/http';
 | 
			
		||||
import { 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);
 | 
			
		||||
            }));
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,128 +0,0 @@
 | 
			
		||||
/* 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']);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,114 +0,0 @@
 | 
			
		||||
/* tslint:disable max-line-length */
 | 
			
		||||
import { getTestBed, TestBed } from '@angular/core/testing';
 | 
			
		||||
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
 | 
			
		||||
import { map, take } from 'rxjs/operators';
 | 
			
		||||
import { CustomerService } from 'app/entities/customer/customer.service';
 | 
			
		||||
import { Customer, ICustomer } from 'app/shared/model/customer.model';
 | 
			
		||||
 | 
			
		||||
describe('Service Tests', () => {
 | 
			
		||||
    describe('Customer Service', () => {
 | 
			
		||||
        let injector: TestBed;
 | 
			
		||||
        let service: CustomerService;
 | 
			
		||||
        let httpMock: HttpTestingController;
 | 
			
		||||
        let elemDefault: ICustomer;
 | 
			
		||||
        beforeEach(() => {
 | 
			
		||||
            TestBed.configureTestingModule({
 | 
			
		||||
                imports: [HttpClientTestingModule]
 | 
			
		||||
            });
 | 
			
		||||
            injector = getTestBed();
 | 
			
		||||
            service = injector.get(CustomerService);
 | 
			
		||||
            httpMock = injector.get(HttpTestingController);
 | 
			
		||||
 | 
			
		||||
            elemDefault = new Customer(0, 0, 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA', 'AAAAAAA');
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        describe('Service methods', async () => {
 | 
			
		||||
            it('should find an element', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign({}, elemDefault);
 | 
			
		||||
                service
 | 
			
		||||
                    .find(123)
 | 
			
		||||
                    .pipe(take(1))
 | 
			
		||||
                    .subscribe(resp => expect(resp).toMatchObject({ body: elemDefault }));
 | 
			
		||||
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'GET' });
 | 
			
		||||
                req.flush(JSON.stringify(returnedFromService));
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('should create a Customer', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        id: 0
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
                const expected = Object.assign({}, returnedFromService);
 | 
			
		||||
                service
 | 
			
		||||
                    .create(new Customer(null))
 | 
			
		||||
                    .pipe(take(1))
 | 
			
		||||
                    .subscribe(resp => expect(resp).toMatchObject({ body: expected }));
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'POST' });
 | 
			
		||||
                req.flush(JSON.stringify(returnedFromService));
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('should update a Customer', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        number: 1,
 | 
			
		||||
                        prefix: 'BBBBBB',
 | 
			
		||||
                        name: 'BBBBBB',
 | 
			
		||||
                        contractualAddress: 'BBBBBB',
 | 
			
		||||
                        contractualSalutation: 'BBBBBB',
 | 
			
		||||
                        billingAddress: 'BBBBBB',
 | 
			
		||||
                        billingSalutation: 'BBBBBB'
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                const expected = Object.assign({}, returnedFromService);
 | 
			
		||||
                service
 | 
			
		||||
                    .update(expected)
 | 
			
		||||
                    .pipe(take(1))
 | 
			
		||||
                    .subscribe(resp => expect(resp).toMatchObject({ body: expected }));
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'PUT' });
 | 
			
		||||
                req.flush(JSON.stringify(returnedFromService));
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('should return a list of Customer', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        number: 1,
 | 
			
		||||
                        prefix: 'BBBBBB',
 | 
			
		||||
                        name: 'BBBBBB',
 | 
			
		||||
                        contractualAddress: 'BBBBBB',
 | 
			
		||||
                        contractualSalutation: 'BBBBBB',
 | 
			
		||||
                        billingAddress: 'BBBBBB',
 | 
			
		||||
                        billingSalutation: 'BBBBBB'
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
                const expected = Object.assign({}, returnedFromService);
 | 
			
		||||
                service
 | 
			
		||||
                    .query(expected)
 | 
			
		||||
                    .pipe(
 | 
			
		||||
                        take(1),
 | 
			
		||||
                        map(resp => resp.body)
 | 
			
		||||
                    )
 | 
			
		||||
                    .subscribe(body => expect(body).toContainEqual(expected));
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'GET' });
 | 
			
		||||
                req.flush(JSON.stringify([returnedFromService]));
 | 
			
		||||
                httpMock.verify();
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            it('should delete a Customer', async () => {
 | 
			
		||||
                const rxPromise = service.delete(123).subscribe(resp => expect(resp.ok));
 | 
			
		||||
 | 
			
		||||
                const req = httpMock.expectOne({ method: 'DELETE' });
 | 
			
		||||
                req.flush({ status: 200 });
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        afterEach(() => {
 | 
			
		||||
            httpMock.verify();
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,52 +0,0 @@
 | 
			
		||||
/* 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();
 | 
			
		||||
                })
 | 
			
		||||
            ));
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,40 +0,0 @@
 | 
			
		||||
/* 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 }));
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
/* tslint:disable max-line-length */
 | 
			
		||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
 | 
			
		||||
import { HttpResponse } from '@angular/common/http';
 | 
			
		||||
import { 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);
 | 
			
		||||
            }));
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,128 +0,0 @@
 | 
			
		||||
/* 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']);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,136 +0,0 @@
 | 
			
		||||
/* 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);
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        describe('Service methods', async () => {
 | 
			
		||||
            it('should find an element', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        sinceDate: currentDate.format(DATE_FORMAT),
 | 
			
		||||
                        untilDate: 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,
 | 
			
		||||
                        sinceDate: currentDate.format(DATE_FORMAT),
 | 
			
		||||
                        untilDate: currentDate.format(DATE_FORMAT)
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
                const expected = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        sinceDate: currentDate,
 | 
			
		||||
                        untilDate: 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(
 | 
			
		||||
                    {
 | 
			
		||||
                        sinceDate: currentDate.format(DATE_FORMAT),
 | 
			
		||||
                        untilDate: currentDate.format(DATE_FORMAT)
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                const expected = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        sinceDate: currentDate,
 | 
			
		||||
                        untilDate: 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(
 | 
			
		||||
                    {
 | 
			
		||||
                        sinceDate: currentDate.format(DATE_FORMAT),
 | 
			
		||||
                        untilDate: currentDate.format(DATE_FORMAT)
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
                const expected = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        sinceDate: currentDate,
 | 
			
		||||
                        untilDate: 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();
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,52 +0,0 @@
 | 
			
		||||
/* 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();
 | 
			
		||||
                })
 | 
			
		||||
            ));
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,40 +0,0 @@
 | 
			
		||||
/* 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 }));
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,60 +0,0 @@
 | 
			
		||||
/* tslint:disable max-line-length */
 | 
			
		||||
import { ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core/testing';
 | 
			
		||||
import { HttpResponse } from '@angular/common/http';
 | 
			
		||||
import { 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);
 | 
			
		||||
            }));
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,128 +0,0 @@
 | 
			
		||||
/* 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']);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
@@ -1,135 +0,0 @@
 | 
			
		||||
/* 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, ShareAction.SUBSCRIPTION, 0, 'AAAAAAA');
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        describe('Service methods', async () => {
 | 
			
		||||
            it('should find an element', async () => {
 | 
			
		||||
                const returnedFromService = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        date: 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,
 | 
			
		||||
                        date: currentDate.format(DATE_FORMAT)
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
                const expected = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        date: 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(
 | 
			
		||||
                    {
 | 
			
		||||
                        date: currentDate.format(DATE_FORMAT),
 | 
			
		||||
                        action: 'BBBBBB',
 | 
			
		||||
                        quantity: 1,
 | 
			
		||||
                        comment: 'BBBBBB'
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
 | 
			
		||||
                const expected = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        date: 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(
 | 
			
		||||
                    {
 | 
			
		||||
                        date: currentDate.format(DATE_FORMAT),
 | 
			
		||||
                        action: 'BBBBBB',
 | 
			
		||||
                        quantity: 1,
 | 
			
		||||
                        comment: 'BBBBBB'
 | 
			
		||||
                    },
 | 
			
		||||
                    elemDefault
 | 
			
		||||
                );
 | 
			
		||||
                const expected = Object.assign(
 | 
			
		||||
                    {
 | 
			
		||||
                        date: 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();
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
		Reference in New Issue
	
	Block a user