use of org.zalando.nakadi.exceptions.runtime.NoSubscriptionException in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenSubscriptionCreationIsDisabledThenCreationFails.
@Test
public void whenSubscriptionCreationIsDisabledThenCreationFails() throws Exception {
final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase();
when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null));
when(featureToggleService.isFeatureEnabled(DISABLE_SUBSCRIPTION_CREATION)).thenReturn(true);
postSubscription(subscriptionBase).andExpect(status().isServiceUnavailable());
}
use of org.zalando.nakadi.exceptions.runtime.NoSubscriptionException in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenMoreThanAllowedEventTypeThenUnprocessableEntity.
@Test
public void whenMoreThanAllowedEventTypeThenUnprocessableEntity() throws Exception {
when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null));
when(subscriptionService.createSubscription(any())).thenThrow(new TooManyPartitionsException("msg"));
final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase();
final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "msg");
checkForProblem(postSubscription(subscriptionBase), expectedProblem);
}
use of org.zalando.nakadi.exceptions.runtime.NoSubscriptionException in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenEventTypeDoesNotExistThenUnprocessableEntity.
@Test
public void whenEventTypeDoesNotExistThenUnprocessableEntity() throws Exception {
final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase();
when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null));
when(subscriptionService.createSubscription(any())).thenThrow(new NoEventTypeException("msg"));
final Problem expectedProblem = Problem.valueOf(UNPROCESSABLE_ENTITY, "msg");
checkForProblem(postSubscription(subscriptionBase), expectedProblem);
}
use of org.zalando.nakadi.exceptions.runtime.NoSubscriptionException in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenPostValidSubscriptionThenOk.
@Test
public void whenPostValidSubscriptionThenOk() throws Exception {
final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase();
final Subscription subscription = new Subscription("123", new DateTime(DateTimeZone.UTC), subscriptionBase);
when(subscriptionService.getExistingSubscription(any())).thenThrow(new NoSubscriptionException("", null));
when(subscriptionService.createSubscription(any())).thenReturn(subscription);
postSubscription(subscriptionBase).andExpect(status().isCreated()).andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON)).andExpect(content().string(sameJSONAs(TestUtils.JSON_TEST_HELPER.asJsonString(subscription)))).andExpect(header().string("Location", "/subscriptions/123")).andExpect(header().string("Content-Location", "/subscriptions/123"));
}
Aggregations