use of org.zalando.nakadi.domain.SubscriptionBase 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.domain.SubscriptionBase 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.domain.SubscriptionBase in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenCreateSubscriptionWithUnknownApplicationThenUnprocessableEntity.
@Test
public void whenCreateSubscriptionWithUnknownApplicationThenUnprocessableEntity() throws Exception {
final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase();
when(applicationService.exists(any())).thenReturn(false);
postSubscription(subscriptionBase).andExpect(status().isUnprocessableEntity()).andExpect(content().contentTypeCompatibleWith("application/problem+json"));
}
use of org.zalando.nakadi.domain.SubscriptionBase in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenEventTypesIsEmptyThenUnprocessableEntity.
@Test
public void whenEventTypesIsEmptyThenUnprocessableEntity() throws Exception {
final SubscriptionBase subscriptionBase = builder().withEventTypes(ImmutableSet.of()).buildSubscriptionBase();
final Problem expectedProblem = invalidProblem("event_types", "must contain at least one element");
checkForProblem(postSubscription(subscriptionBase), expectedProblem);
}
use of org.zalando.nakadi.domain.SubscriptionBase in project nakadi by zalando.
the class PostSubscriptionControllerTest method whenSubscriptionCreationDisabledThenReturnExistentSubscription.
@Test
public void whenSubscriptionCreationDisabledThenReturnExistentSubscription() throws Exception {
final SubscriptionBase subscriptionBase = builder().buildSubscriptionBase();
final Subscription existingSubscription = new Subscription("123", new DateTime(DateTimeZone.UTC), subscriptionBase);
existingSubscription.setReadFrom(SubscriptionBase.InitialPosition.BEGIN);
when(subscriptionService.getExistingSubscription(any())).thenReturn(existingSubscription);
when(featureToggleService.isFeatureEnabled(DISABLE_SUBSCRIPTION_CREATION)).thenReturn(true);
postSubscription(subscriptionBase).andExpect(status().isOk()).andExpect(content().contentTypeCompatibleWith(APPLICATION_JSON)).andExpect(content().string(sameJSONAs(TestUtils.JSON_TEST_HELPER.asJsonString(existingSubscription)))).andExpect(header().string("Location", "/subscriptions/123")).andExpect(header().doesNotExist("Content-Location"));
}
Aggregations