Skip to content

Commit

Permalink
Fix json visibility only for definition
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasponce authored and jshaughn committed Mar 13, 2015
1 parent c70d11f commit a5ef67b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public enum Mode {
@JsonInclude
private boolean safetyEnabled;

@JsonInclude
@JsonIgnore
private Mode mode;

@JsonIgnore
Expand Down Expand Up @@ -89,6 +89,7 @@ public void setId(String id) {
this.id = id;
}

@JsonIgnore
public Mode getMode() {
return mode;
}
Expand Down Expand Up @@ -153,7 +154,14 @@ public boolean equals(Object obj) {

@Override
public String toString() {
return "Trigger [id=" + id + ", enabled=" + enabled + ", mode=" + mode + ", match=" + getMatch() + "]";
return "Trigger [id=" + id + ", " +
"name=" + getName() + ", " +
"description=" + getDescription() + ", " +
"firingMatch=" + getFiringMatch() + ", " +
"safetyMatch=" + getSafetyMatch() + ", " +
"enabled=" + enabled + ", " +
"mode=" + mode + ", " +
"match=" + getMatch() + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.HashSet;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

Expand Down Expand Up @@ -78,7 +77,6 @@ public void setDescription(String description) {
this.description = description;
}

@JsonIgnore
public Match getFiringMatch() {
return firingMatch;
}
Expand All @@ -87,7 +85,6 @@ public void setFiringMatch(Match firingMatch) {
this.firingMatch = firingMatch;
}

@JsonIgnore
public Match getSafetyMatch() {
return safetyMatch;
}
Expand Down Expand Up @@ -127,8 +124,10 @@ public void removeAction(String actionId) {

@Override
public String toString() {
return "TriggerTemplate [name=" + name + ", description=" + description + ", firingMatch=" + firingMatch
+ ", safetyMatch=" + safetyMatch + "]";
return "TriggerTemplate [name=" + name + ", " +
"description=" + description + ", " +
"firingMatch=" + firingMatch + ", " +
"safetyMatch=" + safetyMatch + "]";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,7 @@ public void jsonTriggerTest() throws Exception {
"\"safetyMatch\":\"ALL\"," +
"\"id\":\"test\"," +
"\"enabled\":true," +
"\"safetyEnabled\":true," +
"\"mode\":\"FIRE\"}";
"\"safetyEnabled\":true}";
Trigger trigger = objectMapper.readValue(str, Trigger.class);

assert trigger.getName().equals("test-name");
Expand All @@ -722,12 +721,10 @@ public void jsonTriggerTest() throws Exception {
assert trigger.getId().equals("test");
assert trigger.isEnabled() == true;
assert trigger.isSafetyEnabled() == true;
assert trigger.getMode().equals(Mode.FIRE);

String output = objectMapper.writeValueAsString(trigger);

assert !output.contains("firingMatch");
assert !output.contains("safetyMatch");
assert !output.contains("mode");
assert !output.contains("match");
}

Expand Down

0 comments on commit a5ef67b

Please sign in to comment.