use of io.hops.hopsworks.restutils.RESTCodes.RESTErrorCode in project hopsworks by logicalclocks.
the class TestRESTCodes method getRESTErrorCodes.
@Before
public void getRESTErrorCodes() {
RESTCodes restCodes = new RESTCodes();
Class<?>[] classes = restCodes.getClass().getClasses();
Method method;
for (Class enumClass : classes) {
try {
method = enumClass.getMethod("values");
RESTErrorCode[] obj = (RESTErrorCode[]) method.invoke(null);
values.put(enumClass.getName(), Arrays.asList(obj));
ranges.put(enumClass.getName(), obj[0].getRange());
} catch (ClassCastException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
}
}
}
use of io.hops.hopsworks.restutils.RESTCodes.RESTErrorCode in project hopsworks by logicalclocks.
the class TestRESTCodes method validateErrorCodes.
/**
* Validates the enums only contain error codes within the range assigned to them.
*/
@Test
public void validateErrorCodes() {
Set<String> keySet = ranges.keySet();
List<RESTErrorCode> restErrorCodes;
for (String key : keySet) {
restErrorCodes = values.get(key);
for (RESTErrorCode errorCode : restErrorCodes) {
if (!(errorCode instanceof RESTCodes.SchemaRegistryErrorCode)) {
assertTrue(errorCode.toString(), errorCode.getCode() >= errorCode.getRange());
assertTrue(errorCode.toString(), errorCode.getCode() < errorCode.getRange() + 10000);
}
}
}
}
Aggregations