1b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpackage org.junit.internal; 2b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 3b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.hamcrest.Description; 4b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.hamcrest.Matcher; 5b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.hamcrest.SelfDescribing; 6b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport org.hamcrest.StringDescription; 7b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 8b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpublic class AssumptionViolatedException extends RuntimeException implements SelfDescribing { 9b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot private static final long serialVersionUID= 1L; 10b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 11b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot private final Object fValue; 12b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 13b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot private final Matcher<?> fMatcher; 14b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 15b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public AssumptionViolatedException(Object value, Matcher<?> matcher) { 16b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot super(value instanceof Throwable ? (Throwable) value : null); 17b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot fValue= value; 18b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot fMatcher= matcher; 19b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 20b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 21b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public AssumptionViolatedException(String assumption) { 22b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot this(assumption, null); 23b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 24b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 25b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot @Override 26b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public String getMessage() { 27b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return StringDescription.asString(this); 28b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 29b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 30b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public void describeTo(Description description) { 31b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot if (fMatcher != null) { 32b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot description.appendText("got: "); 33b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot description.appendValue(fValue); 34b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot description.appendText(", expected: "); 35b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot description.appendDescriptionOf(fMatcher); 36b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } else { 37b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot description.appendText("failed assumption: " + fValue); 38b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 39b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 40b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot}