Revert "better display labels and less columns in tables (deliberately not yet in SepaMandate*)"
This reverts commit d81b71cd3a
.
This commit is contained in:
parent
f301364d84
commit
7e3d3ec5de
@ -4,7 +4,6 @@ import org.hostsharing.hsadminng.domain.Asset;
|
||||
import org.hostsharing.hsadminng.repository.AssetRepository;
|
||||
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
||||
import org.hostsharing.hsadminng.service.mapper.AssetMapper;
|
||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.domain.Page;
|
||||
@ -24,12 +23,11 @@ public class AssetService {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(AssetService.class);
|
||||
|
||||
private final EntityManager em;
|
||||
|
||||
private final AssetRepository assetRepository;
|
||||
|
||||
private final AssetMapper assetMapper;
|
||||
private final AssetValidator assetValidator;
|
||||
private final EntityManager em;
|
||||
|
||||
public AssetService(final EntityManager em, final AssetRepository assetRepository, final AssetMapper assetMapper, final AssetValidator assetValidator) {
|
||||
this.em = em;
|
||||
@ -88,7 +86,6 @@ public class AssetService {
|
||||
*/
|
||||
public void delete(Long id) {
|
||||
log.debug("Request to delete Asset : {}", id);
|
||||
|
||||
throw new BadRequestAlertException("Asset transactions are immutable", Asset.ENTITY_NAME, "assetTransactionImmutable");
|
||||
assetRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@ -24,19 +23,15 @@ public class MembershipService implements IdToDtoResolver<MembershipDTO> {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(MembershipService.class);
|
||||
|
||||
private final EntityManager em;
|
||||
|
||||
private final MembershipValidator membershipValidator;
|
||||
|
||||
private final MembershipRepository membershipRepository;
|
||||
|
||||
private final MembershipMapper membershipMapper;
|
||||
|
||||
public MembershipService(final EntityManager em,
|
||||
final MembershipValidator membershipValidator,
|
||||
public MembershipService(final MembershipValidator membershipValidator,
|
||||
final MembershipRepository membershipRepository,
|
||||
final MembershipMapper membershipMapper) {
|
||||
this.em = em;
|
||||
this.membershipValidator = membershipValidator;
|
||||
this.membershipRepository = membershipRepository;
|
||||
this.membershipMapper = membershipMapper;
|
||||
@ -55,8 +50,6 @@ public class MembershipService implements IdToDtoResolver<MembershipDTO> {
|
||||
|
||||
Membership membership = membershipMapper.toEntity(membershipDTO);
|
||||
membership = membershipRepository.save(membership);
|
||||
em.flush();
|
||||
em.refresh(membership);
|
||||
return membershipMapper.toDto(membership);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
@ -24,16 +23,13 @@ public class ShareService implements IdToDtoResolver<ShareDTO> {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(ShareService.class);
|
||||
|
||||
private final EntityManager em;
|
||||
|
||||
private final ShareRepository shareRepository;
|
||||
|
||||
private final ShareMapper shareMapper;
|
||||
|
||||
private final ShareValidator shareValidator;
|
||||
|
||||
public ShareService(final EntityManager em, final ShareRepository shareRepository, final ShareMapper shareMapper, final ShareValidator shareValidator) {
|
||||
this.em = em;
|
||||
public ShareService(ShareRepository shareRepository, ShareMapper shareMapper, ShareValidator shareValidator) {
|
||||
this.shareRepository = shareRepository;
|
||||
this.shareMapper = shareMapper;
|
||||
this.shareValidator = shareValidator;
|
||||
@ -52,8 +48,6 @@ public class ShareService implements IdToDtoResolver<ShareDTO> {
|
||||
|
||||
Share share = shareMapper.toEntity(shareDTO);
|
||||
share = shareRepository.save(share);
|
||||
em.flush();
|
||||
em.refresh(share);
|
||||
return shareMapper.toDto(share);
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class AssetDTO implements Serializable, AccessMappings {
|
||||
private Long membershipId;
|
||||
|
||||
@AccessFor(init=Role.ANYBODY, update=Role.ANYBODY, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
private String membershipDisplayLabel;
|
||||
private String membershipDisplayReference;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -105,12 +105,12 @@ public class AssetDTO implements Serializable, AccessMappings {
|
||||
this.membershipId = membershipId;
|
||||
}
|
||||
|
||||
public String getMembershipDisplayLabel() {
|
||||
return membershipDisplayLabel;
|
||||
public String getMembershipDisplayReference() {
|
||||
return membershipDisplayReference;
|
||||
}
|
||||
|
||||
public void setMembershipDisplayLabel(String membershipDisplayLabel) {
|
||||
this.membershipDisplayLabel = membershipDisplayLabel;
|
||||
public void setMembershipDisplayReference(String membershipDisplayReference) {
|
||||
this.membershipDisplayReference = membershipDisplayReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -144,7 +144,7 @@ public class AssetDTO implements Serializable, AccessMappings {
|
||||
", amount=" + getAmount() +
|
||||
", remark='" + getRemark() + "'" +
|
||||
", membership=" + getMembershipId() +
|
||||
", membership='" + getMembershipDisplayLabel() + "'" +
|
||||
", membership='" + getMembershipDisplayReference() + "'" +
|
||||
"}";
|
||||
}
|
||||
|
||||
|
@ -85,9 +85,6 @@ public class CustomerDTO extends FluentBuilder<CustomerDTO> implements AccessMap
|
||||
@AccessFor(init = Role.ADMIN, update = Role.SUPPORTER, read = Role.SUPPORTER)
|
||||
private String remark;
|
||||
|
||||
@AccessFor(init=Role.ANYBODY, update=Role.ANYBODY, read = Role.ANY_CUSTOMER_USER)
|
||||
private String displayLabel;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
@ -216,14 +213,6 @@ public class CustomerDTO extends FluentBuilder<CustomerDTO> implements AccessMap
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getDisplayLabel() {
|
||||
return displayLabel;
|
||||
}
|
||||
|
||||
public void setDisplayLabel(final String displayLabel) {
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
|
@ -25,18 +25,18 @@ public class MembershipDTO extends FluentBuilder<MembershipDTO> implements Seria
|
||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
private LocalDate admissionDocumentDate;
|
||||
|
||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
private LocalDate cancellationDocumentDate;
|
||||
|
||||
@NotNull
|
||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
private LocalDate memberFromDate;
|
||||
|
||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
private LocalDate memberUntilDate;
|
||||
|
||||
@Size(max = 160)
|
||||
@AccessFor(init = Role.ADMIN,update = Role.ADMIN, read = Role.SUPPORTER)
|
||||
@AccessFor(init = Role.ADMIN, read = Role.SUPPORTER)
|
||||
private String remark;
|
||||
|
||||
@ParentId(resolver = CustomerService.class)
|
||||
@ -46,11 +46,8 @@ public class MembershipDTO extends FluentBuilder<MembershipDTO> implements Seria
|
||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
private String customerPrefix;
|
||||
|
||||
@AccessFor(init = Role.ANYBODY, update = Role.ANYBODY, read = Role.FINANCIAL_CONTACT)
|
||||
private String displayLabel;
|
||||
|
||||
@AccessFor(init = Role.ANYBODY, update = Role.ANYBODY, read = Role.FINANCIAL_CONTACT)
|
||||
private String customerDisplayLabel;
|
||||
@AccessFor(read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
private String membershipDisplayReference;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -116,20 +113,12 @@ public class MembershipDTO extends FluentBuilder<MembershipDTO> implements Seria
|
||||
this.customerPrefix = customerPrefix;
|
||||
}
|
||||
|
||||
public String getDisplayLabel() {
|
||||
return displayLabel;
|
||||
private String getMembershipDisplayReference() {
|
||||
return membershipDisplayReference;
|
||||
}
|
||||
|
||||
public void setDisplayLabel(final String displayLabel) {
|
||||
this.displayLabel = displayLabel;
|
||||
}
|
||||
|
||||
public String getCustomerDisplayLabel() {
|
||||
return customerDisplayLabel;
|
||||
}
|
||||
|
||||
public void setCustomerDisplayLabel(final String customerDisplayLabel) {
|
||||
this.customerDisplayLabel = customerDisplayLabel;
|
||||
public void setMembershipDisplayReference(final String membershipDisplayReference) {
|
||||
this.membershipDisplayReference = membershipDisplayReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,7 +48,7 @@ public class ShareDTO implements Serializable {
|
||||
private Long membershipId;
|
||||
|
||||
@AccessFor(read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
private String membershipDisplayLabel;
|
||||
private String membershipDisplayReference;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
@ -106,12 +106,12 @@ public class ShareDTO implements Serializable {
|
||||
this.membershipId = membershipId;
|
||||
}
|
||||
|
||||
public String getMembershipDisplayLabel() {
|
||||
return membershipDisplayLabel;
|
||||
public String getMembershipDisplayReference() {
|
||||
return membershipDisplayReference;
|
||||
}
|
||||
|
||||
public void setMembershipDisplayLabel(String membershipDisplayLabel) {
|
||||
this.membershipDisplayLabel = membershipDisplayLabel;
|
||||
public void setMembershipDisplayReference(String membershipDisplayReference) {
|
||||
this.membershipDisplayReference = membershipDisplayReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -145,7 +145,7 @@ public class ShareDTO implements Serializable {
|
||||
", quantity=" + getQuantity() +
|
||||
", remark='" + getRemark() + "'" +
|
||||
", membership=" + getMembershipId() +
|
||||
", membership='" + getMembershipDisplayLabel() + "'" +
|
||||
", membership='" + getMembershipDisplayReference() + "'" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,16 @@
|
||||
package org.hostsharing.hsadminng.service.mapper;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.Asset;
|
||||
import org.hostsharing.hsadminng.domain.Customer;
|
||||
import org.hostsharing.hsadminng.domain.Membership;
|
||||
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Mapper for the entity Asset and its DTO AssetDTO.
|
||||
*/
|
||||
@ -14,12 +18,19 @@ import org.mapstruct.MappingTarget;
|
||||
public interface AssetMapper extends EntityMapper<AssetDTO, Asset> {
|
||||
|
||||
@Mapping(source = "membership.id", target = "membershipId")
|
||||
@Mapping(target = "membershipDisplayLabel", ignore = true)
|
||||
@Mapping(target = "membershipDisplayReference", ignore = true)
|
||||
AssetDTO toDto(Asset asset);
|
||||
|
||||
@AfterMapping
|
||||
default void setMembershipDisplayLabel(final @MappingTarget AssetDTO dto, final Asset entity) {
|
||||
dto.setMembershipDisplayLabel(MembershipMapper.displayLabel(entity.getMembership()));
|
||||
default void setMembershipDisplayReference(final @MappingTarget AssetDTO dto, final Asset entity) {
|
||||
// TODO: rather use method extracted from MembershipMaper.setMembershipDisplayReference() to avoid duplicate code
|
||||
final Membership membership = entity.getMembership();
|
||||
final Customer customer = membership.getCustomer();
|
||||
dto.setMembershipDisplayReference(customer.getReference()
|
||||
+ ":" + customer.getPrefix()
|
||||
+ " [" + customer.getName() + "] "
|
||||
+ membership.getAdmissionDocumentDate().toString() + " - "
|
||||
+ Objects.toString(membership.getCancellationDocumentDate(), ""));
|
||||
}
|
||||
|
||||
@Mapping(source = "membershipId", target = "membership")
|
||||
|
@ -1,11 +1,9 @@
|
||||
package org.hostsharing.hsadminng.service.mapper;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.Customer;
|
||||
import org.hostsharing.hsadminng.domain.*;
|
||||
import org.hostsharing.hsadminng.service.dto.CustomerDTO;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
|
||||
import org.mapstruct.*;
|
||||
|
||||
/**
|
||||
* Mapper for the entity Customer and its DTO CustomerDTO.
|
||||
@ -13,18 +11,6 @@ import org.mapstruct.MappingTarget;
|
||||
@Mapper(componentModel = "spring", uses = {})
|
||||
public interface CustomerMapper extends EntityMapper<CustomerDTO, Customer> {
|
||||
|
||||
static String displayLabel(Customer customer) {
|
||||
return customer.getName()
|
||||
+ " [" + customer.getReference() + ":" + customer.getPrefix() +"]";
|
||||
}
|
||||
|
||||
@Mapping(target = "displayLabel", ignore = true)
|
||||
CustomerDTO toDto(Customer customer);
|
||||
|
||||
@AfterMapping
|
||||
default void setDisplayLabel(final @MappingTarget CustomerDTO dto, final Customer entity) {
|
||||
dto.setDisplayLabel(displayLabel(entity));
|
||||
}
|
||||
|
||||
@Mapping(target = "memberships", ignore = true)
|
||||
@Mapping(target = "sepamandates", ignore = true)
|
||||
|
@ -16,25 +16,21 @@ import java.util.Objects;
|
||||
@Mapper(componentModel = "spring", uses = {CustomerMapper.class})
|
||||
public interface MembershipMapper extends EntityMapper<MembershipDTO, Membership> {
|
||||
|
||||
static String displayLabel(final Membership entity) {
|
||||
final Customer customer = entity.getCustomer();
|
||||
return CustomerMapper.displayLabel(customer) + " "
|
||||
+ Objects.toString(entity.getAdmissionDocumentDate(), "") + " - "
|
||||
+ Objects.toString(entity.getCancellationDocumentDate(), "...");
|
||||
}
|
||||
|
||||
@Mapping(source = "customer.id", target = "customerId")
|
||||
@Mapping(source = "customer.prefix", target = "customerPrefix")
|
||||
@Mapping(target = "displayLabel", ignore = true)
|
||||
@Mapping(target = "customerDisplayLabel", ignore = true)
|
||||
@Mapping(target = "membershipDisplayReference", ignore = true)
|
||||
MembershipDTO toDto(Membership membership);
|
||||
|
||||
// TODO BLOG HOWTO: multi-field display reference for selection lists
|
||||
// also change the filed in the option list in *-update.html
|
||||
@AfterMapping
|
||||
default void setMembershipDisplayLabel(final @MappingTarget MembershipDTO dto, final Membership entity) {
|
||||
dto.setDisplayLabel(displayLabel(entity));
|
||||
dto.setCustomerDisplayLabel(CustomerMapper.displayLabel(entity.getCustomer()));
|
||||
default void setMembershipDisplayReference(final @MappingTarget MembershipDTO dto, final Membership entity) {
|
||||
final Customer customer = entity.getCustomer();
|
||||
dto.setMembershipDisplayReference(customer.getReference()
|
||||
+ ":" + customer.getPrefix()
|
||||
+ " [" + customer.getName() + "] "
|
||||
+ entity.getAdmissionDocumentDate().toString() + " - "
|
||||
+ Objects.toString(entity.getCancellationDocumentDate(), ""));
|
||||
}
|
||||
|
||||
@Mapping(target = "shares", ignore = true)
|
||||
|
@ -2,10 +2,8 @@ package org.hostsharing.hsadminng.service.mapper;
|
||||
|
||||
import org.hostsharing.hsadminng.domain.Share;
|
||||
import org.hostsharing.hsadminng.service.dto.ShareDTO;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
|
||||
/**
|
||||
* Mapper for the entity Share and its DTO ShareDTO.
|
||||
@ -14,14 +12,9 @@ import org.mapstruct.MappingTarget;
|
||||
public interface ShareMapper extends EntityMapper<ShareDTO, Share> {
|
||||
|
||||
@Mapping(source = "membership.id", target = "membershipId")
|
||||
@Mapping(target = "membershipDisplayLabel", ignore = true)
|
||||
@Mapping(source = "membership.admissionDocumentDate", target = "membershipDisplayReference")
|
||||
ShareDTO toDto(Share share);
|
||||
|
||||
@AfterMapping
|
||||
default void setMembershipDisplayLabel(final @MappingTarget ShareDTO dto, final Share entity) {
|
||||
dto.setMembershipDisplayLabel(MembershipMapper.displayLabel(entity.getMembership()));
|
||||
}
|
||||
|
||||
@Mapping(source = "membershipId", target = "membership")
|
||||
Share toEntity(ShareDTO shareDTO);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-8">
|
||||
<div *ngIf="asset">
|
||||
<h2><span jhiTranslate="hsadminNgApp.asset.detail.title">Asset</span>: #{{asset.id}} - {{asset.membershipDisplayLabel}}</h2>
|
||||
<h2><span jhiTranslate="hsadminNgApp.asset.detail.title">Asset</span> {{asset.id}}</h2>
|
||||
<hr>
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
<dl class="row-md jh-entity-details">
|
||||
@ -28,7 +28,7 @@
|
||||
<dt><span jhiTranslate="hsadminNgApp.asset.membership">Membership</span></dt>
|
||||
<dd>
|
||||
<div *ngIf="asset.membershipId">
|
||||
<a [routerLink]="['/membership', asset.membershipId, 'view']">{{asset.membershipDisplayLabel}}</a>
|
||||
<a [routerLink]="['/membership', asset.membershipId, 'view']">{{asset.membershipDisplayReference}}</a>
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
|
@ -89,7 +89,7 @@
|
||||
<label class="form-control-label" jhiTranslate="hsadminNgApp.asset.membership" for="field_membership">Membership</label>
|
||||
<select class="form-control" id="field_membership" name="membership" [(ngModel)]="asset.membershipId" required>
|
||||
<option *ngIf="!editForm.value.membership" [ngValue]="null" selected></option>
|
||||
<option [ngValue]="membershipOption.id" *ngFor="let membershipOption of memberships; trackBy: trackMembershipById">{{membershipOption.displayLabel}}</option>
|
||||
<option [ngValue]="membershipOption.id" *ngFor="let membershipOption of memberships; trackBy: trackMembershipById">{{membershipOption.membershipDisplayReference}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div [hidden]="!(editForm.controls.membership?.dirty && editForm.controls.membership?.invalid)">
|
||||
|
@ -19,7 +19,8 @@
|
||||
<th jhiSortBy="valueDate"><span jhiTranslate="hsadminNgApp.asset.valueDate">Value Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="action"><span jhiTranslate="hsadminNgApp.asset.action">Action</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="amount"><span jhiTranslate="hsadminNgApp.asset.amount">Amount</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="membershipDisplayLabel"><span jhiTranslate="hsadminNgApp.asset.membership">Membership</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="remark"><span jhiTranslate="hsadminNgApp.asset.remark">Remark</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="membershipDisplayReference"><span jhiTranslate="hsadminNgApp.asset.membership">Membership</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -30,9 +31,10 @@
|
||||
<td>{{asset.valueDate | date:'mediumDate'}}</td>
|
||||
<td jhiTranslate="{{'hsadminNgApp.AssetAction.' + asset.action}}">{{asset.action}}</td>
|
||||
<td>{{asset.amount}}</td>
|
||||
<td>{{asset.remark}}</td>
|
||||
<td>
|
||||
<div *ngIf="asset.membershipId">
|
||||
<a [routerLink]="['../membership', asset.membershipId , 'view' ]" >{{asset.membershipDisplayLabel}}</a>
|
||||
<a [routerLink]="['../membership', asset.membershipId , 'view' ]" >{{asset.membershipDisplayReference}}</a>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-8">
|
||||
<div *ngIf="customer">
|
||||
<h2><span jhiTranslate="hsadminNgApp.customer.detail.title">Customer</span>: {{customer.displayLabel}}</h2>
|
||||
<h2><span jhiTranslate="hsadminNgApp.customer.detail.title">Customer</span> {{customer.id}}</h2>
|
||||
<hr>
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
<dl class="row-md jh-entity-details">
|
||||
|
@ -18,7 +18,18 @@
|
||||
<th jhiSortBy="reference"><span jhiTranslate="hsadminNgApp.customer.reference">Reference</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="prefix"><span jhiTranslate="hsadminNgApp.customer.prefix">Prefix</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="name"><span jhiTranslate="hsadminNgApp.customer.name">Name</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="kind"><span jhiTranslate="hsadminNgApp.customer.kind">Kind</span> <fa-icon [icon]="'sort'"></fa-icon></thn></th>
|
||||
<th jhiSortBy="kind"><span jhiTranslate="hsadminNgApp.customer.kind">Kind</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="birthDate"><span jhiTranslate="hsadminNgApp.customer.birthDate">Birth Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="birthPlace"><span jhiTranslate="hsadminNgApp.customer.birthPlace">Birth Place</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="registrationCourt"><span jhiTranslate="hsadminNgApp.customer.registrationCourt">Registration Court</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="registrationNumber"><span jhiTranslate="hsadminNgApp.customer.registrationNumber">Registration Number</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="vatRegion"><span jhiTranslate="hsadminNgApp.customer.vatRegion">Vat Region</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="vatNumber"><span jhiTranslate="hsadminNgApp.customer.vatNumber">Vat Number</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="contractualSalutation"><span jhiTranslate="hsadminNgApp.customer.contractualSalutation">Contractual Salutation</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="contractualAddress"><span jhiTranslate="hsadminNgApp.customer.contractualAddress">Contractual Address</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="billingSalutation"><span jhiTranslate="hsadminNgApp.customer.billingSalutation">Billing Salutation</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="billingAddress"><span jhiTranslate="hsadminNgApp.customer.billingAddress">Billing Address</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="remark"><span jhiTranslate="hsadminNgApp.customer.remark">Remark</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -29,6 +40,17 @@
|
||||
<td>{{customer.prefix}}</td>
|
||||
<td>{{customer.name}}</td>
|
||||
<td jhiTranslate="{{'hsadminNgApp.CustomerKind.' + customer.kind}}">{{customer.kind}}</td>
|
||||
<td>{{customer.birthDate | date:'mediumDate'}}</td>
|
||||
<td>{{customer.birthPlace}}</td>
|
||||
<td>{{customer.registrationCourt}}</td>
|
||||
<td>{{customer.registrationNumber}}</td>
|
||||
<td jhiTranslate="{{'hsadminNgApp.VatRegion.' + customer.vatRegion}}">{{customer.vatRegion}}</td>
|
||||
<td>{{customer.vatNumber}}</td>
|
||||
<td>{{customer.contractualSalutation}}</td>
|
||||
<td>{{customer.contractualAddress}}</td>
|
||||
<td>{{customer.billingSalutation}}</td>
|
||||
<td>{{customer.billingAddress}}</td>
|
||||
<td>{{customer.remark}}</td>
|
||||
<td class="text-right">
|
||||
<div class="btn-group flex-btn-group-container">
|
||||
<button type="submit"
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-8">
|
||||
<div *ngIf="membership">
|
||||
<h2><span jhiTranslate="hsadminNgApp.membership.detail.title">Membership</span>: {{membership.displayLabel}}</h2>
|
||||
<h2><span jhiTranslate="hsadminNgApp.membership.detail.title">Membership</span> {{membership.id}}</h2>
|
||||
<hr>
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
<dl class="row-md jh-entity-details">
|
||||
@ -28,7 +28,7 @@
|
||||
<dt><span jhiTranslate="hsadminNgApp.membership.customer">Customer</span></dt>
|
||||
<dd>
|
||||
<div *ngIf="membership.customerId">
|
||||
<a [routerLink]="['/customer', membership.customerId, 'view']">{{membership.customerDisplayLabel}}</a>
|
||||
<a [routerLink]="['/customer', membership.customerId, 'view']">{{membership.customerPrefix}}</a>
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
|
@ -77,7 +77,7 @@
|
||||
<label class="form-control-label" jhiTranslate="hsadminNgApp.membership.customer" for="field_customer">Customer</label>
|
||||
<select class="form-control" id="field_customer" name="customer" [(ngModel)]="membership.customerId" required>
|
||||
<option *ngIf="!editForm.value.customer" [ngValue]="null" selected></option>
|
||||
<option [ngValue]="customerOption.id" *ngFor="let customerOption of customers; trackBy: trackCustomerById">{{customerOption.displayLabel}}</option>
|
||||
<option [ngValue]="customerOption.id" *ngFor="let customerOption of customers; trackBy: trackCustomerById">{{customerOption.prefix}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div [hidden]="!(editForm.controls.customer?.dirty && editForm.controls.customer?.invalid)">
|
||||
|
@ -19,6 +19,7 @@
|
||||
<th jhiSortBy="cancellationDocumentDate"><span jhiTranslate="hsadminNgApp.membership.cancellationDocumentDate">Cancellation Document Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="memberFromDate"><span jhiTranslate="hsadminNgApp.membership.memberFromDate">Member From Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="memberUntilDate"><span jhiTranslate="hsadminNgApp.membership.memberUntilDate">Member Until Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="remark"><span jhiTranslate="hsadminNgApp.membership.remark">Remark</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="customerPrefix"><span jhiTranslate="hsadminNgApp.membership.customer">Customer</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@ -27,12 +28,13 @@
|
||||
<tr *ngFor="let membership of memberships ;trackBy: trackId">
|
||||
<td><a [routerLink]="['/membership', membership.id, 'view' ]">{{membership.id}}</a></td>
|
||||
<td>{{membership.admissionDocumentDate | date:'mediumDate'}}</td>
|
||||
<td>{{membership.cancellationDocumentDate | date:'mediumDsate'}}</td>
|
||||
<td>{{membership.cancellationDocumentDate | date:'mediumDate'}}</td>
|
||||
<td>{{membership.memberFromDate | date:'mediumDate'}}</td>
|
||||
<td>{{membership.memberUntilDate | date:'mediumDate'}}</td>
|
||||
<td>{{membership.remark}}</td>
|
||||
<td>
|
||||
<div *ngIf="membership.customerId">
|
||||
<a [routerLink]="['../customer', membership.customerId , 'view' ]" >{{membership.customerDisplayLabel}}</a>
|
||||
<a [routerLink]="['../customer', membership.customerId , 'view' ]" >{{membership.customerPrefix}}</a>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-8">
|
||||
<div *ngIf="share">
|
||||
<h2><span jhiTranslate="hsadminNgApp.share.detail.title">Share</span>: #{{share.id}} - {{share.membershipDisplayLabel}}</h2>
|
||||
<h2><span jhiTranslate="hsadminNgApp.share.detail.title">Share</span> {{share.id}}</h2>
|
||||
<hr>
|
||||
<jhi-alert-error></jhi-alert-error>
|
||||
<dl class="row-md jh-entity-details">
|
||||
@ -28,7 +28,7 @@
|
||||
<dt><span jhiTranslate="hsadminNgApp.share.membership">Membership</span></dt>
|
||||
<dd>
|
||||
<div *ngIf="share.membershipId">
|
||||
<a [routerLink]="['/membership', share.membershipId, 'view']">{{share.membershipDisplayLabel}}</a>
|
||||
<a [routerLink]="['/membership', share.membershipId, 'view']">{{share.membershipDisplayReference}}</a>
|
||||
</div>
|
||||
</dd>
|
||||
</dl>
|
||||
|
@ -85,7 +85,7 @@
|
||||
<label class="form-control-label" jhiTranslate="hsadminNgApp.share.membership" for="field_membership">Membership</label>
|
||||
<select class="form-control" id="field_membership" name="membership" [(ngModel)]="share.membershipId" required>
|
||||
<option *ngIf="!editForm.value.membership" [ngValue]="null" selected></option>
|
||||
<option [ngValue]="membershipOption.id" *ngFor="let membershipOption of memberships; trackBy: trackMembershipById">{{membershipOption.displayLabel}}</option>
|
||||
<option [ngValue]="membershipOption.id" *ngFor="let membershipOption of memberships; trackBy: trackMembershipById">{{membershipOption.admissionDocumentDate}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div [hidden]="!(editForm.controls.membership?.dirty && editForm.controls.membership?.invalid)">
|
||||
|
@ -19,7 +19,8 @@
|
||||
<th jhiSortBy="valueDate"><span jhiTranslate="hsadminNgApp.share.valueDate">Value Date</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="action"><span jhiTranslate="hsadminNgApp.share.action">Action</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="quantity"><span jhiTranslate="hsadminNgApp.share.quantity">Quantity</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="membershipDisplayLabel"><span jhiTranslate="hsadminNgApp.share.membership">Membership</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="remark"><span jhiTranslate="hsadminNgApp.share.remark">Remark</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th jhiSortBy="membershipDisplayReference"><span jhiTranslate="hsadminNgApp.share.membership">Membership</span> <fa-icon [icon]="'sort'"></fa-icon></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -30,9 +31,10 @@
|
||||
<td>{{share.valueDate | date:'mediumDate'}}</td>
|
||||
<td jhiTranslate="{{'hsadminNgApp.ShareAction.' + share.action}}">{{share.action}}</td>
|
||||
<td>{{share.quantity}}</td>
|
||||
<td>{{share.remark}}</td>
|
||||
<td>
|
||||
<div *ngIf="share.membershipId">
|
||||
<a [routerLink]="['../membership', share.membershipId , 'view' ]" >{{share.membershipDisplayLabel}}</a>
|
||||
<a [routerLink]="['../membership', share.membershipId , 'view' ]" >{{share.membershipDisplayReference}}</a>
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
|
@ -16,8 +16,8 @@ export interface IAsset {
|
||||
action?: AssetAction;
|
||||
amount?: number;
|
||||
remark?: string;
|
||||
membershipDisplayReference?: string;
|
||||
membershipId?: number;
|
||||
membershipDisplayLabel?: string;
|
||||
}
|
||||
|
||||
export class Asset implements IAsset {
|
||||
@ -28,7 +28,7 @@ export class Asset implements IAsset {
|
||||
public action?: AssetAction,
|
||||
public amount?: number,
|
||||
public remark?: string,
|
||||
public membershipId?: number,
|
||||
public membershipDisplayLabel?: string
|
||||
public membershipDisplayReference?: string,
|
||||
public membershipId?: number
|
||||
) {}
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ export interface ICustomer {
|
||||
remark?: string;
|
||||
memberships?: IMembership[];
|
||||
sepamandates?: ISepaMandate[];
|
||||
displayLabel?: string;
|
||||
}
|
||||
|
||||
export class Customer implements ICustomer {
|
||||
@ -54,7 +53,6 @@ export class Customer implements ICustomer {
|
||||
public billingAddress?: string,
|
||||
public remark?: string,
|
||||
public memberships?: IMembership[],
|
||||
public sepamandates?: ISepaMandate[],
|
||||
public displayLabel?: string
|
||||
public sepamandates?: ISepaMandate[]
|
||||
) {}
|
||||
}
|
||||
|
@ -13,8 +13,7 @@ export interface IMembership {
|
||||
assets?: IAsset[];
|
||||
customerPrefix?: string;
|
||||
customerId?: number;
|
||||
membershipDisplayLabel?: string;
|
||||
displayLabel?: string;
|
||||
membershipDisplayReference?: string;
|
||||
}
|
||||
|
||||
export class Membership implements IMembership {
|
||||
@ -29,7 +28,6 @@ export class Membership implements IMembership {
|
||||
public assets?: IAsset[],
|
||||
public customerPrefix?: string,
|
||||
public customerId?: number,
|
||||
public displayLabel?: string,
|
||||
public membershipDisplayLabel?: string
|
||||
public membershipDisplayReference?: string
|
||||
) {}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ export interface IShare {
|
||||
action?: ShareAction;
|
||||
quantity?: number;
|
||||
remark?: string;
|
||||
membershipDisplayLabel?: string;
|
||||
membershipDisplayReference?: string;
|
||||
membershipId?: number;
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ export class Share implements IShare {
|
||||
public action?: ShareAction,
|
||||
public quantity?: number,
|
||||
public remark?: string,
|
||||
public membershipDisplayLabel?: string,
|
||||
public membershipDisplayReference?: string,
|
||||
public membershipId?: number
|
||||
) {}
|
||||
}
|
||||
|
@ -1,167 +0,0 @@
|
||||
package org.hostsharing.hsadminng.service;
|
||||
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
import org.hostsharing.hsadminng.domain.Asset;
|
||||
import org.hostsharing.hsadminng.domain.enumeration.AssetAction;
|
||||
import org.hostsharing.hsadminng.repository.AssetRepository;
|
||||
import org.hostsharing.hsadminng.service.dto.AssetDTO;
|
||||
import org.hostsharing.hsadminng.service.mapper.AssetMapper;
|
||||
import org.hostsharing.hsadminng.web.rest.errors.BadRequestAlertException;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.catchThrowableOfType;
|
||||
import static org.mockito.ArgumentMatchers.same;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
||||
// HINT: In IntelliJ IDEA such unit test classes can be created with Shift-Ctrl-T.
|
||||
// Do not forget to amend the class name (.e.g. ...UnitTest / ...IntTest)!
|
||||
public class AssetServiceUnitTest {
|
||||
|
||||
@Rule
|
||||
public MockitoRule mockitoRule = MockitoJUnit.rule();
|
||||
|
||||
@Mock
|
||||
private EntityManager em;
|
||||
|
||||
@Mock
|
||||
private AssetRepository assetRepository;
|
||||
|
||||
@Mock
|
||||
private AssetValidator assetValidator; // needed for @InjectMocks assetService
|
||||
|
||||
@Mock
|
||||
private AssetMapper assetMapper;
|
||||
|
||||
@InjectMocks
|
||||
private AssetService assetService;
|
||||
|
||||
// HINT: Click outside of any test method (e.g. here) and use Ctrl-Shift-F10
|
||||
// to run all tests from this test class. Use Ctrl-F5 to run the last execution again;
|
||||
// 'execution' here can also apply to running the application, whatever ran last.
|
||||
|
||||
// HINT: In IntelliJ IDEA such test methods can be created with Alt-Insert.
|
||||
@Test
|
||||
public void deleteIsRejectedForAssetTransactions() {
|
||||
// when
|
||||
final Throwable throwException = catchThrowableOfType(() -> assetService.delete(RandomUtils.nextLong()), BadRequestAlertException.class);
|
||||
|
||||
// then
|
||||
// HINT: When using auto-import for assertions (e.g. via Alt-Enter in IntelliJ IDEA),
|
||||
// beware to use the correct candidate from org.assertj.core.api.Assertions.
|
||||
assertThat(throwException).isEqualToComparingFieldByField(
|
||||
new BadRequestAlertException("Asset transactions are immutable", "asset", "assetTransactionImmutable"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void saveShouldPersistValidTransactions() {
|
||||
// given
|
||||
final AssetDTO givenAssetDTO = givenAssetDTO(null, AssetAction.PAYMENT, anyPositiveAmout());
|
||||
// HINT: given(...)...will...() can't be used for void methods, in that case use Mockito's do...() methods
|
||||
doNothing().when(assetValidator).validate(givenAssetDTO);
|
||||
|
||||
// when
|
||||
final AssetDTO returnedAssetDto = assetService.save(givenAssetDTO);
|
||||
|
||||
// then
|
||||
verify(em).flush();
|
||||
verify(em).refresh(any(Asset.class));
|
||||
assertThat(returnedAssetDto).isEqualToIgnoringGivenFields(givenAssetDTO, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void saveShouldNotPersistInvalidTransactions() {
|
||||
// given
|
||||
final AssetDTO givenAssetDTO = givenAssetDTO(null, AssetAction.PAYMENT, anyNegativeAmount());
|
||||
doThrow(new BadRequestAlertException("Some Dummy Test Violation", "asset", "assetInvalidTestDummy")).when(assetValidator).validate(givenAssetDTO);
|
||||
|
||||
// when
|
||||
final Throwable throwException = catchThrowableOfType(() -> assetService.save(givenAssetDTO), BadRequestAlertException.class);
|
||||
|
||||
// then
|
||||
assertThat(throwException).isEqualToComparingFieldByField(
|
||||
new BadRequestAlertException("Some Dummy Test Violation", "asset", "assetInvalidTestDummy"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void saveShouldUpdateValidTransactions() {
|
||||
// given
|
||||
final AssetDTO givenAssetDTO = givenAssetDTO(anyNonNullId(), AssetAction.PAYMENT, anyPositiveAmout());
|
||||
doNothing().when(assetValidator).validate(givenAssetDTO);
|
||||
|
||||
// when
|
||||
final AssetDTO returnedAssetDto = assetService.save(givenAssetDTO);
|
||||
|
||||
// then
|
||||
verify(em).flush();
|
||||
verify(em).refresh(any(Asset.class));
|
||||
assertThat(returnedAssetDto).isEqualToIgnoringGivenFields(givenAssetDTO, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void saveShouldNotUpdateInvalidTransactions() {
|
||||
// given
|
||||
final AssetDTO givenAssetDTO = givenAssetDTO(anyNonNullId(), AssetAction.PAYMENT, anyNegativeAmount());
|
||||
// HINT: given(...) can't be used for void methods, in that case use Mockito's do...() methods
|
||||
doThrow(new BadRequestAlertException("Some Dummy Test Violation", "asset", "assetInvalidTestDummy")).when(assetValidator).validate(givenAssetDTO);
|
||||
|
||||
// when
|
||||
final Throwable throwException = catchThrowableOfType(() -> assetService.save(givenAssetDTO), BadRequestAlertException.class);
|
||||
|
||||
// then
|
||||
assertThat(throwException).isEqualToComparingFieldByField(
|
||||
new BadRequestAlertException("Some Dummy Test Violation", "asset", "assetInvalidTestDummy"));
|
||||
}
|
||||
|
||||
// --- only test fixture code below ---
|
||||
|
||||
private long anyNonNullId() {
|
||||
return RandomUtils.nextInt();
|
||||
}
|
||||
|
||||
// HINT: This rather complicated setup indicates that the method AssetService::save breaks the single responsibility principle.
|
||||
private AssetDTO givenAssetDTO(final Long id, final AssetAction givenAction, final BigDecimal givenQuantity) {
|
||||
final AssetDTO givenAssetDTO = createAssetDTO(id, givenAction, givenQuantity);
|
||||
|
||||
// dto -> entity
|
||||
final Asset givenAssetEntity = Mockito.mock(Asset.class);
|
||||
given(assetMapper.toEntity(same(givenAssetDTO))).willReturn(givenAssetEntity);
|
||||
|
||||
// assetRepository.save(entity);
|
||||
final Asset persistedAssetEntity = Mockito.mock(Asset.class);
|
||||
given(assetRepository.save(same(givenAssetEntity))).willReturn(persistedAssetEntity);
|
||||
|
||||
// entity -> dto
|
||||
AssetDTO persistedAssetDTO = createAssetDTO(id == null ? RandomUtils.nextLong() : id, givenAction, givenQuantity);
|
||||
given(assetMapper.toDto(same(persistedAssetEntity))).willReturn(persistedAssetDTO);
|
||||
|
||||
return givenAssetDTO;
|
||||
}
|
||||
|
||||
private AssetDTO createAssetDTO(Long id, AssetAction givenAction, BigDecimal givenAmount) {
|
||||
final AssetDTO givenAssetDTO = new AssetDTO();
|
||||
givenAssetDTO.setId(id);
|
||||
givenAssetDTO.setAction(givenAction);
|
||||
givenAssetDTO.setAmount(givenAmount);
|
||||
return givenAssetDTO;
|
||||
}
|
||||
|
||||
private BigDecimal anyPositiveAmout() {
|
||||
return BigDecimal.valueOf(RandomUtils.nextInt()).add(new BigDecimal("0.1"));
|
||||
}
|
||||
|
||||
private BigDecimal anyNegativeAmount() {
|
||||
return anyPositiveAmout().negate();
|
||||
}
|
||||
}
|
@ -15,13 +15,12 @@ import org.mockito.Mockito;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.catchThrowableOfType;
|
||||
import static org.mockito.ArgumentMatchers.same;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
|
||||
|
||||
// HINT: In IntelliJ IDEA such unit test classes can be created with Shift-Ctrl-T.
|
||||
@ -31,9 +30,6 @@ public class ShareServiceUnitTest {
|
||||
@Rule
|
||||
public MockitoRule mockitoRule = MockitoJUnit.rule();
|
||||
|
||||
@Mock
|
||||
private EntityManager em;
|
||||
|
||||
@Mock
|
||||
private ShareRepository shareRepository;
|
||||
|
||||
@ -74,8 +70,6 @@ public class ShareServiceUnitTest {
|
||||
final ShareDTO returnedShareDto = shareService.save(givenShareDTO);
|
||||
|
||||
// then
|
||||
verify(em).flush();
|
||||
verify(em).refresh(any(Share.class));
|
||||
assertThat(returnedShareDto).isEqualToIgnoringGivenFields(givenShareDTO, "id");
|
||||
}
|
||||
|
||||
@ -103,8 +97,6 @@ public class ShareServiceUnitTest {
|
||||
final ShareDTO returnedShareDto = shareService.save(givenShareDTO);
|
||||
|
||||
// then
|
||||
verify(em).flush();
|
||||
verify(em).refresh(any(Share.class));
|
||||
assertThat(returnedShareDto).isEqualToIgnoringGivenFields(givenShareDTO, "id");
|
||||
}
|
||||
|
||||
|
@ -82,8 +82,7 @@ public class CustomerDTOUnitTest {
|
||||
toJSonFieldDefinition("id", given.getId()) + "," +
|
||||
toJSonFieldDefinition("reference", given.getReference()) + "," +
|
||||
toJSonFieldDefinition("prefix", given.getPrefix()) + "," +
|
||||
toJSonFieldDefinition("name", given.getName()) + "," +
|
||||
toJSonFieldDefinition("displayLabel", given.getDisplayLabel()) +
|
||||
toJSonFieldDefinition("name", given.getName()) +
|
||||
"}";
|
||||
assertEquals(expectedJSon, actual);
|
||||
}
|
||||
@ -119,7 +118,7 @@ public class CustomerDTOUnitTest {
|
||||
expected.setId(1234L);
|
||||
expected.setContractualSalutation("Hallo Updated");
|
||||
expected.setBillingSalutation("Moin Updated");
|
||||
assertThat(actual).isEqualToIgnoringGivenFields(expected, "displayLabel");
|
||||
assertThat(actual).isEqualToComparingFieldByField(expected);
|
||||
}
|
||||
|
||||
// --- only test fixture below ---
|
||||
@ -141,11 +140,12 @@ public class CustomerDTOUnitTest {
|
||||
toJSonFieldDefinitionIfPresent("contractualAddress", dto.getContractualAddress()) +
|
||||
toJSonFieldDefinitionIfPresent("billingSalutation", dto.getBillingSalutation()) +
|
||||
toJSonFieldDefinitionIfPresent("billingAddress", dto.getBillingAddress()) +
|
||||
toJSonFieldDefinitionIfPresent("remark", dto.getRemark()) +
|
||||
toJSonFieldDefinitionIfPresent("displayLabel", dto.getDisplayLabel());
|
||||
toJSonFieldDefinitionIfPresent("remark", dto.getRemark());
|
||||
return "{" + json.substring(0, json.length() - 1) + "}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String toJSonFieldDefinition(String name, String value) {
|
||||
return inQuotes(name) + ":" + (value != null ? inQuotes(value) : "null");
|
||||
}
|
||||
@ -186,7 +186,6 @@ public class CustomerDTOUnitTest {
|
||||
given.setBillingAddress("Noch eine Adresse");
|
||||
given.setBillingSalutation("Moin");
|
||||
given.setRemark("Eine Bemerkung");
|
||||
given.setDisplayLabel("Display Label");
|
||||
return given;
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ public class ShareDTOUnitTest {
|
||||
givenDTO.setAction(ShareAction.SUBSCRIPTION);
|
||||
givenDTO.setQuantity(3);
|
||||
givenDTO.setDocumentDate(LocalDate.parse("2019-04-22"));
|
||||
givenDTO.setMembershipDisplayLabel("2019-04-21"); // TODO: why is this not a LocalDate?
|
||||
givenDTO.setMembershipDisplayReference("2019-04-21"); // TODO: why is this not a LocalDate?
|
||||
givenDTO.setValueDate(LocalDate.parse("2019-04-30"));
|
||||
givenDTO.setRemark("Some Remark");
|
||||
return givenDTO;
|
||||
|
@ -248,7 +248,7 @@ public class MembershipResourceIntTest {
|
||||
.andExpect(jsonPath("$.[*].cancellationDocumentDate").value(hasItem(DEFAULT_CANCELLATION_DOCUMENT_DATE.toString())))
|
||||
.andExpect(jsonPath("$.[*].memberFromDate").value(hasItem(DEFAULT_MEMBER_FROM_DATE.toString())))
|
||||
.andExpect(jsonPath("$.[*].memberUntilDate").value(hasItem(DEFAULT_MEMBER_UNTIL_DATE.toString())))
|
||||
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK)));
|
||||
.andExpect(jsonPath("$.[*].remark").value(hasItem(DEFAULT_REMARK.toString())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -266,7 +266,7 @@ public class MembershipResourceIntTest {
|
||||
.andExpect(jsonPath("$.cancellationDocumentDate").value(DEFAULT_CANCELLATION_DOCUMENT_DATE.toString()))
|
||||
.andExpect(jsonPath("$.memberFromDate").value(DEFAULT_MEMBER_FROM_DATE.toString()))
|
||||
.andExpect(jsonPath("$.memberUntilDate").value(DEFAULT_MEMBER_UNTIL_DATE.toString()))
|
||||
.andExpect(jsonPath("$.remark").value(DEFAULT_REMARK));
|
||||
.andExpect(jsonPath("$.remark").value(DEFAULT_REMARK.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -682,7 +682,9 @@ public class MembershipResourceIntTest {
|
||||
// Disconnect from session so that the updates on updatedMembership are not directly saved in db
|
||||
em.detach(updatedMembership);
|
||||
updatedMembership
|
||||
.admissionDocumentDate(UPDATED_ADMISSION_DOCUMENT_DATE)
|
||||
.cancellationDocumentDate(UPDATED_CANCELLATION_DOCUMENT_DATE)
|
||||
.memberFromDate(UPDATED_MEMBER_FROM_DATE)
|
||||
.memberUntilDate(UPDATED_MEMBER_UNTIL_DATE)
|
||||
.remark(UPDATED_REMARK);
|
||||
MembershipDTO membershipDTO = membershipMapper.toDto(updatedMembership);
|
||||
@ -696,9 +698,9 @@ public class MembershipResourceIntTest {
|
||||
List<Membership> membershipList = membershipRepository.findAll();
|
||||
assertThat(membershipList).hasSize(databaseSizeBeforeUpdate);
|
||||
Membership testMembership = membershipList.get(membershipList.size() - 1);
|
||||
assertThat(testMembership.getAdmissionDocumentDate()).isEqualTo(DEFAULT_ADMISSION_DOCUMENT_DATE);
|
||||
assertThat(testMembership.getAdmissionDocumentDate()).isEqualTo(UPDATED_ADMISSION_DOCUMENT_DATE);
|
||||
assertThat(testMembership.getCancellationDocumentDate()).isEqualTo(UPDATED_CANCELLATION_DOCUMENT_DATE);
|
||||
assertThat(testMembership.getMemberFromDate()).isEqualTo(DEFAULT_MEMBER_FROM_DATE);
|
||||
assertThat(testMembership.getMemberFromDate()).isEqualTo(UPDATED_MEMBER_FROM_DATE);
|
||||
assertThat(testMembership.getMemberUntilDate()).isEqualTo(UPDATED_MEMBER_UNTIL_DATE);
|
||||
assertThat(testMembership.getRemark()).isEqualTo(UPDATED_REMARK);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user