Skip to content

Commit a29de05

Browse files
committed
Add and update test cases
1 parent ee39b47 commit a29de05

31 files changed

+1419
-917
lines changed

src/main/java/com/relogiclabs/jschema/internal/builder/JPragmaBuilder.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import lombok.Setter;
1010
import lombok.experimental.Accessors;
1111

12-
import static com.relogiclabs.jschema.message.ErrorCode.PRGCHK01;
13-
import static com.relogiclabs.jschema.message.ErrorCode.PRGCHK02;
12+
import static com.relogiclabs.jschema.message.ErrorCode.PRGDEF01;
13+
import static com.relogiclabs.jschema.message.ErrorCode.PRGDEF02;
1414
import static com.relogiclabs.jschema.message.MessageFormatter.formatForSchema;
1515

1616
@Getter @Setter
@@ -22,10 +22,10 @@ public final class JPragmaBuilder extends JNodeBuilder<JPragmaBuilder> {
2222
private void checkPragma() {
2323
var descriptor = PragmaDescriptor.from(name);
2424
if (descriptor == null)
25-
throw new PragmaNotFoundException(formatForSchema(PRGCHK01, "Invalid pragma '"
25+
throw new PragmaNotFoundException(formatForSchema(PRGDEF01, "Invalid pragma '"
2626
+ name + "' with value " + value.getOutline() + " found", context()));
2727
if (!descriptor.matchType(value.getClass()))
28-
throw new InvalidPragmaValueException(formatForSchema(PRGCHK02, "Invalid value "
28+
throw new InvalidPragmaValueException(formatForSchema(PRGDEF02, "Invalid value "
2929
+ value.getOutline() + " for pragma '" + name + "' found", value));
3030
}
3131

src/main/java/com/relogiclabs/jschema/internal/library/LibraryFunctions2.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
import static com.relogiclabs.jschema.message.ErrorCode.FAILEX02;
3636
import static com.relogiclabs.jschema.message.ErrorCode.FAILEX03;
3737
import static com.relogiclabs.jschema.message.ErrorCode.FAILEX04;
38-
import static com.relogiclabs.jschema.message.ErrorCode.FAILMB01;
39-
import static com.relogiclabs.jschema.message.ErrorCode.FAILMB02;
40-
import static com.relogiclabs.jschema.message.ErrorCode.FAILMB03;
41-
import static com.relogiclabs.jschema.message.ErrorCode.FAILMB04;
38+
import static com.relogiclabs.jschema.message.ErrorCode.FAILMV01;
39+
import static com.relogiclabs.jschema.message.ErrorCode.FAILMV02;
40+
import static com.relogiclabs.jschema.message.ErrorCode.FAILMV03;
41+
import static com.relogiclabs.jschema.message.ErrorCode.FAILMV04;
4242
import static com.relogiclabs.jschema.message.MessageFormatter.formatForBoth;
4343
import static com.relogiclabs.jschema.type.EValue.VOID;
4444

@@ -113,26 +113,26 @@ static EValue failFunction4(ScriptScope scope, List<EValue> arguments) {
113113
try {
114114
expectedNode = castMember(expected, Node_Id, JNode.class);
115115
} catch(InvalidArgumentException e) {
116-
e.setContext(FAILMB01, Expected_Id);
116+
e.setContext(FAILMV01, Expected_Id);
117117
throw e.failWithFunctionException();
118118
}
119119
try {
120120
expectedMessage = castMember(expected, Message_Id, EString.class).getValue();
121121
} catch(InvalidArgumentException e) {
122-
e.setContext(FAILMB02, Expected_Id);
122+
e.setContext(FAILMV02, Expected_Id);
123123
throw e.failWithFunctionException();
124124
}
125125

126126
try {
127127
actualNode = castMember(actual, Node_Id, JNode.class);
128128
} catch(InvalidArgumentException e) {
129-
e.setContext(FAILMB03, Actual_Id);
129+
e.setContext(FAILMV03, Actual_Id);
130130
throw e.failWithFunctionException();
131131
}
132132
try {
133133
actualMessage = castMember(actual, Message_Id, EString.class).getValue();
134134
} catch(InvalidArgumentException e) {
135-
e.setContext(FAILMB04, Actual_Id);
135+
e.setContext(FAILMV04, Actual_Id);
136136
throw e.failWithFunctionException();
137137
}
138138
fail(scope, new FunctionValidationException(

src/main/java/com/relogiclabs/jschema/internal/time/DateTimeContext.java

+30-30
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,23 @@
1111
import java.util.HashMap;
1212
import java.util.Map;
1313

14-
import static com.relogiclabs.jschema.message.ErrorCode.AMPMVD01;
14+
import static com.relogiclabs.jschema.message.ErrorCode.AMPMMS01;
1515
import static com.relogiclabs.jschema.message.ErrorCode.CNFLDT01;
16-
import static com.relogiclabs.jschema.message.ErrorCode.DAYVDF01;
17-
import static com.relogiclabs.jschema.message.ErrorCode.DAYVDF02;
18-
import static com.relogiclabs.jschema.message.ErrorCode.ERAVDF01;
19-
import static com.relogiclabs.jschema.message.ErrorCode.HURVDF01;
20-
import static com.relogiclabs.jschema.message.ErrorCode.HURVDF02;
21-
import static com.relogiclabs.jschema.message.ErrorCode.HURVDF03;
22-
import static com.relogiclabs.jschema.message.ErrorCode.HURVDF04;
16+
import static com.relogiclabs.jschema.message.ErrorCode.DAYRNG01;
17+
import static com.relogiclabs.jschema.message.ErrorCode.DAYRNG02;
18+
import static com.relogiclabs.jschema.message.ErrorCode.ERANMS01;
19+
import static com.relogiclabs.jschema.message.ErrorCode.HURRNG01;
20+
import static com.relogiclabs.jschema.message.ErrorCode.HURRNG02;
21+
import static com.relogiclabs.jschema.message.ErrorCode.HURRNG03;
22+
import static com.relogiclabs.jschema.message.ErrorCode.HURRNG04;
2323
import static com.relogiclabs.jschema.message.ErrorCode.INVLDT02;
24-
import static com.relogiclabs.jschema.message.ErrorCode.MNTVDF01;
25-
import static com.relogiclabs.jschema.message.ErrorCode.MONVDF01;
26-
import static com.relogiclabs.jschema.message.ErrorCode.SECVDF01;
27-
import static com.relogiclabs.jschema.message.ErrorCode.UTCVDF01;
28-
import static com.relogiclabs.jschema.message.ErrorCode.UTCVDF02;
29-
import static com.relogiclabs.jschema.message.ErrorCode.WEKVDF01;
30-
import static com.relogiclabs.jschema.message.ErrorCode.YARVDF01;
24+
import static com.relogiclabs.jschema.message.ErrorCode.MNTRNG01;
25+
import static com.relogiclabs.jschema.message.ErrorCode.MONRNG01;
26+
import static com.relogiclabs.jschema.message.ErrorCode.SECRNG01;
27+
import static com.relogiclabs.jschema.message.ErrorCode.UTCRNG01;
28+
import static com.relogiclabs.jschema.message.ErrorCode.UTCRNG02;
29+
import static com.relogiclabs.jschema.message.ErrorCode.WEKDMS01;
30+
import static com.relogiclabs.jschema.message.ErrorCode.YARRNG01;
3131
import static com.relogiclabs.jschema.time.JsonDateTime.UNSET;
3232
import static java.time.DayOfWeek.FRIDAY;
3333
import static java.time.DayOfWeek.MONDAY;
@@ -105,13 +105,13 @@ public void setEra(String era) {
105105
var eraNum = switch(era.toUpperCase()) {
106106
case "BC" -> 1;
107107
case "AD" -> 2;
108-
default -> throw failOnInvalidDateTime(ERAVDF01, "era input");
108+
default -> throw failOnInvalidDateTime(ERANMS01, "era input");
109109
};
110110
this.era = checkField(this.era, eraNum);
111111
}
112112

113113
public void setYear(int year, int digitNum) {
114-
if(year < 1 || year > 9999) throw failOnInvalidDateTime(YARVDF01, "year out of range");
114+
if(year < 1 || year > 9999) throw failOnInvalidDateTime(YARRNG01, "year out of range");
115115
year = digitNum <= 2 ? toFourDigitYear(year) : year;
116116
this.year = checkField(this.year, year);
117117
}
@@ -122,7 +122,7 @@ public void setMonth(String month) {
122122
}
123123

124124
public void setMonth(int month) {
125-
if(month < 1 || month > 12) throw failOnInvalidDateTime(MONVDF01, "month out of range");
125+
if(month < 1 || month > 12) throw failOnInvalidDateTime(MONRNG01, "month out of range");
126126
this.month = checkField(this.month, month);
127127
}
128128

@@ -132,36 +132,36 @@ public void setWeekday(String weekday) {
132132
}
133133

134134
public void setDay(int day) {
135-
if(day < 1 || day > 31) throw failOnInvalidDateTime(DAYVDF01, "day out of range");
135+
if(day < 1 || day > 31) throw failOnInvalidDateTime(DAYRNG01, "day out of range");
136136
this.day = checkField(this.day, day);
137137
}
138138

139139
public void setAmPm(String amPm) {
140140
var amPmNum = switch(amPm.toLowerCase()) {
141141
case "am" -> 1;
142142
case "pm" -> 2;
143-
default -> throw failOnInvalidDateTime(AMPMVD01, "hour AM/PM input");
143+
default -> throw failOnInvalidDateTime(AMPMMS01, "hour AM/PM input");
144144
};
145145
if(hour != UNSET && (hour < 1 || hour > 12))
146-
throw failOnInvalidDateTime(HURVDF01, "hour out of range for AM/PM");
146+
throw failOnInvalidDateTime(HURRNG01, "hour out of range for AM/PM");
147147
this.amPm = checkField(this.amPm, amPmNum);
148148
}
149149

150150
public void setHour(int hour) {
151151
if(amPm != UNSET && (this.hour < 1 || this.hour > 12))
152-
throw failOnInvalidDateTime(HURVDF02, "hour out of range for AM/PM");
152+
throw failOnInvalidDateTime(HURRNG02, "hour out of range for AM/PM");
153153
if(hour < 0 || hour > 23)
154-
throw failOnInvalidDateTime(HURVDF03, "hour out of range");
154+
throw failOnInvalidDateTime(HURRNG03, "hour out of range");
155155
this.hour = checkField(this.hour, hour);
156156
}
157157

158158
public void setMinute(int minute) {
159-
if(minute < 0 || minute > 59) throw failOnInvalidDateTime(MNTVDF01, "minute out of range");
159+
if(minute < 0 || minute > 59) throw failOnInvalidDateTime(MNTRNG01, "minute out of range");
160160
this.minute = checkField(this.minute, minute);
161161
}
162162

163163
public void setSecond(int second) {
164-
if(second < 0 || second > 59) throw failOnInvalidDateTime(SECVDF01, "second out of range");
164+
if(second < 0 || second > 59) throw failOnInvalidDateTime(SECRNG01, "second out of range");
165165
this.second = checkField(this.second, second);
166166
}
167167

@@ -170,9 +170,9 @@ public void setFraction(int fraction) {
170170
}
171171

172172
public void setUtcOffset(int hour, int minute) {
173-
if(hour < -12 || hour > 12) throw failOnInvalidDateTime(UTCVDF01,
173+
if(hour < -12 || hour > 12) throw failOnInvalidDateTime(UTCRNG01,
174174
"UTC offset hour out of range");
175-
if(minute < 0 || minute > 59) throw failOnInvalidDateTime(UTCVDF02,
175+
if(minute < 0 || minute > 59) throw failOnInvalidDateTime(UTCRNG02,
176176
"UTC offset minute out of range");
177177
utcHour = checkField(utcHour, hour);
178178
utcMinute = checkField(utcMinute, minute);
@@ -194,14 +194,14 @@ public JsonDateTime validate() {
194194
if(isAllSet(year, month, day)) {
195195
DAYS_IN_MONTH[2] = isLeapYear(year)? 29 : 28;
196196
if(day < 1 || day > DAYS_IN_MONTH[month])
197-
throw failOnInvalidDateTime(DAYVDF02, "day out of range");
197+
throw failOnInvalidDateTime(DAYRNG02, "day out of range");
198198
dateTime = new JsonDateTime(type, year, month, day);
199199
if(weekday != UNSET && dateTime.getDayOfWeek().getValue() != weekday)
200-
throw failOnInvalidDateTime(WEKVDF01, "weekday not matched");
200+
throw failOnInvalidDateTime(WEKDMS01, "weekday not matched");
201201
}
202202
if(isAllSet(hour, amPm)) convertTo24Hour();
203203
if(hour != UNSET && (hour < 0 || hour > 23))
204-
throw failOnInvalidDateTime(HURVDF04, "hour out of range");
204+
throw failOnInvalidDateTime(HURRNG04, "hour out of range");
205205
return new JsonDateTime(type, year, month, day, hour, minute, second,
206206
fraction, new JsonUtcOffset(utcHour, utcMinute));
207207
} catch(InvalidDateTimeException e) {

src/main/java/com/relogiclabs/jschema/message/ErrorCode.java

+21-21
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public interface ErrorCode {
1414
String ALSDEF03 = "ALSDEF03";
1515
String ALSDUP01 = "ALSDUP01";
1616
String AMPMDT01 = "AMPMDT01";
17-
String AMPMVD01 = "AMPMVD01";
17+
String AMPMMS01 = "AMPMMS01";
1818
String ARNSRT01 = "ARNSRT01";
1919
String ARNSRT02 = "ARNSRT02";
2020
String ARRASN01 = "ARRASN01";
@@ -53,8 +53,8 @@ public interface ErrorCode {
5353
String CNFLDT01 = "CNFLDT01";
5454
String DAYNUM01 = "DAYNUM01";
5555
String DAYNUM02 = "DAYNUM02";
56-
String DAYVDF01 = "DAYVDF01";
57-
String DAYVDF02 = "DAYVDF02";
56+
String DAYRNG01 = "DAYRNG01";
57+
String DAYRNG02 = "DAYRNG02";
5858
String DECPRE01 = "DECPRE01";
5959
String DECPRE02 = "DECPRE02";
6060
String DECPRE03 = "DECPRE03";
@@ -82,7 +82,7 @@ public interface ErrorCode {
8282
String ENMNUM01 = "ENMNUM01";
8383
String ENMSTR01 = "ENMSTR01";
8484
String ERANAM01 = "ERANAM01";
85-
String ERAVDF01 = "ERAVDF01";
85+
String ERANMS01 = "ERANMS01";
8686
String EXPRSE01 = "EXPRSE01";
8787
String EXPRSE02 = "EXPRSE02";
8888
String EXPTSF01 = "EXPTSF01";
@@ -96,10 +96,10 @@ public interface ErrorCode {
9696
String FAILEX02 = "FAILEX02";
9797
String FAILEX03 = "FAILEX03";
9898
String FAILEX04 = "FAILEX04";
99-
String FAILMB01 = "FAILMB01";
100-
String FAILMB02 = "FAILMB02";
101-
String FAILMB03 = "FAILMB03";
102-
String FAILMB04 = "FAILMB04";
99+
String FAILMV01 = "FAILMV01";
100+
String FAILMV02 = "FAILMV02";
101+
String FAILMV03 = "FAILMV03";
102+
String FAILMV04 = "FAILMV04";
103103
String FILARR01 = "FILARR01";
104104
String FLOTVL01 = "FLOTVL01";
105105
String FNCDEF01 = "FNCDEF01";
@@ -134,10 +134,10 @@ public interface ErrorCode {
134134
String FRACDT07 = "FRACDT07";
135135
String HURNUM01 = "HURNUM01";
136136
String HURNUM02 = "HURNUM02";
137-
String HURVDF01 = "HURVDF01";
138-
String HURVDF02 = "HURVDF02";
139-
String HURVDF03 = "HURVDF03";
140-
String HURVDF04 = "HURVDF04";
137+
String HURRNG01 = "HURRNG01";
138+
String HURRNG02 = "HURRNG02";
139+
String HURRNG03 = "HURRNG03";
140+
String HURRNG04 = "HURRNG04";
141141
String IDXASN01 = "IDXASN01";
142142
String IDXUPD01 = "IDXUPD01";
143143
String IFSTMT01 = "IFSTMT01";
@@ -191,15 +191,15 @@ public interface ErrorCode {
191191
String MINICF03 = "MINICF03";
192192
String MNTNUM01 = "MNTNUM01";
193193
String MNTNUM02 = "MNTNUM02";
194-
String MNTVDF01 = "MNTVDF01";
194+
String MNTRNG01 = "MNTRNG01";
195195
String MODASN01 = "MODASN01";
196196
String MODASN02 = "MODASN02";
197197
String MODASN03 = "MODASN03";
198198
String MONNAM01 = "MONNAM01";
199199
String MONNAM02 = "MONNAM02";
200200
String MONNUM01 = "MONNUM01";
201201
String MONNUM02 = "MONNUM02";
202-
String MONVDF01 = "MONVDF01";
202+
String MONRNG01 = "MONRNG01";
203203
String MTHNVK01 = "MTHNVK01";
204204
String MTHNVK02 = "MTHNVK02";
205205
String MULASN01 = "MULASN01";
@@ -242,8 +242,8 @@ public interface ErrorCode {
242242
String POSICF01 = "POSICF01";
243243
String POSICF02 = "POSICF02";
244244
String POWNUM01 = "POWNUM01";
245-
String PRGCHK01 = "PRGCHK01";
246-
String PRGCHK02 = "PRGCHK02";
245+
String PRGDEF01 = "PRGDEF01";
246+
String PRGDEF02 = "PRGDEF02";
247247
String PRGDUP01 = "PRGDUP01";
248248
String PROPMS01 = "PROPMS01";
249249
String PROPMS02 = "PROPMS02";
@@ -286,7 +286,7 @@ public interface ErrorCode {
286286
String SCMPRS01 = "SCMPRS01";
287287
String SECNUM01 = "SECNUM01";
288288
String SECNUM02 = "SECNUM02";
289-
String SECVDF01 = "SECVDF01";
289+
String SECRNG01 = "SECRNG01";
290290
String SRPTSE01 = "SRPTSE01";
291291
String SRPTSE02 = "SRPTSE02";
292292
String STRASN01 = "STRASN01";
@@ -313,24 +313,24 @@ public interface ErrorCode {
313313
String URLADR02 = "URLADR02";
314314
String URLSCM01 = "URLSCM01";
315315
String URLSCM02 = "URLSCM02";
316+
String UTCRNG01 = "UTCRNG01";
317+
String UTCRNG02 = "UTCRNG02";
316318
String UTCTIM01 = "UTCTIM01";
317319
String UTCTIM02 = "UTCTIM02";
318320
String UTCTIM03 = "UTCTIM03";
319-
String UTCVDF01 = "UTCVDF01";
320-
String UTCVDF02 = "UTCVDF02";
321321
String VALDFL01 = "VALDFL01";
322322
String VALFND01 = "VALFND01";
323323
String VARDEC01 = "VARDEC01";
324324
String VARDEC02 = "VARDEC02";
325325
String VARDUP01 = "VARDUP01";
326326
String VARRES01 = "VARRES01";
327327
String VARRES02 = "VARRES02";
328+
String WEKDMS01 = "WEKDMS01";
328329
String WEKNAM01 = "WEKNAM01";
329330
String WEKNAM02 = "WEKNAM02";
330-
String WEKVDF01 = "WEKVDF01";
331331
String WHILSE01 = "WHILSE01";
332332
String WSPACE01 = "WSPACE01";
333333
String YARNUM01 = "YARNUM01";
334334
String YARNUM02 = "YARNUM02";
335-
String YARVDF01 = "YARVDF01";
335+
String YARRNG01 = "YARRNG01";
336336
}

0 commit comments

Comments
 (0)