implemented more AssetDTO+ShareDTO tests and fixed but in ShareDTO
This commit is contained in:
@ -58,6 +58,11 @@ public class Share implements Serializable {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Share id(final Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
@ -150,17 +150,17 @@ public class AssetDTO implements Serializable, AccessMappings {
|
||||
}
|
||||
|
||||
@JsonComponent
|
||||
public static class AssetJsonSerializer extends JsonSerializerWithAccessFilter<AssetDTO> {
|
||||
public static class JsonSerializer extends JsonSerializerWithAccessFilter<AssetDTO> {
|
||||
|
||||
public AssetJsonSerializer(final ApplicationContext ctx) {
|
||||
public JsonSerializer(final ApplicationContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@JsonComponent
|
||||
public static class AssetJsonDeserializer extends JsonDeserializerWithAccessFilter<AssetDTO> {
|
||||
public static class JsonDeserializer extends JsonDeserializerWithAccessFilter<AssetDTO> {
|
||||
|
||||
public AssetJsonDeserializer(final ApplicationContext ctx) {
|
||||
public JsonDeserializer(final ApplicationContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,9 @@ package org.hostsharing.hsadminng.service.dto;
|
||||
import org.hostsharing.hsadminng.domain.enumeration.ShareAction;
|
||||
import org.hostsharing.hsadminng.service.MembershipService;
|
||||
import org.hostsharing.hsadminng.service.ShareService;
|
||||
import org.hostsharing.hsadminng.service.accessfilter.AccessFor;
|
||||
import org.hostsharing.hsadminng.service.accessfilter.ParentId;
|
||||
import org.hostsharing.hsadminng.service.accessfilter.Role;
|
||||
import org.hostsharing.hsadminng.service.accessfilter.SelfId;
|
||||
import org.hostsharing.hsadminng.service.accessfilter.*;
|
||||
import org.springframework.boot.jackson.JsonComponent;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
@ -17,7 +16,7 @@ import java.util.Objects;
|
||||
/**
|
||||
* A DTO for the Share entity.
|
||||
*/
|
||||
public class ShareDTO implements Serializable {
|
||||
public class ShareDTO implements Serializable, AccessMappings {
|
||||
|
||||
@SelfId(resolver = ShareService.class)
|
||||
@AccessFor(read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
@ -40,14 +39,14 @@ public class ShareDTO implements Serializable {
|
||||
private Integer quantity;
|
||||
|
||||
@Size(max = 160)
|
||||
@AccessFor(init = Role.ADMIN, read = Role.SUPPORTER)
|
||||
@AccessFor(init = Role.ADMIN, update = Role.ADMIN, read = Role.SUPPORTER)
|
||||
private String remark;
|
||||
|
||||
@ParentId(resolver = MembershipService.class)
|
||||
@AccessFor(init = Role.ADMIN, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
private Long membershipId;
|
||||
|
||||
@AccessFor(read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
@AccessFor(update = Role.IGNORED, read = {Role.CONTRACTUAL_CONTACT, Role.FINANCIAL_CONTACT})
|
||||
private String membershipDisplayLabel;
|
||||
|
||||
public Long getId() {
|
||||
@ -145,7 +144,23 @@ public class ShareDTO implements Serializable {
|
||||
", quantity=" + getQuantity() +
|
||||
", remark='" + getRemark() + "'" +
|
||||
", membership=" + getMembershipId() +
|
||||
", membership='" + getMembershipDisplayLabel() + "'" +
|
||||
", membershipDisplayLabel='" + getMembershipDisplayLabel() + "'" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@JsonComponent
|
||||
public static class JsonSerializer extends JsonSerializerWithAccessFilter<ShareDTO> {
|
||||
|
||||
public JsonSerializer(final ApplicationContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
@JsonComponent
|
||||
public static class JsonDeserializer extends JsonDeserializerWithAccessFilter<ShareDTO> {
|
||||
|
||||
public JsonDeserializer(final ApplicationContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
package org.hostsharing.hsadminng.service.util;
|
||||
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.RandomUtils;
|
||||
|
||||
/**
|
||||
* Utility class for generating random Strings.
|
||||
* Utility class for generating random Values.
|
||||
*/
|
||||
public final class RandomUtil {
|
||||
|
||||
@ -38,4 +39,14 @@ public final class RandomUtil {
|
||||
public static String generateResetKey() {
|
||||
return RandomStringUtils.randomNumeric(DEF_COUNT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random enum value for a given enum type.
|
||||
*
|
||||
* @return the generated enum value
|
||||
*/
|
||||
public static <E extends Enum<E>> E generateEnumValue(final Class<E> enumType) {
|
||||
final E[] enumValues = enumType.getEnumConstants();
|
||||
return enumValues[RandomUtils.nextInt(0, enumValues.length-1)];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user