Skip to content

Commit

Permalink
Fixes #653, added bean validation to the rest data objects
Browse files Browse the repository at this point in the history
Upgrade openapi-generator-maven-plugin due to bug in generating Typescript client. Removed @NotNull checks until we can fix workflow in UI
  • Loading branch information
stalep authored and jesperpedersen committed Sep 19, 2023
1 parent d8fc5f6 commit 274e0e5
Show file tree
Hide file tree
Showing 52 changed files with 253 additions and 110 deletions.
2 changes: 1 addition & 1 deletion horreum-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>6.0.0</version>
<version>7.0.1</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import io.hyperfoil.tools.horreum.api.data.DataSet;

import jakarta.validation.constraints.NotNull;
import java.time.Instant;

public class Change {
@JsonProperty( required = true )
public int id;
@NotNull
@JsonProperty( required = true )
public Variable variable;
@JsonIgnore
public DataSet dataset;
@NotNull
@JsonProperty( required = true )
public Instant timestamp;
@NotNull
@JsonProperty( required = true )
public boolean confirmed;
public String description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.validation.constraints.NotNull;

public class ChangeDetection {
@JsonProperty( required = true )
public Integer id;
@JsonProperty( required = true )
public String model;
@NotNull
@JsonProperty( required = true )
public JsonNode config;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import io.hyperfoil.tools.horreum.api.data.DataSet;
import jakarta.validation.constraints.NotNull;

import java.time.Instant;

public class DataPoint {
public Integer id;
@NotNull
public Instant timestamp;
@NotNull
public double value;
@NotNull
public Variable variable;

@NotNull
@JsonProperty("datasetId")
public Integer datasetId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import io.hyperfoil.tools.horreum.api.data.PersistentLog;
import jakarta.validation.constraints.NotNull;

public class DatasetLog extends PersistentLog {
@NotNull
@JsonProperty( required = true )
public String source;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.node.ArrayNode;
import jakarta.validation.constraints.NotNull;

import java.time.Instant;
import java.util.Objects;
Expand All @@ -12,6 +13,7 @@ public class MissingDataRule {
public String name;
public ArrayNode labels;
public String condition;
@NotNull
@JsonProperty( required = true )
public long maxStaleness;
public Instant lastNotification;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package io.hyperfoil.tools.horreum.api.alerting;

import jakarta.validation.constraints.NotNull;

import java.time.Instant;
import java.io.Serializable;
import java.util.Objects;

public class MissingDataRuleResult {
private Pk pk;
@NotNull
public Instant timestamp;
public MissingDataRule rule;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package io.hyperfoil.tools.horreum.api.alerting;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;

public class NotificationSettings {
public Integer id;
@NotNull
@JsonProperty( required = true )
public String name;
@JsonProperty( required = true )
public boolean isTeam;
@NotNull
@JsonProperty( required = true )
public String method;
public String data;
@NotNull
@JsonProperty( required = true )
public boolean disabled;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package io.hyperfoil.tools.horreum.api.alerting;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;

import java.time.Instant;

public class RunExpectation {
public Long id;
@NotNull
@JsonProperty(required = true)
public int testId;
@NotNull
@JsonProperty(required = true)
public Instant expectedBefore;
public String expectedBy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,25 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.validation.constraints.NotNull;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

import java.util.Set;

public class Variable {
@JsonProperty( required = true )
public Integer id;
@NotNull
@JsonProperty(required = true)
public int testId;
@NotNull
@JsonProperty(required = true)
public String name;
public String group;
@NotNull
@JsonProperty(required = true)
public int order;
@NotNull
@JsonProperty(required = true)
public JsonNode labels;
@JsonInclude(JsonInclude.Include.NON_NULL)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package io.hyperfoil.tools.horreum.api.alerting;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;

import java.util.List;

public class Watch {
public Integer id;
@NotNull
@JsonProperty( required = true )
public List<String> users;
@NotNull
@JsonProperty( required = true )
public List<String> optout;
@NotNull
@JsonProperty( required = true )
public List<String> teams;
@JsonProperty( value = "testId", required = true )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,30 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import jakarta.validation.constraints.NotNull;

public class Action {
@JsonProperty( required = true )
public Integer id;
@NotNull
@JsonProperty( required = true )
public String event;
@NotNull
@JsonProperty( required = true )
public String type;
@NotNull
@JsonProperty( required = true )
public JsonNode config;
@NotNull
@JsonIgnore
public JsonNode secrets;
@NotNull
@JsonProperty( required = true )
public Integer testId;
@NotNull
@JsonProperty( required = true )
public boolean active = true;
@NotNull
@JsonProperty( required = true )
public boolean runAlways;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package io.hyperfoil.tools.horreum.api.data;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;

public class ActionLog extends PersistentLog {
@NotNull
@JsonProperty( required = true )
public int testId;
@NotNull
@JsonProperty( required = true )
public String event;
public String type;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.hyperfoil.tools.horreum.api.data;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;

public class AllowedSite {

public Long id;
@NotNull
@JsonProperty(required = true)
public String prefix;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.hyperfoil.tools.horreum.api.data;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;

import java.time.Instant;

public class Banner {
Expand All @@ -9,11 +11,14 @@ public class Banner {

public Instant created;

@NotNull
@JsonProperty( required = true )
public boolean active;
@NotNull
@JsonProperty(required = true)
public String severity;

@NotNull
@JsonProperty(required = true)
public String title;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.validation.constraints.NotNull;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

import java.time.Instant;
Expand All @@ -11,16 +12,23 @@

public class DataSet {
public Integer id;
@NotNull
public Instant start;
@NotNull
public Instant stop;
public String description;

@NotNull
public Integer testid;
@NotNull
@JsonProperty( required = true )
public String owner;
@NotNull
@JsonProperty( required = true )
public Access access;
@NotNull
public JsonNode data;
@NotNull
public int ordinal;

public Collection<ValidationError> validationErrors;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.validation.constraints.NotNull;

public class ExperimentComparison {

@NotNull
@JsonProperty( required = true )
public String model;
@NotNull
@JsonProperty( required = true )
public JsonNode config;

@NotNull
@JsonProperty(value = "variableId")
public Integer variableId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import jakarta.validation.constraints.NotNull;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

import java.util.Collection;

public class ExperimentProfile {
@JsonProperty(required = true )
public Integer id;
@NotNull
public String name;

//@NotNull - we can not enforce this check until we have clean workflows in the UI
// atm it is possible to have a new test in the UI and create an experiment profile
// before the test is saved, therefore the test might not have an ID
public Integer testId;
@Schema(implementation = String[].class, required = true )
public JsonNode selectorLabels;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package io.hyperfoil.tools.horreum.api.data;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotNull;

public class Extractor {
@NotNull
@JsonProperty( required = true )
public String name;
@NotNull
@JsonProperty( required = true )
public String jsonpath;
@NotNull
@JsonProperty(required = true)
public boolean array;

Expand Down
Loading

0 comments on commit 274e0e5

Please sign in to comment.