Commit b9fef132 authored by Georg Mittendorfer's avatar Georg Mittendorfer

Remove default values for custom command validation.

Default values are set via properties file. Validation set to 0 or max values as fallback.
parent c13541e7
......@@ -39,9 +39,6 @@ import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
public class AttachToTangle extends IriCommand {
static final String COMMAND = "attachToTangle";
public static final int DEFAULT_WEIGHT_MAX = 15;
public static final int DEFAULT_WEIGHT_MIN = 14;
public static final int DEFAULT_MAX_TRYTES_COUNT = 20;
public AttachToTangle() {
super();
......
......@@ -35,11 +35,6 @@ public class GetTransactionsToApprove extends IriCommand {
static final String COMMAND = "getTransactionsToApprove";
// 3 is the recommended value
// 15 is the current iri limit but that seems to be too high.
public static final int DEFAULT_DEPTH_MIN = 1;
public static final int DEFAULT_DEPTH_MAX = 10;
@NotNull
private int depth;
......
......@@ -38,8 +38,6 @@ public class GetTrytes extends IriCommand {
static final String COMMAND = "getTrytes";
public static final int DEFAULT_HASHES_SIZE_MAX = 1000;
//@NotEmpty // can be empty for a new seed (light wallet)
@NotNull
@JsonInclude(value=NON_NULL)
......
......@@ -40,9 +40,9 @@ public class AttachToTangleValidator implements Validator {
public AttachToTangleValidator(Environment env, MinMaxValidator minMaxValidator) {
this.minMaxValidator = minMaxValidator;
min = env.getProperty("iri.attachToTangle.minWeightMagnitude.min", Integer.class, AttachToTangle.DEFAULT_WEIGHT_MIN);
max = env.getProperty("iri.attachToTangle.minWeightMagnitude.max", Integer.class, AttachToTangle.DEFAULT_WEIGHT_MAX);
maxTrytes = env.getProperty("iri.attachToTangle.trytes.max", Integer.class, AttachToTangle.DEFAULT_MAX_TRYTES_COUNT);
min = env.getProperty("iri.attachToTangle.minWeightMagnitude.min", Integer.class, 0);
max = env.getProperty("iri.attachToTangle.minWeightMagnitude.max", Integer.class, Integer.MAX_VALUE);
maxTrytes = env.getProperty("iri.attachToTangle.trytes.max", Integer.class, Integer.MAX_VALUE);
}
@Override
......
......@@ -34,8 +34,8 @@ public class GetTransactionsToApproveValidator implements Validator {
public GetTransactionsToApproveValidator(Environment env, MinMaxValidator minMaxValidator) {
this.minMaxValidator = minMaxValidator;
min = env.getProperty("iri.getTransactionsToApprove.depth.min", Integer.class, GetTransactionsToApprove.DEFAULT_DEPTH_MIN);
max = env.getProperty("iri.getTransactionsToApprove.depth.max", Integer.class, GetTransactionsToApprove.DEFAULT_DEPTH_MAX);
min = env.getProperty("iri.getTransactionsToApprove.depth.min", Integer.class, 0);
max = env.getProperty("iri.getTransactionsToApprove.depth.max", Integer.class, Integer.MAX_VALUE);
}
@Override
......
......@@ -34,7 +34,7 @@ public class GetTrytesValidator implements Validator {
public GetTrytesValidator(Environment env, MinMaxValidator minMaxValidator) {
this.minMaxValidator = minMaxValidator;
max = env.getProperty("iri.getTrytes.hashes.max", Integer.class, GetTrytes.DEFAULT_HASHES_SIZE_MAX);
max = env.getProperty("iri.getTrytes.hashes.max", Integer.class, Integer.MAX_VALUE);
}
@Override
......
......@@ -42,11 +42,11 @@ public class AttachToTangleValidatorTest {
@Before
public void initEnvironment() {
Environment env = mock(Environment.class);
when(env.getProperty("iri.attachToTangle.minWeightMagnitude.max", Integer.class, AttachToTangle.DEFAULT_WEIGHT_MAX))
when(env.getProperty("iri.attachToTangle.minWeightMagnitude.max", Integer.class, Integer.MAX_VALUE))
.thenReturn(3);
when(env.getProperty("iri.attachToTangle.minWeightMagnitude.min", Integer.class, AttachToTangle.DEFAULT_WEIGHT_MIN))
when(env.getProperty("iri.attachToTangle.minWeightMagnitude.min", Integer.class, 0))
.thenReturn(2);
when(env.getProperty("iri.attachToTangle.trytes.max", Integer.class, AttachToTangle.DEFAULT_MAX_TRYTES_COUNT))
when(env.getProperty("iri.attachToTangle.trytes.max", Integer.class, Integer.MAX_VALUE))
.thenReturn(5);
validator = new AttachToTangleValidator(env, minMaxValidator);
}
......
......@@ -40,9 +40,9 @@ public class GetTransactionsToApproveValidatorTest {
@Before
public void initEnvironment() {
Environment env = mock(Environment.class);
when(env.getProperty("iri.getTransactionsToApprove.depth.max", Integer.class, GetTransactionsToApprove.DEFAULT_DEPTH_MAX))
when(env.getProperty("iri.getTransactionsToApprove.depth.max", Integer.class, Integer.MAX_VALUE))
.thenReturn(3);
when(env.getProperty("iri.getTransactionsToApprove.depth.min", Integer.class, GetTransactionsToApprove.DEFAULT_DEPTH_MIN))
when(env.getProperty("iri.getTransactionsToApprove.depth.min", Integer.class, 0))
.thenReturn(2);
validator = new GetTransactionsToApproveValidator(env, minMaxValidator);
}
......
......@@ -42,7 +42,7 @@ public class GetTrytesValidatorTest {
@Before
public void initEnvironment() {
Environment env = mock(Environment.class);
when(env.getProperty("iri.getTrytes.hashes.max", Integer.class, GetTrytes.DEFAULT_HASHES_SIZE_MAX))
when(env.getProperty("iri.getTrytes.hashes.max", Integer.class, Integer.MAX_VALUE))
.thenReturn(42);
validator = new GetTrytesValidator(env, minMaxValidator);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment