Skip to content

Commit 382070e

Browse files
authored
Merge pull request #77 from Genability/GEN-5150/addPrivateTouGroupWorksCorrectly
fix intermittent TOU test failure
2 parents 949ac93 + 02c72c9 commit 382070e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/test/java/com/genability/client/api/service/TimeOfUseServiceTests.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ public void addPrivateTouGroupWorksCorrectly() {
154154
Response<TimeOfUseGroup> response = touService.addPrivateTimeOfUseGroup(grp);
155155
assertEquals("Didn't successfully add the private TOU", Response.STATUS_SUCCESS, response.getStatus());
156156

157-
cleanUpPrivateTou(response.getResults().get(0));
157+
TimeOfUseGroup addedGroup = response.getResults().get(0);
158+
159+
// Make sure the returned group has a proper ID that we can use for deletion
160+
assertNotNull("The returned TOU group should have a touGroupId", addedGroup.getTouGroupId());
161+
cleanUpPrivateTou(addedGroup);
158162
}
159163

160164

@@ -223,12 +227,17 @@ private void cleanUpPrivateTou(TimeOfUseGroup grp) {
223227
private TimeOfUseGroup getValidTouGroup() {
224228
TimeOfUseGroup group = new TimeOfUseGroup();
225229
group.setTimeOfUses(new ArrayList<TimeOfUse>());
226-
group.setLseId(734L);
230+
group.setLseId(734L);
231+
// Explicitly set the touGroupId to null so the server assigns a new one
232+
group.setTouGroupId(null);
227233

228234
TimeOfUse tou = new TimeOfUse();
229235
tou.setTouName("JAVA CLIENT LIB TOU");
230236
tou.setTouPeriods(new ArrayList<TimeOfUsePeriod>());
231-
tou.setTouType(String.valueOf(TimeOfUseType.OFF_PEAK));
237+
tou.setTouType(String.valueOf(TimeOfUseType.OFF_PEAK));
238+
// Make sure we don't have a conflicting ID
239+
tou.setTouId(null);
240+
tou.setTouGroupId(null);
232241
group.getTimeOfUses().add(tou);
233242

234243
TimeOfUsePeriod period = new TimeOfUsePeriod();
@@ -237,7 +246,10 @@ private TimeOfUseGroup getValidTouGroup() {
237246
period.setFromHour(0);
238247
period.setToHour(0);
239248
period.setFromMinute(0);
240-
period.setToMinute(0);
249+
period.setToMinute(0);
250+
// Make sure we don't have a conflicting ID
251+
period.setTouPeriodId(null);
252+
period.setTouId(null);
241253
tou.getTouPeriods().add(period);
242254

243255
return group;

0 commit comments

Comments
 (0)