Skip to content

Commit

Permalink
Add in(Input<?>) in InputValidationIssue for a fluent single input se…
Browse files Browse the repository at this point in the history
…tter (#141)

Fixes #140

---------

Co-authored-by: Jimmy Praet <jimmy.praet@ksz-bcss.fgov.be>
  • Loading branch information
jflabatBCSS and jpraet authored Nov 19, 2024
1 parent 8fc48cb commit f205722
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,14 @@ public InputValidationIssue in(InEnum in, String name, Object value) {
return in(in).name(name).value(value);
}

public InputValidationIssue in(Input<?> input) {
if (input != null) {
return in(input.getIn(), input.getName(), input.getValue());
} else {
return this;
}
}

public InputValidationIssue in(InEnum in) {
setIn(in);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,29 @@ void in() {

issue.setIn(null);
assertThat(issue.getIn()).isNull();
issue.in(null);
issue.in((InEnum) null);
assertThat(issue.getIn()).isNull();

issue.setIn(InEnum.QUERY);
assertThat(issue.getIn()).isEqualTo(InEnum.QUERY);
assertThat(new InputValidationIssue().in(InEnum.QUERY).getIn()).isEqualTo(InEnum.QUERY);
}

@Test
void inInput() {
InputValidationIssue issue = new InputValidationIssue();

issue.in((Input<?>) null);
assertThat(issue.getIn()).isNull();
assertThat(issue.getName()).isNull();
assertThat(issue.getValue()).isNull();

issue = issue.in(Input.query("name", "value"));
assertThat(issue.getIn()).isEqualTo(InEnum.QUERY);
assertThat(issue.getName()).isEqualTo("name");
assertThat(issue.getValue()).isEqualTo("value");
}

@Test
void name() {
InputValidationIssue issue = new InputValidationIssue();
Expand Down
6 changes: 6 additions & 0 deletions src/main/asciidoc/release-notes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

// tag::recent-versions[]

== Version 0.11

*belgif-rest-problem:*

* Add in(Input<?>) in InputValidationIssue for a fluent single input setter

== Version 0.10

*belgif-rest-problem:*
Expand Down

0 comments on commit f205722

Please sign in to comment.