1
0

Merge branch 'master' into spike/JSonSerializerDeserializerForDTOs

# Conflicts:
#	package-lock.json
#	src/main/java/org/hostsharing/hsadminng/service/dto/CustomerDTO.java
This commit is contained in:
Michael Hoennig
2019-04-18 17:36:35 +02:00
180 changed files with 5157 additions and 5641 deletions

View File

@@ -69,20 +69,20 @@ public class MembershipRepositoryIntTest {
private Customer createCustomer() {
final Customer customer = new Customer();
customer.setPrefix(RandomStringUtils.randomAlphabetic(3).toLowerCase());
customer.setNumber(RandomUtils.nextInt(10001, 19999));
customer.setReference(RandomUtils.nextInt(10001, 19999));
customer.setName(RandomStringUtils.randomAlphabetic(10));
customer.setContractualAddress(RandomStringUtils.randomAlphabetic(10));
customerRepository.save(customer);
return customer;
}
private Customer createCustomerWithMembership(final String sinceDate, final String untilDate) {
private Customer createCustomerWithMembership(final String from, final String to) {
final Customer customer = createCustomer();
final Membership membership = new Membership();
membership.setCustomer(customer);
membership.setSinceDate(LocalDate.parse(sinceDate));
if (untilDate != null) {
membership.setUntilDate(LocalDate.parse(untilDate));
membership.setMemberUntil(LocalDate.parse(from));
if (to != null) {
membership.setMemberFrom(LocalDate.parse(to));
}
membershipRepository.save(membership);
return customer;

View File

@@ -101,12 +101,12 @@ public class MembershipValidatorUnitTest {
GivenMembershipValidationTestCase since(final String sinceDate) {
membershipDto.setSinceDate(LocalDate.parse(sinceDate));
membershipDto.setMemberFrom(LocalDate.parse(sinceDate));
return this;
}
public GivenMembershipValidationTestCase until(final String untilDate) {
membershipDto.setUntilDate(LocalDate.parse(untilDate));
membershipDto.setMemberUntil(LocalDate.parse(untilDate));
return this;
}

View File

@@ -1,15 +1,17 @@
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.hostsharing.hsadminng.service.dto.AssetCriteria;
import org.hostsharing.hsadminng.service.AssetQueryService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -31,11 +33,14 @@ import java.time.LocalDate;
import java.time.ZoneId;
import java.util.List;
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
/**
* Test class for the AssetResource REST controller.
*
@@ -45,8 +50,11 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@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 LocalDate DEFAULT_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_VALUE_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_VALUE_DATE = LocalDate.now(ZoneId.systemDefault());
private static final AssetAction DEFAULT_ACTION = AssetAction.PAYMENT;
private static final AssetAction UPDATED_ACTION = AssetAction.HANDOVER;
@@ -54,8 +62,8 @@ public class AssetResourceIntTest {
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";
private static final String DEFAULT_REMARK = "AAAAAAAAAA";
private static final String UPDATED_REMARK = "BBBBBBBBBB";
@Autowired
private AssetRepository assetRepository;
@@ -108,15 +116,16 @@ public class AssetResourceIntTest {
*/
public static Asset createEntity(EntityManager em) {
Asset asset = new Asset()
.date(DEFAULT_DATE)
.documentDate(DEFAULT_DOCUMENT_DATE)
.valueDate(DEFAULT_VALUE_DATE)
.action(DEFAULT_ACTION)
.amount(DEFAULT_AMOUNT)
.comment(DEFAULT_COMMENT);
.remark(DEFAULT_REMARK);
// Add required entity
Membership membership = MembershipResourceIntTest.createEntity(em);
em.persist(membership);
em.flush();
asset.setMember(membership);
asset.setMembership(membership);
return asset;
}
@@ -141,10 +150,11 @@ public class AssetResourceIntTest {
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.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE);
assertThat(testAsset.getValueDate()).isEqualTo(DEFAULT_VALUE_DATE);
assertThat(testAsset.getAction()).isEqualTo(DEFAULT_ACTION);
assertThat(testAsset.getAmount()).isEqualTo(DEFAULT_AMOUNT);
assertThat(testAsset.getComment()).isEqualTo(DEFAULT_COMMENT);
assertThat(testAsset.getRemark()).isEqualTo(DEFAULT_REMARK);
}
@Test
@@ -169,10 +179,29 @@ public class AssetResourceIntTest {
@Test
@Transactional
public void checkDateIsRequired() throws Exception {
public void checkDocumentDateIsRequired() throws Exception {
int databaseSizeBeforeTest = assetRepository.findAll().size();
// set the field null
asset.setDate(null);
asset.setDocumentDate(null);
// Create the Asset, which fails.
AssetDTO assetDTO = assetMapper.toDto(asset);
restAssetMockMvc.perform(post("/api/assets")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(assetDTO)))
.andExpect(status().isBadRequest());
List<Asset> assetList = assetRepository.findAll();
assertThat(assetList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkValueDateIsRequired() throws Exception {
int databaseSizeBeforeTest = assetRepository.findAll().size();
// set the field null
asset.setValueDate(null);
// Create the Asset, which fails.
AssetDTO assetDTO = assetMapper.toDto(asset);
@@ -235,10 +264,11 @@ public class AssetResourceIntTest {
.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("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].valueDate").value(hasItem(DEFAULT_VALUE_DATE.toString())))
.andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString())))
.andExpect(jsonPath("$.[*].amount").value(hasItem(DEFAULT_AMOUNT.intValue())))
.andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT.toString())));
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString())));
}
@Test
@@ -252,75 +282,142 @@ public class AssetResourceIntTest {
.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("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString()))
.andExpect(jsonPath("$.valueDate").value(DEFAULT_VALUE_DATE.toString()))
.andExpect(jsonPath("$.action").value(DEFAULT_ACTION.toString()))
.andExpect(jsonPath("$.amount").value(DEFAULT_AMOUNT.intValue()))
.andExpect(jsonPath("$.comment").value(DEFAULT_COMMENT.toString()));
.andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString()));
}
@Test
@Transactional
public void getAllAssetsByDateIsEqualToSomething() throws Exception {
public void getAllAssetsByDocumentDateIsEqualToSomething() 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 documentDate equals to DEFAULT_DOCUMENT_DATE
defaultAssetShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE);
// Get all the assetList where date equals to UPDATED_DATE
defaultAssetShouldNotBeFound("date.equals=" + UPDATED_DATE);
// Get all the assetList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultAssetShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllAssetsByDateIsInShouldWork() throws Exception {
public void getAllAssetsByDocumentDateIsInShouldWork() 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 documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE
defaultAssetShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE);
// Get all the assetList where date equals to UPDATED_DATE
defaultAssetShouldNotBeFound("date.in=" + UPDATED_DATE);
// Get all the assetList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultAssetShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllAssetsByDateIsNullOrNotNull() throws Exception {
public void getAllAssetsByDocumentDateIsNullOrNotNull() 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 documentDate is not null
defaultAssetShouldBeFound("documentDate.specified=true");
// Get all the assetList where date is null
defaultAssetShouldNotBeFound("date.specified=false");
// Get all the assetList where documentDate is null
defaultAssetShouldNotBeFound("documentDate.specified=false");
}
@Test
@Transactional
public void getAllAssetsByDateIsGreaterThanOrEqualToSomething() throws Exception {
public void getAllAssetsByDocumentDateIsGreaterThanOrEqualToSomething() 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 documentDate greater than or equals to DEFAULT_DOCUMENT_DATE
defaultAssetShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the assetList where date greater than or equals to UPDATED_DATE
defaultAssetShouldNotBeFound("date.greaterOrEqualThan=" + UPDATED_DATE);
// Get all the assetList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE
defaultAssetShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllAssetsByDateIsLessThanSomething() throws Exception {
public void getAllAssetsByDocumentDateIsLessThanSomething() 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 documentDate less than or equals to DEFAULT_DOCUMENT_DATE
defaultAssetShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the assetList where date less than or equals to UPDATED_DATE
defaultAssetShouldBeFound("date.lessThan=" + UPDATED_DATE);
// Get all the assetList where documentDate less than or equals to UPDATED_DOCUMENT_DATE
defaultAssetShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllAssetsByValueDateIsEqualToSomething() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where valueDate equals to DEFAULT_VALUE_DATE
defaultAssetShouldBeFound("valueDate.equals=" + DEFAULT_VALUE_DATE);
// Get all the assetList where valueDate equals to UPDATED_VALUE_DATE
defaultAssetShouldNotBeFound("valueDate.equals=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllAssetsByValueDateIsInShouldWork() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where valueDate in DEFAULT_VALUE_DATE or UPDATED_VALUE_DATE
defaultAssetShouldBeFound("valueDate.in=" + DEFAULT_VALUE_DATE + "," + UPDATED_VALUE_DATE);
// Get all the assetList where valueDate equals to UPDATED_VALUE_DATE
defaultAssetShouldNotBeFound("valueDate.in=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllAssetsByValueDateIsNullOrNotNull() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where valueDate is not null
defaultAssetShouldBeFound("valueDate.specified=true");
// Get all the assetList where valueDate is null
defaultAssetShouldNotBeFound("valueDate.specified=false");
}
@Test
@Transactional
public void getAllAssetsByValueDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where valueDate greater than or equals to DEFAULT_VALUE_DATE
defaultAssetShouldBeFound("valueDate.greaterOrEqualThan=" + DEFAULT_VALUE_DATE);
// Get all the assetList where valueDate greater than or equals to UPDATED_VALUE_DATE
defaultAssetShouldNotBeFound("valueDate.greaterOrEqualThan=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllAssetsByValueDateIsLessThanSomething() throws Exception {
// Initialize the database
assetRepository.saveAndFlush(asset);
// Get all the assetList where valueDate less than or equals to DEFAULT_VALUE_DATE
defaultAssetShouldNotBeFound("valueDate.lessThan=" + DEFAULT_VALUE_DATE);
// Get all the assetList where valueDate less than or equals to UPDATED_VALUE_DATE
defaultAssetShouldBeFound("valueDate.lessThan=" + UPDATED_VALUE_DATE);
}
@@ -404,59 +501,59 @@ public class AssetResourceIntTest {
@Test
@Transactional
public void getAllAssetsByCommentIsEqualToSomething() throws Exception {
public void getAllAssetsByRemarkIsEqualToSomething() 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 remark equals to DEFAULT_REMARK
defaultAssetShouldBeFound("remark.equals=" + DEFAULT_REMARK);
// Get all the assetList where comment equals to UPDATED_COMMENT
defaultAssetShouldNotBeFound("comment.equals=" + UPDATED_COMMENT);
// Get all the assetList where remark equals to UPDATED_REMARK
defaultAssetShouldNotBeFound("remark.equals=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllAssetsByCommentIsInShouldWork() throws Exception {
public void getAllAssetsByRemarkIsInShouldWork() 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 remark in DEFAULT_REMARK or UPDATED_REMARK
defaultAssetShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK);
// Get all the assetList where comment equals to UPDATED_COMMENT
defaultAssetShouldNotBeFound("comment.in=" + UPDATED_COMMENT);
// Get all the assetList where remark equals to UPDATED_REMARK
defaultAssetShouldNotBeFound("remark.in=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllAssetsByCommentIsNullOrNotNull() throws Exception {
public void getAllAssetsByRemarkIsNullOrNotNull() 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 remark is not null
defaultAssetShouldBeFound("remark.specified=true");
// Get all the assetList where comment is null
defaultAssetShouldNotBeFound("comment.specified=false");
// Get all the assetList where remark is null
defaultAssetShouldNotBeFound("remark.specified=false");
}
@Test
@Transactional
public void getAllAssetsByMemberIsEqualToSomething() throws Exception {
public void getAllAssetsByMembershipIsEqualToSomething() throws Exception {
// Initialize the database
Membership member = MembershipResourceIntTest.createEntity(em);
em.persist(member);
Membership membership = MembershipResourceIntTest.createEntity(em);
em.persist(membership);
em.flush();
asset.setMember(member);
asset.setMembership(membership);
assetRepository.saveAndFlush(asset);
Long memberId = member.getId();
Long membershipId = membership.getId();
// Get all the assetList where member equals to memberId
defaultAssetShouldBeFound("memberId.equals=" + memberId);
// Get all the assetList where membership equals to membershipId
defaultAssetShouldBeFound("membershipId.equals=" + membershipId);
// Get all the assetList where member equals to memberId + 1
defaultAssetShouldNotBeFound("memberId.equals=" + (memberId + 1));
// Get all the assetList where membership equals to membershipId + 1
defaultAssetShouldNotBeFound("membershipId.equals=" + (membershipId + 1));
}
/**
@@ -467,10 +564,11 @@ public class AssetResourceIntTest {
.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("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].valueDate").value(hasItem(DEFAULT_VALUE_DATE.toString())))
.andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString())))
.andExpect(jsonPath("$.[*].amount").value(hasItem(DEFAULT_AMOUNT.intValue())))
.andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT)));
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK)));
// Check, that the count call also returns 1
restAssetMockMvc.perform(get("/api/assets/count?sort=id,desc&" + filter))
@@ -518,10 +616,11 @@ public class AssetResourceIntTest {
// Disconnect from session so that the updates on updatedAsset are not directly saved in db
em.detach(updatedAsset);
updatedAsset
.date(UPDATED_DATE)
.documentDate(UPDATED_DOCUMENT_DATE)
.valueDate(UPDATED_VALUE_DATE)
.action(UPDATED_ACTION)
.amount(UPDATED_AMOUNT)
.comment(UPDATED_COMMENT);
.remark(UPDATED_REMARK);
AssetDTO assetDTO = assetMapper.toDto(updatedAsset);
restAssetMockMvc.perform(put("/api/assets")
@@ -533,10 +632,11 @@ public class AssetResourceIntTest {
List<Asset> assetList = assetRepository.findAll();
assertThat(assetList).hasSize(databaseSizeBeforeUpdate);
Asset testAsset = assetList.get(assetList.size() - 1);
assertThat(testAsset.getDate()).isEqualTo(UPDATED_DATE);
assertThat(testAsset.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE);
assertThat(testAsset.getValueDate()).isEqualTo(UPDATED_VALUE_DATE);
assertThat(testAsset.getAction()).isEqualTo(UPDATED_ACTION);
assertThat(testAsset.getAmount()).isEqualTo(UPDATED_AMOUNT);
assertThat(testAsset.getComment()).isEqualTo(UPDATED_COMMENT);
assertThat(testAsset.getRemark()).isEqualTo(UPDATED_REMARK);
}
@Test

View File

@@ -1,535 +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.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.createDefaultEntity(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();
}
}

View File

@@ -1,449 +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.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 a CustomerContaact entity for the given Customer for testing purposes.
*
* 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 crateEnitity(final EntityManager em, Customer customer) {
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
em.persist(customer);
em.flush();
customerContact.setCustomer(customer);
return customerContact;
}
/**
* Create an arbitrary CustomerContact entity for tests.
*
* 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 createDefaultEntity(EntityManager em) {
return crateEnitity(em, CustomerResourceIntTest.createEntity(em));
}
/**
* Create another arbitrary CustomerContact 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 createAnotherEntity(EntityManager em) {
return crateEnitity(em, CustomerResourceIntTest.createAnotherEntity(em));
}
@Before
public void initTest() {
customerContact = createDefaultEntity(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.createAnotherEntity(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();
}
}

View File

@@ -1,15 +1,18 @@
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.domain.SepaMandate;
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.hostsharing.hsadminng.service.dto.CustomerCriteria;
import org.hostsharing.hsadminng.service.CustomerQueryService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -28,9 +31,10 @@ 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.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
@@ -43,32 +47,29 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@SpringBootTest(classes = HsadminNgApp.class)
public class CustomerResourceIntTest {
private static final Integer DEFAULT_NUMBER = 10000;
private static final Integer UPDATED_NUMBER = 10001;
private static final Integer OTHER_NUMBER_BASE = 11000;
private static final Integer DEFAULT_REFERENCE = 10000;
private static final Integer UPDATED_REFERENCE = 10001;
private static final String DEFAULT_PREFIX = "def";
private static final String UPDATED_PREFIX = "new";
private static final String OTHER_PREFIX_BASE = "o";
private static final String DEFAULT_PREFIX = "hu";
private static final String UPDATED_PREFIX = "umj";
private static final String DEFAULT_NAME = "Default GmbH";
private static final String UPDATED_NAME = "Updated Default GmbH";
private static final String OTHER_NAME_BASE = "Other Corp.";
private static final String DEFAULT_CONTRACTUAL_ADDRESS = "Default Address";
private static final String UPDATED_CONTRACTUAL_ADDRESS = "Updated Address";
private static final String OTHER_CONTRACTUAL_ADDRESS_BASE = "Other Street ";
private static final String DEFAULT_NAME = "AAAAAAAAAA";
private static final String UPDATED_NAME = "BBBBBBBBBB";
private static final String DEFAULT_CONTRACTUAL_SALUTATION = "AAAAAAAAAA";
private static final String UPDATED_CONTRACTUAL_SALUTATION = "BBBBBBBBBB";
private static final String DEFAULT_BILLING_ADDRESS = "AAAAAAAAAA";
private static final String UPDATED_BILLING_ADDRESS = "BBBBBBBBBB";
private static final String DEFAULT_CONTRACTUAL_ADDRESS = "AAAAAAAAAA";
private static final String UPDATED_CONTRACTUAL_ADDRESS = "BBBBBBBBBB";
private static final String DEFAULT_BILLING_SALUTATION = "AAAAAAAAAA";
private static final String UPDATED_BILLING_SALUTATION = "BBBBBBBBBB";
private static int otherCounter = 0;
private static final String DEFAULT_BILLING_ADDRESS = "AAAAAAAAAA";
private static final String UPDATED_BILLING_ADDRESS = "BBBBBBBBBB";
private static final String DEFAULT_REMARK = "AAAAAAAAAA";
private static final String UPDATED_REMARK = "BBBBBBBBBB";
@Autowired
private CustomerRepository customerRepository;
@@ -114,36 +115,21 @@ public class CustomerResourceIntTest {
}
/**
* Create an entity for tests.
* 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)
.reference(DEFAULT_REFERENCE)
.prefix(DEFAULT_PREFIX)
.name(DEFAULT_NAME)
.contractualAddress(DEFAULT_CONTRACTUAL_ADDRESS)
.contractualSalutation(DEFAULT_CONTRACTUAL_SALUTATION)
.contractualAddress(DEFAULT_CONTRACTUAL_ADDRESS)
.billingSalutation(DEFAULT_BILLING_SALUTATION)
.billingAddress(DEFAULT_BILLING_ADDRESS)
.billingSalutation(DEFAULT_BILLING_SALUTATION);
return customer;
}
/**
* Create another entity for tests.
*
* 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 createAnotherEntity(EntityManager em) {
Customer customer = new Customer()
.number(OTHER_NUMBER_BASE + otherCounter)
.prefix(OTHER_PREFIX_BASE + String.format("%02d", otherCounter))
.name(OTHER_NAME_BASE + otherCounter)
.contractualAddress(OTHER_CONTRACTUAL_ADDRESS_BASE + otherCounter);
++otherCounter;
.remark(DEFAULT_REMARK);
return customer;
}
@@ -168,13 +154,14 @@ public class CustomerResourceIntTest {
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.getReference()).isEqualTo(DEFAULT_REFERENCE);
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.getContractualAddress()).isEqualTo(DEFAULT_CONTRACTUAL_ADDRESS);
assertThat(testCustomer.getBillingSalutation()).isEqualTo(DEFAULT_BILLING_SALUTATION);
assertThat(testCustomer.getBillingAddress()).isEqualTo(DEFAULT_BILLING_ADDRESS);
assertThat(testCustomer.getRemark()).isEqualTo(DEFAULT_REMARK);
}
@Test
@@ -199,10 +186,10 @@ public class CustomerResourceIntTest {
@Test
@Transactional
public void checkNumberIsRequired() throws Exception {
public void checkReferenceIsRequired() throws Exception {
int databaseSizeBeforeTest = customerRepository.findAll().size();
// set the field null
customer.setNumber(null);
customer.setReference(null);
// Create the Customer, which fails.
CustomerDTO customerDTO = customerMapper.toDto(customer);
@@ -284,13 +271,14 @@ public class CustomerResourceIntTest {
.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("$.[*].reference").value(hasItem(DEFAULT_REFERENCE)))
.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("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS.toString())))
.andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION.toString())))
.andExpect(jsonPath("$.[*].billingAddress").value(hasItem(DEFAULT_BILLING_ADDRESS.toString())))
.andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION.toString())));
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString())));
}
@Test
@@ -304,78 +292,79 @@ public class CustomerResourceIntTest {
.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("$.reference").value(DEFAULT_REFERENCE))
.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("$.contractualAddress").value(DEFAULT_CONTRACTUAL_ADDRESS.toString()))
.andExpect(jsonPath("$.billingSalutation").value(DEFAULT_BILLING_SALUTATION.toString()))
.andExpect(jsonPath("$.billingAddress").value(DEFAULT_BILLING_ADDRESS.toString()))
.andExpect(jsonPath("$.billingSalutation").value(DEFAULT_BILLING_SALUTATION.toString()));
.andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString()));
}
@Test
@Transactional
public void getAllCustomersByNumberIsEqualToSomething() throws Exception {
public void getAllCustomersByReferenceIsEqualToSomething() 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 reference equals to DEFAULT_REFERENCE
defaultCustomerShouldBeFound("reference.equals=" + DEFAULT_REFERENCE);
// Get all the customerList where number equals to UPDATED_NUMBER
defaultCustomerShouldNotBeFound("number.equals=" + UPDATED_NUMBER);
// Get all the customerList where reference equals to UPDATED_REFERENCE
defaultCustomerShouldNotBeFound("reference.equals=" + UPDATED_REFERENCE);
}
@Test
@Transactional
public void getAllCustomersByNumberIsInShouldWork() throws Exception {
public void getAllCustomersByReferenceIsInShouldWork() 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 reference in DEFAULT_REFERENCE or UPDATED_REFERENCE
defaultCustomerShouldBeFound("reference.in=" + DEFAULT_REFERENCE + "," + UPDATED_REFERENCE);
// Get all the customerList where number equals to UPDATED_NUMBER
defaultCustomerShouldNotBeFound("number.in=" + UPDATED_NUMBER);
// Get all the customerList where reference equals to UPDATED_REFERENCE
defaultCustomerShouldNotBeFound("reference.in=" + UPDATED_REFERENCE);
}
@Test
@Transactional
public void getAllCustomersByNumberIsNullOrNotNull() throws Exception {
public void getAllCustomersByReferenceIsNullOrNotNull() 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 reference is not null
defaultCustomerShouldBeFound("reference.specified=true");
// Get all the customerList where number is null
defaultCustomerShouldNotBeFound("number.specified=false");
// Get all the customerList where reference is null
defaultCustomerShouldNotBeFound("reference.specified=false");
}
@Test
@Transactional
public void getAllCustomersByNumberIsGreaterThanOrEqualToSomething() throws Exception {
public void getAllCustomersByReferenceIsGreaterThanOrEqualToSomething() 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 reference greater than or equals to DEFAULT_REFERENCE
defaultCustomerShouldBeFound("reference.greaterOrEqualThan=" + DEFAULT_REFERENCE);
// Get all the customerList where number greater than or equals to (DEFAULT_NUMBER + 1)
defaultCustomerShouldNotBeFound("number.greaterOrEqualThan=" + (DEFAULT_NUMBER + 1));
// Get all the customerList where reference greater than or equals to (DEFAULT_REFERENCE + 1)
defaultCustomerShouldNotBeFound("reference.greaterOrEqualThan=" + (DEFAULT_REFERENCE + 1));
}
@Test
@Transactional
public void getAllCustomersByNumberIsLessThanSomething() throws Exception {
public void getAllCustomersByReferenceIsLessThanSomething() 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 reference less than or equals to DEFAULT_REFERENCE
defaultCustomerShouldNotBeFound("reference.lessThan=" + DEFAULT_REFERENCE);
// Get all the customerList where number less than or equals to (DEFAULT_NUMBER + 1)
defaultCustomerShouldBeFound("number.lessThan=" + (DEFAULT_NUMBER + 1));
// Get all the customerList where reference less than or equals to (DEFAULT_REFERENCE + 1)
defaultCustomerShouldBeFound("reference.lessThan=" + (DEFAULT_REFERENCE + 1));
}
@@ -457,45 +446,6 @@ public class CustomerResourceIntTest {
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 {
@@ -537,41 +487,41 @@ public class CustomerResourceIntTest {
@Test
@Transactional
public void getAllCustomersByBillingAddressIsEqualToSomething() throws Exception {
public void getAllCustomersByContractualAddressIsEqualToSomething() 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 contractualAddress equals to DEFAULT_CONTRACTUAL_ADDRESS
defaultCustomerShouldBeFound("contractualAddress.equals=" + DEFAULT_CONTRACTUAL_ADDRESS);
// Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS
defaultCustomerShouldNotBeFound("billingAddress.equals=" + UPDATED_BILLING_ADDRESS);
// Get all the customerList where contractualAddress equals to UPDATED_CONTRACTUAL_ADDRESS
defaultCustomerShouldNotBeFound("contractualAddress.equals=" + UPDATED_CONTRACTUAL_ADDRESS);
}
@Test
@Transactional
public void getAllCustomersByBillingAddressIsInShouldWork() throws Exception {
public void getAllCustomersByContractualAddressIsInShouldWork() 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 contractualAddress in DEFAULT_CONTRACTUAL_ADDRESS or UPDATED_CONTRACTUAL_ADDRESS
defaultCustomerShouldBeFound("contractualAddress.in=" + DEFAULT_CONTRACTUAL_ADDRESS + "," + UPDATED_CONTRACTUAL_ADDRESS);
// Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS
defaultCustomerShouldNotBeFound("billingAddress.in=" + UPDATED_BILLING_ADDRESS);
// Get all the customerList where contractualAddress equals to UPDATED_CONTRACTUAL_ADDRESS
defaultCustomerShouldNotBeFound("contractualAddress.in=" + UPDATED_CONTRACTUAL_ADDRESS);
}
@Test
@Transactional
public void getAllCustomersByBillingAddressIsNullOrNotNull() throws Exception {
public void getAllCustomersByContractualAddressIsNullOrNotNull() 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 contractualAddress is not null
defaultCustomerShouldBeFound("contractualAddress.specified=true");
// Get all the customerList where billingAddress is null
defaultCustomerShouldNotBeFound("billingAddress.specified=false");
// Get all the customerList where contractualAddress is null
defaultCustomerShouldNotBeFound("contractualAddress.specified=false");
}
@Test
@@ -613,6 +563,84 @@ public class CustomerResourceIntTest {
defaultCustomerShouldNotBeFound("billingSalutation.specified=false");
}
@Test
@Transactional
public void getAllCustomersByBillingAddressIsEqualToSomething() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where billingAddress equals to DEFAULT_BILLING_ADDRESS
defaultCustomerShouldBeFound("billingAddress.equals=" + DEFAULT_BILLING_ADDRESS);
// Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS
defaultCustomerShouldNotBeFound("billingAddress.equals=" + UPDATED_BILLING_ADDRESS);
}
@Test
@Transactional
public void getAllCustomersByBillingAddressIsInShouldWork() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where billingAddress in DEFAULT_BILLING_ADDRESS or UPDATED_BILLING_ADDRESS
defaultCustomerShouldBeFound("billingAddress.in=" + DEFAULT_BILLING_ADDRESS + "," + UPDATED_BILLING_ADDRESS);
// Get all the customerList where billingAddress equals to UPDATED_BILLING_ADDRESS
defaultCustomerShouldNotBeFound("billingAddress.in=" + UPDATED_BILLING_ADDRESS);
}
@Test
@Transactional
public void getAllCustomersByBillingAddressIsNullOrNotNull() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where billingAddress is not null
defaultCustomerShouldBeFound("billingAddress.specified=true");
// Get all the customerList where billingAddress is null
defaultCustomerShouldNotBeFound("billingAddress.specified=false");
}
@Test
@Transactional
public void getAllCustomersByRemarkIsEqualToSomething() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where remark equals to DEFAULT_REMARK
defaultCustomerShouldBeFound("remark.equals=" + DEFAULT_REMARK);
// Get all the customerList where remark equals to UPDATED_REMARK
defaultCustomerShouldNotBeFound("remark.equals=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllCustomersByRemarkIsInShouldWork() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where remark in DEFAULT_REMARK or UPDATED_REMARK
defaultCustomerShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK);
// Get all the customerList where remark equals to UPDATED_REMARK
defaultCustomerShouldNotBeFound("remark.in=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllCustomersByRemarkIsNullOrNotNull() throws Exception {
// Initialize the database
customerRepository.saveAndFlush(customer);
// Get all the customerList where remark is not null
defaultCustomerShouldBeFound("remark.specified=true");
// Get all the customerList where remark is null
defaultCustomerShouldNotBeFound("remark.specified=false");
}
@Test
@Transactional
public void getAllCustomersByMembershipIsEqualToSomething() throws Exception {
@@ -634,20 +662,20 @@ public class CustomerResourceIntTest {
@Test
@Transactional
public void getAllCustomersByRoleIsEqualToSomething() throws Exception {
public void getAllCustomersBySepamandateIsEqualToSomething() throws Exception {
// Initialize the database
CustomerContact role = CustomerContactResourceIntTest.createAnotherEntity(em);
em.persist(role);
SepaMandate sepamandate = SepaMandateResourceIntTest.createEntity(em);
em.persist(sepamandate);
em.flush();
customer.addRole(role);
customer.addSepamandate(sepamandate);
customerRepository.saveAndFlush(customer);
Long roleId = role.getId();
Long sepamandateId = sepamandate.getId();
// Get all the customerList where role equals to roleId
defaultCustomerShouldBeFound("roleId.equals=" + roleId);
// Get all the customerList where sepamandate equals to sepamandateId
defaultCustomerShouldBeFound("sepamandateId.equals=" + sepamandateId);
// Get all the customerList where role equals to roleId + 1
defaultCustomerShouldNotBeFound("roleId.equals=" + (roleId + 1));
// Get all the customerList where sepamandate equals to sepamandateId + 1
defaultCustomerShouldNotBeFound("sepamandateId.equals=" + (sepamandateId + 1));
}
/**
@@ -658,13 +686,14 @@ public class CustomerResourceIntTest {
.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("$.[*].reference").value(hasItem(DEFAULT_REFERENCE)))
.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("$.[*].contractualAddress").value(hasItem(DEFAULT_CONTRACTUAL_ADDRESS)))
.andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION)))
.andExpect(jsonPath("$.[*].billingAddress").value(hasItem(DEFAULT_BILLING_ADDRESS)))
.andExpect(jsonPath("$.[*].billingSalutation").value(hasItem(DEFAULT_BILLING_SALUTATION)));
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK)));
// Check, that the count call also returns 1
restCustomerMockMvc.perform(get("/api/customers/count?sort=id,desc&" + filter))
@@ -712,13 +741,14 @@ public class CustomerResourceIntTest {
// Disconnect from session so that the updates on updatedCustomer are not directly saved in db
em.detach(updatedCustomer);
updatedCustomer
.number(UPDATED_NUMBER)
.reference(UPDATED_REFERENCE)
.prefix(UPDATED_PREFIX)
.name(UPDATED_NAME)
.contractualAddress(UPDATED_CONTRACTUAL_ADDRESS)
.contractualSalutation(UPDATED_CONTRACTUAL_SALUTATION)
.contractualAddress(UPDATED_CONTRACTUAL_ADDRESS)
.billingSalutation(UPDATED_BILLING_SALUTATION)
.billingAddress(UPDATED_BILLING_ADDRESS)
.billingSalutation(UPDATED_BILLING_SALUTATION);
.remark(UPDATED_REMARK);
CustomerDTO customerDTO = customerMapper.toDto(updatedCustomer);
restCustomerMockMvc.perform(put("/api/customers")
@@ -730,13 +760,14 @@ public class CustomerResourceIntTest {
List<Customer> customerList = customerRepository.findAll();
assertThat(customerList).hasSize(databaseSizeBeforeUpdate);
Customer testCustomer = customerList.get(customerList.size() - 1);
assertThat(testCustomer.getNumber()).isEqualTo(UPDATED_NUMBER);
assertThat(testCustomer.getReference()).isEqualTo(UPDATED_REFERENCE);
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.getContractualAddress()).isEqualTo(UPDATED_CONTRACTUAL_ADDRESS);
assertThat(testCustomer.getBillingSalutation()).isEqualTo(UPDATED_BILLING_SALUTATION);
assertThat(testCustomer.getBillingAddress()).isEqualTo(UPDATED_BILLING_ADDRESS);
assertThat(testCustomer.getRemark()).isEqualTo(UPDATED_REMARK);
}
@Test

View File

@@ -1,16 +1,19 @@
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.domain.Asset;
import org.hostsharing.hsadminng.domain.Customer;
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.hostsharing.hsadminng.service.dto.MembershipCriteria;
import org.hostsharing.hsadminng.service.MembershipQueryService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -31,9 +34,10 @@ import java.time.LocalDate;
import java.time.ZoneId;
import java.util.List;
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
@@ -46,12 +50,17 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@SpringBootTest(classes = HsadminNgApp.class)
public class MembershipResourceIntTest {
private static final LocalDate DEFAULT_SINCE_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate UPDATED_SINCE_DATE = DEFAULT_SINCE_DATE.plusMonths(1);
private static final LocalDate DEFAULT_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_UNTIL_DATE = UPDATED_SINCE_DATE.plusDays(600).withMonth(12).withDayOfMonth(31);
private static final LocalDate UPDATED_UNTIL_DATE = DEFAULT_UNTIL_DATE.plusYears(1);
private static final LocalDate ANOTHER_QUERY_DATE = DEFAULT_UNTIL_DATE.plusMonths(2);
private static final LocalDate DEFAULT_MEMBER_FROM = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_MEMBER_FROM = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_MEMBER_UNTIL = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_MEMBER_UNTIL = LocalDate.now(ZoneId.systemDefault());
private static final String DEFAULT_REMARK = "AAAAAAAAAA";
private static final String UPDATED_REMARK = "BBBBBBBBBB";
@Autowired
private MembershipRepository membershipRepository;
@@ -102,12 +111,14 @@ public class MembershipResourceIntTest {
* 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(final EntityManager em) {
public static Membership createEntity(EntityManager em) {
Membership membership = new Membership()
.sinceDate(DEFAULT_SINCE_DATE)
.untilDate(DEFAULT_UNTIL_DATE);
.documentDate(DEFAULT_DOCUMENT_DATE)
.memberFrom(DEFAULT_MEMBER_FROM)
.memberUntil(DEFAULT_MEMBER_UNTIL)
.remark(DEFAULT_REMARK);
// Add required entity
Customer customer = CustomerResourceIntTest.createAnotherEntity(em);
Customer customer = CustomerResourceIntTest.createEntity(em);
em.persist(customer);
em.flush();
membership.setCustomer(customer);
@@ -135,8 +146,10 @@ public class MembershipResourceIntTest {
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);
assertThat(testMembership.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE);
assertThat(testMembership.getMemberFrom()).isEqualTo(DEFAULT_MEMBER_FROM);
assertThat(testMembership.getMemberUntil()).isEqualTo(DEFAULT_MEMBER_UNTIL);
assertThat(testMembership.getRemark()).isEqualTo(DEFAULT_REMARK);
}
@Test
@@ -161,10 +174,29 @@ public class MembershipResourceIntTest {
@Test
@Transactional
public void checkSinceDateIsRequired() throws Exception {
public void checkDocumentDateIsRequired() throws Exception {
int databaseSizeBeforeTest = membershipRepository.findAll().size();
// set the field null
membership.setSinceDate(null);
membership.setDocumentDate(null);
// Create the Membership, which fails.
MembershipDTO membershipDTO = membershipMapper.toDto(membership);
restMembershipMockMvc.perform(post("/api/memberships")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(membershipDTO)))
.andExpect(status().isBadRequest());
List<Membership> membershipList = membershipRepository.findAll();
assertThat(membershipList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkMemberFromIsRequired() throws Exception {
int databaseSizeBeforeTest = membershipRepository.findAll().size();
// set the field null
membership.setMemberFrom(null);
// Create the Membership, which fails.
MembershipDTO membershipDTO = membershipMapper.toDto(membership);
@@ -189,8 +221,10 @@ public class MembershipResourceIntTest {
.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())));
.andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].memberFrom").value(hasItem(DEFAULT_MEMBER_FROM.toString())))
.andExpect(jsonPath("$.[*].memberUntil").value(hasItem(DEFAULT_MEMBER_UNTIL.toString())))
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString())));
}
@Test
@@ -204,151 +238,258 @@ public class MembershipResourceIntTest {
.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()));
.andExpect(jsonPath("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString()))
.andExpect(jsonPath("$.memberFrom").value(DEFAULT_MEMBER_FROM.toString()))
.andExpect(jsonPath("$.memberUntil").value(DEFAULT_MEMBER_UNTIL.toString()))
.andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString()));
}
@Test
@Transactional
public void getAllMembershipsBySinceDateIsEqualToSomething() throws Exception {
public void getAllMembershipsByDocumentDateIsEqualToSomething() 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 documentDate equals to DEFAULT_DOCUMENT_DATE
defaultMembershipShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE);
// Get all the membershipList where sinceDate equals to UPDATED_SINCE_DATE
defaultMembershipShouldNotBeFound("sinceDate.equals=" + UPDATED_SINCE_DATE);
// Get all the membershipList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsBySinceDateIsInShouldWork() throws Exception {
public void getAllMembershipsByDocumentDateIsInShouldWork() 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 documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE
defaultMembershipShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE);
// Get all the membershipList where sinceDate equals to UPDATED_SINCE_DATE
defaultMembershipShouldNotBeFound("sinceDate.in=" + UPDATED_SINCE_DATE);
// Get all the membershipList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsBySinceDateIsNullOrNotNull() throws Exception {
public void getAllMembershipsByDocumentDateIsNullOrNotNull() 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 documentDate is not null
defaultMembershipShouldBeFound("documentDate.specified=true");
// Get all the membershipList where sinceDate is null
defaultMembershipShouldNotBeFound("sinceDate.specified=false");
// Get all the membershipList where documentDate is null
defaultMembershipShouldNotBeFound("documentDate.specified=false");
}
@Test
@Transactional
public void getAllMembershipsBySinceDateIsGreaterThanOrEqualToSomething() throws Exception {
public void getAllMembershipsByDocumentDateIsGreaterThanOrEqualToSomething() 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 documentDate greater than or equals to DEFAULT_DOCUMENT_DATE
defaultMembershipShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the membershipList where sinceDate greater than or equals to UPDATED_SINCE_DATE
defaultMembershipShouldNotBeFound("sinceDate.greaterOrEqualThan=" + UPDATED_SINCE_DATE);
// Get all the membershipList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsBySinceDateIsLessThanSomething() throws Exception {
public void getAllMembershipsByDocumentDateIsLessThanSomething() 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 documentDate less than or equals to DEFAULT_DOCUMENT_DATE
defaultMembershipShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the membershipList where sinceDate less than or equals to UPDATED_SINCE_DATE
defaultMembershipShouldBeFound("sinceDate.lessThan=" + UPDATED_SINCE_DATE);
// Get all the membershipList where documentDate less than or equals to UPDATED_DOCUMENT_DATE
defaultMembershipShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllMembershipsByUntilDateIsEqualToSomething() throws Exception {
public void getAllMembershipsByMemberFromIsEqualToSomething() 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 memberFrom equals to DEFAULT_MEMBER_FROM
defaultMembershipShouldBeFound("memberFrom.equals=" + DEFAULT_MEMBER_FROM);
// Get all the membershipList where untilDate equals to UPDATED_UNTIL_DATE
defaultMembershipShouldNotBeFound("untilDate.equals=" + asString(UPDATED_UNTIL_DATE));
// Get all the membershipList where memberFrom equals to UPDATED_MEMBER_FROM
defaultMembershipShouldNotBeFound("memberFrom.equals=" + UPDATED_MEMBER_FROM);
}
@Test
@Transactional
public void getAllMembershipsByUntilDateIsInShouldWork() throws Exception {
public void getAllMembershipsByMemberFromIsInShouldWork() 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 + "," + ANOTHER_QUERY_DATE);
// Get all the membershipList where memberFrom in DEFAULT_MEMBER_FROM or UPDATED_MEMBER_FROM
defaultMembershipShouldBeFound("memberFrom.in=" + DEFAULT_MEMBER_FROM + "," + UPDATED_MEMBER_FROM);
// Get all the membershipList where untilDate equals to UPDATED_UNTIL_DATE
defaultMembershipShouldNotBeFound("untilDate.in=" + asString(UPDATED_UNTIL_DATE));
// Get all the membershipList where memberFrom equals to UPDATED_MEMBER_FROM
defaultMembershipShouldNotBeFound("memberFrom.in=" + UPDATED_MEMBER_FROM);
}
@Test
@Transactional
public void getAllMembershipsByUntilDateIsNullOrNotNull() throws Exception {
public void getAllMembershipsByMemberFromIsNullOrNotNull() 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 memberFrom is not null
defaultMembershipShouldBeFound("memberFrom.specified=true");
// Get all the membershipList where untilDate is null
defaultMembershipShouldNotBeFound("untilDate.specified=false");
// Get all the membershipList where memberFrom is null
defaultMembershipShouldNotBeFound("memberFrom.specified=false");
}
@Test
@Transactional
public void getAllMembershipsByUntilDateIsGreaterThanOrEqualToSomething() throws Exception {
public void getAllMembershipsByMemberFromIsGreaterThanOrEqualToSomething() 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 memberFrom greater than or equals to DEFAULT_MEMBER_FROM
defaultMembershipShouldBeFound("memberFrom.greaterOrEqualThan=" + DEFAULT_MEMBER_FROM);
// Get all the membershipList where untilDate greater than or equals to UPDATED_UNTIL_DATE
defaultMembershipShouldNotBeFound("untilDate.greaterOrEqualThan=" + asString(UPDATED_UNTIL_DATE));
// Get all the membershipList where memberFrom greater than or equals to UPDATED_MEMBER_FROM
defaultMembershipShouldNotBeFound("memberFrom.greaterOrEqualThan=" + UPDATED_MEMBER_FROM);
}
@Test
@Transactional
public void getAllMembershipsByUntilDateIsLessThanSomething() throws Exception {
public void getAllMembershipsByMemberFromIsLessThanSomething() 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 memberFrom less than or equals to DEFAULT_MEMBER_FROM
defaultMembershipShouldNotBeFound("memberFrom.lessThan=" + DEFAULT_MEMBER_FROM);
// Get all the membershipList where untilDate less than or equals to UPDATED_UNTIL_DATE
defaultMembershipShouldBeFound("untilDate.lessThan=" + asString(UPDATED_UNTIL_DATE));
// Get all the membershipList where memberFrom less than or equals to UPDATED_MEMBER_FROM
defaultMembershipShouldBeFound("memberFrom.lessThan=" + UPDATED_MEMBER_FROM);
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilIsEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntil equals to DEFAULT_MEMBER_UNTIL
defaultMembershipShouldBeFound("memberUntil.equals=" + DEFAULT_MEMBER_UNTIL);
// Get all the membershipList where memberUntil equals to UPDATED_MEMBER_UNTIL
defaultMembershipShouldNotBeFound("memberUntil.equals=" + UPDATED_MEMBER_UNTIL);
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilIsInShouldWork() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntil in DEFAULT_MEMBER_UNTIL or UPDATED_MEMBER_UNTIL
defaultMembershipShouldBeFound("memberUntil.in=" + DEFAULT_MEMBER_UNTIL + "," + UPDATED_MEMBER_UNTIL);
// Get all the membershipList where memberUntil equals to UPDATED_MEMBER_UNTIL
defaultMembershipShouldNotBeFound("memberUntil.in=" + UPDATED_MEMBER_UNTIL);
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilIsNullOrNotNull() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntil is not null
defaultMembershipShouldBeFound("memberUntil.specified=true");
// Get all the membershipList where memberUntil is null
defaultMembershipShouldNotBeFound("memberUntil.specified=false");
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntil greater than or equals to DEFAULT_MEMBER_UNTIL
defaultMembershipShouldBeFound("memberUntil.greaterOrEqualThan=" + DEFAULT_MEMBER_UNTIL);
// Get all the membershipList where memberUntil greater than or equals to UPDATED_MEMBER_UNTIL
defaultMembershipShouldNotBeFound("memberUntil.greaterOrEqualThan=" + UPDATED_MEMBER_UNTIL);
}
@Test
@Transactional
public void getAllMembershipsByMemberUntilIsLessThanSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where memberUntil less than or equals to DEFAULT_MEMBER_UNTIL
defaultMembershipShouldNotBeFound("memberUntil.lessThan=" + DEFAULT_MEMBER_UNTIL);
// Get all the membershipList where memberUntil less than or equals to UPDATED_MEMBER_UNTIL
defaultMembershipShouldBeFound("memberUntil.lessThan=" + UPDATED_MEMBER_UNTIL);
}
@Test
@Transactional
public void getAllMembershipsByRemarkIsEqualToSomething() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where remark equals to DEFAULT_REMARK
defaultMembershipShouldBeFound("remark.equals=" + DEFAULT_REMARK);
// Get all the membershipList where remark equals to UPDATED_REMARK
defaultMembershipShouldNotBeFound("remark.equals=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllMembershipsByRemarkIsInShouldWork() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where remark in DEFAULT_REMARK or UPDATED_REMARK
defaultMembershipShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK);
// Get all the membershipList where remark equals to UPDATED_REMARK
defaultMembershipShouldNotBeFound("remark.in=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllMembershipsByRemarkIsNullOrNotNull() throws Exception {
// Initialize the database
membershipRepository.saveAndFlush(membership);
// Get all the membershipList where remark is not null
defaultMembershipShouldBeFound("remark.specified=true");
// Get all the membershipList where remark is null
defaultMembershipShouldNotBeFound("remark.specified=false");
}
@Test
@Transactional
public void getAllMembershipsByShareIsEqualToSomething() throws Exception {
// Initialize the database
Share share = ShareResourceIntTest.createEntity(em, membership);
Share share = ShareResourceIntTest.createEntity(em);
em.persist(share);
em.flush();
membership.addShare(share);
membershipRepository.flush();
membershipRepository.saveAndFlush(membership);
Long shareId = share.getId();
// Get all the membershipList where share equals to shareId
@@ -364,10 +505,10 @@ public class MembershipResourceIntTest {
public void getAllMembershipsByAssetIsEqualToSomething() throws Exception {
// Initialize the database
Asset asset = AssetResourceIntTest.createEntity(em);
membership.addAsset(asset);
em.persist(membership);
em.persist(asset);
em.flush();
membership.addAsset(asset);
membershipRepository.saveAndFlush(membership);
Long assetId = asset.getId();
// Get all the membershipList where asset equals to assetId
@@ -382,7 +523,7 @@ public class MembershipResourceIntTest {
@Transactional
public void getAllMembershipsByCustomerIsEqualToSomething() throws Exception {
// Initialize the database
Customer customer = CustomerResourceIntTest.createAnotherEntity(em);
Customer customer = CustomerResourceIntTest.createEntity(em);
em.persist(customer);
em.flush();
membership.setCustomer(customer);
@@ -404,8 +545,10 @@ public class MembershipResourceIntTest {
.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())));
.andExpect(jsonPath("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].memberFrom").value(hasItem(DEFAULT_MEMBER_FROM.toString())))
.andExpect(jsonPath("$.[*].memberUntil").value(hasItem(DEFAULT_MEMBER_UNTIL.toString())))
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK)));
// Check, that the count call also returns 1
restMembershipMockMvc.perform(get("/api/memberships/count?sort=id,desc&" + filter))
@@ -453,8 +596,10 @@ public class MembershipResourceIntTest {
// 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);
.documentDate(UPDATED_DOCUMENT_DATE)
.memberFrom(UPDATED_MEMBER_FROM)
.memberUntil(UPDATED_MEMBER_UNTIL)
.remark(UPDATED_REMARK);
MembershipDTO membershipDTO = membershipMapper.toDto(updatedMembership);
restMembershipMockMvc.perform(put("/api/memberships")
@@ -466,8 +611,10 @@ public class MembershipResourceIntTest {
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);
assertThat(testMembership.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE);
assertThat(testMembership.getMemberFrom()).isEqualTo(UPDATED_MEMBER_FROM);
assertThat(testMembership.getMemberUntil()).isEqualTo(UPDATED_MEMBER_UNTIL);
assertThat(testMembership.getRemark()).isEqualTo(UPDATED_REMARK);
}
@Test
@@ -500,11 +647,11 @@ public class MembershipResourceIntTest {
// Delete the membership
restMembershipMockMvc.perform(delete("/api/memberships/{id}", membership.getId())
.accept(TestUtil.APPLICATION_JSON_UTF8))
.andExpect(status().isBadRequest());
.andExpect(status().isOk());
// Validate the database is unchanged empty
// Validate the database is empty
List<Membership> membershipList = membershipRepository.findAll();
assertThat(membershipList).hasSize(databaseSizeBeforeDelete);
assertThat(membershipList).hasSize(databaseSizeBeforeDelete - 1);
}
@Test
@@ -544,8 +691,4 @@ public class MembershipResourceIntTest {
assertThat(membershipMapper.fromId(42L).getId()).isEqualTo(42);
assertThat(membershipMapper.fromId(null)).isNull();
}
private String asString(LocalDate updatedUntilDate) {
return updatedUntilDate == null ? "" : updatedUntilDate.toString();
}
}

View File

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

View File

@@ -1,15 +1,17 @@
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.domain.Membership;
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.hostsharing.hsadminng.service.dto.ShareCriteria;
import org.hostsharing.hsadminng.service.ShareQueryService;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -30,12 +32,14 @@ import java.time.LocalDate;
import java.time.ZoneId;
import java.util.List;
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.hostsharing.hsadminng.web.rest.TestUtil.createFormattingConversionService;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
/**
* Test class for the ShareResource REST controller.
*
@@ -45,17 +49,20 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
@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 LocalDate DEFAULT_DOCUMENT_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_DOCUMENT_DATE = LocalDate.now(ZoneId.systemDefault());
private static final LocalDate DEFAULT_VALUE_DATE = LocalDate.ofEpochDay(0L);
private static final LocalDate UPDATED_VALUE_DATE = LocalDate.now(ZoneId.systemDefault());
private static final ShareAction DEFAULT_ACTION = ShareAction.SUBSCRIPTION;
private static final ShareAction UPDATED_ACTION = ShareAction.CANCELLATION;
private static final Integer DEFAULT_QUANTITY = 2;
private static final Integer UPDATED_QUANTITY = 3;
private static final Integer DEFAULT_QUANTITY = 1;
private static final Integer UPDATED_QUANTITY = 2;
private static final String DEFAULT_COMMENT = "Some Comment";
private static final String UPDATED_COMMENT = "Updated Comment";
private static final String DEFAULT_REMARK = "AAAAAAAAAA";
private static final String UPDATED_REMARK = "BBBBBBBBBB";
@Autowired
private ShareRepository shareRepository;
@@ -102,24 +109,28 @@ public class ShareResourceIntTest {
/**
* Create an entity for this test.
* <p>
*
* 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(final EntityManager em, final Membership membership) {
em.persist(membership);
public static Share createEntity(EntityManager em) {
Share share = new Share()
.member(membership)
.date(DEFAULT_DATE)
.documentDate(DEFAULT_DOCUMENT_DATE)
.valueDate(DEFAULT_VALUE_DATE)
.action(DEFAULT_ACTION)
.quantity(DEFAULT_QUANTITY)
.comment(DEFAULT_COMMENT);
.remark(DEFAULT_REMARK);
// Add required entity
Membership membership = MembershipResourceIntTest.createEntity(em);
em.persist(membership);
em.flush();
share.setMembership(membership);
return share;
}
@Before
public void initTest() {
share = createEntity(em, MembershipResourceIntTest.createEntity(em));
share = createEntity(em);
}
@Test
@@ -138,10 +149,11 @@ public class ShareResourceIntTest {
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.getDocumentDate()).isEqualTo(DEFAULT_DOCUMENT_DATE);
assertThat(testShare.getValueDate()).isEqualTo(DEFAULT_VALUE_DATE);
assertThat(testShare.getAction()).isEqualTo(DEFAULT_ACTION);
assertThat(testShare.getQuantity()).isEqualTo(DEFAULT_QUANTITY);
assertThat(testShare.getComment()).isEqualTo(DEFAULT_COMMENT);
assertThat(testShare.getRemark()).isEqualTo(DEFAULT_REMARK);
}
@Test
@@ -166,10 +178,29 @@ public class ShareResourceIntTest {
@Test
@Transactional
public void checkDateIsRequired() throws Exception {
public void checkDocumentDateIsRequired() throws Exception {
int databaseSizeBeforeTest = shareRepository.findAll().size();
// set the field null
share.setDate(null);
share.setDocumentDate(null);
// Create the Share, which fails.
ShareDTO shareDTO = shareMapper.toDto(share);
restShareMockMvc.perform(post("/api/shares")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(shareDTO)))
.andExpect(status().isBadRequest());
List<Share> shareList = shareRepository.findAll();
assertThat(shareList).hasSize(databaseSizeBeforeTest);
}
@Test
@Transactional
public void checkValueDateIsRequired() throws Exception {
int databaseSizeBeforeTest = shareRepository.findAll().size();
// set the field null
share.setValueDate(null);
// Create the Share, which fails.
ShareDTO shareDTO = shareMapper.toDto(share);
@@ -232,12 +263,13 @@ public class ShareResourceIntTest {
.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("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].valueDate").value(hasItem(DEFAULT_VALUE_DATE.toString())))
.andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString())))
.andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY)))
.andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT.toString())));
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString())));
}
@Test
@Transactional
public void getShare() throws Exception {
@@ -249,75 +281,142 @@ public class ShareResourceIntTest {
.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("$.documentDate").value(DEFAULT_DOCUMENT_DATE.toString()))
.andExpect(jsonPath("$.valueDate").value(DEFAULT_VALUE_DATE.toString()))
.andExpect(jsonPath("$.action").value(DEFAULT_ACTION.toString()))
.andExpect(jsonPath("$.quantity").value(DEFAULT_QUANTITY))
.andExpect(jsonPath("$.comment").value(DEFAULT_COMMENT.toString()));
.andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString()));
}
@Test
@Transactional
public void getAllSharesByDateIsEqualToSomething() throws Exception {
public void getAllSharesByDocumentDateIsEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where date equals to DEFAULT_DATE
shouldFindDefaultShare("date.equals=" + DEFAULT_DATE);
// Get all the shareList where documentDate equals to DEFAULT_DOCUMENT_DATE
defaultShareShouldBeFound("documentDate.equals=" + DEFAULT_DOCUMENT_DATE);
// Get all the shareList where date equals to UPDATED_DATE
shouldNotFindAnyShare("date.equals=" + UPDATED_DATE);
// Get all the shareList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultShareShouldNotBeFound("documentDate.equals=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSharesByDateIsInShouldWork() throws Exception {
public void getAllSharesByDocumentDateIsInShouldWork() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where date in DEFAULT_DATE or UPDATED_DATE
shouldFindDefaultShare("date.in=" + DEFAULT_DATE + "," + UPDATED_DATE);
// Get all the shareList where documentDate in DEFAULT_DOCUMENT_DATE or UPDATED_DOCUMENT_DATE
defaultShareShouldBeFound("documentDate.in=" + DEFAULT_DOCUMENT_DATE + "," + UPDATED_DOCUMENT_DATE);
// Get all the shareList where date equals to UPDATED_DATE
shouldNotFindAnyShare("date.in=" + UPDATED_DATE);
// Get all the shareList where documentDate equals to UPDATED_DOCUMENT_DATE
defaultShareShouldNotBeFound("documentDate.in=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSharesByDateIsNullOrNotNull() throws Exception {
public void getAllSharesByDocumentDateIsNullOrNotNull() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where date is not null
shouldFindDefaultShare("date.specified=true");
// Get all the shareList where documentDate is not null
defaultShareShouldBeFound("documentDate.specified=true");
// Get all the shareList where date is null
shouldNotFindAnyShare("date.specified=false");
// Get all the shareList where documentDate is null
defaultShareShouldNotBeFound("documentDate.specified=false");
}
@Test
@Transactional
public void getAllSharesByDateIsGreaterThanOrEqualToSomething() throws Exception {
public void getAllSharesByDocumentDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where date greater than or equals to DEFAULT_DATE
shouldFindDefaultShare("date.greaterOrEqualThan=" + DEFAULT_DATE);
// Get all the shareList where documentDate greater than or equals to DEFAULT_DOCUMENT_DATE
defaultShareShouldBeFound("documentDate.greaterOrEqualThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the shareList where date greater than or equals to UPDATED_DATE
shouldNotFindAnyShare("date.greaterOrEqualThan=" + UPDATED_DATE);
// Get all the shareList where documentDate greater than or equals to UPDATED_DOCUMENT_DATE
defaultShareShouldNotBeFound("documentDate.greaterOrEqualThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSharesByDateIsLessThanSomething() throws Exception {
public void getAllSharesByDocumentDateIsLessThanSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where date less than or equals to DEFAULT_DATE
shouldNotFindAnyShare("date.lessThan=" + DEFAULT_DATE);
// Get all the shareList where documentDate less than or equals to DEFAULT_DOCUMENT_DATE
defaultShareShouldNotBeFound("documentDate.lessThan=" + DEFAULT_DOCUMENT_DATE);
// Get all the shareList where date less than or equals to UPDATED_DATE
shouldFindDefaultShare("date.lessThan=" + UPDATED_DATE);
// Get all the shareList where documentDate less than or equals to UPDATED_DOCUMENT_DATE
defaultShareShouldBeFound("documentDate.lessThan=" + UPDATED_DOCUMENT_DATE);
}
@Test
@Transactional
public void getAllSharesByValueDateIsEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where valueDate equals to DEFAULT_VALUE_DATE
defaultShareShouldBeFound("valueDate.equals=" + DEFAULT_VALUE_DATE);
// Get all the shareList where valueDate equals to UPDATED_VALUE_DATE
defaultShareShouldNotBeFound("valueDate.equals=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllSharesByValueDateIsInShouldWork() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where valueDate in DEFAULT_VALUE_DATE or UPDATED_VALUE_DATE
defaultShareShouldBeFound("valueDate.in=" + DEFAULT_VALUE_DATE + "," + UPDATED_VALUE_DATE);
// Get all the shareList where valueDate equals to UPDATED_VALUE_DATE
defaultShareShouldNotBeFound("valueDate.in=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllSharesByValueDateIsNullOrNotNull() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where valueDate is not null
defaultShareShouldBeFound("valueDate.specified=true");
// Get all the shareList where valueDate is null
defaultShareShouldNotBeFound("valueDate.specified=false");
}
@Test
@Transactional
public void getAllSharesByValueDateIsGreaterThanOrEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where valueDate greater than or equals to DEFAULT_VALUE_DATE
defaultShareShouldBeFound("valueDate.greaterOrEqualThan=" + DEFAULT_VALUE_DATE);
// Get all the shareList where valueDate greater than or equals to UPDATED_VALUE_DATE
defaultShareShouldNotBeFound("valueDate.greaterOrEqualThan=" + UPDATED_VALUE_DATE);
}
@Test
@Transactional
public void getAllSharesByValueDateIsLessThanSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where valueDate less than or equals to DEFAULT_VALUE_DATE
defaultShareShouldNotBeFound("valueDate.lessThan=" + DEFAULT_VALUE_DATE);
// Get all the shareList where valueDate less than or equals to UPDATED_VALUE_DATE
defaultShareShouldBeFound("valueDate.lessThan=" + UPDATED_VALUE_DATE);
}
@@ -328,10 +427,10 @@ public class ShareResourceIntTest {
shareRepository.saveAndFlush(share);
// Get all the shareList where action equals to DEFAULT_ACTION
shouldFindDefaultShare("action.equals=" + DEFAULT_ACTION);
defaultShareShouldBeFound("action.equals=" + DEFAULT_ACTION);
// Get all the shareList where action equals to UPDATED_ACTION
shouldNotFindAnyShare("action.equals=" + UPDATED_ACTION);
defaultShareShouldNotBeFound("action.equals=" + UPDATED_ACTION);
}
@Test
@@ -341,10 +440,10 @@ public class ShareResourceIntTest {
shareRepository.saveAndFlush(share);
// Get all the shareList where action in DEFAULT_ACTION or UPDATED_ACTION
shouldFindDefaultShare("action.in=" + DEFAULT_ACTION + "," + UPDATED_ACTION);
defaultShareShouldBeFound("action.in=" + DEFAULT_ACTION + "," + UPDATED_ACTION);
// Get all the shareList where action equals to UPDATED_ACTION
shouldNotFindAnyShare("action.in=" + UPDATED_ACTION);
defaultShareShouldNotBeFound("action.in=" + UPDATED_ACTION);
}
@Test
@@ -354,10 +453,10 @@ public class ShareResourceIntTest {
shareRepository.saveAndFlush(share);
// Get all the shareList where action is not null
shouldFindDefaultShare("action.specified=true");
defaultShareShouldBeFound("action.specified=true");
// Get all the shareList where action is null
shouldNotFindAnyShare("action.specified=false");
defaultShareShouldNotBeFound("action.specified=false");
}
@Test
@@ -367,11 +466,10 @@ public class ShareResourceIntTest {
shareRepository.saveAndFlush(share);
// Get all the shareList where quantity equals to DEFAULT_QUANTITY
shouldFindDefaultShare("quantity.equals=" + DEFAULT_QUANTITY);
defaultShareShouldBeFound("quantity.equals=" + DEFAULT_QUANTITY);
// Get all the shareList where quantity is not in database
shouldNotFindAnyShare("quantity.equals=" + (DEFAULT_QUANTITY + 1));
shouldNotFindAnyShare("quantity.equals=" + (-DEFAULT_QUANTITY));
// Get all the shareList where quantity equals to UPDATED_QUANTITY
defaultShareShouldNotBeFound("quantity.equals=" + UPDATED_QUANTITY);
}
@Test
@@ -381,10 +479,10 @@ public class ShareResourceIntTest {
shareRepository.saveAndFlush(share);
// Get all the shareList where quantity in DEFAULT_QUANTITY or UPDATED_QUANTITY
shouldFindDefaultShare("quantity.in=" + DEFAULT_QUANTITY + "," + (-DEFAULT_QUANTITY));
defaultShareShouldBeFound("quantity.in=" + DEFAULT_QUANTITY + "," + UPDATED_QUANTITY);
// Get all the shareList where quantity equals to UPDATED_QUANTITY
shouldNotFindAnyShare("quantity.in=" + (DEFAULT_QUANTITY + 1));
defaultShareShouldNotBeFound("quantity.in=" + UPDATED_QUANTITY);
}
@Test
@@ -394,10 +492,10 @@ public class ShareResourceIntTest {
shareRepository.saveAndFlush(share);
// Get all the shareList where quantity is not null
shouldFindDefaultShare("quantity.specified=true");
defaultShareShouldBeFound("quantity.specified=true");
// Get all the shareList where quantity is null
shouldNotFindAnyShare("quantity.specified=false");
defaultShareShouldNotBeFound("quantity.specified=false");
}
@Test
@@ -407,10 +505,10 @@ public class ShareResourceIntTest {
shareRepository.saveAndFlush(share);
// Get all the shareList where quantity greater than or equals to DEFAULT_QUANTITY
shouldFindDefaultShare("quantity.greaterOrEqualThan=" + DEFAULT_QUANTITY);
defaultShareShouldBeFound("quantity.greaterOrEqualThan=" + DEFAULT_QUANTITY);
// Get all the shareList where quantity greater than or equals to DEFAULT_QUANTITY+1
shouldNotFindAnyShare("quantity.greaterOrEqualThan=" + (DEFAULT_QUANTITY + 1));
// Get all the shareList where quantity greater than or equals to UPDATED_QUANTITY
defaultShareShouldNotBeFound("quantity.greaterOrEqualThan=" + UPDATED_QUANTITY);
}
@Test
@@ -420,82 +518,83 @@ public class ShareResourceIntTest {
shareRepository.saveAndFlush(share);
// Get all the shareList where quantity less than or equals to DEFAULT_QUANTITY
shouldNotFindAnyShare("quantity.lessThan=" + DEFAULT_QUANTITY);
defaultShareShouldNotBeFound("quantity.lessThan=" + DEFAULT_QUANTITY);
// Get all the shareList where quantity less than or equals to DEFAULT_QUANTITY-1
shouldFindDefaultShare("quantity.lessThan=" + (DEFAULT_QUANTITY + 1));
// 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 {
public void getAllSharesByRemarkIsEqualToSomething() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where comment equals to DEFAULT_COMMENT
shouldFindDefaultShare("comment.equals=" + DEFAULT_COMMENT);
// Get all the shareList where remark equals to DEFAULT_REMARK
defaultShareShouldBeFound("remark.equals=" + DEFAULT_REMARK);
// Get all the shareList where comment equals to UPDATED_COMMENT
shouldNotFindAnyShare("comment.equals=" + UPDATED_COMMENT);
// Get all the shareList where remark equals to UPDATED_REMARK
defaultShareShouldNotBeFound("remark.equals=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllSharesByCommentIsInShouldWork() throws Exception {
public void getAllSharesByRemarkIsInShouldWork() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where comment in DEFAULT_COMMENT or UPDATED_COMMENT
shouldFindDefaultShare("comment.in=" + DEFAULT_COMMENT + "," + UPDATED_COMMENT);
// Get all the shareList where remark in DEFAULT_REMARK or UPDATED_REMARK
defaultShareShouldBeFound("remark.in=" + DEFAULT_REMARK + "," + UPDATED_REMARK);
// Get all the shareList where comment equals to UPDATED_COMMENT
shouldNotFindAnyShare("comment.in=" + UPDATED_COMMENT);
// Get all the shareList where remark equals to UPDATED_REMARK
defaultShareShouldNotBeFound("remark.in=" + UPDATED_REMARK);
}
@Test
@Transactional
public void getAllSharesByCommentIsNullOrNotNull() throws Exception {
public void getAllSharesByRemarkIsNullOrNotNull() throws Exception {
// Initialize the database
shareRepository.saveAndFlush(share);
// Get all the shareList where comment is not null
shouldFindDefaultShare("comment.specified=true");
// Get all the shareList where remark is not null
defaultShareShouldBeFound("remark.specified=true");
// Get all the shareList where comment is null
shouldNotFindAnyShare("comment.specified=false");
// Get all the shareList where remark is null
defaultShareShouldNotBeFound("remark.specified=false");
}
@Test
@Transactional
public void getAllSharesByMemberIsEqualToSomething() throws Exception {
public void getAllSharesByMembershipIsEqualToSomething() throws Exception {
// Initialize the database
Membership member = MembershipResourceIntTest.createEntity(em);
em.persist(member);
Membership membership = MembershipResourceIntTest.createEntity(em);
em.persist(membership);
em.flush();
share.setMember(member);
share.setMembership(membership);
shareRepository.saveAndFlush(share);
Long memberId = member.getId();
Long membershipId = membership.getId();
// Get all the shareList where member equals to memberId
shouldFindDefaultShare("memberId.equals=" + memberId);
// Get all the shareList where membership equals to membershipId
defaultShareShouldBeFound("membershipId.equals=" + membershipId);
// Get all the shareList where member equals to memberId + 1
shouldNotFindAnyShare("memberId.equals=" + (memberId + 1));
// Get all the shareList where membership equals to membershipId + 1
defaultShareShouldNotBeFound("membershipId.equals=" + (membershipId + 1));
}
/**
* Executes the search, and checks that the default entity is returned
*/
private void shouldFindDefaultShare(String filter) throws Exception {
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("$.[*].documentDate").value(hasItem(DEFAULT_DOCUMENT_DATE.toString())))
.andExpect(jsonPath("$.[*].valueDate").value(hasItem(DEFAULT_VALUE_DATE.toString())))
.andExpect(jsonPath("$.[*].action").value(hasItem(DEFAULT_ACTION.toString())))
.andExpect(jsonPath("$.[*].quantity").value(hasItem(DEFAULT_QUANTITY)))
.andExpect(jsonPath("$.[*].comment").value(hasItem(DEFAULT_COMMENT)));
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK)));
// Check, that the count call also returns 1
restShareMockMvc.perform(get("/api/shares/count?sort=id,desc&" + filter))
@@ -507,7 +606,7 @@ public class ShareResourceIntTest {
/**
* Executes the search, and checks that the default entity is not returned
*/
private void shouldNotFindAnyShare(String filter) throws Exception {
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))
@@ -543,25 +642,27 @@ public class ShareResourceIntTest {
// Disconnect from session so that the updates on updatedShare are not directly saved in db
em.detach(updatedShare);
updatedShare
.date(UPDATED_DATE)
.documentDate(UPDATED_DOCUMENT_DATE)
.valueDate(UPDATED_VALUE_DATE)
.action(UPDATED_ACTION)
.quantity(UPDATED_QUANTITY)
.comment(UPDATED_COMMENT);
.remark(UPDATED_REMARK);
ShareDTO shareDTO = shareMapper.toDto(updatedShare);
restShareMockMvc.perform(put("/api/shares")
.contentType(TestUtil.APPLICATION_JSON_UTF8)
.content(TestUtil.convertObjectToJsonBytes(shareDTO)))
.andExpect(status().isBadRequest());
.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(DEFAULT_DATE);
assertThat(testShare.getAction()).isEqualTo(DEFAULT_ACTION);
assertThat(testShare.getQuantity()).isEqualTo(DEFAULT_QUANTITY);
assertThat(testShare.getComment()).isEqualTo(DEFAULT_COMMENT);
assertThat(testShare.getDocumentDate()).isEqualTo(UPDATED_DOCUMENT_DATE);
assertThat(testShare.getValueDate()).isEqualTo(UPDATED_VALUE_DATE);
assertThat(testShare.getAction()).isEqualTo(UPDATED_ACTION);
assertThat(testShare.getQuantity()).isEqualTo(UPDATED_QUANTITY);
assertThat(testShare.getRemark()).isEqualTo(UPDATED_REMARK);
}
@Test
@@ -594,11 +695,11 @@ public class ShareResourceIntTest {
// Delete the share
restShareMockMvc.perform(delete("/api/shares/{id}", share.getId())
.accept(TestUtil.APPLICATION_JSON_UTF8))
.andExpect(status().isBadRequest());
.andExpect(status().isOk());
// Validate the share is still in the database
// Validate the database is empty
List<Share> shareList = shareRepository.findAll();
assertThat(shareList).hasSize(databaseSizeBeforeDelete);
assertThat(shareList).hasSize(databaseSizeBeforeDelete - 1);
}
@Test