Skip to content

Commit 4bbb8ee

Browse files
committed
hand-rename "RATING" from bad codegen
1 parent 07f8db9 commit 4bbb8ee

4 files changed

Lines changed: 43 additions & 21 deletions

File tree

cwms-data-api-client/src/test/java/mil/army/usace/hec/cwms/data/api/client/controllers/TestLevelController.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import java.util.Set;
4040
import mil.army.usace.hec.cwms.data.api.client.model.ConstantLocationLevel;
4141
import mil.army.usace.hec.cwms.data.api.client.model.LocationLevel;
42+
import mil.army.usace.hec.cwms.data.api.client.model.LocationLevelConstituent;
4243
import mil.army.usace.hec.cwms.data.api.client.model.LocationLevels;
4344
import mil.army.usace.hec.cwms.data.api.client.model.RadarObjectMapper;
4445
import mil.army.usace.hec.cwms.data.api.client.model.SeasonalLocationLevel;
@@ -147,6 +148,25 @@ void testRetrieveLocationLevelSubtypes() throws IOException {
147148
.anyMatch(l -> l instanceof SeasonalLocationLevel));
148149
}
149150

151+
@Test
152+
void testRetrieveVirtualLevel() throws IOException {
153+
String resource = "radar/v2/json/location_levels.json";
154+
String collect = readJsonFile(resource);
155+
mockHttpServer.enqueue(collect);
156+
mockHttpServer.start();
157+
LocationLevelEndpointInput.GetAll input = LocationLevelEndpointInput.getAll()
158+
.officeId("LRL");
159+
LocationLevels locationLevels = new LevelController().retrieveLocationLevels(buildConnectionInfo(), input);
160+
VirtualLocationLevel virtualLevel = (VirtualLocationLevel) locationLevels.getLevels().stream()
161+
.filter(l -> l instanceof VirtualLocationLevel)
162+
.findAny()
163+
.get();
164+
assertTrue(virtualLevel.getConstituents().stream()
165+
.anyMatch(l -> !(l instanceof LocationLevelConstituent)));
166+
assertTrue(virtualLevel.getConstituents().stream()
167+
.anyMatch(l -> l instanceof LocationLevelConstituent));
168+
}
169+
150170
@Test
151171
void testRetrieveLocationLevel() throws IOException {
152172
String resource = "radar/v2/json/location_level.json";

cwms-data-api-model/src/main/java/mil/army/usace/hec/cwms/data/api/client/model/LocationLevelConstituent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
*/
3434
@JsonIgnoreProperties(ignoreUnknown = true)
3535
@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2025-11-17T16:46:44.562396200-08:00[America/Los_Angeles]")
36-
public class LocationLevelConstituent extends RATING {
36+
public class LocationLevelConstituent extends RatingConstituent {
3737

3838
@JsonProperty("attribute-id")
3939
private String attributeId = null;

cwms-data-api-model/src/main/java/mil/army/usace/hec/cwms/data/api/client/model/RATING.java renamed to cwms-data-api-model/src/main/java/mil/army/usace/hec/cwms/data/api/client/model/RatingConstituent.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", visible = true)
4242
@JsonSubTypes({
4343
@JsonSubTypes.Type(value = LocationLevelConstituent.class, name = "LOCATION_LEVEL"),
44-
@JsonSubTypes.Type(value = RATING.class, name = "RATING")
44+
@JsonSubTypes.Type(value = RatingConstituent.class, name = "RATING")
4545
})
46-
public class RATING {
46+
public class RatingConstituent {
4747

4848
@JsonProperty("abbr")
4949
private String abbr = null;
@@ -58,7 +58,7 @@ public class RATING {
5858
@Valid
5959
private List<String> constituentList = new ArrayList<>();
6060

61-
public RATING abbr(String abbr) {
61+
public RatingConstituent abbr(String abbr) {
6262
this.abbr = abbr;
6363
return this;
6464
}
@@ -71,7 +71,7 @@ public void setAbbr(String abbr) {
7171
this.abbr = abbr;
7272
}
7373

74-
public RATING type(String type) {
74+
public RatingConstituent type(String type) {
7575
this.type = type;
7676
return this;
7777
}
@@ -84,7 +84,7 @@ public void setType(String type) {
8484
this.type = type;
8585
}
8686

87-
public RATING name(String name) {
87+
public RatingConstituent name(String name) {
8888
this.name = name;
8989
return this;
9090
}
@@ -97,12 +97,12 @@ public void setName(String name) {
9797
this.name = name;
9898
}
9999

100-
public RATING constituentList(List<String> constituentList) {
100+
public RatingConstituent constituentList(List<String> constituentList) {
101101
this.constituentList = constituentList;
102102
return this;
103103
}
104104

105-
public RATING addConstituentListItem(String constituentListItem) {
105+
public RatingConstituent addConstituentListItem(String constituentListItem) {
106106
if (this.constituentList == null) {
107107
this.constituentList = new ArrayList<>();
108108
}
@@ -126,14 +126,16 @@ public boolean equals(Object o) {
126126
if (o == null || getClass() != o.getClass()) {
127127
return false;
128128
}
129-
RATING RATING = (RATING) o;
130-
return this.abbr == null || RATING.abbr == null ? Objects.equals(this.abbr, RATING.abbr) :
131-
this.abbr.equalsIgnoreCase(RATING.abbr)
132-
&& this.type == null || RATING.type == null ? Objects.equals(this.type, RATING.type) :
133-
this.type.equalsIgnoreCase(RATING.type)
134-
&& this.name == null || RATING.name == null ? Objects.equals(this.name, RATING.name) :
135-
this.name.equalsIgnoreCase(RATING.name)
136-
&& Objects.equals(this.constituentList, RATING.constituentList)
129+
RatingConstituent ratingConstituent = (RatingConstituent) o;
130+
return this.abbr == null || ratingConstituent.abbr == null ? Objects.equals(this.abbr, ratingConstituent.abbr) :
131+
this.abbr.equalsIgnoreCase(ratingConstituent.abbr)
132+
&& this.type == null || ratingConstituent.type == null ?
133+
Objects.equals(this.type, ratingConstituent.type) :
134+
this.type.equalsIgnoreCase(ratingConstituent.type)
135+
&& this.name == null || ratingConstituent.name == null ?
136+
Objects.equals(this.name, ratingConstituent.name) :
137+
this.name.equalsIgnoreCase(ratingConstituent.name)
138+
&& Objects.equals(this.constituentList, ratingConstituent.constituentList)
137139
;
138140
}
139141

cwms-data-api-model/src/main/java/mil/army/usace/hec/cwms/data/api/client/model/VirtualLocationLevel.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,29 @@ public class VirtualLocationLevel extends LocationLevel {
4242

4343
@JsonProperty("constituents")
4444
@Valid
45-
private List<RATING> constituents = new ArrayList<>();
45+
private List<RatingConstituent> constituents = new ArrayList<>();
4646

4747
@JsonProperty("constituent-connections")
4848
private String constituentConnections = null;
4949

50-
public VirtualLocationLevel constituents(List<RATING> constituents) {
50+
public VirtualLocationLevel constituents(List<RatingConstituent> constituents) {
5151
this.constituents = constituents;
5252
return this;
5353
}
5454

55-
public VirtualLocationLevel addConstituentsItem(RATING constituentsItem) {
55+
public VirtualLocationLevel addConstituentsItem(RatingConstituent constituentsItem) {
5656
if (this.constituents == null) {
5757
this.constituents = new ArrayList<>();
5858
}
5959
this.constituents.add(constituentsItem);
6060
return this;
6161
}
6262

63-
public List<RATING> getConstituents() {
63+
public List<RatingConstituent> getConstituents() {
6464
return constituents;
6565
}
6666

67-
public void setConstituents(List<RATING> constituents) {
67+
public void setConstituents(List<RatingConstituent> constituents) {
6868
this.constituents = constituents;
6969
}
7070

0 commit comments

Comments
 (0)