ShareServiceUnitTest and fixes in other related tests
This commit is contained in:
		@@ -2,16 +2,15 @@ package org.hostsharing.hsadminng.domain;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 | 
			
		||||
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
 | 
			
		||||
 | 
			
		||||
import javax.persistence.*;
 | 
			
		||||
import javax.validation.constraints.*;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.NotNull;
 | 
			
		||||
import javax.validation.constraints.Size;
 | 
			
		||||
import java.io.Serializable;
 | 
			
		||||
import java.time.LocalDate;
 | 
			
		||||
import java.util.Objects;
 | 
			
		||||
 | 
			
		||||
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A Share.
 | 
			
		||||
 */
 | 
			
		||||
@@ -20,7 +19,9 @@ import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
 | 
			
		||||
public class Share implements Serializable {
 | 
			
		||||
 | 
			
		||||
    private static final long serialVersionUID = 1L;
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    public static final String ENTITY_NAME = "share";
 | 
			
		||||
 | 
			
		||||
    @Id
 | 
			
		||||
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
 | 
			
		||||
    @SequenceGenerator(name = "sequenceGenerator")
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,6 @@ import org.hostsharing.hsadminng.service.mapper.ShareMapper;
 | 
			
		||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
 | 
			
		||||
import org.slf4j.Logger;
 | 
			
		||||
import org.slf4j.LoggerFactory;
 | 
			
		||||
 | 
			
		||||
import org.springframework.data.domain.Page;
 | 
			
		||||
import org.springframework.data.domain.Pageable;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
@@ -42,11 +41,16 @@ public class ShareService {
 | 
			
		||||
     */
 | 
			
		||||
    public ShareDTO save(ShareDTO shareDTO) {
 | 
			
		||||
        log.debug("Request to save Share : {}", shareDTO);
 | 
			
		||||
 | 
			
		||||
        if (shareDTO.getId() != null) {
 | 
			
		||||
            throw new BadRequestAlertException("Share transactions are immutable", Share.ENTITY_NAME, "shareTransactionImmutable");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if((shareDTO.getAction() == ShareAction.SUBSCRIPTION) && (shareDTO.getQuantity() <= 0)) {
 | 
			
		||||
            throw new BadRequestAlertException("Share subscriptions require a positive quantity", "share", "sharesubscriptionpositivquantity");
 | 
			
		||||
            throw new BadRequestAlertException("Share subscriptions require a positive quantity", Share.ENTITY_NAME, "shareSubscriptionPositivQuantity");
 | 
			
		||||
        }
 | 
			
		||||
        if((shareDTO.getAction() == ShareAction.CANCELLATION) && (shareDTO.getQuantity() >= 0)) {
 | 
			
		||||
            throw new BadRequestAlertException("Share cancellations require a negative quantity", "share", "sharecancellationnegativequantity");
 | 
			
		||||
            throw new BadRequestAlertException("Share cancellations require a negative quantity", Share.ENTITY_NAME, "shareCancellationNegativeQuantity");
 | 
			
		||||
        }
 | 
			
		||||
        Share share = shareMapper.toEntity(shareDTO);
 | 
			
		||||
        share = shareRepository.save(share);
 | 
			
		||||
@@ -87,6 +91,7 @@ public class ShareService {
 | 
			
		||||
     */
 | 
			
		||||
    public void delete(Long id) {
 | 
			
		||||
        log.debug("Request to delete Share : {}", id);
 | 
			
		||||
        shareRepository.deleteById(id);
 | 
			
		||||
 | 
			
		||||
        throw new BadRequestAlertException("Share transactions are immutable", Share.ENTITY_NAME, "shareTransactionImmutable");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
    "error": {
 | 
			
		||||
        "sharesubscriptionpositivquantity": "Zeichnungen von Geschäftsanteilen erfordern eine positive Stückzahl",
 | 
			
		||||
        "sharecancellationnegativequantity": "Kündigungen von Geschäftsanteilen erfordern eine negative Stückzahl"
 | 
			
		||||
        "shareSubscriptionPositivQuantity": "Zeichnungen von Geschäftsanteilen erfordern eine positive Stückzahl",
 | 
			
		||||
        "shareCancellationNegativeQuantity": "Kündigungen von Geschäftsanteilen erfordern eine negative Stückzahl",
 | 
			
		||||
        "shareTransactionImmutable": "Transaktionen mit Geschäftsanteilen sind unveränderlich"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
{
 | 
			
		||||
    "error": {
 | 
			
		||||
        "sharesubscriptionpositivquantity": "Share subscriptions require a positive quantity",
 | 
			
		||||
        "sharecancellationnegativequantity": "Share cancellations require a negative quantity"
 | 
			
		||||
        "shareSubscriptionPositivQuantity": "Share subscriptions require a positive quantity",
 | 
			
		||||
        "shareCancellationNegativeQuantity": "Share cancellations require a negative quantity",
 | 
			
		||||
        "shareTransactionImmutable": "Share transactions are immutable"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user