mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 07:57:13 +02:00
Use StatusValue XML names in EPP error messages
This changes ResourceStatusProhibitsOperationException so that we print out the list of StatusValues using their XML names rather than the literal enum name, i.e. we use "pendingDelete" rather than "PENDING_DELETE". This seems more correct given that EPP clients will be used to seeing the status values in the XML representation, and it also matches the existing ResourceHasClientUpdateProhibitedException that hardcodes "clientUpdateProhibited": http://[]/third_party/java_src/gtld/java/google/registry/flows/exceptions/ResourceHasClientUpdateProhibitedException.java?l=22&rcl=146111211 Also reorganized related test methods and added some missing tests, including for ContactTransferRequestFlow which previously had none. I also renamed the "clientProhibitedStatusValue" tests to instead say "statusValueNotClientSettable" to be clearer about what's being tested, and that it's not related to the "clientXXProhibited" statuses. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=150248562
This commit is contained in:
parent
e60c01c2f7
commit
6a8b25360c
13 changed files with 197 additions and 120 deletions
|
@ -15,6 +15,7 @@
|
|||
package google.registry.flows.exceptions;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import google.registry.flows.EppException.StatusProhibitsOperationException;
|
||||
import google.registry.model.eppcommon.StatusValue;
|
||||
import java.util.Set;
|
||||
|
@ -22,7 +23,16 @@ import java.util.Set;
|
|||
/** Resource status prohibits this operation. */
|
||||
public class ResourceStatusProhibitsOperationException
|
||||
extends StatusProhibitsOperationException {
|
||||
public ResourceStatusProhibitsOperationException(Set<StatusValue> status) {
|
||||
super("Operation disallowed by status: " + Joiner.on(", ").join(status));
|
||||
public ResourceStatusProhibitsOperationException(Set<StatusValue> statuses) {
|
||||
super("Operation disallowed by status: " + formatStatusValues(statuses));
|
||||
}
|
||||
|
||||
/** Returns a human-readable string listing the XML names of the given status values. */
|
||||
private static String formatStatusValues(Set<StatusValue> statuses) {
|
||||
ImmutableSet.Builder<String> statusXmlNames = new ImmutableSet.Builder<>();
|
||||
for (StatusValue status : statuses) {
|
||||
statusXmlNames.add(status.getXmlName());
|
||||
}
|
||||
return Joiner.on(", ").join(statusXmlNames.build());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue