use of com.emc.storageos.svcs.errorhandling.resources.ServiceCode in project coprhd-controller by CoprHD.
the class Operation method getServiceError.
public ServiceError getServiceError() {
ServiceCode serviceCode = ServiceCode.toServiceCode(getServiceCode());
ServiceError serviceError = ServiceError.buildServiceError(serviceCode, getMessage());
return serviceError;
}
use of com.emc.storageos.svcs.errorhandling.resources.ServiceCode in project coprhd-controller by CoprHD.
the class ServiceErrorTest method testJSONUnauthorized.
@Test
public void testJSONUnauthorized() throws Exception {
final ServiceCode code = ServiceCode.SECURITY_UNAUTHORIZED_OPERATION;
final String message = "No credentials were specified";
final String json = json(error(code, message, null));
// useful for debugging
// System.out.println(json);
assertJSONContains(json, "code", "4000");
assertJSONContains(json, "retryable", "false");
assertJSONContains(json, "details", message);
}
use of com.emc.storageos.svcs.errorhandling.resources.ServiceCode in project coprhd-controller by CoprHD.
the class ServiceCodeTest method codesWithoutMessages.
@Test
public void codesWithoutMessages() {
final Set<String> failures = new TreeSet<String>();
final ResourceBundle bundle = MessageUtils.bundleForClass(ServiceCode.class);
for (final ServiceCode serviceCode : ServiceCode.values()) {
String name = serviceCode.name();
if (!bundle.keySet().contains(name)) {
failures.add(name);
}
}
assertTrue("The following ServiceCodes do not have messages in the Bundle: " + failures, failures.isEmpty());
}
use of com.emc.storageos.svcs.errorhandling.resources.ServiceCode in project coprhd-controller by CoprHD.
the class ServiceCodeTest method serviceCodeNumbersAreUnique.
@Test
public void serviceCodeNumbersAreUnique() {
final Map<Integer, ServiceCode> codes = new HashMap<Integer, ServiceCode>();
final Map<Integer, Set<ServiceCode>> duplicates = new HashMap<Integer, Set<ServiceCode>>();
for (final ServiceCode code : ServiceCode.values()) {
final int serviceCode = code.getCode();
final ServiceCode orginal = codes.put(serviceCode, code);
if (orginal != null) {
final Set<ServiceCode> set;
if (duplicates.containsKey(serviceCode)) {
set = duplicates.get(serviceCode);
} else {
set = new HashSet<ServiceCode>();
set.add(orginal);
}
set.add(code);
duplicates.put(serviceCode, set);
}
}
assertTrue("Found Duplicates: " + duplicates, duplicates.isEmpty());
}
use of com.emc.storageos.svcs.errorhandling.resources.ServiceCode in project coprhd-controller by CoprHD.
the class Documenter method documentServiceCode.
private static void documentServiceCode(PrintStream out, final ServiceCode code, final List<DocumenterEntry> messages) throws NoSuchFieldException {
final StatusType status = messages.get(0).getStatus();
final boolean retryable = status.getStatusCode() == 503;
out.println("Service Code: " + code.getCode());
out.println("Name: " + code.name());
out.println("Description: " + code.getSummary(Locale.ENGLISH));
out.println("Retryable: " + retryable);
out.println("Deprecated: " + checkDeprecation(ServiceCode.class.getField(code.name())));
out.println("HTTP Status: " + status.getStatusCode() + " " + status.getReasonPhrase());
out.println();
}
Aggregations