use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class KsqlResourceTest method shouldFailUnsetPropertyOnInvalidPropertyName.
@Test
public void shouldFailUnsetPropertyOnInvalidPropertyName() {
// When:
final KsqlErrorMessage response = makeFailingRequest("UNSET 'ksql.unknown.property';", BAD_REQUEST.code());
// Then:
assertThat(response, instanceOf(KsqlStatementErrorMessage.class));
assertThat(response.getErrorCode(), is(Errors.ERROR_CODE_BAD_STATEMENT));
assertThat(response.getMessage(), containsString("Unknown property"));
}
use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class ServerStateTest method shouldReturnErrorWhenInitializing.
@Test
public void shouldReturnErrorWhenInitializing() {
// Given:
final KsqlErrorMessage error = new KsqlErrorMessage(12345, "bad stuff is happening");
serverState.setInitializingReason(error);
// When:
final Optional<EndpointResponse> result = serverState.checkReady();
// Then:
assertThat(result.isPresent(), is(true));
final EndpointResponse response = result.get();
final EndpointResponse expected = Errors.serverNotReady(error);
assertThat(response.getStatus(), equalTo(expected.getStatus()));
assertThat(response.getEntity(), equalTo(expected.getEntity()));
}
use of io.confluent.ksql.rest.entity.KsqlErrorMessage in project ksql by confluentinc.
the class KsqlRestExceptionMatchers method exceptionErrorMessage.
/**
* Matches a {@code KsqlRestException} where the response entity holds a {@link KsqlErrorMessage}
* that matches the supplied matcher.
*
* @param expected - see {@link io.confluent.ksql.rest.entity.KsqlErrorMessageMatchers}
* @return the matcher.
*/
public static Matcher<? super KsqlRestException> exceptionErrorMessage(final Matcher<? super KsqlErrorMessage> expected) {
return new TypeSafeDiagnosingMatcher<KsqlRestException>() {
@Override
protected boolean matchesSafely(final KsqlRestException actual, final Description mismatchDescription) {
final Object entity = actual.getResponse().getEntity();
if (!(entity instanceof KsqlErrorMessage)) {
mismatchDescription.appendText("but entity was instance of ").appendValue(entity.getClass());
return false;
}
final KsqlErrorMessage errorMessage = (KsqlErrorMessage) entity;
if (!expected.matches(errorMessage)) {
expected.describeMismatch(errorMessage, mismatchDescription);
return false;
}
return true;
}
@Override
public void describeTo(final Description description) {
description.appendText(KsqlErrorMessage.class.getSimpleName() + " where ").appendDescriptionOf(expected);
}
};
}
Aggregations