Skip to content

Commit

Permalink
Completed unit testing of parameter validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mjunkin committed Dec 4, 2024
1 parent 8e3f10c commit 40c64e9
Show file tree
Hide file tree
Showing 21 changed files with 701 additions and 511 deletions.
3 changes: 1 addition & 2 deletions backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@
<artifactId>jersey-media-multipart</artifactId>
<version>${jersey2-version}</version>
</dependency>
<!-- Base64 encoding that works in
both JVM and Android -->
<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ public Filters copy() {
return new Filters().maintainer(maintainer).mapsheet(mapsheet).polygon(polygon).polygonId(polygonId);
}

public Filters maintainer(String maintainer) {
this.maintainer = maintainer;
return this;
}

/**
* only those polygons with the specified maintainer will be considered for inclusion in the output
*
Expand All @@ -63,13 +58,13 @@ public String getMaintainer() {
return maintainer;
}

public void setMaintainer(String maintainer) {
this.maintainer = maintainer;
public Filters maintainer(String maintainer) {
setMaintainer(maintainer);
return this;
}

public Filters mapsheet(String mapsheet) {
this.mapsheet = mapsheet;
return this;
public void setMaintainer(String maintainer) {
this.maintainer = maintainer;
}

/**
Expand All @@ -82,13 +77,13 @@ public String getMapsheet() {
return mapsheet;
}

public void setMapsheet(String mapsheet) {
this.mapsheet = mapsheet;
public Filters mapsheet(String mapsheet) {
setMapsheet(mapsheet);
return this;
}

public Filters polygon(String polygon) {
this.polygon = polygon;
return this;
public void setMapsheet(String mapsheet) {
this.mapsheet = mapsheet;
}

/**
Expand All @@ -101,13 +96,13 @@ public String getPolygon() {
return polygon;
}

public void setPolygon(String polygon) {
this.polygon = polygon;
public Filters polygon(String polygon) {
setPolygon(polygon);
return this;
}

public Filters polygonId(String polygonId) {
this.polygonId = polygonId;
return this;
public void setPolygon(String polygon) {
this.polygon = polygon;
}

/**
Expand All @@ -120,6 +115,11 @@ public String getPolygonId() {
return polygonId;
}

public Filters polygonId(String polygonId) {
setPolygonId(polygonId);
return this;
}

public void setPolygonId(String polygonId) {
this.polygonId = polygonId;
}
Expand All @@ -146,7 +146,6 @@ public int hashCode() {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Filters {\n");

sb.append(" maintainer: ").append(toIndentedString(maintainer)).append("\n");
sb.append(" mapsheet: ").append(toIndentedString(mapsheet)).append("\n");
sb.append(" polygon: ").append(toIndentedString(polygon)).append("\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ public class Parameters {

public static final String JSON_PROPERTY_FILTERS = "filters";
@JsonProperty(JSON_PROPERTY_FILTERS)
// protected because this parameter requires no validation and therefore isn't in ValidatedParameters.
// This is the only such parameter
protected Filters filters;
public Filters filters;

public static final String JSON_PROPERTY_UTILS = "utils";
@JsonProperty(JSON_PROPERTY_UTILS)
Expand Down Expand Up @@ -375,15 +373,6 @@ public List<String> getSelectedExecutionOptions() {
return selectedExecutionOptions;
}

public void setSelectedExecutionOptions(List<ExecutionOption> selectedExecutionOptions) {
if (selectedExecutionOptions == null) {
this.selectedExecutionOptions.clear();
} else {
this.selectedExecutionOptions = new ArrayList<String>();
selectedExecutionOptions.stream().forEach(o -> this.selectedExecutionOptions.add(o.getValue()));
}
}

public Parameters selectedExecutionOptions(List<ExecutionOption> selectedExecutionOptions) {
setSelectedExecutionOptions(selectedExecutionOptions);
return this;
Expand All @@ -394,6 +383,15 @@ public Parameters addSelectedExecutionOptionsItem(ExecutionOption selectedExecut
return this;
}

public void setSelectedExecutionOptions(List<ExecutionOption> selectedExecutionOptions) {
if (selectedExecutionOptions == null) {
this.selectedExecutionOptions.clear();
} else {
this.selectedExecutionOptions = new ArrayList<String>();
selectedExecutionOptions.stream().forEach(o -> this.selectedExecutionOptions.add(o.getValue()));
}
}

public Parameters addSelectedExecutionOptionsItem(String selectedExecutionOptionsItemText) {
if (selectedExecutionOptionsItemText != null) {
this.selectedExecutionOptions.add(selectedExecutionOptionsItemText);
Expand Down Expand Up @@ -426,12 +424,15 @@ public Parameters selectedDebugOptions(List<DebugOption> selectedDebugOptions) {
}

public Parameters addSelectedDebugOptionsItem(DebugOption selectedDebugOptionsItem) {
if (selectedDebugOptions == null) {
selectedDebugOptions = new ArrayList<>();
}
this.selectedDebugOptions.add(selectedDebugOptionsItem.getValue());
return this;
}

public Parameters addSelectedDebugOptionsItem(String selectedDebugOptionsItemText) {
if (selectedDebugOptionsItemText != null) {
if (selectedDebugOptionsItemText != null) {
this.selectedDebugOptions.add(selectedDebugOptionsItemText);
}
return this;
Expand Down Expand Up @@ -632,7 +633,7 @@ public Parameters combineAgeYearRange(String combineAgeYearRangeText) {
public void setCombineAgeYearRange(String combineAgeYearRangeText) {
this.combineAgeYearRange = combineAgeYearRangeText;
}

/**
* Get progressFrequency
*
Expand Down Expand Up @@ -715,12 +716,12 @@ public Filters getFilters() {
}

public Parameters filters(Filters filters) {
this.filters = filters;
setFilters(filters);
return this;
}

public void setFilters(Filters filters) {
this.filters = filters;
this.filters = filters == null ? null : filters.copy();
}

/**
Expand All @@ -740,7 +741,8 @@ public Parameters utils(List<ValidatedUtilizationParameter> utils) {

public Parameters addUtilsItem(ValidatedUtilizationParameter utilsItem) {
this.utils.add(
new UtilizationParameter().speciesName(utilsItem.getSpeciesName()).utilizationClass(utilsItem.getUtilizationClass().getValue())
new UtilizationParameter().speciesName(utilsItem.getSpeciesName())
.utilizationClass(utilsItem.getUtilizationClass().getValue())
);
return this;
}
Expand All @@ -750,13 +752,12 @@ public void setUtils(List<ValidatedUtilizationParameter> utils) {
this.utils = null;
} else {
this.utils = new ArrayList<>();
utils.stream()
.forEach(
u -> this.utils.add(
new UtilizationParameter().speciesName(u.getSpeciesName())
.utilizationClass(u.getUtilizationClass().getValue())
)
);
utils.stream().forEach(
u -> this.utils.add(
new UtilizationParameter().speciesName(u.getSpeciesName())
.utilizationClass(u.getUtilizationClass().getValue())
)
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public enum FrequencyKind {
public String toString() {
return getValue();
}

@JsonValue
public String getValue() {
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@
/**
* This class records a utilization class for a given sp0 (species group) name.
*/
@JsonPropertyOrder({ UtilizationParameter.JSON_PROPERTY_SPECIES_NAME, UtilizationParameter.JSON_PROPERTY_VALUE })
@JsonPropertyOrder(
{ UtilizationParameter.JSON_PROPERTY_SPECIES_NAME, UtilizationParameter.JSON_PROPERTY_UTILIZATION_CLASS }
)
@RegisterForReflection
public class UtilizationParameter {
public static final String JSON_PROPERTY_SPECIES_NAME = "speciesName";
@JsonProperty(JSON_PROPERTY_SPECIES_NAME)
private String speciesName;

public static final String JSON_PROPERTY_VALUE = "value";
@JsonProperty(JSON_PROPERTY_VALUE)
public static final String JSON_PROPERTY_UTILIZATION_CLASS = "utilizationClass";
@JsonProperty(JSON_PROPERTY_UTILIZATION_CLASS)
private String utilizationClass;

/**
Expand Down Expand Up @@ -61,7 +63,7 @@ public enum UtilizationClass {
public String toString() {
return getValue();
}

@JsonValue
public String getValue() {
return value;
Expand All @@ -78,22 +80,21 @@ public static UtilizationClass fromValue(String value) {
}
}

public UtilizationParameter speciesName(String speciesName) {
this.speciesName = speciesName;
return this;
}

/**
* Get speciesName
*
* @return speciesName
**/
@JsonProperty(value = "speciesName")

@JsonProperty(value = JSON_PROPERTY_SPECIES_NAME)
public String getSpeciesName() {
return speciesName;
}

public UtilizationParameter speciesName(String speciesName) {
setSpeciesName(speciesName);
return this;
}

public void setSpeciesName(String speciesName) {
this.speciesName = speciesName;
}
Expand All @@ -103,7 +104,7 @@ public void setSpeciesName(String speciesName) {
*
* @return value
**/
@JsonProperty(value = "utilizationClass")
@JsonProperty(value = JSON_PROPERTY_UTILIZATION_CLASS)
public String getUtilizationClass() {
return utilizationClass;
}
Expand Down Expand Up @@ -135,7 +136,8 @@ public boolean equals(Object o) {
return false;
}
UtilizationParameter up = (UtilizationParameter) o;
return Objects.equals(this.speciesName, up.speciesName) && Objects.equals(this.utilizationClass, up.utilizationClass);
return Objects.equals(this.speciesName, up.speciesName)
&& Objects.equals(this.utilizationClass, up.utilizationClass);
}

@Override
Expand All @@ -149,7 +151,7 @@ public String toString() {
sb.append("class ");
sb.append(UtilizationParameter.class.getSimpleName());
sb.append(" {\n speciesName: ").append(toIndentedString(speciesName)).append("\n");
sb.append(" value: ").append(toIndentedString(utilizationClass)).append("\n");
sb.append(" utilizationClass: ").append(toIndentedString(utilizationClass)).append("\n");
sb.append("}");
return sb.toString();
}
Expand Down
Loading

0 comments on commit 40c64e9

Please sign in to comment.