Make Stackdriver tests conform to testing practices in rest of codebase

The major changes are using the ExpectedException rule instead of a try/catch
pattern, asserting the message for thrown exceptions, defaulting to JUnit4
unless Mockito is really necessary, and making each test examine one behavior.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=131211346
This commit is contained in:
mcilwain 2016-08-24 13:48:48 -07:00 committed by Ben McIlwain
parent 1c5b4e16c6
commit 9bdb2ef1f3

View file

@ -41,11 +41,12 @@ public abstract class LabelDescriptor {
* blank * blank
*/ */
public static LabelDescriptor create(String name, String description) { public static LabelDescriptor create(String name, String description) {
checkArgument(!name.isEmpty(), "Name must not be empty");
checkArgument(!description.isEmpty(), "Description must not be empty");
checkArgument( checkArgument(
ALLOWED_LABEL_PATTERN.matches(name), ALLOWED_LABEL_PATTERN.matches(name),
"Label must match the regex %s", "Label name must match the regex %s",
ALLOWED_LABEL_PATTERN); ALLOWED_LABEL_PATTERN);
checkArgument(!description.isEmpty(), "Description must not be empty");
return new AutoValue_LabelDescriptor(name, description); return new AutoValue_LabelDescriptor(name, description);
} }